Skip to content

Commit

Permalink
Added activation information: method name, energy, reaction time
Browse files Browse the repository at this point in the history
  • Loading branch information
chhh committed Nov 11, 2016
1 parent e10f6ea commit bf98628
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2016 Dmitry Avtonomov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package umich.ms.datatypes.scan.props;

/**
* @author Dmitry Avtonomov
*/
public class ActivationInfo {
private String activationMethod;
private Double activationEnergyLo;
private Double activationEnergyHi;
private Double activationTime;

public String getActivationMethod() {
return activationMethod;
}

public void setActivationMethod(String activationMethod) {
this.activationMethod = activationMethod;
}

/** Either the beginning of the collision energy ramp or just the collision energy. In electronvolts. */
public Double getActivationEnergyLo() {
return activationEnergyLo;
}

/** Either the beginning of the collision energy ramp or just the collision energy. In electronvolts. */
public void setActivationEnergyLo(Double activationEnergyLo) {
this.activationEnergyLo = activationEnergyLo;
}

/** Either the end of the collision energy ramp or just the collision energy. In electronvolts. */
public Double getActivationEnergyHi() {
return activationEnergyHi;
}

/** Either the end of the collision energy ramp or just the collision energy. In electronvolts. */
public void setActivationEnergyHi(Double activationEnergyHi) {
this.activationEnergyHi = activationEnergyHi;
}

/** This would mean different things for different activation methods and might not be present most of the time. */
public Double getActivationTime() {
return activationTime;
}

public void setActivationTime(Double activationTime) {
this.activationTime = activationTime;
}

@Override
public String toString() {
if (activationTime == null)
return String.format("Activation:%s@[%.2f-%.2f]", activationMethod, activationEnergyLo, activationEnergyHi);
else
return String.format("Activation:%s@[%.2f-%.2f] for %.2f", activationMethod, activationEnergyLo, activationEnergyHi, activationTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ public class PrecursorInfo implements Serializable {
private Double mzRangeEnd;
private Double mzTarget;
private Integer charge;
private String activationMethod;
private ActivationInfo activationInfo;
private Double intensity;

public PrecursorInfo() {
activationInfo = new ActivationInfo();
}

public String getParentScanRefRaw() {
return parentScanRefRaw;
}
Expand Down Expand Up @@ -120,16 +124,12 @@ public void setMzRangeEnd(Double mzRangeEnd) {
this.mzRangeEnd = mzRangeEnd;
}

/**
* TODO: This is a STUB. Should probably be an instance of a class, defining activation methods
* @return
*/
public String getActivationMethod() {
return activationMethod;
public ActivationInfo getActivationInfo() {
return activationInfo;
}

public void setActivationMethod(String activationMethod) {
this.activationMethod = activationMethod;
public void setActivationInfo(ActivationInfo activationInfo) {
this.activationInfo = activationInfo;
}

public Double getIntensity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
*/
package umich.ms.fileio.filetypes.mzml;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.zip.DataFormatException;
import javolution.text.CharArray;
import javolution.xml.internal.stream.XMLStreamReaderImpl;
import javolution.xml.sax.Attributes;
Expand All @@ -40,7 +33,6 @@
import umich.ms.datatypes.spectrum.impl.SpectrumDefault;
import umich.ms.fileio.exceptions.FileParsingException;
import umich.ms.fileio.filetypes.mzml.util.PSIMSCV;
import umich.ms.fileio.filetypes.mzml.util.UnitsCV;
import umich.ms.fileio.filetypes.util.MultiSpectraParser;
import umich.ms.fileio.filetypes.xmlbased.IndexBuilder;
import umich.ms.fileio.filetypes.xmlbased.OffsetLength;
Expand All @@ -50,6 +42,14 @@
import umich.ms.util.base64.Base64Context;
import umich.ms.util.base64.Base64ContextPooled;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.zip.DataFormatException;

/**
* Parses multiple spectra read from mzML file. One chunk of bytes should be given to it.
* @author Dmitry Avtonomov
Expand Down Expand Up @@ -247,6 +247,7 @@ private void tagPrecursorStart(XMLStreamReaderImpl reader) throws FileParsingExc

// read until the closing </precursor> tag
PrecursorInfo precursorInfo = new PrecursorInfo();
ActivationInfo activationInfo = precursorInfo.getActivationInfo();
attrs = reader.getAttributes();
attr = attrs.getValue(ATTR.PRECURSOR_SPEC_REF.name);
if (attr != null) {
Expand Down Expand Up @@ -294,9 +295,9 @@ private void tagPrecursorStart(XMLStreamReaderImpl reader) throws FileParsingExc
// check for activation method
String activationMethod = PSIMSCV.activationMethodFromAccession(attr);
if (activationMethod != null) {
precursorInfo.setActivationMethod(activationMethod);
activationInfo.setActivationMethod(activationMethod);
}
break;
continue;
}
switch (cvEntry) {
case MS_PRECURSOR_ISO_WND_TARGET:
Expand Down Expand Up @@ -324,8 +325,17 @@ private void tagPrecursorStart(XMLStreamReaderImpl reader) throws FileParsingExc
case MS_PRECURSOR_CHARGE:
precursorInfo.setCharge(val.toInt());
break;
case MS_PRECURSOR_COLLISION_ENERGY:
// we don't use those
case MS_ACTIVATION_ENERGY_1:
case MS_ACTIVATION_ENERGY_2:
case MS_ACTIVATION_ENERGY_LO:
case MS_ACTIVATION_ENERGY_SUP:
activationInfo.setActivationEnergyLo(val.toDouble());
final Double eHi = activationInfo.getActivationEnergyHi();
if (eHi == null || Double.isNaN(eHi))
activationInfo.setActivationEnergyHi(val.toDouble());
break;
case MS_ACTIVATION_ENERGY_HI:
activationInfo.setActivationEnergyHi(val.toDouble());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public enum PSIMSCV {
MS_PRECURSOR_INTENSITY ("MS:1000042", "peak intensity"),
MS_PRECURSOR_MZ ("MS:1000744", "selected ion m/z"),
MS_PRECURSOR_CHARGE ("MS:1000041", "charge state"),
MS_PRECURSOR_COLLISION_ENERGY ("MS:1000045", "collision energy"),
MS_DATA_ARRAY_MZ ("MS:1000514", "m/z array"),
MS_DATA_ARRAY_INTENSITY ("MS:1000515", "intensity array"),
MS_PRECISION_32 ("MS:1000521", "32-bit float"),
Expand All @@ -94,13 +93,17 @@ public enum PSIMSCV {

MS_DISSOCIATION_METHOD ("MS:1000044", "dissociation method"),
MS_PEAK_PICKING ("MS:1000035", "peak picking"),
MS_ACTIVATION_ENERGY_1 ("MS:1000045", "collision energy"),
MS_ACTIVATION_ENERGY_2 ("MS:1000509", "activation energy"),
MS_ACTIVATION_ENERGY_LO ("MS:1002013", "collision energy ramp start"),
MS_ACTIVATION_ENERGY_HI ("MS:1002014", "collision energy ramp end"),
MS_ACTIVATION_ENERGY_SUP ("MS:1002680", "supplemental collision energy"),

MS_INSTRUMENT ("MS:1000463", "instrument"),
MS_INSTRUMENT_MODEL ("MS:1000031", "instrument model"),
MS_INSTRUMENT_VENDOR_OBSOLETE ("MS:1000030", "vendor"),
MS_INSTRUMENT_SERIAL_NUMBER ("MS:1000529", "instrument serial number"),


MS_INSTRUMENT_COMPONENT_SOURCE ("MS:1000458", "source"),
MS_INSTRUMENT_COMPONENT_ANALYZER ("MS:1000443", "mass analyzer type"),
MS_INSTRUMENT_COMPONENT_DETECTOR ("MS:1000026", "detector type"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Copyright 2016 Dmitry Avtonomov.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright 2016 Dmitry Avtonomov.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package umich.ms.fileio.filetypes.mzxml;

import javolution.text.CharArray;
Expand All @@ -28,6 +28,7 @@
import umich.ms.datatypes.scan.IScan;
import umich.ms.datatypes.scan.PeaksCompression;
import umich.ms.datatypes.scan.impl.ScanDefault;
import umich.ms.datatypes.scan.props.ActivationInfo;
import umich.ms.datatypes.scan.props.Polarity;
import umich.ms.datatypes.scan.props.PrecursorInfo;
import umich.ms.datatypes.scan.props.ScanType;
Expand Down Expand Up @@ -117,6 +118,7 @@ protected enum ATTR {
PRECURSOR_CHARGE("precursorCharge", false),
PRECURSOR_ISOLATION_WINDOW("windowWideness", false),
FRAGMENTATION_METHOD("activationMethod", false),
ACTIVATION_ENERGY("collisionEnergy", false),
COMPRESSION_TYPE("compressionType", true),
COMPRESSED_LEN("compressedLen", true),
PRECISION("precision", false);
Expand Down Expand Up @@ -466,7 +468,11 @@ protected int tagPrecursorStart(XMLStreamReaderImpl reader) throws FileParsingEx
vars.flushVars();
}
attrs = reader.getAttributes();
PrecursorInfo precursorInfo = new PrecursorInfo();
PrecursorInfo precursorInfo = vars.curScan.getPrecursor();
if (precursorInfo == null) {
precursorInfo = new PrecursorInfo();
vars.curScan.setPrecursor(precursorInfo);
}

attr = attrs.getValue(ATTR.PRECURSOR_SCAN_NUM.name);
if (attr != null) {
Expand All @@ -482,7 +488,7 @@ protected int tagPrecursorStart(XMLStreamReaderImpl reader) throws FileParsingEx
}
attr = attrs.getValue(ATTR.FRAGMENTATION_METHOD.name);
if (attr != null) {
precursorInfo.setActivationMethod(attr.toString());
precursorInfo.getActivationInfo().setActivationMethod(attr.toString());
}
attr = attrs.getValue(ATTR.PRECURSOR_ISOLATION_WINDOW.name);
Double isolationWindowWidth = null;
Expand All @@ -509,7 +515,6 @@ protected int tagPrecursorStart(XMLStreamReaderImpl reader) throws FileParsingEx
precursorInfo.setMzRangeStart(precursorMz - isolationWindowWidth/2d);
precursorInfo.setMzRangeEnd(precursorMz + isolationWindowWidth/2d);

vars.curScan.setPrecursor(precursorInfo);
return eventType;
}

Expand Down Expand Up @@ -569,6 +574,18 @@ protected void tagScanStart(XMLStreamReaderImpl reader) throws FileParsingExcept
vars.curScan.setPolarity(Polarity.NEGATIVE);
}
}

attr = attrs.getValue(ATTR.ACTIVATION_ENERGY.name);
if (attr != null) {
PrecursorInfo precursorInfo = vars.curScan.getPrecursor();
if (precursorInfo == null) {
precursorInfo = new PrecursorInfo();
vars.curScan.setPrecursor(precursorInfo);
}
precursorInfo.getActivationInfo().setActivationEnergyLo(attr.toDouble());
precursorInfo.getActivationInfo().setActivationEnergyHi(attr.toDouble());
}

attr = attrs.getValue(ATTR.RT.name);
if (attr != null) {
vars.curScan.setRt(DATA_FACTORY.newDuration(attr.toString()).getTimeInMillis(new Date()) / 1000d / 60d);
Expand Down
11 changes: 10 additions & 1 deletion MSFileToolbox/src/umich/ms/msfiletoolbox/MsftbxInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@

package umich.ms.msfiletoolbox;

import java.util.TreeMap;

/**
* @author Dmitry Avtonomov
*/
public class MsftbxInfo {
public static final String version = "1.1.1";
public static final String version = "1.2.0";

private static TreeMap<String, String> changelog = new TreeMap<>();

static {
String v1_2_0 = "v1.2.0";
changelog.put(v1_2_0, "Added fragmentation energy and reaction time");
}
}

0 comments on commit bf98628

Please sign in to comment.