use of de.ipbhalle.metfraglib.list.SortedTandemMassPeakList in project MetFragRelaunched by ipb-halle.
the class FilteredStringTandemMassPeakListReader method read.
public DefaultPeakList read() throws Exception {
int numberMaximumPeaksUsed = (Integer) settings.get(VariableNames.NUMBER_MAXIMUM_PEAKS_USED_NAME);
SortedTandemMassPeakList peakList = null;
String stringname = (String) this.settings.get(VariableNames.PEAK_LIST_STRING_NAME);
String peakDelim1 = "\\n";
String peakDelim2 = "\\s+";
if (stringname.contains(";") || stringname.contains("_")) {
peakDelim1 = ";";
peakDelim2 = "_";
}
peakList = new SortedTandemMassPeakList((Double) this.settings.get(VariableNames.PRECURSOR_NEUTRAL_MASS_NAME));
String[] tmp = stringname.split(peakDelim1);
for (int i = 0; i < tmp.length; i++) {
tmp[i] = tmp[i].trim();
if (tmp[i].startsWith("#") || tmp[i].length() == 0)
continue;
String[] tmp2 = tmp[i].split(peakDelim2);
TandemMassPeak peak = new TandemMassPeak(Double.parseDouble(tmp2[0].trim()), Double.parseDouble(tmp2[1].trim()));
/*
* filtering step
*/
if (peak.getMass() >= ((Double) settings.get(VariableNames.PRECURSOR_NEUTRAL_MASS_NAME) - 5.0 + Constants.ADDUCT_MASSES.get(this.precursorAdductTypeIndex)))
continue;
if (peak.getAbsoluteIntensity() < this.minimumAbsolutePeakIntensity)
continue;
peakList.addElement(peak);
}
for (int i = 0; i < peakList.getNumberElements(); i++) peakList.getElement(i).setID(i);
this.deleteByMaximumNumberPeaksUsed(numberMaximumPeaksUsed, peakList);
peakList.calculateRelativeIntensities(Constants.DEFAULT_MAXIMUM_RELATIVE_INTENSITY);
return peakList;
}
use of de.ipbhalle.metfraglib.list.SortedTandemMassPeakList in project MetFragRelaunched by ipb-halle.
the class FilteredTandemMassPeakListReader method read.
public DefaultPeakList read() {
int numberMaximumPeaksUsed = (Integer) settings.get(VariableNames.NUMBER_MAXIMUM_PEAKS_USED_NAME);
SortedTandemMassPeakList peakList = null;
String filename = (String) this.settings.get(VariableNames.PEAK_LIST_PATH_NAME);
try {
java.io.BufferedReader breader = new java.io.BufferedReader(new java.io.FileReader(new java.io.File(filename)));
peakList = new SortedTandemMassPeakList((Double) this.settings.get(VariableNames.PRECURSOR_NEUTRAL_MASS_NAME));
String line = "";
while ((line = breader.readLine()) != null) {
line = line.trim();
if (line.startsWith("#") || line.length() == 0)
continue;
String[] tmp = line.split("\\s+");
double currentMass;
double currentIntensity;
try {
currentMass = Double.parseDouble(tmp[0].trim().replaceAll("^-*", ""));
currentIntensity = Double.parseDouble(tmp[1].trim());
} catch (Exception e) {
breader.close();
throw new IOException();
}
/*
* filtering step
*/
if (currentMass >= ((Double) settings.get(VariableNames.PRECURSOR_NEUTRAL_MASS_NAME) - 5.0 + Constants.ADDUCT_MASSES.get(this.precursorAdductTypeIndex)))
continue;
if (currentIntensity < this.minimumAbsolutePeakIntensity)
continue;
/*
* if filters passed add the current peak
*/
peakList.addElement(new TandemMassPeak(currentMass, currentIntensity));
}
breader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
for (int i = 0; i < peakList.getNumberElements(); i++) peakList.getElement(i).setID(i);
this.deleteByMaximumNumberPeaksUsed(numberMaximumPeaksUsed, peakList);
peakList.calculateRelativeIntensities(Constants.DEFAULT_MAXIMUM_RELATIVE_INTENSITY);
return peakList;
}
use of de.ipbhalle.metfraglib.list.SortedTandemMassPeakList in project MetFragRelaunched by ipb-halle.
the class HDFilteredTandemMassPeakListReader method read.
public DefaultPeakList read() {
int numberMaximumPeaksUsed = (Integer) settings.get(VariableNames.NUMBER_MAXIMUM_PEAKS_USED_NAME);
SortedTandemMassPeakList peakList = null;
String filename = (String) this.settings.get(VariableNames.HD_PEAK_LIST_PATH_NAME);
try {
java.io.BufferedReader breader = new java.io.BufferedReader(new java.io.FileReader(new java.io.File(filename)));
peakList = new SortedTandemMassPeakList((Double) this.settings.get(VariableNames.HD_PRECURSOR_NEUTRAL_MASS_NAME));
String line = "";
while ((line = breader.readLine()) != null) {
line = line.trim();
if (line.startsWith("#") || line.length() == 0)
continue;
String[] tmp = line.split("\\s+");
double currentMass = Double.parseDouble(tmp[0].trim().replaceAll("^-*", ""));
double currentIntensity = Double.parseDouble(tmp[1].trim());
/*
* filtering step
*/
if (currentMass >= ((Double) settings.get(VariableNames.HD_PRECURSOR_NEUTRAL_MASS_NAME) - 5.0 + Constants.ADDUCT_MASSES.get(this.precursorAdductTypeIndex)))
continue;
if (currentIntensity < this.minimumAbsolutePeakIntensity)
continue;
/*
* if filters passed add the current peak
*/
peakList.addElement(new TandemMassPeak(currentMass, currentIntensity));
}
breader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
for (int i = 0; i < peakList.getNumberElements(); i++) peakList.getElement(i).setID(i);
this.deleteByMaximumNumberPeaksUsed(numberMaximumPeaksUsed, peakList);
peakList.calculateRelativeIntensities(Constants.DEFAULT_MAXIMUM_RELATIVE_INTENSITY);
return peakList;
}
use of de.ipbhalle.metfraglib.list.SortedTandemMassPeakList in project MetFragRelaunched by ipb-halle.
the class StringTandemMassPeakListReader method readSingle.
public static DefaultPeakList readSingle(String peaklist, double precursorMass, double minimumAbsoluteIntensity, double maximumMass) {
SortedTandemMassPeakList peakList = null;
peakList = new SortedTandemMassPeakList(precursorMass);
String[] tmp = peaklist.split("\\n");
for (int i = 0; i < tmp.length; i++) {
tmp[i] = tmp[i].trim();
if (tmp[i].startsWith("#") || tmp[i].length() == 0)
continue;
String[] tmp2 = tmp[i].split("\\s+");
double intensity = Double.parseDouble(tmp2[1].trim());
if (minimumAbsoluteIntensity > intensity)
continue;
double mass = Double.parseDouble(tmp2[0].trim());
if (mass > maximumMass)
continue;
peakList.addElement(new TandemMassPeak(mass, intensity));
}
for (int i = 0; i < peakList.getNumberElements(); i++) peakList.getElement(i).setID(i);
peakList.calculateRelativeIntensities(Constants.DEFAULT_MAXIMUM_RELATIVE_INTENSITY);
return peakList;
}
use of de.ipbhalle.metfraglib.list.SortedTandemMassPeakList in project MetFragRelaunched by ipb-halle.
the class StringTandemMassPeakListReader method read.
public DefaultPeakList read() throws Exception {
int numberMaximumPeaksUsed = (Integer) settings.get(VariableNames.NUMBER_MAXIMUM_PEAKS_USED_NAME);
SortedTandemMassPeakList peakList = null;
String stringname = (String) this.settings.get(VariableNames.PEAK_LIST_STRING_NAME);
peakList = new SortedTandemMassPeakList((Double) this.settings.get(VariableNames.PRECURSOR_NEUTRAL_MASS_NAME));
String[] tmp = stringname.split("\\n");
for (int i = 0; i < tmp.length; i++) {
tmp[i] = tmp[i].trim();
if (tmp[i].startsWith("#") || tmp[i].length() == 0)
continue;
String[] tmp2 = tmp[i].split("\\s+");
peakList.addElement(new TandemMassPeak(Double.parseDouble(tmp2[0].trim()), Double.parseDouble(tmp2[1].trim())));
}
for (int i = 0; i < peakList.getNumberElements(); i++) peakList.getElement(i).setID(i);
this.deleteByMaximumNumberPeaksUsed(numberMaximumPeaksUsed, peakList);
peakList.calculateRelativeIntensities(Constants.DEFAULT_MAXIMUM_RELATIVE_INTENSITY);
return peakList;
}
Aggregations