Changeset 1532
- Timestamp:
- Feb 9, 2007, 3:22:39 PM (15 years ago)
- Location:
- trunk/src/org/proteios
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/proteios/gui/query/CombinedProteinHitsReportEditor.java
r1530 r1532 57 57 CombinedProteinHitsReportQuery pQuery = (CombinedProteinHitsReportQuery)query; 58 58 pQuery.setReverseText(reverseText.getText()); 59 if (peptidesButton.isSelected()) 60 { 61 pQuery.setIsProteinScores(false); 62 } 63 else 64 { 65 pQuery.setIsProteinScores(true); 66 } 59 67 if (dateCheckBox.isSelected()) 60 68 { … … 84 92 { 85 93 setBackground(new java.awt.Color(102, 204, 255)); 86 setBorder(new javax.swing.border.TitledBorder(" Settings for combined gelreport"));94 setBorder(new javax.swing.border.TitledBorder("Mascot and Tandem combined report")); 87 95 setMinimumSize(new java.awt.Dimension(72, 90)); 88 96 setPreferredSize(new java.awt.Dimension(116, 90)); … … 135 143 JPanel main = new JPanel(); 136 144 main.setBorder(BorderFactory.createLineBorder(Color.darkGray)); 137 main.setLayout(new java.awt.GridLayout( 5, 1));145 main.setLayout(new java.awt.GridLayout(6, 1)); 138 146 main.setBackground(new java.awt.Color(255, 255, 255)); 139 147 add(main); … … 153 161 /* End of text label */ 154 162 163 /** The sorting panel */ 164 JPanel sortingPanel = new JPanel(); 165 sortingPanel.setBackground(new java.awt.Color(255, 255, 255)); 166 167 JLabel sortingLabel = new JLabel("Calculate for protein or peptides: "); 168 sortingLabel.setBackground(new java.awt.Color(255, 255, 255)); 169 sortingPanel.add(sortingLabel); 170 171 proteinsButton = new JRadioButton("proteins", true); 172 proteinsButton.setActionCommand("proteins"); 173 proteinsButton.addActionListener(listener); 174 proteinsButton.setBackground(new java.awt.Color(255, 255, 255)); 175 sortingPanel.add(proteinsButton); 176 177 peptidesButton = new JRadioButton("peptides"); 178 peptidesButton.setActionCommand("peptides"); 179 peptidesButton.addActionListener(listener); 180 peptidesButton.setBackground(new java.awt.Color(255, 255, 255)); 181 sortingPanel.add(peptidesButton); 182 183 ButtonGroup bg = new ButtonGroup(); 184 bg.add(proteinsButton); 185 bg.add(peptidesButton); 186 187 main.add(sortingPanel); 188 /** End of the sorting panel */ 189 155 190 /** The fdr cut off panel */ 156 191 JPanel cutOffPanel = new JPanel(); … … 232 267 /** Gui components */ 233 268 private JCheckBox dateCheckBox, cutOffCheckBox, dateCheckBox2; 269 private JRadioButton proteinsButton, peptidesButton; 234 270 private JSpinner cutOffSpinner; 235 271 private JTextField dateText, dateText2, reverseText; -
trunk/src/org/proteios/query/CombinedProteinHitsReportQuery.java
r1526 r1532 15 15 // along with this program; if not, write to the Free Software 16 16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 17 18 17 package org.proteios.query; 19 18 20 19 import java.text.SimpleDateFormat; 21 import java. text.DateFormat;20 import java.util.ArrayList; 22 21 import java.util.Date; 22 import java.util.HashMap; 23 import java.util.Iterator; 23 24 import java.util.List; 24 import java.util.ArrayList; 25 import java.util.TreeSet; 25 import java.util.Map; 26 26 import java.util.Set; 27 27 import java.util.SortedSet; 28 import java.util.Iterator; 29 import java.util.Map; 30 import java.util.HashMap; 31 28 import java.util.TreeSet; 29 import org.proteios.core.SQLConnection; 32 30 import org.proteios.core.SQLEvictConnection; 33 import org.proteios.core.SQLConnection;34 35 import org.proteios.core.Element;36 31 import org.proteios.core.element.Gel; 37 32 import org.proteios.core.element.Gel1D; 38 import org.proteios.core.element.Gel2D; 33 import org.proteios.core.element.IdentificationHypothesis; 34 import org.proteios.core.element.MoleculeIdentifier; 35 import org.proteios.core.element.MzAnalysis; 36 import org.proteios.core.element.MzData; 37 import org.proteios.core.element.ParentMolecule; 38 import org.proteios.core.element.PolyPeptide; 39 import org.proteios.core.element.Result; 39 40 import org.proteios.core.element.Spot; 40 import org.proteios.core.element.Band;41 import org.proteios.core.element.MzData;42 import org.proteios.core.element.SpectrumList;43 import org.proteios.core.element.Spectrum;44 import org.proteios.core.element.PeakList;45 import org.proteios.core.element.Peak;46 import org.proteios.core.element.HypothesisProperty;47 import org.proteios.core.element.MzAnalysis;48 import org.proteios.core.element.Result;49 import org.proteios.core.element.IdentificationHypothesis;50 import org.proteios.core.element.PolyPeptide;51 import org.proteios.core.element.ParentMolecule;52 import org.proteios.core.element.MoleculeIdentifier;53 41 import org.proteios.core.element.UserModification; 54 42 55 43 /** 56 This class generate a protein list with user-defined error ratio 57 58 @author Fredrik Levander 59 60 */ 44 * This class generate a protein list with user-defined error ratio 45 * 46 * @author Fredrik Levander 47 */ 61 48 public class CombinedProteinHitsReportQuery 62 extends Query49 extends Query 63 50 { 64 51 public CombinedProteinHitsReportQuery() … … 69 56 70 57 /** 71 * Executable if the object we query from is either Gel1D or Gel2D (i.e.72 * instanceof Gel) and all parameters set.73 *74 * @return true if query is executable.75 */58 * Executable if the object we query from is either Gel1D or Gel2D (i.e. 59 * instanceof Gel) and all parameters set. 60 * 61 * @return true if query is executable. 62 */ 76 63 public boolean isExecutable() 77 64 { … … 81 68 82 69 /** 83 * Set query origin and set executable if Gel.84 *85 * @param origin The gel that is being queried.86 * @param parent The query object's parent - null is OK.87 */70 * Set query origin and set executable if Gel. 71 * 72 * @param origin The gel that is being queried. 73 * @param parent The query object's parent - null is OK. 74 */ 88 75 public void setQueryOrigin(Object queryObject, Object parentObject) 89 76 { … … 95 82 /** Once all parameters needed to run the query have been supplied. */ 96 83 public QueryResult execute() 97 throws QueryException84 throws QueryException 98 85 { 99 86 if (executable == false) 100 87 { 101 throw new QueryException("Unable to execute " + query_name + " from: " + queryObject); 88 throw new QueryException( 89 "Unable to execute " + query_name + " from: " + queryObject); 102 90 } 103 91 resultSet = getResult(); 104 CombinedProteinHitsReportQueryResult result = new CombinedProteinHitsReportQueryResult(resultSet); 92 CombinedProteinHitsReportQueryResult result = new CombinedProteinHitsReportQueryResult( 93 resultSet); 105 94 result.setGelId(gelId); 106 95 result.setInfo(info); 107 96 return result; 108 97 } 109 110 111 /** 112 Will exctract info from the proteios data structure and create 113 a TreeSet containing sorted ResultRow objects. 114 */ 115 private Set getResult() 116 throws QueryException 98 99 100 public Set getProteinSet(Gel gel) 101 throws QueryException 117 102 { 118 103 Set result = new TreeSet(); 119 Gel gel = (Gel)queryObject;120 gelId = gel.getGel_id();121 int total_results=0;122 int score_types=1;123 int db_entries=0;124 104 try 125 105 { 126 // Iterate through all the spots and find assosciated mzData elements 127 Map attributes=new HashMap(); 128 dbconnection=new SQLEvictConnection((SQLConnection) gel.getDataConnection()); 106 dbconnection = new SQLEvictConnection((SQLConnection) gel 107 .getDataConnection()); 129 108 dbconnection.beginTransaction(); 130 109 List proteinList = null; 131 110 List parentMoleculeList = null; 132 111 String gelSpotType = "spot.gel2D"; 133 112 // Gel is either Gel1D or Gel2D with Band or Spot respectively. 134 // We check if there are results from one or two search engines135 113 if (gel instanceof Gel1D) 136 114 { 137 String query_string="from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.score_type='Mascot protein score'"; 138 query_string+=" and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel1D.gel_id='"+gelId+"'"; 139 proteinList= dbconnection.getQueryResult(query_string); 140 if (proteinList!=null && !proteinList.isEmpty()) 141 query_string="from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.result.mzAnalysis.softwareName='X!Tandem'"; 142 query_string+=" and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel1D.gel_id='"+gelId+"'"; 143 proteinList.addAll(dbconnection.getQueryResult(query_string)); 144 query_string="from ParentMolecule pm where pm.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel1D.gel_id='"+gelId+"'"; 145 parentMoleculeList=dbconnection.getQueryResult(query_string); 146 } 147 else if (gel instanceof Gel2D) 148 { 149 String query_string="from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.score_type='Mascot protein score'"; 150 query_string+=" and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel2D.gel_id='"+gelId+"'"; 151 proteinList= dbconnection.getQueryResult(query_string); 152 query_string="from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.result.mzAnalysis.softwareName='X!Tandem'"; 153 query_string+=" and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel2D.gel_id='"+gelId+"'"; 154 proteinList.addAll(dbconnection.getQueryResult(query_string)); 155 query_string="from ParentMolecule pm where pm.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel2D.gel_id='"+gelId+"'"; 156 parentMoleculeList=dbconnection.getQueryResult(query_string); 157 } 158 115 gelSpotType = "band.gel1D"; 116 } 117 String query_string = "from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.score_type='Mascot protein score'"; 118 query_string += " and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'"; 119 proteinList = dbconnection.getQueryResult(query_string); 120 query_string = "from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.result.mzAnalysis.softwareName='X!Tandem'"; 121 query_string += " and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'"; 122 proteinList.addAll(dbconnection.getQueryResult(query_string)); 123 query_string = "from ParentMolecule pm where pm.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'"; 124 parentMoleculeList = dbconnection.getQueryResult(query_string); 159 125 if (proteinList == null || proteinList.isEmpty()) 160 126 { 161 throw new QueryException("There are no identifications that fulfil the criteria for this gel."); 162 } 163 System.out.println("Proteins:"+proteinList.size()+" ParentMolecules:"+parentMoleculeList.size()); 164 total_results=proteinList.size(); 127 throw new QueryException( 128 "There are no identifications that fulfil the criteria for this gel."); 129 } 130 System.out 131 .println("Proteins:" + proteinList.size() + " ParentMolecules:" + parentMoleculeList 132 .size()); 165 133 Iterator protIter = proteinList.iterator(); 166 134 // First populate the protein list with identification info 167 135 while (protIter.hasNext()) 168 136 { 169 MoleculeIdentifier currentMI = (MoleculeIdentifier)protIter.next(); 137 MoleculeIdentifier currentMI = (MoleculeIdentifier) protIter 138 .next(); 170 139 ResultRow row = new ResultRow(); 171 140 PolyPeptide currentPP = currentMI.getPolyPeptide(); 172 IdentificationHypothesis currentHypothesis = currentPP.getIdentificationHypothesis(); 141 IdentificationHypothesis currentHypothesis = currentPP 142 .getIdentificationHypothesis(); 173 143 row.eValue = currentHypothesis.getE_value(); 174 144 row.score = currentHypothesis.getScore(); 175 145 row.score_type = currentHypothesis.getScore_type(); 176 // The score type was not written in some old Tandem imports. 146 // The score type was not written in some old Tandem imports. 177 147 // It is supposed to be there for all other imports 178 148 if (row.score_type.equals("")) 179 149 { 180 row.score_type ="Tandem";150 row.score_type = "Tandem"; 181 151 } 182 152 row.proteinId = currentMI.getAccession_number(); 183 // Sometimes IPI accessions are preceeded by IPI: which should be removed 153 // Sometimes IPI accessions are preceeded by IPI: which should 154 // be removed 184 155 if (row.proteinId.startsWith("IPI:")) 185 156 { 186 row.proteinId =row.proteinId.substring(4);157 row.proteinId = row.proteinId.substring(4); 187 158 if (row.proteinId.contains("|")) 188 159 { 189 row.proteinId=row.proteinId.substring(0,row.proteinId.indexOf('|')); 190 } 191 } 192 Result currentResult=currentHypothesis.getResult(); 193 MzAnalysis currentAnalysis=currentResult.getMzAnalysis(); 194 if (db_entries==0) 195 { 196 if (currentAnalysis.getSearchDatabaseEntriesAfterTaxonomy()!=0) 197 { 198 db_entries=currentAnalysis.getSearchDatabaseEntriesAfterTaxonomy(); 199 } 160 row.proteinId = row.proteinId.substring(0, 161 row.proteinId.indexOf('|')); 162 } 163 } 164 Result currentResult = currentHypothesis.getResult(); 165 MzAnalysis currentAnalysis = currentResult.getMzAnalysis(); 166 if (db_entries == 0) 167 { 168 if (currentAnalysis.getSearchDatabaseEntriesAfterTaxonomy() != 0) 169 { 170 db_entries = currentAnalysis 171 .getSearchDatabaseEntriesAfterTaxonomy(); 172 } 200 173 else 201 174 { 202 db_entries=currentAnalysis.getSearchDatabaseSizeInDbEntries(); 203 } 204 } 205 MzData currentMzData=currentAnalysis.getMzData(); 206 Spot currentSpot=currentMzData.getSpot(); 207 row.spotId=(int) currentSpot.getId(); 208 row.dBSearchId=dfXML.parse(currentAnalysis.getAnalysisTime()); 209 row.description=currentMI.getName(); 210 row.mw=currentMI.getPredicted_mass(); 211 row.pi=currentMI.getPredicted_pI(); 212 boolean add=true; 175 db_entries = currentAnalysis 176 .getSearchDatabaseSizeInDbEntries(); 177 } 178 } 179 MzData currentMzData = currentAnalysis.getMzData(); 180 Spot currentSpot = currentMzData.getSpot(); 181 row.spotId = (int) currentSpot.getId(); 182 row.dBSearchId = dfXML.parse(currentAnalysis.getAnalysisTime()); 183 row.description = currentMI.getName(); 184 row.mw = currentMI.getPredicted_mass(); 185 row.pi = currentMI.getPredicted_pI(); 186 boolean add = true; 213 187 if (getDate() != null) 214 188 { 215 if (!dfXML.format(row.dBSearchId).startsWith(getDate()) && row.score_type.startsWith("Mascot")) 216 { 217 add=false; 189 if (!dfXML.format(row.dBSearchId).startsWith(getDate()) && row.score_type 190 .startsWith("Mascot")) 191 { 192 add = false; 218 193 } 219 194 } 220 195 if (getDate2() != null) 221 196 { 222 if (!dfXML.format(row.dBSearchId).startsWith(getDate2()) && row.score_type.startsWith("Tandem")) 223 { 224 add=false; 225 } 226 } 227 if (row.score_type.startsWith("Mascot") && (row.score==0.0)) 228 { 229 add=false; 197 if (!dfXML.format(row.dBSearchId).startsWith(getDate2()) && row.score_type 198 .startsWith("Tandem")) 199 { 200 add = false; 201 } 202 } 203 if (row.score_type.startsWith("Mascot") && (row.score == 0.0)) 204 { 205 add = false; 230 206 } 231 207 if (add) 232 208 { 233 209 // Find subsequence hits: 234 235 /*String pepID=Long.toString(currentPP.getId()); 236 /String new_query="from ParentMolecule pm where pm.polyPeptideId='"+pepID+"'"; 237 List pmlist=dbconnection.getQueryResult(new_query);*/ 238 long pepID=currentPP.getId(); 239 Iterator parentIt=parentMoleculeList.iterator(); 240 List pmlist=new ArrayList(); 210 long pepID = currentPP.getId(); 211 Iterator parentIt = parentMoleculeList.iterator(); 241 212 ParentMolecule currentpm; 242 213 while (parentIt.hasNext()) 243 214 { 244 currentpm=(ParentMolecule) parentIt.next(); 245 //long currentID=currentpm.getPolyPeptideId(); 246 if (pepID==currentpm.getPolyPeptideId()) 247 { 248 PolyPeptide currentpp=currentpm.getPolyPeptide(); 249 IdentificationHypothesis currentih=currentpp.getIdentificationHypothesis(); 250 row.identificationHypotheses.add(currentih.getAuto_id()); 251 } 252 } 253 // end of subsequence find part 215 currentpm = (ParentMolecule) parentIt.next(); 216 // long currentID=currentpm.getPolyPeptideId(); 217 if (pepID == currentpm.getPolyPeptideId()) 218 { 219 PolyPeptide currentpp = currentpm.getPolyPeptide(); 220 IdentificationHypothesis currentih = currentpp 221 .getIdentificationHypothesis(); 222 row.identificationHypotheses.add(currentih 223 .getAuto_id()); 224 } 225 } 226 // end of subsequence find part 254 227 result.add(row); 255 228 } … … 262 235 throw new QueryException("Error building report: " + e.getMessage()); 263 236 } 264 265 237 // Now mark subsequence hits and remove them! 266 Iterator resit =result.iterator();238 Iterator resit = result.iterator(); 267 239 while (resit.hasNext()) 268 240 { 269 ResultRow row =(ResultRow) resit.next();270 boolean subsequence =false;271 Iterator res2it =result.iterator();241 ResultRow row = (ResultRow) resit.next(); 242 boolean subsequence = false; 243 Iterator res2it = result.iterator(); 272 244 while (res2it.hasNext() && !subsequence) 273 245 { 274 ResultRow row2=(ResultRow) res2it.next(); 275 if (row.spotId==row2.spotId && row.score_type==row2.score_type) 276 { 277 if (row.identificationHypotheses.size()<row2.identificationHypotheses.size()) 278 { 279 boolean allmatched=true; 280 Iterator ihit=row.identificationHypotheses.iterator(); 246 ResultRow row2 = (ResultRow) res2it.next(); 247 if (row.spotId == row2.spotId && row.score_type == row2.score_type) 248 { 249 if (row.identificationHypotheses.size() < row2.identificationHypotheses 250 .size()) 251 { 252 boolean allmatched = true; 253 Iterator ihit = row.identificationHypotheses.iterator(); 281 254 while (ihit.hasNext()) 282 255 { 283 Long ihid=(Long) ihit.next(); 284 boolean matched=false; 285 Iterator ih2it=row2.identificationHypotheses.iterator(); 256 Long ihid = (Long) ihit.next(); 257 boolean matched = false; 258 Iterator ih2it = row2.identificationHypotheses 259 .iterator(); 286 260 while (ih2it.hasNext() && allmatched) 287 261 { 288 262 if (((Long) ih2it.next()).equals(ihid)) 289 263 { 290 matched =true;264 matched = true; 291 265 } 292 266 } 293 267 if (!matched) 294 268 { 295 allmatched =false;269 allmatched = false; 296 270 } 297 271 } 298 272 if (allmatched) 299 273 { 300 subsequence =true;274 subsequence = true; 301 275 } 302 276 } … … 308 282 } 309 283 } 310 311 312 resit=result.iterator(); 313 int spots=0; 314 int lastSpotId=-1; 315 // Now put the reverse and forward hits into different lists. Count spots 284 return result; 285 } 286 287 288 public Set getPeptideSet(Gel gel) 289 throws QueryException 290 { 291 Set result = new TreeSet(); 292 try 293 { 294 dbconnection = new SQLEvictConnection((SQLConnection) gel 295 .getDataConnection()); 296 dbconnection.beginTransaction(); 297 List peptideList = null; 298 // List parentMoleculeList = null; 299 String gelSpotType = "spot.gel2D"; 300 // Gel is either Gel1D or Gel2D with Band or Spot respectively. 301 if (gel instanceof Gel1D) 302 { 303 gelSpotType = "band.gel1D"; 304 } 305 String query_string = "from PolyPeptide pp where pp.identificationHypothesis.score_type='Mascot peptide score'"; 306 query_string += " and pp.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'"; 307 peptideList = dbconnection.getQueryResult(query_string); 308 query_string = "from PolyPeptide pp where pp.identificationHypothesis.score_type='Tandem hyperscore'"; 309 query_string += " and pp.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'"; 310 peptideList.addAll(dbconnection.getQueryResult(query_string)); 311 if (peptideList == null || peptideList.isEmpty()) 312 { 313 throw new QueryException( 314 "There are no identifications that fulfil the criteria for this gel."); 315 } 316 System.out.println("Peptides:" + peptideList.size()); 317 Iterator pepIter = peptideList.iterator(); 318 // First populate the peptide list with identification info 319 while (pepIter.hasNext()) 320 { 321 PolyPeptide currentPP = (PolyPeptide) pepIter.next(); 322 ResultRow row = new ResultRow(); 323 IdentificationHypothesis currentHypothesis = currentPP 324 .getIdentificationHypothesis(); 325 row.eValue = currentHypothesis.getE_value(); 326 row.score = currentHypothesis.getScore(); 327 row.score_type = currentHypothesis.getScore_type(); 328 row.proteinId = ""; 329 Iterator pmit = currentPP.getParentMoleculeCollection() 330 .iterator(); 331 while (pmit.hasNext()) 332 { 333 String desc = ((ParentMolecule) pmit.next()) 334 .getAccession_number(); 335 // Sometimes IPI accessions are preceeded by IPI: which 336 // should 337 // be removed 338 if (desc.startsWith("IPI:")) 339 { 340 desc = desc.substring(4); 341 } 342 if (desc.contains("|")) 343 { 344 desc = desc.substring(0, desc.indexOf('|')); 345 } 346 if (row.proteinId.length() > 0) 347 { 348 // We want reverse accessions first 349 if (desc.startsWith(reverseText)) 350 { 351 row.proteinId = desc + " " + row.proteinId; 352 } 353 else 354 { 355 row.proteinId = row.proteinId + " " + desc; 356 } 357 } 358 else 359 { 360 row.proteinId = desc; 361 } 362 } 363 Result currentResult = currentHypothesis.getResult(); 364 MzAnalysis currentAnalysis = currentResult.getMzAnalysis(); 365 if (db_entries == 0) 366 { 367 if (currentAnalysis.getSearchDatabaseEntriesAfterTaxonomy() != 0) 368 { 369 db_entries = currentAnalysis 370 .getSearchDatabaseEntriesAfterTaxonomy(); 371 } 372 else 373 { 374 db_entries = currentAnalysis 375 .getSearchDatabaseSizeInDbEntries(); 376 } 377 } 378 MzData currentMzData = currentAnalysis.getMzData(); 379 Spot currentSpot = currentMzData.getSpot(); 380 row.spotId = (int) currentSpot.getId(); 381 row.dBSearchId = dfXML.parse(currentAnalysis.getAnalysisTime()); 382 row.description = currentPP.getSequence(); 383 Iterator moditerator = currentPP 384 .getUserModificationCollection().iterator(); 385 while (moditerator.hasNext()) 386 { 387 row.description += " + " + ((UserModification) moditerator 388 .next()).getName(); 389 } 390 row.mw = currentResult.getSpectrumId(); 391 row.pi = 0; 392 boolean add = true; 393 if (getDate() != null) 394 { 395 if (!dfXML.format(row.dBSearchId).startsWith(getDate()) && row.score_type 396 .startsWith("Mascot")) 397 { 398 add = false; 399 } 400 } 401 if (getDate2() != null) 402 { 403 if (!dfXML.format(row.dBSearchId).startsWith(getDate2()) && row.score_type 404 .startsWith("Tandem")) 405 { 406 add = false; 407 } 408 } 409 if (add) 410 { 411 result.add(row); 412 } 413 } 414 dbconnection.clear(); 415 dbconnection.closeSession(); 416 } 417 catch (Exception e) 418 { 419 throw new QueryException("Error building report: " + e.getMessage()); 420 } 421 return result; 422 } 423 424 425 /** 426 * Will exctract info from the proteios data structure and create a TreeSet 427 * containing sorted ResultRow objects. 428 */ 429 private Set getResult() 430 throws QueryException 431 { 432 Set result = new TreeSet(); 433 Gel gel = (Gel) queryObject; 434 gelId = gel.getGel_id(); 435 gel_autoid = Long.toString(gel.getAuto_id()); 436 int score_types = 1; 437 try 438 { 439 if (isProteinScores) 440 { 441 result = getProteinSet(gel); 442 } 443 else 444 { 445 result = getPeptideSet(gel); 446 } 447 } 448 catch (QueryException e) 449 { 450 throw e; 451 } 452 Iterator resit = result.iterator(); 453 int spots = 0; 454 int lastSpotId = -1; 455 // Now put the reverse and forward hits into different lists. Count 456 // spots 316 457 List<FdrRow> fdrlist = new ArrayList<FdrRow>(); 317 458 List<FdrRow> reverselist = new ArrayList<FdrRow>(); 318 459 // Check if both Tandem and Mascot results 319 boolean mascot=false, tandem=false; 460 boolean mascot = false, tandem = false; 461 // Sequence without modifications (used for peptides only) 462 String seqstart = ""; 320 463 while (resit.hasNext()) 321 464 { 322 ResultRow row=(ResultRow) resit.next(); 465 ResultRow row = (ResultRow) resit.next(); 466 if (!isProteinScores) 467 { 468 seqstart = row.description; 469 if (seqstart.contains(" ")) 470 { 471 seqstart = seqstart.substring(0, seqstart.indexOf(' ')); 472 } 473 } 323 474 // spot count 324 if (row.spotId !=lastSpotId)475 if (row.spotId != lastSpotId) 325 476 { 326 477 spots++; 327 lastSpotId =row.spotId;478 lastSpotId = row.spotId; 328 479 } 329 480 // First try to find it in list or add new row 330 Iterator<FdrRow> fdrit =fdrlist.iterator();481 Iterator<FdrRow> fdrit = fdrlist.iterator(); 331 482 if (!row.proteinId.startsWith(reverseText)) 332 483 { 333 fdrit =fdrlist.iterator();484 fdrit = fdrlist.iterator(); 334 485 } 335 486 else 336 487 { 337 fdrit =reverselist.iterator();338 } 339 boolean foundrow =false;340 FdrRow addtorow =new FdrRow();488 fdrit = reverselist.iterator(); 489 } 490 boolean foundrow = false; 491 FdrRow addtorow = new FdrRow(); 341 492 while (!foundrow && fdrit.hasNext()) 342 493 { 343 FdrRow currentfdrrow=fdrit.next(); 344 if (currentfdrrow.spotId==row.spotId) 345 { 346 if (row.proteinId.startsWith(currentfdrrow.ipi)) 347 { 348 foundrow=true; 349 addtorow=currentfdrrow; 494 FdrRow currentfdrrow = fdrit.next(); 495 if (currentfdrrow.spotId == row.spotId) 496 { 497 if (isProteinScores) 498 { 499 if (row.proteinId.startsWith(currentfdrrow.ipi)) 500 { 501 foundrow = true; 502 addtorow = currentfdrrow; 503 fdrit.remove(); 504 } 505 } 506 /* 507 * For peptides the row.mw is actually the spectrum ID. If 508 * the spectrum Id and the sequence are equal we guess it is 509 * the same result 510 */ 511 else if (currentfdrrow.description.startsWith(seqstart) && row.mw == currentfdrrow.mw) 512 { 513 foundrow = true; 514 addtorow = currentfdrrow; 350 515 fdrit.remove(); 351 516 } 352 517 } 353 518 } 354 addtorow.mw =row.mw;355 addtorow.pi =row.pi;356 addtorow.ipi =row.proteinId;357 addtorow.description =row.description;358 addtorow.spotId =row.spotId;519 addtorow.mw = row.mw; 520 addtorow.pi = row.pi; 521 addtorow.ipi = row.proteinId; 522 addtorow.description = row.description; 523 addtorow.spotId = row.spotId; 359 524 // Now add score to list 360 525 if (row.score_type.startsWith("Mascot")) 361 526 { 362 addtorow.mascot_score =row.score;363 mascot =true;364 } 527 addtorow.mascot_score = row.score; 528 mascot = true; 529 } 365 530 else 366 531 // Tandem result 367 532 { 368 addtorow.tandem_eValue =row.eValue;369 tandem =true;533 addtorow.tandem_eValue = row.eValue; 534 tandem = true; 370 535 } 371 536 if (!row.proteinId.startsWith(reverseText)) … … 378 543 } 379 544 } 380 Iterator<FdrRow> fdrit =fdrlist.iterator();545 Iterator<FdrRow> fdrit = fdrlist.iterator(); 381 546 // Now we want to calcluate the p_values 382 int total_number =db_entries/2*spots;383 int reverse_total =reverselist.size();384 int forward_total =fdrlist.size();547 int total_number = db_entries / 2 * spots; 548 int reverse_total = reverselist.size(); 549 int forward_total = fdrlist.size(); 385 550 while (fdrit.hasNext()) 386 551 { 387 FdrRow currentrow= fdrit.next(); 388 int scores_above=0; 389 Iterator<FdrRow> reverseit=reverselist.iterator(); 390 // Count how many reverse hits have both scores better, or the score if only one given 552 FdrRow currentrow = fdrit.next(); 553 int scores_above = 0; 554 Iterator<FdrRow> reverseit = reverselist.iterator(); 555 // Count how many reverse hits have both scores better, or the score 556 // if only one given 391 557 while (reverseit.hasNext()) 392 558 { 393 boolean hit_above =false;394 FdrRow currentreverse =reverseit.next();395 if (currentrow.mascot_score !=0 && currentrow.tandem_eValue!=0)396 { 397 //Both scores to compare398 if (currentreverse.mascot_score !=0 && currentreverse.tandem_eValue!=0)399 { 400 if (currentreverse.mascot_score >=currentrow.mascot_score && currentreverse.tandem_eValue<=currentrow.tandem_eValue)401 { 402 hit_above =true;403 } 404 } 559 boolean hit_above = false; 560 FdrRow currentreverse = reverseit.next(); 561 if (currentrow.mascot_score != 0 && currentrow.tandem_eValue != 0) 562 { 563 // Both scores to compare 564 if (currentreverse.mascot_score != 0 && currentreverse.tandem_eValue != 0) 565 { 566 if (currentreverse.mascot_score >= currentrow.mascot_score && currentreverse.tandem_eValue <= currentrow.tandem_eValue) 567 { 568 hit_above = true; 569 } 570 } 405 571 } 406 572 // only one score! 407 else 408 { 409 if (currentrow.mascot_score !=0 && currentreverse.mascot_score!=0)410 { 411 // Only compare mascot score412 if (currentreverse.mascot_score >=currentrow.mascot_score)413 { 414 hit_above =true;415 } 416 } 417 else if (currentrow.tandem_eValue !=0 && currentreverse.tandem_eValue!=0)573 else 574 { 575 if (currentrow.mascot_score != 0 && currentreverse.mascot_score != 0) 576 { 577 // Only compare mascot score 578 if (currentreverse.mascot_score >= currentrow.mascot_score) 579 { 580 hit_above = true; 581 } 582 } 583 else if (currentrow.tandem_eValue != 0 && currentreverse.tandem_eValue != 0) 418 584 // Only tandem score 419 { 420 if (currentreverse.tandem_eValue <=currentrow.tandem_eValue)421 { 422 hit_above =true;423 } 424 } 425 } 585 { 586 if (currentreverse.tandem_eValue <= currentrow.tandem_eValue) 587 { 588 hit_above = true; 589 } 590 } 591 } 426 592 if (hit_above) 427 593 { 428 594 scores_above++; 429 595 } 430 } 431 currentrow.pValue =(double)(scores_above+1)/(double)(total_number+1);596 } 597 currentrow.pValue = (double) (scores_above + 1) / (double) (total_number + 1); 432 598 } 433 599 SortedSet<FdrRow> hitlist = new TreeSet<FdrRow>(fdrlist); 434 System.out.println("Forward proteins to consider:"+hitlist.size()); 435 FdrRow[] fdrarray=hitlist.toArray(new FdrRow[0]); 436 // Now all the forward hits are in fdrarray, sorted with ascending p_values 437 // To correct for multiple possibilities we multiply by the number of search engines 600 System.out.println("Forward proteins to consider:" + hitlist.size()); 601 FdrRow[] fdrarray = hitlist.toArray(new FdrRow[0]); 602 // Now all the forward hits are in fdrarray, sorted with ascending 603 // p_values 604 // To correct for multiple possibilities we multiply by the number of 605 // search engines 438 606 if (mascot && tandem) 439 607 { 440 score_types=2; 441 } 442 for (int i=0;i<fdrarray.length;++i) 443 { 444 fdrarray[i].corrected_p=score_types*fdrarray[i].pValue*((double) total_number)/(((double)(i+1))); 445 } 446 for (int i=0;i<fdrarray.length;++i) 447 { 448 double min=1; 449 for (int j=i;j<fdrarray.length;++j) 450 { 451 if (fdrarray[j].corrected_p<min) 452 { 453 min=fdrarray[j].corrected_p; 454 } 455 } 456 fdrarray[i].fdr=min; 457 /* for debugging: 458 System.out.print("mascot:"+fdrarray[i].mascot_score+" tandem:"+fdrarray[i].tandem_eValue); 459 System.out.println(" p_value:"+fdrarray[i].pValue+" corrected:"+fdrarray[i].corrected_p+" fdr:"+fdrarray[i].fdr); 460 */ 461 } 462 int truecount=0, falsecount=0, tandem_count=0, mascot_count=0,combined_count=0; 463 double tandem_only_limit=0,mascot_only_limit=1000,tandem_combined=0,mascot_combined=1000; 464 FdrRow lasthit=fdrarray[0]; 608 score_types = 2; 609 } 610 for (int i = 0; i < fdrarray.length; ++i) 611 { 612 fdrarray[i].corrected_p = score_types * fdrarray[i].pValue * ((double) total_number) / (((double) (i + 1))); 613 } 614 for (int i = 0; i < fdrarray.length; ++i) 615 { 616 double min = 1; 617 for (int j = i; j < fdrarray.length; ++j) 618 { 619 if (fdrarray[j].corrected_p < min) 620 { 621 min = fdrarray[j].corrected_p; 622 } 623 } 624 fdrarray[i].fdr = min; 625 /* 626 * for debugging: 627 * System.out.print("mascot:"+fdrarray[i].mascot_score+" 628 * tandem:"+fdrarray[i].tandem_eValue); System.out.println(" 629 * p_value:"+fdrarray[i].pValue+" 630 * corrected:"+fdrarray[i].corrected_p+" fdr:"+fdrarray[i].fdr); 631 */ 632 } 633 int truecount = 0, falsecount = 0, tandem_count = 0, mascot_count = 0, combined_count = 0; 634 double tandem_only_limit = 0, mascot_only_limit = 1000, tandem_combined = 0, mascot_combined = 1000; 635 FdrRow lasthit = fdrarray[0]; 465 636 SortedSet final_result = new TreeSet(); 466 for (int i =0;i<fdrarray.length;++i)467 { 468 if (fdrarray[i].fdr <=this.getCutOff())469 { 470 ResultRow newrow =new ResultRow();471 newrow.spotId =fdrarray[i].spotId;472 newrow.proteinId =fdrarray[i].ipi;473 newrow.description =fdrarray[i].description;474 newrow.eValue =fdrarray[i].tandem_eValue;475 newrow.score =fdrarray[i].mascot_score;476 newrow.pi =fdrarray[i].pi;477 newrow.mw =fdrarray[i].mw;637 for (int i = 0; i < fdrarray.length; ++i) 638 { 639 if (fdrarray[i].fdr <= this.getCutOff()) 640 { 641 ResultRow newrow = new ResultRow(); 642 newrow.spotId = fdrarray[i].spotId; 643 newrow.proteinId = fdrarray[i].ipi; 644 newrow.description = fdrarray[i].description; 645 newrow.eValue = fdrarray[i].tandem_eValue; 646 newrow.score = fdrarray[i].mascot_score; 647 newrow.pi = fdrarray[i].pi; 648 newrow.mw = fdrarray[i].mw; 478 649 final_result.add(newrow); 479 650 truecount++; 480 lasthit =fdrarray[i];651 lasthit = fdrarray[i]; 481 652 // We want to report the worst scores that passed the FDR 482 if (fdrarray[i].mascot_score !=0)483 { 484 if (fdrarray[i].tandem_eValue ==0)653 if (fdrarray[i].mascot_score != 0) 654 { 655 if (fdrarray[i].tandem_eValue == 0) 485 656 { 486 657 mascot_count++; 487 if (mascot_only_limit >fdrarray[i].mascot_score)488 { 489 mascot_only_limit =fdrarray[i].mascot_score;490 } 491 } 492 else 658 if (mascot_only_limit > fdrarray[i].mascot_score) 659 { 660 mascot_only_limit = fdrarray[i].mascot_score; 661 } 662 } 663 else 493 664 { 494 665 combined_count++; 495 666 // For combined hits we keep the lowest of any 496 if (mascot_combined >fdrarray[i].mascot_score)497 { 498 mascot_combined =fdrarray[i].mascot_score;499 } 500 if (tandem_combined <fdrarray[i].tandem_eValue)501 { 502 tandem_combined =fdrarray[i].tandem_eValue;503 } 504 } 667 if (mascot_combined > fdrarray[i].mascot_score) 668 { 669 mascot_combined = fdrarray[i].mascot_score; 670 } 671 if (tandem_combined < fdrarray[i].tandem_eValue) 672 { 673 tandem_combined = fdrarray[i].tandem_eValue; 674 } 675 } 505 676 } 506 677 else 507 678 { 508 679 tandem_count++; 509 if (tandem_only_limit <fdrarray[i].tandem_eValue)510 { 511 tandem_only_limit =fdrarray[i].tandem_eValue;512 } 680 if (tandem_only_limit < fdrarray[i].tandem_eValue) 681 { 682 tandem_only_limit = fdrarray[i].tandem_eValue; 683 } 513 684 } 514 685 } … … 518 689 } 519 690 } 520 System.out.println("Worst hit fdr:"+lasthit.fdr+" pValue:"+lasthit.pValue+ " corrected:"+lasthit.corrected_p+" spot+ipi:"+lasthit.spotId+" "+lasthit.ipi); 521 System.out.println("Lowest mascot only score:"+mascot_only_limit+" Tandem:"+tandem_only_limit); 522 System.out.println("Lowest scores in combined. Mascot:"+mascot_combined+" tandem:"+tandem_combined); 523 System.out.println("Positives:"+truecount+" Combined:"+combined_count+" tandem:"+tandem_count+" mascot:"+mascot_count); 524 // now count false tandem and mascot hits in order to find out if OK. Print the reverse db hits. 525 526 int mascot_scores_above=0,tandem_scores_below=0, both_scores=0; 527 Iterator<FdrRow> reverse_it=reverselist.iterator(); 691 System.out 692 .println("Worst hit fdr:" + lasthit.fdr + " pValue:" + lasthit.pValue + " corrected:" + lasthit.corrected_p + " spot+ipi:" + lasthit.spotId + " " + lasthit.ipi); 693 System.out 694 .println("Lowest mascot only score:" + mascot_only_limit + " Tandem:" + tandem_only_limit); 695 System.out 696 .println("Lowest scores in combined. Mascot:" + mascot_combined + " tandem:" + tandem_combined); 697 System.out 698 .println("Positives:" + truecount + " Combined:" + combined_count + " tandem:" + tandem_count + " mascot:" + mascot_count); 699 // now count false tandem and mascot hits in order to find out if OK. 700 // Print the reverse db hits. 701 int mascot_scores_above = 0, tandem_scores_below = 0, both_scores = 0; 702 Iterator<FdrRow> reverse_it = reverselist.iterator(); 528 703 System.out.println("Random DB hits passing:"); 529 704 while (reverse_it.hasNext()) 530 705 { 531 FdrRow currentrow =reverse_it.next();532 if ((currentrow.mascot_score !=0) && (currentrow.tandem_eValue==0))533 { 534 if (currentrow.mascot_score >=mascot_only_limit)706 FdrRow currentrow = reverse_it.next(); 707 if ((currentrow.mascot_score != 0) && (currentrow.tandem_eValue == 0)) 708 { 709 if (currentrow.mascot_score >= mascot_only_limit) 535 710 { 536 711 mascot_scores_above++; 537 System.out.println("spot+accession:"+currentrow.spotId+" "+currentrow.ipi+" mascot:"+currentrow.mascot_score); 538 } 539 } 540 else if ((currentrow.mascot_score==0) && (currentrow.tandem_eValue!=0)) 541 { 542 if (currentrow.tandem_eValue<=tandem_only_limit) 712 System.out 713 .println("spot+accession:" + currentrow.spotId + " " + currentrow.ipi + " mascot:" + currentrow.mascot_score); 714 } 715 } 716 else if ((currentrow.mascot_score == 0) && (currentrow.tandem_eValue != 0)) 717 { 718 if (currentrow.tandem_eValue <= tandem_only_limit) 543 719 { 544 720 tandem_scores_below++; 545 System.out.println("spot+accession:"+currentrow.spotId+" "+currentrow.ipi+" tandem:"+currentrow.tandem_eValue); 546 } 547 } 548 else if ((currentrow.mascot_score!=0) && (currentrow.tandem_eValue!=0)) 549 { 550 if (currentrow.tandem_eValue<=tandem_combined && currentrow.mascot_score>=mascot_combined) 721 System.out 722 .println("spot+accession:" + currentrow.spotId + " " + currentrow.ipi + " tandem:" + currentrow.tandem_eValue); 723 } 724 } 725 else if ((currentrow.mascot_score != 0) && (currentrow.tandem_eValue != 0)) 726 { 727 if (currentrow.tandem_eValue <= tandem_combined && currentrow.mascot_score >= mascot_combined) 551 728 { 552 729 // This one is tricky, since the score limit is a curve 553 // We have to calculate a p-value for the reverse hit as we did for 554 // the forward hits and find out if it is lower than the limit. 555 Iterator<FdrRow> reverseit=reverselist.iterator(); 556 int reversehits=0; 730 // We have to calculate a p-value for the reverse hit as we 731 // did for 732 // the forward hits and find out if it is lower than the 733 // limit. 734 Iterator<FdrRow> reverseit = reverselist.iterator(); 735 int reversehits = 0; 557 736 // Count how many reverse hits have both scores better 558 737 while (reverseit.hasNext()) 559 738 { 560 FdrRow currentreverse =reverseit.next();561 if (currentreverse.mascot_score !=0 && currentreverse.tandem_eValue!=0)562 { 563 if (currentreverse.mascot_score >=currentrow.mascot_score && currentreverse.tandem_eValue<=currentrow.tandem_eValue)739 FdrRow currentreverse = reverseit.next(); 740 if (currentreverse.mascot_score != 0 && currentreverse.tandem_eValue != 0) 741 { 742 if (currentreverse.mascot_score >= currentrow.mascot_score && currentreverse.tandem_eValue <= currentrow.tandem_eValue) 564 743 { 565 744 reversehits++; … … 567 746 } 568 747 } 569 currentrow.pValue =(double)(reversehits+1)/(double)(total_number+1);570 if (currentrow.pValue <lasthit.pValue)748 currentrow.pValue = (double) (reversehits + 1) / (double) (total_number + 1); 749 if (currentrow.pValue < lasthit.pValue) 571 750 { 572 751 both_scores++; 573 System.out .println("spot+accession:"+currentrow.spotId+" "+currentrow.ipi+" tandem:"+currentrow.tandem_eValue+" mascot:"+currentrow.mascot_score);574 }575 }576 }577 }578 info = "FPR:"+cutOff+" Tandem only limit:"+tandem_only_limit+" Mascot only limit:"+mascot_only_limit+". Worst scores passing in combined hits: (Tandem, Mascot):"+tandem_combined+", "+mascot_combined;579 info += ". Hits passing:"+truecount+" Tandem:"+tandem_count+" Mascot:"+mascot_count+" Combined:"+combined_count;580 info += ". Reverse db hits passing - Tandem:"+tandem_scores_below+" Mascot:"+mascot_scores_above+" Combined:"+both_scores;581 System.out.println("Reverse mascot above:"+mascot_scores_above);582 System.out.println("Reverse tandem below:"+tandem_scores_below);583 System.out.println("Reverse both:"+both_scores);584 752 System.out 753 .println("spot+accession:" + currentrow.spotId + " " + currentrow.ipi + " tandem:" + currentrow.tandem_eValue + " mascot:" + currentrow.mascot_score); 754 } 755 } 756 } 757 } 758 info = "FPR:" + cutOff + " Tandem only limit:" + tandem_only_limit + " Mascot only limit:" + mascot_only_limit + ". Worst scores passing in combined hits: (Tandem, Mascot):" + tandem_combined + ", " + mascot_combined; 759 info += ". Hits passing:" + truecount + " Tandem:" + tandem_count + " Mascot:" + mascot_count + " Combined:" + combined_count; 760 info += ". Reverse db hits passing - Tandem:" + tandem_scores_below + " Mascot:" + mascot_scores_above + " Combined:" + both_scores; 761 System.out.println("Reverse mascot above:" + mascot_scores_above); 762 System.out.println("Reverse tandem below:" + tandem_scores_below); 763 System.out.println("Reverse both:" + both_scores); 585 764 return final_result; 586 765 } 587 766 767 588 768 public void setDate(String date) 589 769 { 590 770 this.date = date; 591 771 } 772 773 592 774 public String getDate() 593 775 { 594 776 return date; 595 777 } 596 778 779 597 780 public void setDate2(String date2) 598 781 { 599 782 this.date2 = date2; 600 783 } 784 785 601 786 public String getDate2() 602 787 { 603 788 return date2; 604 789 } 790 791 605 792 public void setReverseText(String reverseText) 606 793 { 607 794 this.reverseText = reverseText; 608 795 } 796 797 609 798 public String getReverseText() 610 799 { 611 800 return reverseText; 612 801 } 613 802 803 804 public void setIsProteinScores(boolean isproteins) 805 { 806 this.isProteinScores = isproteins; 807 } 808 809 614 810 public void setCutOff(Double cutOff) 615 811 { 616 812 this.cutOff = cutOff.doubleValue(); 617 813 } 814 815 618 816 public Double getCutOff() 619 817 { 620 818 return new Double(cutOff); 621 819 } 622 820 623 821 public class FdrRow 624 implements Comparable822 implements Comparable 625 823 { 626 824 FdrRow() 627 { 628 } 825 {} 826 629 827 630 828 public int compareTo(Object o) 631 829 { 632 int retval =1;633 FdrRow other = (FdrRow) o;634 if (this.pValue <other.pValue)635 { 636 retval =-1;637 } 638 else if (this.pValue ==other.pValue)639 { 640 if (this.spotId ==other.spotId)641 { 642 retval =this.ipi.compareTo(other.ipi);643 } 644 else if (this.spotId <other.spotId)645 { 646 retval =-1;830 int retval = 1; 831 FdrRow other = (FdrRow) o; 832 if (this.pValue < other.pValue) 833 { 834 retval = -1; 835 } 836 else if (this.pValue == other.pValue) 837 { 838 if (this.spotId == other.spotId) 839 { 840 retval = this.ipi.compareTo(other.ipi); 841 } 842 else if (this.spotId < other.spotId) 843 { 844 retval = -1; 647 845 } 648 846 } … … 650 848 } 651 849 652 public double pValue =1;850 public double pValue = 1; 653 851 public double fdr; 654 public int spotId =0;655 public String ipi ="";852 public int spotId = 0; 853 public String ipi = ""; 656 854 public String description; 657 public double mascot_score =0;658 public double tandem_eValue =0;855 public double mascot_score = 0; 856 public double tandem_eValue = 0; 659 857 public double corrected_p; 660 public double mw=0; 661 public double pi=0; 662 663 664 } 665 666 858 public double mw = 0; 859 public double pi = 0; 860 } 861 667 862 /** 668 669 contains a compareTo method that will sort the objects correct670 */863 * This abstract inner class stores data for one row in the report. It also 864 * contains a compareTo method that will sort the objects correct 865 */ 671 866 public class ResultRow 672 implements Comparable867 implements Comparable 673 868 { 674 869 ResultRow() 675 { 676 } 677 870 {} 871 872 678 873 /** 679 Comparator that for sorting the objects according to SpotId,680 and eValue.681 682 683 */874 * Comparator that for sorting the objects according to SpotId, and 875 * eValue. 876 * 877 * @param o The object to compare with. 878 */ 684 879 public int compareTo(Object o) 685 880 { 686 881 int compValue = 1; 687 ResultRow other = (ResultRow) o;882 ResultRow other = (ResultRow) o; 688 883 if (this.spotId < other.spotId) 689 884 { 690 885 compValue = -1; 691 } 692 else if (this.spotId ==other.spotId)886 } 887 else if (this.spotId == other.spotId) 693 888 { 694 889 if (this.eValue < other.eValue) … … 696 891 compValue = -1; 697 892 } 698 else if (this.eValue ==other.eValue && (this.score>other.score))893 else if (this.eValue == other.eValue && (this.score > other.score)) 699 894 { 700 895 compValue = -1; 701 } 896 } 702 897 } 703 898 return compValue; 704 899 } 705 900 901 706 902 public String toString() 707 903 { 708 String out = spotId +"\t"+eValue+"\t"+score+"\t"+proteinId+"\t"+description+"\t"+mw+"\t"+pi;904 String out = spotId + "\t" + eValue + "\t" + score + "\t" + proteinId + "\t" + description + "\t" + mw + "\t" + pi; 709 905 return out; 710 906 } 711 712 907 713 908 // Variables 714 public Date dBSearchId =new Date(10000);715 public int spotId =0;909 public Date dBSearchId = new Date(10000); 910 public int spotId = 0; 716 911 public String MPId; 717 912 public String MPLabel; 718 913 public String TargetId; 719 914 public String TargetPosition; 720 public double eValue =1000;721 public String proteinId ="";915 public double eValue = 1000; 916 public String proteinId = ""; 722 917 public String description; 723 public String score_type ="";724 public double score =0;725 public double mw =0;726 public double pi =0;727 public double rms =0;728 public List identificationHypotheses =new ArrayList();918 public String score_type = ""; 919 public double score = 0; 920 public double mw = 0; 921 public double pi = 0; 922 public double rms = 0; 923 public List identificationHypotheses = new ArrayList(); 729 924 } 730 925 731 926 SimpleDateFormat dfXML = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 732 733 927 private SQLEvictConnection dbconnection; 734 928 private Set resultSet; 929 private int db_entries = 0; 735 930 private String gelId; 736 private String info ="";931 private String info = ""; 737 932 private String date; 738 933 private String date2; 739 934 private String reverseText; 740 private double cutOff=0.01; 935 private String gel_autoid; 936 private boolean isProteinScores = true; 937 private double cutOff = 0.01; 741 938 }
Note: See TracChangeset
for help on using the changeset viewer.