Changeset 4545
- Timestamp:
- Feb 26, 2014, 4:55:01 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/api/core/src/org/proteios/core/Modification.java
r4504 r4545 168 168 public String getDiffFormula() 169 169 { 170 return getData().getDiffFormula(); 170 if (getData().getDiffFormula()!=null) 171 return getData().getDiffFormula(); 172 else { 173 return getDiffFormulaFromModificationName(this); 174 } 171 175 } 172 176 … … 313 317 mod.setPosition(mod.getPosition() + 1); 314 318 } 319 320 protected static String getDiffFormulaFromModificationName(Modification<?> mod) 321 { 322 Map<String, String> modMap = new HashMap<String, String>(); 323 modMap.put("Carbamidomethyl", "H(3) C(2) N(1) O(1)"); 324 modMap.put("Phospho", "H(1) O(3) P(1)"); 325 modMap.put("Oxidation", "O(1)"); 326 modMap.put("Acetyl", "H(2) C(2) O(1)"); 327 modMap.put("Deamidation", "H(-1) N(-1) O(1)"); 328 modMap.put("Pyro_glu", "H(-2) O(-1)"); 329 modMap.put("Pyro-glu", "H(-3) N(-1)"); 330 return modMap.get(mod.getName()); 331 } 315 332 } -
trunk/contrib/SpectrumLibraryExport/src/satoshi/CreateLibraryExportJob.java
r4264 r4545 34 34 // List<Integer> files = getValidIntegerList(FormFactory.VID); 35 35 Float fdr = getValidFloat(LibraryExportForm.FDRCUTOFF); 36 Float fragTol = getValidFloat(LibraryExportForm.FRAGMENTTOL); 36 37 String prefix2 = getValidString(LibraryExportForm.OUTFILENAME); 37 38 String prefix3 = getValidString(LibraryExportForm.OUTFILENAME2); 38 39 Boolean ssl = getValidBoolean(LibraryExportForm.SSLFORMAT); 39 40 Boolean msp = getValidBoolean(LibraryExportForm.MSPFORMAT); 41 Boolean eValue = getValidBoolean(LibraryExportForm.EVALUE); 42 if (eValue == null) 43 eValue = new Boolean(false); 40 44 if (ssl == null) 41 45 ssl = new Boolean(false); 42 46 if (msp == null) 43 47 msp = new Boolean(false); 44 if (msp == null && ssl == null) 45 { 46 throw new NullPointerException( 47 "Failed to initialize job. Missing values"); 48 if (!msp.booleanValue() && !ssl.booleanValue()){ 49 throw new ActionException( 50 "Failed to initialize job. Missing output format"); 48 51 } 49 52 … … 64 67 Job job = factory.createJob(plugin, null); 65 68 job.setName(plugin.getName()); // pass the name of the plugin 66 // Tell the job which file to work with67 // File file = factory.getById(File.class, fileId);68 job.setDescription("Library export");69 // Tell the job which file to work with70 // FileParameterType fileParam = new FileParameterType();71 // job.setParameterValue(ImportXFile.FILEPARAM, fileParam, file);72 73 // Tell the job which prefix to add74 69 FloatParameterType prefixParam = new FloatParameterType(); 75 70 job.setParameterValue(LibraryExportPlugin.FDRCUTOFFPARAM, prefixParam, 76 71 fdr); 72 job.setParameterValue(LibraryExportPlugin.FRAGMENTTOLERANCEPARAM, new FloatParameterType(), 73 fragTol); 77 74 StringParameterType prefixParam2 = new StringParameterType(); 78 75 job.setParameterValue(LibraryExportPlugin.OUTFILEPARAM, prefixParam2, … … 85 82 BooleanParameterType prefixParam5 = new BooleanParameterType(); 86 83 job.setParameterValue(LibraryExportPlugin.MSPPARAM, prefixParam5, msp); 87 84 job.setParameterValue(LibraryExportPlugin.EVALUEPARAM, new BooleanParameterType(), eValue); 88 85 Project project = isProjectActive(dc); // returns the active project if 89 86 // any 90 87 Directory dir = project.getProjectDirectory(); // returns the project 91 88 // directory path 89 job.setDescription("Library export "+ project.getName()); 92 90 ItemParameterType<Directory> dirParam = new ItemParameterType<Directory>( 93 91 Directory.class, null); -
trunk/contrib/SpectrumLibraryExport/src/satoshi/LibraryExportForm.java
r4300 r4545 6 6 import org.proteios.TableToolbarContext; 7 7 import org.proteios.action.ProteiosAction; 8 import org.proteios.action.feature.FeatureHitMatchForm;9 import org.proteios.action.hit.CreateProteinAssemblyJob;10 8 import org.proteios.core.Hit; 11 9 import org.proteios.gui.Title; … … 45 43 public static final VBoolean SSLFORMAT = new VBoolean("sslON", false); 46 44 public static final VBoolean MSPFORMAT = new VBoolean("mspON", false); 45 public static final VBoolean EVALUE = new VBoolean("evalueON", false); 46 public static final VFloat FRAGMENTTOL = new VFloat("fragTol", 0f, 1f); 47 47 48 48 … … 64 64 fdrCutOff.setValue("0.01"); 65 65 fieldSet.add(fdrCutOff); 66 67 Checkbox<VBoolean> eON = new Checkbox<VBoolean>(EVALUE); 68 eON.setValue("true"); 69 eON.isChecked(false); 70 eON.setLabel(getLocale().get("E-value")); 71 eON.setHelp("E-value instead of FDR cutoff"); 72 fieldSet.add(eON); 66 73 67 74 TextField<String> filename = new TextField<String>(OUTFILENAME); … … 86 93 mspON.setLabel(getLocale().get(".msp format as output")); 87 94 fieldSet.add(mspON); 95 96 TextField<String> fragTolF = new TextField<String>(FRAGMENTTOL); 97 fragTolF.setLabel(getLocale().get("Fragment m/z tolerance")); 98 fragTolF.setValue("0.5"); 99 fieldSet.add(fragTolF); 88 100 89 101 /* -
trunk/contrib/SpectrumLibraryExport/src/satoshi/LibraryExportPlugin.java
r4485 r4545 9 9 import org.proteios.core.ItemFactory; 10 10 import org.proteios.core.ItemQuery; 11 import org.proteios.core.ItemResultIterator;12 11 import org.proteios.core.ItemResultList; 13 12 import org.proteios.core.ObservedModification; … … 19 18 import org.proteios.core.SearchModification; 20 19 import org.proteios.core.SessionControl; 21 import org.proteios.core.SpectrumSearch;22 import org.proteios.core.SearchModification.TerminalSpecificity;23 20 import org.proteios.core.plugin.About; 24 21 import org.proteios.core.plugin.AboutImpl; … … 39 36 import org.proteios.io.SpectrumPrecursor; 40 37 38 import se.lth.immun.chem.Ion; 39 import se.lth.immun.chem.ModifiedAminoAcid; 40 import se.lth.immun.chem.Modifier; 41 import se.lth.immun.chem.PeptideFragment; 42 import se.lth.immun.chem.PeptideUtil; 43 41 44 import java.io.BufferedWriter; 42 45 import java.io.IOException; … … 73 76 public static final String SSLPARAM = "sslFormat"; 74 77 public static final String MSPPARAM = "mspFormat"; 78 public static final String EVALUEPARAM = "eValue"; 79 public static final String FRAGMENTTOLERANCEPARAM = "fragTol"; 75 80 private static final Double MONOISTOPIC_PROTON_MASS = 1.007276035; 76 81 … … 87 92 private boolean mspFormat = true; // to be used for SpectraSt 88 93 private boolean sslFormat = true; 94 private boolean eValue = false; 89 95 // other variables 90 96 private Project project = null; … … 92 98 private boolean fileNameAssigned2 = false; 93 99 private int spectrumNumber = 1; 100 private double mzTolerance = 0.5d; 94 101 95 102 // SessionControl sc; // instantiated below … … 139 146 String filename2 = (String) job.getValue(OUTFILEPARAM2); // for .msp 140 147 fdrCutOff = ((Float) job.getValue(FDRCUTOFFPARAM)).doubleValue(); 148 mzTolerance = ((Float) job.getValue(FRAGMENTTOLERANCEPARAM)).doubleValue(); 141 149 mgfFormat = false; 142 150 sslFormat = ((Boolean) job.getValue(SSLPARAM)).booleanValue(); 143 151 mspFormat = ((Boolean) job.getValue(MSPPARAM)).booleanValue(); 144 152 eValue = ((Boolean) job.getValue(EVALUEPARAM)).booleanValue(); 145 153 if (filename == null && filename2 == null) // stop 146 154 { … … 401 409 Expressions.parameter("protein"))); 402 410 hitQuery.setPermanentParameter("protein", false, null); 403 hitQuery.restrict(Restrictions.lteq(Hql.property("combinedFDR"), 411 if (!eValue) 412 { 413 hitQuery.restrict(Restrictions.lteq(Hql.property("combinedFDR"), 404 414 Expressions.aFloat((float) fdrCutOff))); 415 } 416 else 417 { 418 hitQuery.restrict(Restrictions.lteq(Hql.property("expectationValue"), 419 Expressions.aFloat((float) fdrCutOff))); 420 421 } 405 422 hitQuery.restrict(Restrictions.neq(Hql.property("scoreType"), 406 423 Expressions.string("Proteios aligned"))); 407 424 hitQuery.order(Orders.asc(Hql.property("charge"))); 408 425 hitQuery.order(Orders.asc(Hql.property("description"))); 409 hitQuery.order(Orders.asc(Hql.property("combinedFDR")));426 if (!eValue) hitQuery.order(Orders.asc(Hql.property("combinedFDR"))); 410 427 hitQuery.order(Orders.asc(Hql.property("expectationValue"))); 411 428 List<String> sequencesForCharge = new ArrayList<String>(); … … 413 430 ItemResultList<Hit> hitlist = hitQuery.list(dc); 414 431 int currentCharge = 0; 432 log.debug("Number of hits:"+hitlist.size()); 415 433 for (Hit h : hitlist) { 416 434 if (currentCharge != h.getCharge().intValue()) { … … 433 451 while (hitit.hasNext()) { 434 452 Hit currentHit = hitit.next(); 435 if (hitit.hasNext()) { 436 // log.debug(">" + pklFile + "\t" + output + "\t" + 437 // output2 + "\t" + peptidelist + "\n"); 438 if (pklFile != null 439 && currentHit.getPeakListFile() != pklFile) { 440 // start retrieving all necessary info. 441 // including spectrum for each hit 442 retrieveAndWriteSpectra(pklFile, hitList, output, 453 if (pklFile == null) 454 { 455 pklFile = currentHit.getPeakListFile(); 456 } 457 if (pklFile != currentHit.getPeakListFile()) 458 { 459 retrieveAndWriteSpectra(pklFile, hitList, output, 443 460 output2, dc); 444 // empty hitList and store the currentHit 445 hitList.clear(); 446 hitList.add(currentHit); 447 pklFile = currentHit.getPeakListFile(); 448 } else { 449 hitList.add(currentHit); 450 pklFile = currentHit.getPeakListFile(); // get the 451 // file name 452 // even if it is the same as before 453 } 454 } else { 455 // log.debug(">2" + pklFile + "\t" + output + "\t" + 456 // output2 + "\t" + peptidelist + "\n"); 457 retrieveAndWriteSpectra(pklFile, hitList, output, output2, 458 dc); 461 // empty hitList 459 462 hitList.clear(); 460 hitList.add(currentHit); 461 } 462 } 463 pklFile = currentHit.getPeakListFile(); 464 } 465 log.debug("Adding hit:"+currentHit.getDescription()); 466 hitList.add(currentHit); 467 } 468 log.debug("At final"); 469 if (!hitList.isEmpty()) retrieveAndWriteSpectra(pklFile, hitList, output, output2,dc); 463 470 if (output != null) { 464 471 // log.debug(">3 output closed\n"); … … 597 604 // correct only unique ones 598 605 int requestSpectraNr = 0; 606 log.debug("PKL file:"+pklFile.getName()+" hits:"+peptideHits.size()); 599 607 for (Hit phit : peptideHits) { 600 608 // make sure the file format and its interface … … 603 611 requestSpectraStringID.add(phit.getSpectrumStringId()); 604 612 String[] s1 = phit.getDescription().split(" ", 2); 613 if (s1.length == 2 && s1[1].contains(">")) 614 { 615 log.debug("Sequence:"+s1[0]+" mod:"+s1[1]); 616 String[] parts = s1[1].split(" "); 617 String newString = null; 618 for (String s2:parts) 619 { 620 if (s2.contains(">")) 621 { 622 int pos = Integer.parseInt(s2.substring(s2.indexOf('@')+2,s2.indexOf('('))); 623 char newchar = s2.charAt(s2.indexOf('>')+1); 624 if (pos>0) --pos; 625 String newSeq = s1[0].substring(0,pos)+newchar+s1[0].substring(pos+1); 626 s1[0]=newSeq; 627 log.debug("new Sequence:"+newSeq); 628 } 629 else 630 { 631 if (newString == null) newString=s2; 632 else newString+=" "+s2; 633 } 634 } 635 s1[1]=newString; 636 } 637 605 638 requestSpectraSEQ.add(s1[0]); // sequence 606 639 if (s1.length == 2) { … … 958 991 requestSpectraSEQ.get(i), 959 992 requestSpectraModification.get(i), fixedMods); 993 List<ObservedModification> obsMods = ObservedModification.getModList(requestSpectraSEQ.get(i), requestSpectraModification.get(i), 994 fixedMods, factory); 995 se.lth.immun.chem.Peptide pep = PeptideUtil.standardPeptideFromString(requestSpectraSEQ.get(i)); 996 for (ObservedModification om : obsMods) 997 { 998 int pos = om.getPosition(); 999 ModifiedAminoAcid maa = new ModifiedAminoAcid(pep.aminoAcids[pos],Modifier.parseMolecule(om.getDiffFormula())); 1000 pep.aminoAcids[pos]=maa; 1001 } 1002 List<Ion<PeptideFragment>> ions = PeptideUtil.possibleYAndBIons(pep, 2); 960 1003 output2.write(charge + "\n" + "MW: " + mass + "\n"); 961 1004 // List<Double> parent = new ArrayList<Double>(); … … 1047 1090 for (int l = 0; l < mzs.size(); l++) { 1048 1091 output2.write(fourDecimals.format(mzs.get(l)) + "\t" 1049 + ints.get(l) + "\t\"?\"\n"); 1092 + ints.get(l) + "\t\""); 1093 String s = PeptideUtil.matchedIonsAsString(PeptideUtil.matchingIons(ions, mzs.get(l), mzTolerance)); 1094 if (s!=null && s.length()>0) 1095 { 1096 output2.write(s+"\"\n"); 1097 } 1098 else 1099 { 1100 output2.write("?\"\n"); 1101 } 1050 1102 } 1051 1103 output2.write("\n");
Note: See TracChangeset
for help on using the changeset viewer.