Changeset 4545


Ignore:
Timestamp:
Feb 26, 2014, 4:55:01 PM (9 years ago)
Author:
Fredrik Levander
Message:

Updates to Modification to give diff formula. Updates to contrib library expeort with msp library peak annotation.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/api/core/src/org/proteios/core/Modification.java

    r4504 r4545  
    168168  public String getDiffFormula()
    169169  {
    170     return getData().getDiffFormula();
     170    if (getData().getDiffFormula()!=null)
     171      return getData().getDiffFormula();
     172    else {
     173      return getDiffFormulaFromModificationName(this);
     174    }
    171175  }
    172176
     
    313317    mod.setPosition(mod.getPosition() + 1);
    314318  }
     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  }
    315332}
  • trunk/contrib/SpectrumLibraryExport/src/satoshi/CreateLibraryExportJob.java

    r4264 r4545  
    3434    // List<Integer> files = getValidIntegerList(FormFactory.VID);
    3535    Float fdr = getValidFloat(LibraryExportForm.FDRCUTOFF);
     36    Float fragTol = getValidFloat(LibraryExportForm.FRAGMENTTOL);
    3637    String prefix2 = getValidString(LibraryExportForm.OUTFILENAME);
    3738    String prefix3 = getValidString(LibraryExportForm.OUTFILENAME2);
    3839    Boolean ssl = getValidBoolean(LibraryExportForm.SSLFORMAT);
    3940    Boolean msp = getValidBoolean(LibraryExportForm.MSPFORMAT);
     41    Boolean eValue = getValidBoolean(LibraryExportForm.EVALUE);
     42    if (eValue == null)
     43      eValue = new Boolean(false);
    4044    if (ssl == null)
    4145      ssl = new Boolean(false);
    4246    if (msp == null)
    4347      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");
    4851    }
    4952
     
    6467    Job job = factory.createJob(plugin, null);
    6568    job.setName(plugin.getName()); // pass the name of the plugin
    66     // Tell the job which file to work with
    67     // File file = factory.getById(File.class, fileId);
    68     job.setDescription("Library export");
    69     // Tell the job which file to work with
    70     // FileParameterType fileParam = new FileParameterType();
    71     // job.setParameterValue(ImportXFile.FILEPARAM, fileParam, file);
    72 
    73     // Tell the job which prefix to add
    7469    FloatParameterType prefixParam = new FloatParameterType();
    7570    job.setParameterValue(LibraryExportPlugin.FDRCUTOFFPARAM, prefixParam,
    7671      fdr);
     72    job.setParameterValue(LibraryExportPlugin.FRAGMENTTOLERANCEPARAM, new FloatParameterType(),
     73      fragTol);
    7774    StringParameterType prefixParam2 = new StringParameterType();
    7875    job.setParameterValue(LibraryExportPlugin.OUTFILEPARAM, prefixParam2,
     
    8582    BooleanParameterType prefixParam5 = new BooleanParameterType();
    8683    job.setParameterValue(LibraryExportPlugin.MSPPARAM, prefixParam5, msp);
    87 
     84    job.setParameterValue(LibraryExportPlugin.EVALUEPARAM, new BooleanParameterType(), eValue);
    8885    Project project = isProjectActive(dc); // returns the active project if
    8986    // any
    9087    Directory dir = project.getProjectDirectory(); // returns the project
    9188    // directory path
     89    job.setDescription("Library export "+ project.getName());
    9290    ItemParameterType<Directory> dirParam = new ItemParameterType<Directory>(
    9391      Directory.class, null);
  • trunk/contrib/SpectrumLibraryExport/src/satoshi/LibraryExportForm.java

    r4300 r4545  
    66import org.proteios.TableToolbarContext;
    77import org.proteios.action.ProteiosAction;
    8 import org.proteios.action.feature.FeatureHitMatchForm;
    9 import org.proteios.action.hit.CreateProteinAssemblyJob;
    108import org.proteios.core.Hit;
    119import org.proteios.gui.Title;
     
    4543  public static final VBoolean SSLFORMAT = new VBoolean("sslON", false);
    4644  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);
    4747
    4848
     
    6464    fdrCutOff.setValue("0.01");
    6565    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);
    6673
    6774    TextField<String> filename = new TextField<String>(OUTFILENAME);
     
    8693    mspON.setLabel(getLocale().get(".msp format as output"));
    8794    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);
    88100
    89101    /*
  • trunk/contrib/SpectrumLibraryExport/src/satoshi/LibraryExportPlugin.java

    r4485 r4545  
    99import org.proteios.core.ItemFactory;
    1010import org.proteios.core.ItemQuery;
    11 import org.proteios.core.ItemResultIterator;
    1211import org.proteios.core.ItemResultList;
    1312import org.proteios.core.ObservedModification;
     
    1918import org.proteios.core.SearchModification;
    2019import org.proteios.core.SessionControl;
    21 import org.proteios.core.SpectrumSearch;
    22 import org.proteios.core.SearchModification.TerminalSpecificity;
    2320import org.proteios.core.plugin.About;
    2421import org.proteios.core.plugin.AboutImpl;
     
    3936import org.proteios.io.SpectrumPrecursor;
    4037
     38import se.lth.immun.chem.Ion;
     39import se.lth.immun.chem.ModifiedAminoAcid;
     40import se.lth.immun.chem.Modifier;
     41import se.lth.immun.chem.PeptideFragment;
     42import se.lth.immun.chem.PeptideUtil;
     43
    4144import java.io.BufferedWriter;
    4245import java.io.IOException;
     
    7376  public static final String SSLPARAM = "sslFormat";
    7477  public static final String MSPPARAM = "mspFormat";
     78  public static final String EVALUEPARAM = "eValue";
     79  public static final String FRAGMENTTOLERANCEPARAM = "fragTol";
    7580  private static final Double MONOISTOPIC_PROTON_MASS = 1.007276035;
    7681
     
    8792  private boolean mspFormat = true; // to be used for SpectraSt
    8893  private boolean sslFormat = true;
     94  private boolean eValue = false;
    8995  // other variables
    9096  private Project project = null;
     
    9298  private boolean fileNameAssigned2 = false;
    9399  private int spectrumNumber = 1;
     100  private double mzTolerance = 0.5d;
    94101
    95102  // SessionControl sc; // instantiated below
     
    139146      String filename2 = (String) job.getValue(OUTFILEPARAM2); // for .msp
    140147      fdrCutOff = ((Float) job.getValue(FDRCUTOFFPARAM)).doubleValue();
     148      mzTolerance = ((Float) job.getValue(FRAGMENTTOLERANCEPARAM)).doubleValue();
    141149      mgfFormat = false;
    142150      sslFormat = ((Boolean) job.getValue(SSLPARAM)).booleanValue();
    143151      mspFormat = ((Boolean) job.getValue(MSPPARAM)).booleanValue();
    144 
     152      eValue = ((Boolean) job.getValue(EVALUEPARAM)).booleanValue();
    145153      if (filename == null && filename2 == null) // stop
    146154      {
     
    401409          Expressions.parameter("protein")));
    402410      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"),
    404414          Expressions.aFloat((float) fdrCutOff)));
     415      }
     416      else
     417      {
     418        hitQuery.restrict(Restrictions.lteq(Hql.property("expectationValue"),
     419          Expressions.aFloat((float) fdrCutOff)));
     420       
     421      }
    405422      hitQuery.restrict(Restrictions.neq(Hql.property("scoreType"),
    406423          Expressions.string("Proteios aligned")));
    407424      hitQuery.order(Orders.asc(Hql.property("charge")));
    408425      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")));
    410427      hitQuery.order(Orders.asc(Hql.property("expectationValue")));
    411428      List<String> sequencesForCharge = new ArrayList<String>();
     
    413430      ItemResultList<Hit> hitlist = hitQuery.list(dc);
    414431      int currentCharge = 0;
     432      log.debug("Number of hits:"+hitlist.size());
    415433      for (Hit h : hitlist) {
    416434        if (currentCharge != h.getCharge().intValue()) {
     
    433451      while (hitit.hasNext()) {
    434452        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,
    443460                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
    459462          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);
    463470      if (output != null) {
    464471        // log.debug(">3 output closed\n");
     
    597604      // correct only unique ones
    598605      int requestSpectraNr = 0;
     606      log.debug("PKL file:"+pklFile.getName()+" hits:"+peptideHits.size());
    599607      for (Hit phit : peptideHits) {
    600608        // make sure the file format and its interface
     
    603611          requestSpectraStringID.add(phit.getSpectrumStringId());
    604612          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         
    605638          requestSpectraSEQ.add(s1[0]); // sequence
    606639          if (s1.length == 2) {
     
    958991              requestSpectraSEQ.get(i),
    959992              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);
    9601003          output2.write(charge + "\n" + "MW: " + mass + "\n");
    9611004          // List<Double> parent = new ArrayList<Double>();
     
    10471090          for (int l = 0; l < mzs.size(); l++) {
    10481091            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            }
    10501102          }
    10511103          output2.write("\n");
Note: See TracChangeset for help on using the changeset viewer.