use of net.sf.mzmine.datamodel.impl.SimplePeakListRow in project mzmine2 by mzmine.
the class PeakListOpenHandler_2_3 method startElement.
/**
* @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String,
* java.lang.String, org.xml.sax.Attributes)
*/
@Override
public void startElement(String namespaceURI, String lName, String qName, Attributes attrs) throws SAXException {
if (canceled)
throw new SAXException("Parsing canceled");
// This will remove any remaining characters from previous elements
getTextOfElement();
// <ROW>
if (qName.equals(PeakListElementName_2_3.ROW.getElementName())) {
if (buildingPeakList == null) {
initializePeakList();
}
int rowID = Integer.parseInt(attrs.getValue(PeakListElementName_2_3.ID.getElementName()));
buildingRow = new SimplePeakListRow(rowID);
String comment = attrs.getValue(PeakListElementName_2_3.COMMENT.getElementName());
buildingRow.setComment(comment);
}
// <PEAK_IDENTITY>
if (qName.equals(PeakListElementName_2_3.PEAK_IDENTITY.getElementName())) {
identityProperties = new Hashtable<String, String>();
preferred = Boolean.parseBoolean(attrs.getValue(PeakListElementName_2_3.PREFERRED.getElementName()));
}
// <IDENTITY_PROPERTY>
if (qName.equals(PeakListElementName_2_3.IDPROPERTY.getElementName())) {
identityPropertyName = attrs.getValue(PeakListElementName_2_3.NAME.getElementName());
}
// <PEAK>
if (qName.equals(PeakListElementName_2_3.PEAK.getElementName())) {
peakColumnID = attrs.getValue(PeakListElementName_2_3.COLUMN.getElementName());
mass = Double.parseDouble(attrs.getValue(PeakListElementName_2_3.MZ.getElementName()));
// Before MZmine 2.6 retention time was saved in seconds, but now we
// use minutes, so we need to divide by 60
rt = Double.parseDouble(attrs.getValue(PeakListElementName_2_3.RT.getElementName())) / 60d;
height = Double.parseDouble(attrs.getValue(PeakListElementName_2_3.HEIGHT.getElementName()));
area = Double.parseDouble(attrs.getValue(PeakListElementName_2_3.AREA.getElementName()));
peakStatus = attrs.getValue(PeakListElementName_2_3.STATUS.getElementName());
String chargeString = attrs.getValue(PeakListElementName_2_3.CHARGE.getElementName());
if (chargeString != null)
currentPeakCharge = Integer.valueOf(chargeString);
else
currentPeakCharge = 0;
}
// <MZPEAK>
if (qName.equals(PeakListElementName_2_3.MZPEAKS.getElementName())) {
numOfMZpeaks = Integer.parseInt(attrs.getValue(PeakListElementName_2_3.QUANTITY.getElementName()));
}
// <ISOTOPE_PATTERN>
if (qName.equals(PeakListElementName_2_3.ISOTOPE_PATTERN.getElementName())) {
currentIsotopes.clear();
currentIsotopePatternStatus = IsotopePatternStatus.valueOf(attrs.getValue(PeakListElementName_2_3.STATUS.getElementName()));
currentIsotopePatternDescription = attrs.getValue(PeakListElementName_2_3.DESCRIPTION.getElementName());
}
}
use of net.sf.mzmine.datamodel.impl.SimplePeakListRow in project mzmine2 by mzmine.
the class DeconvolutionTask method resolvePeaks.
/**
* Deconvolve a chromatogram into separate peaks.
*
* @param peakList holds the chromatogram to deconvolve.
* @param mzCenterFunction2
* @return a new feature list holding the resolved peaks.
* @throws RSessionWrapperException
*/
private PeakList resolvePeaks(final PeakList peakList, RSessionWrapper rSession) throws RSessionWrapperException {
// Get data file information.
final RawDataFile dataFile = peakList.getRawDataFile(0);
// Peak resolver.
final MZmineProcessingStep<PeakResolver> resolver = parameters.getParameter(PEAK_RESOLVER).getValue();
// set msms pairing range
this.setMSMSRange = parameters.getParameter(mzRangeMSMS).getValue();
if (setMSMSRange)
this.msmsRange = parameters.getParameter(mzRangeMSMS).getEmbeddedParameter().getValue();
else
this.msmsRange = 0;
this.setMSMSRT = parameters.getParameter(RetentionTimeMSMS).getValue();
if (setMSMSRT)
this.RTRangeMSMS = parameters.getParameter(RetentionTimeMSMS).getEmbeddedParameter().getValue();
else
this.RTRangeMSMS = 0;
// Create new feature list.
final PeakList resolvedPeaks = new SimplePeakList(peakList + " " + parameters.getParameter(SUFFIX).getValue(), dataFile);
// Load previous applied methods.
for (final PeakListAppliedMethod method : peakList.getAppliedMethods()) {
resolvedPeaks.addDescriptionOfAppliedTask(method);
}
// Add task description to feature list.
resolvedPeaks.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Peak deconvolution by " + resolver, resolver.getParameterSet()));
// Initialise counters.
processedRows = 0;
totalRows = peakList.getNumberOfRows();
int peakId = 1;
// Process each chromatogram.
final PeakListRow[] peakListRows = peakList.getRows();
final int chromatogramCount = peakListRows.length;
for (int index = 0; !isCanceled() && index < chromatogramCount; index++) {
final PeakListRow currentRow = peakListRows[index];
final Feature chromatogram = currentRow.getPeak(dataFile);
// Resolve peaks.
final PeakResolver resolverModule = resolver.getModule();
final ParameterSet resolverParams = resolver.getParameterSet();
final ResolvedPeak[] peaks = resolverModule.resolvePeaks(chromatogram, resolverParams, rSession, mzCenterFunction, msmsRange, RTRangeMSMS);
// Add peaks to the new feature list.
for (final ResolvedPeak peak : peaks) {
peak.setParentChromatogramRowID(currentRow.getID());
final PeakListRow newRow = new SimplePeakListRow(peakId++);
newRow.addPeak(dataFile, peak);
newRow.setPeakInformation(peak.getPeakInformation());
resolvedPeaks.addRow(newRow);
}
processedRows++;
}
return resolvedPeaks;
}
use of net.sf.mzmine.datamodel.impl.SimplePeakListRow in project mzmine2 by mzmine.
the class MsMsPeakPickingTask method run.
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
final Scan[] scans = scanSelection.getMatchingScans(dataFile);
totalScans = scans.length;
for (Scan scan : scans) {
if (isCanceled())
return;
// Get the MS Scan
Scan bestScan = null;
Range<Double> rtWindow = Range.closed(scan.getRetentionTime() - (binTime / 2.0), scan.getRetentionTime() + (binTime / 2.0));
Range<Double> mzWindow = Range.closed(scan.getPrecursorMZ() - (binSize / 2.0), scan.getPrecursorMZ() + (binSize / 2.0));
DataPoint point;
DataPoint maxPoint = null;
int[] regionScanNumbers = dataFile.getScanNumbers(1, rtWindow);
for (int regionScanNumber : regionScanNumbers) {
Scan regionScan = dataFile.getScan(regionScanNumber);
point = ScanUtils.findBasePeak(regionScan, mzWindow);
// no datapoint found
if (point == null) {
continue;
}
if (maxPoint == null) {
maxPoint = point;
}
int result = Double.compare(maxPoint.getIntensity(), point.getIntensity());
if (result <= 0) {
maxPoint = point;
bestScan = regionScan;
}
}
// if no representative dataPoint
if (bestScan == null) {
continue;
}
assert maxPoint != null;
SimpleFeature c = new SimpleFeature(dataFile, scan.getPrecursorMZ(), bestScan.getRetentionTime(), maxPoint.getIntensity(), maxPoint.getIntensity(), new int[] { bestScan.getScanNumber() }, new DataPoint[] { maxPoint }, FeatureStatus.DETECTED, bestScan.getScanNumber(), scan.getScanNumber(), new int[] {}, Range.singleton(bestScan.getRetentionTime()), Range.singleton(scan.getPrecursorMZ()), Range.singleton(maxPoint.getIntensity()));
PeakListRow entry = new SimplePeakListRow(scan.getScanNumber());
entry.addPeak(dataFile, c);
newPeakList.addRow(entry);
processedScans++;
}
project.addPeakList(newPeakList);
// Add quality parameters to peaks
QualityParameters.calculateQualityParameters(newPeakList);
logger.info("Finished MS/MS peak builder on " + dataFile + ", " + processedScans + " scans processed");
setStatus(TaskStatus.FINISHED);
}
Aggregations