use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class IsotopePatternUtils method getIsotopicPeakResults.
/**
* Returns a list of all DPPIsotopicPeakResults
*
* @param dp the ProcessedDataPoint to gather the list from.
* @return List of all results, empty if no such results exists.
*/
@Nonnull
public static List<DPPIsotopicPeakResult> getIsotopicPeakResults(@Nonnull ProcessedDataPoint dp) {
List<DPPIsotopicPeakResult> results = new ArrayList<>();
if (!dp.resultTypeExists(ResultType.ISOTOPICPEAK))
return results;
List<DPPResult<?>> patternResults = dp.getAllResultsByType(ResultType.ISOTOPICPEAK);
for (int i = 0; i < patternResults.size(); i++) results.add((DPPIsotopicPeakResult) patternResults.get(i));
return results;
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class IsotopePatternUtils method mergeIsotopicPeakResults.
/**
* Scans a ProcessedDataPoint (= parent) for DPPIsotopicPeakResults. If results exist, these
* results are scanned for isotopic peak results, too. If results exist here aswell, they are
* merged into the parent. This method recursively calls itself and will merge all results into
* the parent peak. The results of the child peaks will be removed, the isotopic composition is
* updated on every merge step, making it possible to be evaluated in later steps.
*
* Please note, that on bigger isotope patterns the parent might contain a peak twice. This has
* the following reason (e.g.:) Let's assume an isotope pattern of C1 Cl1
*
* This isotope pattern will have the following compositions: A: 12C, 35Cl
*
* B: 13C, 35Cl
*
* C: 12C, 37Cl D: 13C, 37Cl
*
* When using the findIsotopicPeaks method, the following assignments will be made:
*
* A -> B (13C of A) A -> C (37Cl of A) B -> D (37Cl of B) C -> D (13C of C)
*
* As you can see, D has been assigned twice. This is correct behaviour of the method, but if the
* convertIsotopicPeakResultsToPattern method was called now, it would contain peak D twice, even
* though there was only one peak. Comparing isotope patterns now would lead to wrong results.
* This is why the use of sortAndRemoveDuplicateIsotopicPeakResults before converting to an
* isotope pattern is recommended.
*
* @param parent The peak to process
*/
public static void mergeIsotopicPeakResults(ProcessedDataPoint parent) {
List<DPPIsotopicPeakResult> iprs = getIsotopicPeakResults(parent);
if (iprs.isEmpty())
return;
List<Integer> charges = getChargeStates(iprs);
for (DPPIsotopicPeakResult ipr : iprs) {
ProcessedDataPoint child = ipr.getValue();
if (child == parent)
continue;
mergeIsotopicPeakResults(child);
List<DPPIsotopicPeakResult> childIPRS = getIsotopicPeakResults(child);
for (DPPIsotopicPeakResult childIPR : childIPRS) {
if (charges.contains(childIPR.getCharge())) {
// make new result, combine isotopes
DPPIsotopicPeakResult newResult = new DPPIsotopicPeakResult(childIPR.getValue(), ipr.getIsotope() + "" + childIPR.getIsotope(), childIPR.getCharge());
parent.addResult(newResult);
child.removeResult(childIPR);
}
}
}
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class IsotopePatternUtils method findIsotopicPeaks.
/**
* Searches for an isotopic peaks (pattern) of the data point dp within an array of data points by
* the elements m/z differences.
*
* @param dp the base peak with lowest m/z.
* @param originalDataPoints All the data points in consideration for isotope peaks.
* @param mzTolerance the m/z tolerance.
* @param pattern The isotope pattern of an element to search for.
* @param mzrange the range of m/z to search for isotope peaks.
* @return dp will be modified and given an DPPIsotopePatternResult.
*/
public static ProcessedDataPoint findIsotopicPeaks(ProcessedDataPoint dp, ProcessedDataPoint[] originalDataPoints, MZTolerance mzTolerance, ExtendedIsotopePattern pattern, Range<Double> mzrange, int maxCharge) {
if (maxCharge < 1 || !mzrange.contains(dp.getMZ()))
return dp;
int i_dp = ArrayUtils.indexOf(dp, originalDataPoints);
int numIsotopes = pattern.getDataPoints().length;
for (int i_charge = 1; i_charge <= maxCharge; i_charge++) {
Double[] bestppm = new Double[numIsotopes];
ProcessedDataPoint[] bestdp = new ProcessedDataPoint[numIsotopes];
bestppm[0] = 0.0;
bestdp[0] = dp;
// every isotope
for (int isotopeindex = 1; isotopeindex < numIsotopes; isotopeindex++) {
// this is the mass difference the current isotope peak would add to the base peak.
double isoMzDiff = pattern.getDataPoints()[isotopeindex].getMZ() - pattern.getDataPoints()[0].getMZ();
bestdp[isotopeindex] = (ProcessedDataPoint) findBestMZDiff(dp, originalDataPoints, i_dp, mzTolerance, isoMzDiff);
}
// element, else we have to discard the results
for (int isotopeindex = 0; isotopeindex < numIsotopes; isotopeindex++) if (bestdp[isotopeindex] == null)
return dp;
// composition later on
for (int isotopeIndex = 1; isotopeIndex < numIsotopes; isotopeIndex++) {
// TODO; changed to 1
// here
ProcessedDataPoint p = bestdp[isotopeIndex];
dp.addResult(new DPPIsotopicPeakResult(p, pattern.getIsotopeComposition(isotopeIndex), i_charge));
}
}
return dp;
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class IsotopePatternUtils method convertIsotopicPeakResultsToPattern.
/**
* Takes all DPPIsotopicPeakResults of one charge and puts them into one isotope pattern (per
* charge).
*
* @param dp A ProcessedDataPoint
* @param keepResults if false, all DPPIsotopicPeakResults will be removed from this data point.
*/
public static void convertIsotopicPeakResultsToPattern(ProcessedDataPoint dp, boolean keepResults) {
sortAndRemoveDuplicateIsotopicPeakResult(dp);
List<DPPIsotopicPeakResult> iprs = getIsotopicPeakResults(dp);
if (iprs.isEmpty())
return;
List<Integer> charges = getChargeStates(iprs);
List<ProcessedDataPoint> peaks = new ArrayList<>();
List<String> isotopes = new ArrayList<>();
peaks.add(dp);
isotopes.add("");
for (int charge : charges) {
for (DPPIsotopicPeakResult ipr : iprs) {
if (ipr.getCharge() == charge) {
peaks.add(ipr.getValue());
isotopes.add(mergeIsotopicPeakDescription(ipr.getIsotope()));
}
}
ProcessedDataPoint[] dps = peaks.toArray(new ProcessedDataPoint[0]);
String[] isos = isotopes.toArray(new String[0]);
ExtendedIsotopePattern pattern = new ExtendedIsotopePattern(dps, IsotopePatternStatus.DETECTED, format.format(dp.getMZ()), /*+ Arrays.toString(isos)*/
isos);
dp.addResult(new DPPIsotopePatternResult(pattern, (ProcessedDataPoint[]) pattern.getDataPoints(), charge));
peaks.clear();
isotopes.clear();
}
if (!keepResults)
dp.removeAllResultsByType(ResultType.ISOTOPICPEAK);
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class IsotopePatternUtils method mergeIsotopePatternResults.
// -------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------
// old-new
public static void mergeIsotopePatternResults(ProcessedDataPoint dp) {
if (!dp.resultTypeExists(ResultType.ISOTOPEPATTERN))
return;
List<DPPIsotopePatternResult> patternResults = getIsotopePatternResults(dp);
List<DPPResult<?>> newResults = new ArrayList<>();
for (DPPIsotopePatternResult dpPatternResult : patternResults) {
ProcessedDataPoint[] dpPattern = dpPatternResult.getLinkedDataPoints();
int patternCharge = dpPatternResult.getCharge();
for (ProcessedDataPoint p : dpPattern) {
List<DPPIsotopePatternResult> pPatternResults = getIsotopePatternResults(p);
for (DPPIsotopePatternResult pPatternResult : pPatternResults) {
if (pPatternResult.getCharge() != patternCharge)
continue;
ProcessedDataPoint[] dataPoints = pPatternResult.getLinkedDataPoints();
p.removeResult(pPatternResult);
newResults.add(new DPPIsotopePatternResult(new SimpleIsotopePattern(dataPoints, IsotopePatternStatus.DETECTED, ""), dataPoints, patternCharge));
}
}
}
dp.getAllResultsByType(ResultType.ISOTOPEPATTERN);
dp.addAllResults(newResults);
logger.finest("-------------------------");
for (DPPResult<?> result : newResults) logger.finest("FINAL: " + format.format(dp.getMZ()) + " pattern: " + getResultIsoComp((DPPIsotopePatternResult) result));
// TODO: test
}
Aggregations