diff --git a/src/main/java/edu/ucsd/msjava/msutil/CvParamInfo.java b/src/main/java/edu/ucsd/msjava/msutil/CvParamInfo.java new file mode 100644 index 00000000..96cd07da --- /dev/null +++ b/src/main/java/edu/ucsd/msjava/msutil/CvParamInfo.java @@ -0,0 +1,53 @@ +package edu.ucsd.msjava.msutil; + +/** + * Stored information for a cvParam, for "copying" cvParams from mzML( and potentially other formats) to mzIdentML + * @author Bryson Gibbons + */ +public class CvParamInfo { + private String accession; + private String name; + private String value; + private String unitAccession; + private String unitName; + private Boolean hasUnit; + + public CvParamInfo(String accession, String name, String value) { + this.accession = accession; + this.name = name; + this.value = value; + } + + public CvParamInfo(String accession, String name, String value, String unitAccession, String unitName) { + this.accession = accession; + this.name = name; + this.value = value; + this.hasUnit = true; + this.unitAccession = unitAccession; + this.unitName = unitName; + } + + public String getAccession() { + return this.accession; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + public Boolean getHasUnit() { + return this.hasUnit; + } + + public String getUnitAccession() { + return this.unitAccession; + } + + public String getUnitName() { + return this.unitName; + } +} diff --git a/src/main/java/edu/ucsd/msjava/msutil/Spectrum.java b/src/main/java/edu/ucsd/msjava/msutil/Spectrum.java index 2a928734..ccd76447 100644 --- a/src/main/java/edu/ucsd/msjava/msutil/Spectrum.java +++ b/src/main/java/edu/ucsd/msjava/msutil/Spectrum.java @@ -47,6 +47,8 @@ public class Spectrum extends ArrayList implements Comparable { // private Float fractionIonCurrent = null; // private Integer numMS1Features = null; + private ArrayList addlCvParams; + private Float isolationWindowTargetMz = null; /***** CONSTRUCTORS *****/ @@ -268,6 +270,14 @@ public int getMSLevel() { return this.msLevel; } + /** + * Gets additional cvParams to output as cvParams under the mzIdentML SpectrumIdentificationResult + * @return cvParam necessary info + */ + public ArrayList getAddlCvParams() { + return this.addlCvParams; + } + /***** SETTERS *****/ /** @@ -495,6 +505,18 @@ public void setChargeIfSinglyCharged() { if (ticBelowPrecursor / tic > 0.9f) precursor.setCharge(1); } + + /** + * Add an additional cvParam to output as a cvParam under the mzIdentML SpectrumIdentificationResult + * @param cvParam + */ + public void addAddlCvParam(CvParamInfo cvParam) { + if (addlCvParams == null){ + addlCvParams = new ArrayList(); + } + + addlCvParams.add(cvParam); + } /****** FUNCTIONS *****/ @Override diff --git a/src/main/java/edu/ucsd/msjava/mzid/MZIdentMLGen.java b/src/main/java/edu/ucsd/msjava/mzid/MZIdentMLGen.java index 02804a32..36d059e9 100644 --- a/src/main/java/edu/ucsd/msjava/mzid/MZIdentMLGen.java +++ b/src/main/java/edu/ucsd/msjava/mzid/MZIdentMLGen.java @@ -298,6 +298,18 @@ public synchronized void addSpectrumIdentificationResults(List re sir.getCvParam().add(cvParam); } + if (spec.getAddlCvParams() != null) { + for (CvParamInfo cvParamInfo : spec.getAddlCvParams()) { + CvParam cvParam = Constants.makeCvParam(cvParamInfo.getAccession(), cvParamInfo.getName()); + cvParam.setValue(cvParamInfo.getValue()); + if (cvParamInfo.getHasUnit()) { + cvParam.setUnitCv(Constants.unitCV); + cvParam.setUnitAccession(cvParamInfo.getUnitAccession()); + cvParam.setUnitName(cvParamInfo.getUnitName()); + } + sir.getCvParam().add(cvParam); + } + } int rank = 0; int resultCount = 0; diff --git a/src/main/java/edu/ucsd/msjava/mzml/SpectrumConverter.java b/src/main/java/edu/ucsd/msjava/mzml/SpectrumConverter.java index 437572d4..154e3969 100644 --- a/src/main/java/edu/ucsd/msjava/mzml/SpectrumConverter.java +++ b/src/main/java/edu/ucsd/msjava/mzml/SpectrumConverter.java @@ -1,6 +1,7 @@ package edu.ucsd.msjava.mzml; import edu.ucsd.msjava.msutil.ActivationMethod; +import edu.ucsd.msjava.msutil.CvParamInfo; import edu.ucsd.msjava.msutil.Peak; import uk.ac.ebi.jmzml.model.mzml.*; @@ -58,6 +59,20 @@ public static edu.ucsd.msjava.msutil.Spectrum getSpectrumFromJMzMLSpec(uk.ac.ebi scanStartTimeIsSeconds = true; } } + // is_a: MS:1002892 ! ion mobility attribute cvParams + else if (cvParam.getAccession().equals("MS:1001581") // FAIMS compensation voltage + || cvParam.getAccession().equals("MS:1002476") // ion mobility drift time + || cvParam.getAccession().equals("MS:1002815")) { // inverse reduced ion mobility + CvParamInfo cvParamInfo; + if (cvParam.getUnitAccession() != null && !cvParam.getUnitAccession().isEmpty()) { + cvParamInfo = new CvParamInfo(cvParam.getAccession(), cvParam.getName(), cvParam.getValue(), cvParam.getUnitAccession(), cvParam.getUnitName()); + } + else { + cvParamInfo = new CvParamInfo(cvParam.getAccession(), cvParam.getName(), cvParam.getValue()); + } + + spec.addAddlCvParam(cvParamInfo); + } } for (UserParam param : scanList.getScan().get(0).getUserParam()) { if (param.getName().equals("[Thermo Trailer Extra]Monoisotopic M/Z:")) {