Changeset 3766
- Timestamp:
- Aug 16, 2010, 2:14:37 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugin/src/org/proteios/plugins/FeatureHitMatcher.java
r3764 r3766 34 34 import org.proteios.core.Hit; 35 35 import org.proteios.core.Include; 36 import org.proteios.core.ItemFactory; 36 37 import org.proteios.core.ItemQuery; 37 38 import org.proteios.core.ItemResultList; … … 51 52 import org.proteios.core.query.Restrictions; 52 53 54 import java.io.OutputStream; 55 import java.io.PrintWriter; 53 56 import java.util.ArrayList; 54 57 import java.util.Arrays; … … 121 124 boolean matchRelated = ((Boolean) job.getValue("secondary")) 122 125 .booleanValue(); 123 /* Check that the feature file hasn't been imported already */124 126 QueryFactory qf = new QueryFactory(); 125 127 try 126 128 { 129 ItemFactory factory = new ItemFactory(dc); 130 File outCoreFile = factory.create(File.class); 131 dc.reattachItem(project); 132 outCoreFile.setDirectory(project.getProjectDirectory()); 133 outCoreFile.setName("MatchLog-" + job.getId() + ".txt"); 134 dc.saveItem(outCoreFile); 135 OutputStream outstream = outCoreFile.getUploadStream(false); 136 PrintWriter writer = new PrintWriter(outstream); 137 writer.println("Matching report for project:" + project 138 .getName()); 139 writer.println("m/z tolerance:" + tolerance); 140 writer 141 .println("RT (minutes) tolerance - start:" + startTimeTol + " end:" + endTimeTol); 142 writer.println("Matching with related files" + matchRelated); 127 143 List<File> uniqueMsFiles = Feature 128 144 .getUniqueMsFiles(project, dc); 145 writer 146 .println("Number of files with MS features:" + uniqueMsFiles 147 .size() + "\n"); 129 148 ItemQuery<Feature> featureQuery = qf.select(Feature.class); 130 149 featureQuery.restrictPermanent(Restrictions.eq(Hql … … 135 154 .property("msFile"), Hql.entity(currentMsFile))); 136 155 log.debug("Matching for file:" + currentMsFile); 156 writer.println("File:" + currentMsFile); 137 157 List<Hit> hits = retrieveHits(currentMsFile, project, dc, 138 158 matchRelated); 139 159 List<Feature> features = featureQuery.list(dc); 140 160 count += matchFeatures(features, hits, dc, tolerance, 141 startTimeTol, endTimeTol );161 startTimeTol, endTimeTol, writer); 142 162 featureQuery.reset(); 143 163 } 164 writer.close(); 144 165 dc.commit(); 145 166 response … … 164 185 private int matchFeatures(List<Feature> features, List<Hit> hits, 165 186 DbControl dc, double tolerance, double startTimeTol, 166 double endTimeTol )187 double endTimeTol, PrintWriter writer) 167 188 { 168 189 log.debug("Features to match:" + features.size()); 169 190 log.debug("Hits to match:" + hits.size()); 191 writer.println("Features to match:" + features.size()); 192 writer.println("MS/MS identifications to match:" + hits.size()); 170 193 int count = 0; 194 int newmatches = 0; 195 int replaced = 0; 196 int ambiguities = 0; 171 197 for (Feature f : features) 172 198 { … … 199 225 { 200 226 h.setPrecursorQuantity(f.getApexIntensity()); 227 replaced++; 201 228 } 202 229 f.setPeptideSequence(h.getDescription()); 203 230 f.addHit(h); 231 newmatches++; 204 232 } 205 233 else … … 209 237 * Use the feature with the highest intensity 210 238 */ 211 if (h.getPrecursorQuantity() == null ||(h239 if (h.getPrecursorQuantity() == null && (h 212 240 .getPrecursorQuantity() < f.getApexIntensity())) 213 241 { 214 242 h.setPrecursorQuantity(f.getApexIntensity()); 243 if (!h.getDescription().equals( 244 f.getPeptideSequence())) 245 { 246 f.setPeptideSequence(h.getDescription()); 247 ambiguities++; 248 } 249 replaced++; 215 250 } 216 251 f.addHit(h); … … 257 292 f.setPeptideSequence(h.getDescription()); 258 293 count++; 294 newmatches++; 259 295 } 260 296 } … … 262 298 } 263 299 } 300 writer.println("New features matched:" + newmatches); 301 writer.println("Multiply matched features:" + replaced); 302 writer.println("Matched hits:" + count); 303 writer 304 .println("Ambiguous matches (different sequences from MS/MS identifications):" + ambiguities); 305 writer.println("==============================="); 264 306 return count; 265 307 }
Note: See TracChangeset
for help on using the changeset viewer.