Search in sources :

Example 1 with SortedTandemMassPeakList

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;
}
Also used : SortedTandemMassPeakList(de.ipbhalle.metfraglib.list.SortedTandemMassPeakList) TandemMassPeak(de.ipbhalle.metfraglib.peak.TandemMassPeak)

Example 2 with SortedTandemMassPeakList

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;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SortedTandemMassPeakList(de.ipbhalle.metfraglib.list.SortedTandemMassPeakList) TandemMassPeak(de.ipbhalle.metfraglib.peak.TandemMassPeak)

Example 3 with SortedTandemMassPeakList

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;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) SortedTandemMassPeakList(de.ipbhalle.metfraglib.list.SortedTandemMassPeakList) TandemMassPeak(de.ipbhalle.metfraglib.peak.TandemMassPeak)

Example 4 with SortedTandemMassPeakList

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;
}
Also used : SortedTandemMassPeakList(de.ipbhalle.metfraglib.list.SortedTandemMassPeakList) TandemMassPeak(de.ipbhalle.metfraglib.peak.TandemMassPeak)

Example 5 with SortedTandemMassPeakList

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;
}
Also used : SortedTandemMassPeakList(de.ipbhalle.metfraglib.list.SortedTandemMassPeakList) TandemMassPeak(de.ipbhalle.metfraglib.peak.TandemMassPeak)

Aggregations

SortedTandemMassPeakList (de.ipbhalle.metfraglib.list.SortedTandemMassPeakList)15 TandemMassPeak (de.ipbhalle.metfraglib.peak.TandemMassPeak)9 IOException (java.io.IOException)6 FileNotFoundException (java.io.FileNotFoundException)4 MatchList (de.ipbhalle.metfraglib.list.MatchList)3 AbstractTopDownBitArrayFragment (de.ipbhalle.metfraglib.fragment.AbstractTopDownBitArrayFragment)2 ICandidate (de.ipbhalle.metfraglib.interfaces.ICandidate)2 DefaultPeakList (de.ipbhalle.metfraglib.list.DefaultPeakList)2 MatchFragmentList (de.ipbhalle.metfraglib.match.MatchFragmentList)2 MatchPeakList (de.ipbhalle.metfraglib.match.MatchPeakList)2 IBitFingerprint (org.openscience.cdk.fingerprint.IBitFingerprint)2 TopDownPrecursorCandidate (de.ipbhalle.metfraglib.candidate.TopDownPrecursorCandidate)1 PreProcessingCandidateSuspectListFilter (de.ipbhalle.metfraglib.candidatefilter.PreProcessingCandidateSuspectListFilter)1 AtomTypeNotKnownFromInputListException (de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException)1 AbstractTopDownBitArrayFragmentWrapper (de.ipbhalle.metfraglib.fragment.AbstractTopDownBitArrayFragmentWrapper)1 HDTopDownBitArrayFragmentWrapper (de.ipbhalle.metfraglib.fragment.HDTopDownBitArrayFragmentWrapper)1 MoNARestWebService (de.ipbhalle.metfraglib.functions.MoNARestWebService)1 IMatch (de.ipbhalle.metfraglib.interfaces.IMatch)1 SortedMergedTandemMassPeakList (de.ipbhalle.metfraglib.list.SortedMergedTandemMassPeakList)1 MatchFragmentNode (de.ipbhalle.metfraglib.match.MatchFragmentNode)1