Skip to content
Merged
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
69 changes: 3 additions & 66 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,72 +95,9 @@
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
<filter>
<artifact>it.unimi.dsi:fastutil</artifact>
<includes>
<!-- Added a maven shade plugin step with minimize-jar set to true to mzIdentML pom to determine the needed fastutil classes.
Then used Beyond Compare 4 to compare the resulting jar vs. the result of this step until the fastutil classes matched. -->
<!-- booleans -->
<include>it/unimi/dsi/fastutil/booleans/BooleanArrays**</include>
<include>it/unimi/dsi/fastutil/booleans/BooleanComparator**</include>
<!-- chars -->
<include>it/unimi/dsi/fastutil/chars/AbstractCharBidirectionalIterator**</include>
<include>it/unimi/dsi/fastutil/chars/AbstractCharCollection**</include>
<include>it/unimi/dsi/fastutil/chars/AbstractCharIterator**</include>
<include>it/unimi/dsi/fastutil/chars/AbstractCharList**</include>
<include>it/unimi/dsi/fastutil/chars/AbstractCharListIterator**</include>
<include>it/unimi/dsi/fastutil/chars/AbstractCharSet**</include>
<include>it/unimi/dsi/fastutil/chars/CharArrayList**</include>
<include>it/unimi/dsi/fastutil/chars/CharArrays**</include>
<include>it/unimi/dsi/fastutil/chars/CharBidirectionalIterator**</include>
<include>it/unimi/dsi/fastutil/chars/CharCollection**</include>
<include>it/unimi/dsi/fastutil/chars/CharComparator**</include>
<include>it/unimi/dsi/fastutil/chars/CharIterable**</include>
<include>it/unimi/dsi/fastutil/chars/CharIterator**</include>
<include>it/unimi/dsi/fastutil/chars/CharIterators**</include>
<include>it/unimi/dsi/fastutil/chars/CharList**</include>
<include>it/unimi/dsi/fastutil/chars/CharListIterator**</include>
<include>it/unimi/dsi/fastutil/chars/CharOpenHashSet**</include>
<include>it/unimi/dsi/fastutil/chars/CharSet**</include>
<include>it/unimi/dsi/fastutil/chars/CharStack**</include>
<!-- ints -->
<include>it/unimi/dsi/fastutil/ints/IntArrays**</include>
<include>it/unimi/dsi/fastutil/ints/IntComparator**</include>
<!-- objects -->
<include>it/unimi/dsi/fastutil/objects/AbstractObjectBidirectionalIterator**</include>
<include>it/unimi/dsi/fastutil/objects/AbstractObjectCollection**</include>
<include>it/unimi/dsi/fastutil/objects/AbstractObjectIterator**</include>
<include>it/unimi/dsi/fastutil/objects/AbstractObjectList**</include>
<include>it/unimi/dsi/fastutil/objects/AbstractObjectListIterator**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectArrayList**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectArrays**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectBidirectionalIterator**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectCollection**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectIterable**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectIterator**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectIterators**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectList**</include>
<include>it/unimi/dsi/fastutil/objects/ObjectListIterator**</include>
<!-- base-level objects -->
<include>it/unimi/dsi/fastutil/Arrays**</include>
<include>it/unimi/dsi/fastutil/BidirectionalIterator**</include>
<include>it/unimi/dsi/fastutil/Hash**</include>
<include>it/unimi/dsi/fastutil/HashCommon**</include>
<include>it/unimi/dsi/fastutil/Stack**</include>
<include>it/unimi/dsi/fastutil/Swapper**</include>
</includes>
<excludes>
<exclude>it/unimi/dsi/fastutil/chars/AbstractChar2**</exclude>
<exclude>it/unimi/dsi/fastutil/chars/Char2**</exclude>
<exclude>it/unimi/dsi/fastutil/ints/IntComparators**</exclude>
<exclude>it/unimi/dsi/fastutil/objects/ObjectCollections**</exclude>
<exclude>it/unimi/dsi/fastutil/objects/ObjectLists**</exclude>
<exclude>it/unimi/dsi/fastutil/chars/CharCollections**</exclude>
<exclude>it/unimi/dsi/fastutil/chars/CharComparators**</exclude>
<exclude>it/unimi/dsi/fastutil/chars/CharLists**</exclude>
<exclude>it/unimi/dsi/fastutil/chars/CharSets**</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>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/edu/ucsd/msjava/msdbsearch/SearchParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class SearchParams {
private int maxMissedCleavages;
private int maxNumMods;
private boolean allowDenseCentroidedPeaks;
private int minMSLevel;
private int maxMSLevel;

public SearchParams() {
}
Expand Down Expand Up @@ -220,6 +222,16 @@ public boolean getAllowDenseCentroidedPeaks() {
return allowDenseCentroidedPeaks;
}

// Used by MS-GF+
public int getMinMSLevel() {
return minMSLevel;
}

// Used by MS-GF+
public int getMaxMSLevel() {
return maxMSLevel;
}

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

allowDenseCentroidedPeaks = paramManager.getAllowDenseCentroidedPeaks() == 1;

IntRangeParameter msLevelParam = paramManager.getMSLevelParameter();
minMSLevel = msLevelParam.getMin();
maxMSLevel = msLevelParam.getMax();

maxNumMods = paramManager.getMaxNumModsPerPeptide();
int maxNumModsCompare = aaSet.getMaxNumberOfVariableModificationsPerPeptide();

Expand Down Expand Up @@ -594,6 +610,7 @@ public String toString() {
buf.append(" (custom)\n");
}

buf.append("\tMSLevel: " + this.minMSLevel + "," + this.maxMSLevel + "\n");
buf.append("\tMinNumPeaksPerSpectrum: " + this.minNumPeaksPerSpectrum + "\n");
buf.append("\tNumIsoforms: " + this.maxNumVariantsPerPeptide + "\n");

Expand Down
21 changes: 18 additions & 3 deletions src/main/java/edu/ucsd/msjava/msutil/SpecKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public static ArrayList<SpecKey> getSpecKeyList(
int maxCharge,
ActivationMethod activationMethod,
int minNumPeaksPerSpectrum,
boolean allowDenseCentroidedData) {
boolean allowDenseCentroidedData,
int minMSLevel,
int maxMSLevel) {

Iterator<Spectrum> itr = specAcc.getSpecItr();

Expand All @@ -80,7 +82,9 @@ public static ArrayList<SpecKey> getSpecKeyList(
maxCharge,
activationMethod,
minNumPeaksPerSpectrum,
allowDenseCentroidedData);
allowDenseCentroidedData,
minMSLevel,
maxMSLevel);


SpectrumParser parser = specAcc.getSpectrumParser();
Expand All @@ -104,7 +108,9 @@ public static ArrayList<SpecKey> getSpecKeyList(
int maxCharge,
ActivationMethod activationMethod,
int minNumPeaksPerSpectrum,
boolean allowDenseCentroidedData) {
boolean allowDenseCentroidedData,
int minMSLevel,
int maxMSLevel) {

if (activationMethod == ActivationMethod.FUSION)
return getFusedSpecKeyList(itr, startSpecIndex, endSpecIndex, minCharge, maxCharge);
Expand All @@ -114,6 +120,7 @@ public static ArrayList<SpecKey> getSpecKeyList(
int numProfileSpectra = 0;
int numDenseCentroidedSpectra = 0;
int numSpectraWithTooFewPeaks = 0;
int numFilteredByMSLevel = 0;
final int MAX_INFORMATIVE_MESSAGES = 10;
int informativeMessageCount = 0;

Expand All @@ -126,6 +133,11 @@ public static ArrayList<SpecKey> getSpecKeyList(
if (specIndex >= endSpecIndex)
continue;

if (spec.getMSLevel() < minMSLevel || spec.getMSLevel() > maxMSLevel) {
numFilteredByMSLevel++;
continue;
}

spec.setChargeIfSinglyCharged();
int charge = spec.getCharge();
ActivationMethod specActivationMethod = spec.getActivationMethod();
Expand Down Expand Up @@ -217,6 +229,9 @@ public static ArrayList<SpecKey> getSpecKeyList(
}

System.out.println("Ignoring " + numProfileSpectra + " profile spectra.");
if (numFilteredByMSLevel > 0) {
System.out.println("Ignoring " + numFilteredByMSLevel + " spectra with MS level outside range [" + minMSLevel + "," + maxMSLevel + "].");
}
System.out.println("Ignoring " + numSpectraWithTooFewPeaks + " spectra having less than " + minNumPeaksPerSpectrum + " peaks.");
if (numDenseCentroidedSpectra > 0) {
System.out.println("Ignoring " + numDenseCentroidedSpectra + " spectra marked as centroid with dense peaks (<50ppm median distance).\n" +
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/edu/ucsd/msjava/msutil/SpectraAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class SpectraAccessor {

private MzMLAdapter mzmlAdapter = null;

private int minMSLevel = 2;
private int maxMSLevel = 2;

SpectrumAccessorBySpecIndex specMap = null;
Iterator<Spectrum> specItr = null;

Expand All @@ -45,13 +48,25 @@ public SpectraAccessor(File specFile, SpecFileFormat specFormat) {
this.spectrumParser = null;
}

/**
* Set the MS level range for spectrum filtering (both inclusive).
*
* @param minMSLevel minimum MS level to consider (inclusive).
* @param maxMSLevel maximum MS level to consider (inclusive).
*/
public void setMSLevelRange(int minMSLevel, int maxMSLevel) {
this.minMSLevel = minMSLevel;
this.maxMSLevel = maxMSLevel;
}

public SpectrumAccessorBySpecIndex getSpecMap() {
if (specMap == null) {
if (specFormat == SpecFileFormat.MZXML)
specMap = new MzXMLSpectraMap(specFile.getPath());
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);
} else if (specFormat == SpecFileFormat.DTA_TXT)
specMap = new PNNLSpectraMap(specFile.getPath());
Expand Down Expand Up @@ -82,10 +97,11 @@ else if (specFormat == SpecFileFormat.PKL)
public Iterator<Spectrum> getSpecItr() {
if (specItr == null) {
if (specFormat == SpecFileFormat.MZXML)
specItr = new MzXMLSpectraIterator(specFile.getPath());
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);
} else if (specFormat == SpecFileFormat.DTA_TXT)
try {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/edu/ucsd/msjava/mzid/MZIdentMLGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ public synchronized void addSpectrumIdentificationResults(List<MSGFPlusMatch> re
continue;

edu.ucsd.msjava.msutil.Spectrum spec = specAcc.getSpecMap().getSpectrumBySpecIndex(specIndex);
if (spec == null) {
System.err.println("Warning: spectrum index " + specIndex + " not found in spectrum file; skipping");
continue;
}
String specID = spec.getID();
float precursorMz = spec.getPrecursorPeak().getMz();

Expand Down Expand Up @@ -322,7 +326,7 @@ public synchronized void addSpectrumIdentificationResults(List<MSGFPlusMatch> re
DatabaseMatch match = matchList.get(i);

if (match.getDeNovoScore() < params.getMinDeNovoScore())
break;
continue;

// int pepIndex = match.getIndex(); // Position of preAA
int length = match.getLength(); // Peptide length + 2
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/ucsd/msjava/mzml/MzMLAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MzMLAdapter {
private final File specFile;
private MzMLUnmarshaller unmarshaller;
private int minMSLevel = 2; // inclusive
private int maxMSLevel = Integer.MAX_VALUE; // exclusive
private int maxMSLevel = Integer.MAX_VALUE; // inclusive
private CvParam spectrumIDFormatCvParam = null;

public MzMLAdapter(File specFile) {
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/edu/ucsd/msjava/params/IntRangeParameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ public IntRangeParameter(String key, String name, String description) {
public String parse(String value) {
String[] token = value.split(",");
try {
// if(token.length == 1)
// {
// min = Integer.parseInt(token[0]);
// max = min;
// }
if (token.length == 2) {
if (token.length == 1) {
min = Integer.parseInt(token[0]);
max = min;
} else if (token.length == 2) {
min = Integer.parseInt(token[0]);
max = Integer.parseInt(token[1]);
} else {
return "illegar syntax";
return "illegal syntax";
}
} catch (NumberFormatException e) {
return "not a valid integer or integer range";
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/edu/ucsd/msjava/params/ParamManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public enum ParamNameEnum {
SPEC_INDEX("index", "SpecIndex", "Range of spectrum indices to be considered",
"For example, to analyze the first 1000 spectra use -index 1,1000"),

MS_LEVEL("msLevel", "MSLevel", "MS level or range of MS levels to consider; Default: 2",
"Accepts a single value or a comma-separated range.\n" +
"\t For example, -msLevel 2 to search only MS2 spectra\n" +
"\t Or -msLevel 2,3 to search both MS2 and MS3 spectra"),

MAX_MISSED_CLEAVAGES("maxMissedCleavages", "MaxMissedCleavages", "Exclude peptides with more than this number of missed cleavages from the search; Default: -1 (no limit)", null),

TDA_STRATEGY("tda", "TDA", "Target decoy strategy",
Expand Down Expand Up @@ -695,6 +700,14 @@ private void addSpecIndexRangeParam(boolean isHidden) {
addParameter(specIndexParam);
}

private void addMSLevelParam() {
IntRangeParameter msLevelParam = new IntRangeParameter(ParamNameEnum.MS_LEVEL);
msLevelParam.minValue(1);
msLevelParam.setMaxInclusive();
msLevelParam.defaultValue("2,2");
addParameter(msLevelParam);
}

private void addEdgeScoreParam(boolean isHidden) {
EnumParameter edgeScoreParam = new EnumParameter(ParamNameEnum.EDGE_SCORE.key);
edgeScoreParam.registerEntry("Use edge scoring").setDefault();
Expand Down Expand Up @@ -792,6 +805,7 @@ public void addMSGFPlusParams() {
addMaxNumModsParam();

addAllowDenseCentroidedPeaksParam();
addMSLevelParam();

addExample("Example (high-precision): java -Xmx3500M -jar MSGFPlus.jar -s test.mzML -d IPI_human_3.79.fasta -inst 1 -t 20ppm -ti -1,2 -ntt 2 -tda 1 -o testMSGFPlus.mzid -mod Mods.txt");
addExample("Example (low-precision): java -Xmx3500M -jar MSGFPlus.jar -s test.mzML -d IPI_human_3.79.fasta -inst 0 -t 0.5Da,2.5Da -ntt 2 -tda 1 -o testMSGFPlus.mzid -mod Mods.txt");
Expand Down Expand Up @@ -1103,6 +1117,10 @@ public IntRangeParameter getSpecIndexParameter() {
return ((IntRangeParameter) getParameter(ParamNameEnum.SPEC_INDEX.key));
}

public IntRangeParameter getMSLevelParameter() {
return ((IntRangeParameter) getParameter(ParamNameEnum.MS_LEVEL.key));
}

public int getTDA() {
return getIntValue(ParamNameEnum.TDA_STRATEGY.key);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/edu/ucsd/msjava/parser/MzXMLSpectraMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class MzXMLSpectraMap implements SpectrumAccessorBySpecIndex {

// if(maxMSLevel >= minMSLevel > 0) only spectra within [minMSLevel, maxMSLevel] will be returned
private int minMSLevel = 2; // inclusive
private int maxMSLevel = Integer.MAX_VALUE; // exclusive
private int maxMSLevel = Integer.MAX_VALUE; // inclusive

/***** CONSTRUCTORS *****/
/**
Expand Down Expand Up @@ -64,7 +64,7 @@ public Spectrum getSpectrumByScanNum(int scanNumber) {

if (scanObj == null) return null;
int msLevel = scanObj.getHeader().getMsLevel();
if (msLevel < minMSLevel || msLevel >= maxMSLevel)
if (msLevel < minMSLevel || msLevel > maxMSLevel)
return null;
// get peak list array (mass, intensities) pairs
double[][] peakList = scanObj.getMassIntensityList();
Expand Down Expand Up @@ -168,7 +168,7 @@ public String getID(int specIndex) {

if (scanObj == null) return null;
int msLevel = scanObj.getHeader().getMsLevel();
if (msLevel < minMSLevel || msLevel >= maxMSLevel)
if (msLevel < minMSLevel || msLevel > maxMSLevel)
return null;
return String.valueOf(specIndex);
}
Expand All @@ -187,7 +187,7 @@ public Float getPrecursorMz(int specIndex) {

if (scanObj == null) return null;
int msLevel = scanObj.getHeader().getMsLevel();
if (msLevel < minMSLevel || msLevel >= maxMSLevel)
if (msLevel < minMSLevel || msLevel > maxMSLevel)
return null;

ScanHeader header = scanObj.getHeader();
Expand Down
Loading