use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.
the class PeakLearnerTask method copyPeakRow.
/**
* Create a copy of a feature list row.
*
* @param row the row to copy.
* @return the newly created copy.
*/
private static PeakListRow copyPeakRow(final PeakListRow row) {
// Copy the feature list row.
final PeakListRow newRow = new SimplePeakListRow(row.getID());
PeakUtils.copyPeakListRowProperties(row, newRow);
// Copy the peaks.
for (final Feature peak : row.getPeaks()) {
final Feature newPeak = new SimpleFeature(peak);
PeakUtils.copyPeakProperties(peak, newPeak);
newRow.addPeak(peak.getDataFile(), newPeak);
}
return newRow;
}
use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.
the class NeutralLossFilterTask method copyPeakRow.
/**
* Create a copy of a feature list row.
*
* @param row the row to copy.
* @return the newly created copy.
*/
private static PeakListRow copyPeakRow(final PeakListRow row) {
// Copy the feature list row.
final PeakListRow newRow = new SimplePeakListRow(row.getID());
PeakUtils.copyPeakListRowProperties(row, newRow);
// Copy the peaks.
for (final Feature peak : row.getPeaks()) {
final Feature newPeak = new SimpleFeature(peak);
PeakUtils.copyPeakProperties(peak, newPeak);
newRow.addPeak(peak.getDataFile(), newPeak);
}
return newRow;
}
use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.
the class PeakFilterTask method copyPeakRow.
/**
* Create a copy of a feature list row.
*/
private static PeakListRow copyPeakRow(final PeakListRow row, final boolean[] keepPeak) {
// Copy the feature list row.
final PeakListRow newRow = new SimplePeakListRow(row.getID());
PeakUtils.copyPeakListRowProperties(row, newRow);
// Copy the peaks.
int i = 0;
for (final Feature peak : row.getPeaks()) {
// Only keep peak if it fulfills the filter criteria
if (keepPeak[i]) {
final Feature newPeak = new SimpleFeature(peak);
PeakUtils.copyPeakProperties(peak, newPeak);
newRow.addPeak(peak.getDataFile(), newPeak);
}
i++;
}
return newRow;
}
use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.
the class RowsFilterTask method copyPeakRow.
/**
* Create a copy of a feature list row.
*
* @param row the row to copy.
* @return the newly created copy.
*/
private static PeakListRow copyPeakRow(final PeakListRow row) {
// Copy the feature list row.
final PeakListRow newRow = new SimplePeakListRow(row.getID());
PeakUtils.copyPeakListRowProperties(row, newRow);
// Copy the peaks.
for (final Feature peak : row.getPeaks()) {
final Feature newPeak = new SimpleFeature(peak);
PeakUtils.copyPeakProperties(peak, newPeak);
newRow.addPeak(peak.getDataFile(), newPeak);
}
// Add PeakInformation
if (row.getPeakInformation() != null) {
SimplePeakInformation information = new SimplePeakInformation(new HashMap<>(row.getPeakInformation().getAllProperties()));
newRow.setPeakInformation(information);
}
return newRow;
}
use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.
the class Gap method noMoreOffers.
/**
* Finalizes the gap, adds a peak
*
* @param lock A lock for multi threading purpose. null if single threaded
*/
public void noMoreOffers() {
// Check peak that was last constructed
if (currentPeakDataPoints != null) {
checkCurrentPeak();
currentPeakDataPoints = null;
}
// If we have best peak candidate, construct a SimpleChromatographicPeak
if (bestPeakDataPoints != null) {
double area = 0, height = 0, mz = 0, rt = 0;
int[] scanNumbers = new int[bestPeakDataPoints.size()];
DataPoint[] finalDataPoint = new DataPoint[bestPeakDataPoints.size()];
Range<Double> finalRTRange = null, finalMZRange = null, finalIntensityRange = null;
int representativeScan = 0;
// Process all datapoints
for (int i = 0; i < bestPeakDataPoints.size(); i++) {
GapDataPoint dp = bestPeakDataPoints.get(i);
if (i == 0) {
finalRTRange = Range.singleton(dp.getRT());
finalMZRange = Range.singleton(dp.getMZ());
finalIntensityRange = Range.singleton(dp.getIntensity());
} else {
assert finalRTRange != null && finalMZRange != null && finalIntensityRange != null;
finalRTRange = finalRTRange.span(Range.singleton(dp.getRT()));
finalMZRange = finalMZRange.span(Range.singleton(dp.getMZ()));
finalIntensityRange = finalIntensityRange.span(Range.singleton(dp.getIntensity()));
}
scanNumbers[i] = bestPeakDataPoints.get(i).getScanNumber();
finalDataPoint[i] = new SimpleDataPoint(dp.getMZ(), dp.getIntensity());
mz += bestPeakDataPoints.get(i).getMZ();
// Check height
if (bestPeakDataPoints.get(i).getIntensity() > height) {
height = bestPeakDataPoints.get(i).getIntensity();
rt = bestPeakDataPoints.get(i).getRT();
representativeScan = bestPeakDataPoints.get(i).getScanNumber();
}
// Skip last data point
if (i == bestPeakDataPoints.size() - 1)
break;
// X axis interval length
double rtDifference = (bestPeakDataPoints.get(i + 1).getRT() - bestPeakDataPoints.get(i).getRT()) * 60d;
// intensity at the beginning and end of the interval
double intensityStart = bestPeakDataPoints.get(i).getIntensity();
double intensityEnd = bestPeakDataPoints.get(i + 1).getIntensity();
// calculate area of the interval
area += (rtDifference * (intensityStart + intensityEnd) / 2);
}
// Calculate average m/z value
mz /= bestPeakDataPoints.size();
// Find the best fragmentation scan, if available
int fragmentScan = ScanUtils.findBestFragmentScan(rawDataFile, finalRTRange, finalMZRange);
// Find all MS2 level scans
int[] allMS2FragmentScanNumbers = ScanUtils.findAllMS2FragmentScans(rawDataFile, finalRTRange, finalMZRange);
SimpleFeature newPeak = new SimpleFeature(rawDataFile, mz, rt, height, area, scanNumbers, finalDataPoint, FeatureStatus.ESTIMATED, representativeScan, fragmentScan, allMS2FragmentScanNumbers, finalRTRange, finalMZRange, finalIntensityRange);
// Fill the gap
peakListRow.addPeak(rawDataFile, newPeak);
}
}
Aggregations