use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class SimplePeakList method getPeaksInsideScanAndMZRange.
/**
* @see net.sf.mzmine.datamodel.PeakList#getPeaksInsideScanAndMZRange(double, double, double,
* double)
*/
@Override
public Feature[] getPeaksInsideScanAndMZRange(RawDataFile file, Range<Double> rtRange, Range<Double> mzRange) {
Vector<Feature> peaksInside = new Vector<Feature>();
Feature[] peaks = getPeaks(file);
for (Feature p : peaks) {
if (rtRange.contains(p.getRT()) && mzRange.contains(p.getMZ()))
peaksInside.add(p);
}
return peaksInside.toArray(new Feature[0]);
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class SimplePeakListRow method calculateAverageValues.
private synchronized void calculateAverageValues() {
double rtSum = 0, mzSum = 0, heightSum = 0, areaSum = 0;
int charge = 0;
HashSet<Integer> chargeArr = new HashSet<Integer>();
Enumeration<Feature> peakEnum = peaks.elements();
while (peakEnum.hasMoreElements()) {
Feature p = peakEnum.nextElement();
rtSum += p.getRT();
mzSum += p.getMZ();
heightSum += p.getHeight();
areaSum += p.getArea();
if (p.getCharge() > 0) {
chargeArr.add(p.getCharge());
charge = p.getCharge();
}
}
averageRT = rtSum / peaks.size();
averageMZ = mzSum / peaks.size();
averageHeight = heightSum / peaks.size();
averageArea = areaSum / peaks.size();
if (chargeArr.size() < 2) {
rowCharge = charge;
} else {
rowCharge = 0;
}
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class SimplePeakListRow method getBestIsotopePattern.
/**
* Returns the highest isotope pattern of a peak in this row
*/
@Override
public IsotopePattern getBestIsotopePattern() {
Feature[] peaks = getPeaks();
Arrays.sort(peaks, new PeakSorter(SortingProperty.Height, SortingDirection.Descending));
for (Feature peak : peaks) {
IsotopePattern ip = peak.getIsotopePattern();
if (ip != null)
return ip;
}
return null;
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class SimplePeakListRow method getBestPeak.
/**
* Returns the highest peak in this row
*/
@Override
public Feature getBestPeak() {
Feature[] peaks = getPeaks();
Arrays.sort(peaks, new PeakSorter(SortingProperty.Height, SortingDirection.Descending));
if (peaks.length == 0)
return null;
return peaks[0];
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class ADAP3DecompositionV1_5Task method getPeaks.
/**
* Convert MZmine PeakList to a list of ADAP Peaks
*
* @param peakList MZmine PeakList object
* @param edgeToHeightThreshold edge-to-height threshold to determine peaks that can be merged
* @param deltaToHeightThreshold delta-to-height threshold to determine peaks that can be merged
* @return list of ADAP Peaks
*/
@Nonnull
public static List<Peak> getPeaks(final PeakList peakList, final double edgeToHeightThreshold, final double deltaToHeightThreshold) {
RawDataFile dataFile = peakList.getRawDataFile(0);
List<Peak> peaks = new ArrayList<>();
for (PeakListRow row : peakList.getRows()) {
Feature peak = row.getBestPeak();
int[] scanNumbers = peak.getScanNumbers();
// Build chromatogram
NavigableMap<Double, Double> chromatogram = new TreeMap<>();
for (int scanNumber : scanNumbers) {
DataPoint dataPoint = peak.getDataPoint(scanNumber);
if (dataPoint != null)
chromatogram.put(dataFile.getScan(scanNumber).getRetentionTime(), dataPoint.getIntensity());
}
if (chromatogram.size() <= 1)
continue;
// Fill out PeakInfo
PeakInfo info = new PeakInfo();
try {
// Note: info.peakID is the index of PeakListRow in PeakList.peakListRows (starts from 0)
// row.getID is row.myID (starts from 1)
info.peakID = row.getID() - 1;
double height = -Double.MIN_VALUE;
for (int scan : scanNumbers) {
double intensity = peak.getDataPoint(scan).getIntensity();
if (intensity > height) {
height = intensity;
info.peakIndex = scan;
}
}
info.leftApexIndex = scanNumbers[0];
info.rightApexIndex = scanNumbers[scanNumbers.length - 1];
info.retTime = peak.getRT();
info.mzValue = peak.getMZ();
info.intensity = peak.getHeight();
info.leftPeakIndex = info.leftApexIndex;
info.rightPeakIndex = info.rightApexIndex;
} catch (Exception e) {
LOG.info("Skipping " + row + ": " + e.getMessage());
continue;
}
peaks.add(new Peak(chromatogram, info));
}
FeatureTools.correctPeakBoundaries(peaks, edgeToHeightThreshold, deltaToHeightThreshold);
return peaks;
}
Aggregations