use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class DPPResultsLabelGenerator method generateLabel.
/**
* @see org.jfree.chart.labels.XYItemLabelGenerator#generateLabel(org.jfree.data.xy.XYDataset,
* int, int)
*/
public String generateLabel(XYDataset dataset, int series, int item) {
// X and Y values of current data point
double originalX = dataset.getX(series, item).doubleValue();
double originalY = dataset.getY(series, item).doubleValue();
// Calculate data size of 1 screen pixel
double xLength = (double) plot.getXYPlot().getDomainAxis().getRange().getLength();
double pixelX = xLength / plot.getWidth();
// Size of data set
int itemCount = dataset.getItemCount(series);
// Search for data points higher than this one in the interval
// from limitLeft to limitRight
double limitLeft = originalX - ((POINTS_RESERVE_X / 2) * pixelX);
double limitRight = originalX + ((POINTS_RESERVE_X / 2) * pixelX);
// Iterate data points to the left and right
for (int i = 1; (item - i > 0) || (item + i < itemCount); i++) {
// If we get out of the limit we can stop searching
if ((item - i > 0) && (dataset.getXValue(series, item - i) < limitLeft) && ((item + i >= itemCount) || (dataset.getXValue(series, item + i) > limitRight)))
break;
if ((item + i < itemCount) && (dataset.getXValue(series, item + i) > limitRight) && ((item - i <= 0) || (dataset.getXValue(series, item - i) < limitLeft)))
break;
// If we find higher data point, bail out
if ((item - i > 0) && (originalY <= dataset.getYValue(series, item - i)))
return null;
if ((item + i < itemCount) && (originalY <= dataset.getYValue(series, item + i)))
return null;
}
// Create label
String label = null;
if (dataset instanceof ScanDataSet) {
label = ((ScanDataSet) dataset).getAnnotation(item);
} else if (dataset instanceof DPPResultsDataSet) {
DataPoint[] dps = ((DPPResultsDataSet) dataset).getDataPoints();
if (dps[item] instanceof ProcessedDataPoint) {
ProcessedDataPoint p = (ProcessedDataPoint) dps[item];
label = createLabel(p);
}
}
if (label == null || label.equals("")) {
double mzValue = dataset.getXValue(series, item);
label = mzFormat.format(mzValue);
}
return label;
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class DynamicParameterUtils method buildFormulaRangeOnIsotopePatternResults.
/**
* Creates an ElementParameter based on the previous processing results. If no results were
* detected, the default value is returned. Upper and lower boundaries are chosen according to
* lowerElementBoundaryPercentage and upperElementBoundaryPercentage values of this utility class.
* These values can be set via {@link #setLowerElementBoundaryPercentage} and
* {@link #setUpperElementBoundaryPercentage}. The elements contained in
*
* @param dp The data point to build a parameter for.
* @param def The default set of parameters.
* @return The built ElementsParameter
*/
public static MolecularFormulaRange buildFormulaRangeOnIsotopePatternResults(ProcessedDataPoint dp, MolecularFormulaRange def) {
DPPIsotopePatternResult result = (DPPIsotopePatternResult) dp.getFirstResultByType(ResultType.ISOTOPEPATTERN);
if (result == null)
return def;
if (!(result.getValue() instanceof ExtendedIsotopePattern))
return def;
ExtendedIsotopePattern pattern = (ExtendedIsotopePattern) result.getValue();
String form = IsotopePatternUtils.makePatternSuggestion(pattern.getIsotopeCompositions());
MolecularFormulaRange range = new MolecularFormulaRange();
IMolecularFormula formula = FormulaUtils.createMajorIsotopeMolFormula(form);
if (formula == null) {
logger.finest("could not generate formula for m/z " + dp.getMZ() + " " + form);
return def;
}
for (IIsotope isotope : def.isotopes()) range.addIsotope(isotope, def.getIsotopeCountMin(isotope), def.getIsotopeCountMax(isotope));
for (IIsotope isotope : formula.isotopes()) {
if (range.contains(isotope))
continue;
int count = formula.getIsotopeCount(isotope);
range.addIsotope(isotope, (int) (count * lowerElementBoundaryPercentage), (int) (count * upperElementBoundaryPercentage));
}
for (IIsotope isotope : range.isotopes()) {
int min = range.getIsotopeCountMin(isotope);
int max = range.getIsotopeCountMax(isotope);
// logger.info("m/z = " + dp.getMZ() + " " + isotope.getSymbol() + " " + min + " - " + max);
}
return range;
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class DPPMassDetectionTask method run.
@Override
public void run() {
if (!checkParameterSet() || !checkValues()) {
setStatus(TaskStatus.ERROR);
return;
}
if (getStatus() == TaskStatus.CANCELED) {
return;
}
setStatus(TaskStatus.PROCESSING);
MassDetector detector = massDetector.getModule();
DataPoint[] masses = detector.getMassValues(getDataPoints(), massDetector.getParameterSet());
if (masses == null || masses.length <= 0) {
Logger.info("Data point/Spectra processing: No masses were detected with the given parameters.");
setStatus(TaskStatus.CANCELED);
return;
}
ProcessedDataPoint[] dp = ProcessedDataPoint.convert(masses);
currentIndex = dataPoints.length;
setResults(dp);
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class DPPIsotopeGrouperTask method compressIsotopeDataSets.
/**
* This method generates a single IsotopesDataSet from all detected isotope patterns in the
* results.
*
* @param dataPoints
* @return
*/
private IsotopesDataSet compressIsotopeDataSets(ProcessedDataPoint[] dataPoints) {
List<IsotopePattern> list = new ArrayList<>();
for (ProcessedDataPoint dp : dataPoints) {
if (dp.resultTypeExists(ResultType.ISOTOPEPATTERN)) {
list.add(((DPPIsotopePatternResult) dp.getFirstResultByType(ResultType.ISOTOPEPATTERN)).getValue());
}
}
if (list.isEmpty())
return null;
List<DataPoint> dpList = new ArrayList<>();
for (IsotopePattern pattern : list) {
for (DataPoint dp : pattern.getDataPoints()) dpList.add(dp);
}
if (dpList.isEmpty())
return null;
IsotopePattern full = new SimpleIsotopePattern(dpList.toArray(new DataPoint[0]), IsotopePatternStatus.DETECTED, "Isotope patterns");
return new IsotopesDataSet(full);
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.
the class IsotopePatternUtils method sortAndRemoveDuplicateIsotopicPeakResult.
/**
* Sorts DPPIsotopicPeakResults by m/z and removes duplicates
*
* @param dp
*/
public static void sortAndRemoveDuplicateIsotopicPeakResult(ProcessedDataPoint dp) {
List<DPPIsotopicPeakResult> results = getIsotopicPeakResults(dp);
Collections.sort(results, (o1, o2) -> {
return Double.compare(o1.getValue().getMZ(), o2.getValue().getMZ());
});
for (int i = 0; i < results.size() - 1; i++) {
DPPIsotopicPeakResult a = results.get(i);
DPPIsotopicPeakResult b = results.get(i + 1);
if (a.getValue() == b.getValue()) {
// logger.info("removed duplicates at positions " + i + ", " + j);
results.remove(a);
}
}
dp.removeAllResultsByType(ResultType.ISOTOPICPEAK);
for (DPPIsotopicPeakResult r : results) dp.addResult(r);
}
Aggregations