Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 2 additions & 40 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifest>
<mainClass>edu.ucsd.msjava.ui.MSGFPlus</mainClass>
</manifest>
</archive>
Expand Down Expand Up @@ -79,7 +77,6 @@
<goal>shade</goal>
</goals>
<configuration>
<!-- <finalName>${project.artifactId}-${project.version}-jar-w-reduced-deps</finalName> -->
<finalName>${project.artifactId}</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
Expand All @@ -95,14 +92,10 @@
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
<!-- fastutil shade filter removed: jmzml 1.7.11 requires
additional fastutil classes beyond the original whitelist.
Full fastutil 8.5.12 is now included as an explicit dependency. -->
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/.svn/**</exclude>
<!-- <exclude>**/*.java</exclude> -->
</excludes>
</filter>
</filters>
Expand All @@ -124,34 +117,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>uk.ac.ebi.pride.tools</groupId>
<artifactId>jmzreader</artifactId>
<version>2.0.6</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -175,11 +140,8 @@
<artifactId>commons-text</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>uk.ac.ebi.jmzml</groupId>
<artifactId>jmzml</artifactId>
<version>1.7.11</version>
</dependency>
<!-- jmzml removed: replaced by StaxMzMLParser -->
<!-- fastutil is required at runtime by jmzidentml -->
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/edu/ucsd/msjava/msdbsearch/SearchParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class SearchParams {
private boolean allowDenseCentroidedPeaks;
private int minMSLevel;
private int maxMSLevel;
private int outputFormat; // 0=mzid, 1=tsv, 2=both

public SearchParams() {
}
Expand Down Expand Up @@ -232,6 +233,19 @@ public int getMaxMSLevel() {
return maxMSLevel;
}

/** 0=mzid, 1=tsv, 2=both */
public int getOutputFormat() {
return outputFormat;
}

public boolean writeMzid() {
return outputFormat == 0 || outputFormat == 2;
}

public boolean writeTsv() {
return outputFormat == 1 || outputFormat == 2;
}

/**
* Look for # in dataLine
* If present, remove that character and any comment after it
Expand Down Expand Up @@ -421,6 +435,7 @@ public String parse(ParamManager paramManager) {
}

allowDenseCentroidedPeaks = paramManager.getAllowDenseCentroidedPeaks() == 1;
outputFormat = paramManager.getOutputFormat();

IntRangeParameter msLevelParam = paramManager.getMSLevelParameter();
minMSLevel = msLevelParam.getMin();
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/edu/ucsd/msjava/msutil/SpecFileFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public String getPSIName() {
}

public static final SpecFileFormat MGF;
public static final SpecFileFormat MZXML;
public static final SpecFileFormat MZML;
public static final SpecFileFormat MS2;
public static final SpecFileFormat PKL;
Expand All @@ -44,7 +43,6 @@ public static SpecFileFormat getSpecFileFormat(String specFileName) {

static {
MGF = new SpecFileFormat(".mgf", "MS:1001062", "Mascot MGF file");
MZXML = new SpecFileFormat(".mzXML", "MS:1000566", "ISB mzXML file");
MZML = new SpecFileFormat(".mzML", "MS:1000584", "mzML file");
MS2 = new SpecFileFormat(".ms2", "MS:1001466", "MS2 file");
PKL = new SpecFileFormat(".pkl", "MS:1000565", "Micromass PKL file");
Expand All @@ -53,7 +51,6 @@ public static SpecFileFormat getSpecFileFormat(String specFileName) {

specFileFormatList = new ArrayList<SpecFileFormat>();
specFileFormatList.add(MGF);
specFileFormatList.add(MZXML);
specFileFormatList.add(MZML);
specFileFormatList.add(MS2);
specFileFormatList.add(PKL);
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/edu/ucsd/msjava/msutil/SpecKey.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.ucsd.msjava.msutil;

import edu.ucsd.msjava.parser.MzXMLSpectraIterator;
import edu.ucsd.msjava.parser.SpectrumParser;

import java.util.ArrayList;
Expand Down Expand Up @@ -292,20 +291,5 @@ public static ArrayList<SpecKey> getFusedSpecKeyList(Iterator<Spectrum> itr, int
return specKeyList;
}

public static void main(String argv[]) throws Exception {
test();
}

public static void test() throws Exception {
String fileName = "/home/sangtaekim/Research/Data/HeckRevision/CIDETDPairs/mzXML/090121_NM_Trypsin_20.mzXML";
int minCharge = 2, maxCharge = 3;
MzXMLSpectraIterator itr = new MzXMLSpectraIterator(fileName);
ArrayList<SpecKey> list = SpecKey.getFusedSpecKeyList(itr, 0, Integer.MAX_VALUE, minCharge, maxCharge);
for (SpecKey specKey : list) {
if (specKey.getSpecIndexList() == null || specKey.getSpecIndexList().size() != 2)
System.out.println(specKey.getSpecKeyString() + "\t" + specKey.getSpecIndexList());
}
System.out.println("Size: " + list.size());
}

}
62 changes: 39 additions & 23 deletions src/main/java/edu/ucsd/msjava/msutil/SpectraAccessor.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package edu.ucsd.msjava.msutil;

import edu.ucsd.msjava.mzid.Constants;
import edu.ucsd.msjava.mzml.MzMLAdapter;
import edu.ucsd.msjava.mzml.MzMLSpectraIterator;
import edu.ucsd.msjava.mzml.MzMLSpectraMap;
import edu.ucsd.msjava.mzml.StaxMzMLParser;
import edu.ucsd.msjava.mzml.StaxMzMLSpectraIterator;
import edu.ucsd.msjava.mzml.StaxMzMLSpectraMap;
import edu.ucsd.msjava.parser.*;
import uk.ac.ebi.jmzidml.model.mzidml.CvParam;

Expand All @@ -18,7 +18,7 @@ public class SpectraAccessor {

private SpectrumParser spectrumParser;

private MzMLAdapter mzmlAdapter = null;
private StaxMzMLParser staxParser = null;

private int minMSLevel = 2;
private int maxMSLevel = 2;
Expand All @@ -43,6 +43,9 @@ public SpectraAccessor(File specFile) {
* @param specFormat
*/
public SpectraAccessor(File specFile, SpecFileFormat specFormat) {
if (specFormat == null) {
throw new IllegalArgumentException("Unsupported spectrum file format: " + specFile.getName());
}
this.specFile = specFile;
this.specFormat = specFormat;
this.spectrumParser = null;
Expand All @@ -61,13 +64,15 @@ public void setMSLevelRange(int minMSLevel, int maxMSLevel) {

public SpectrumAccessorBySpecIndex getSpecMap() {
if (specMap == null) {
if (specFormat == SpecFileFormat.MZXML)
specMap = new MzXMLSpectraMap(specFile.getPath()).msLevel(minMSLevel, maxMSLevel);
else if (specFormat == SpecFileFormat.MZML) {
if (mzmlAdapter == null)
mzmlAdapter = new MzMLAdapter(specFile);
mzmlAdapter.msLevel(minMSLevel, maxMSLevel);
specMap = new MzMLSpectraMap(mzmlAdapter);
if (specFormat == SpecFileFormat.MZML) {
if (staxParser == null) {
try {
staxParser = new StaxMzMLParser(specFile);
} catch (Exception e) {
throw new RuntimeException("Failed to parse mzML file: " + specFile.getAbsolutePath(), e);
}
}
specMap = new StaxMzMLSpectraMap(staxParser, minMSLevel, maxMSLevel);
} else if (specFormat == SpecFileFormat.DTA_TXT)
specMap = new PNNLSpectraMap(specFile.getPath());
else {
Expand Down Expand Up @@ -96,13 +101,15 @@ else if (specFormat == SpecFileFormat.PKL)

public Iterator<Spectrum> getSpecItr() {
if (specItr == null) {
if (specFormat == SpecFileFormat.MZXML)
specItr = new MzXMLSpectraIterator(specFile.getPath(), minMSLevel, maxMSLevel);
else if (specFormat == SpecFileFormat.MZML) {
if (mzmlAdapter == null)
mzmlAdapter = new MzMLAdapter(specFile);
mzmlAdapter.msLevel(minMSLevel, maxMSLevel);
specItr = new MzMLSpectraIterator(mzmlAdapter);
if (specFormat == SpecFileFormat.MZML) {
if (staxParser == null) {
try {
staxParser = new StaxMzMLParser(specFile);
} catch (Exception e) {
throw new RuntimeException("Failed to parse mzML file: " + specFile.getAbsolutePath(), e);
}
}
specItr = new StaxMzMLSpectraIterator(staxParser, minMSLevel, maxMSLevel);
} else if (specFormat == SpecFileFormat.DTA_TXT)
try {
specItr = new PNNLSpectraIterator(specFile.getPath());
Expand Down Expand Up @@ -168,14 +175,23 @@ public CvParam getSpectrumIDFormatCvParam() {
|| specFormat == SpecFileFormat.MS2
)
cvParam = Constants.makeCvParam("MS:1000774", "multiple peak list nativeID format");
else if (specFormat == SpecFileFormat.MZXML)
cvParam = Constants.makeCvParam("MS:1000776", "scan number only nativeID format");
else if (specFormat == SpecFileFormat.MZDATA)
cvParam = Constants.makeCvParam("MS:1000777", "spectrum identifier nativeID format");
else if (specFormat == SpecFileFormat.MZML) {
if (mzmlAdapter == null)
mzmlAdapter = new MzMLAdapter(specFile);
cvParam = mzmlAdapter.getSpectrumIDFormatCvParam();
if (staxParser == null) {
try {
staxParser = new StaxMzMLParser(specFile);
} catch (Exception e) {
throw new RuntimeException("Failed to parse mzML file: " + specFile.getAbsolutePath(), e);
}
}
String[] idFormat = staxParser.detectSpectrumIDFormat();
if (idFormat != null) {
cvParam = Constants.makeCvParam(idFormat[0], idFormat[1]);
} else {
throw new IllegalStateException("Unsupported mzML format: " + specFile.getAbsolutePath()
+ " does not contain a child term of MS:1000767 (native spectrum identifier format)");
}
}

return cvParam;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/ucsd/msjava/msutil/Spectrum.java
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ public static SpecFileFormat getSpectrumFileFormat(String specFileName) {
int posDot = specFileName.lastIndexOf('.');
if (posDot >= 0) {
String extension = specFileName.substring(posDot);
if (extension.equalsIgnoreCase(".mzXML") || extension.equalsIgnoreCase(".mzML"))
specFormat = SpecFileFormat.MZXML;
if (extension.equalsIgnoreCase(".mzML"))
specFormat = SpecFileFormat.MZML;
else if (extension.equalsIgnoreCase(".mgf"))
specFormat = SpecFileFormat.MGF;
else if (extension.equalsIgnoreCase(".ms2"))
Expand Down
Loading