use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class FormulaPredictionModule method showSingleRowIdentificationDialog.
public static void showSingleRowIdentificationDialog(PeakListRow row) {
ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(FormulaPredictionModule.class);
double mzValue = row.getAverageMZ();
parameters.getParameter(FormulaPredictionParameters.neutralMass).setIonMass(mzValue);
int bestScanNum = row.getBestPeak().getRepresentativeScanNumber();
if (bestScanNum > 0) {
RawDataFile dataFile = row.getBestPeak().getDataFile();
Scan bestScan = dataFile.getScan(bestScanNum);
PolarityType scanPolarity = bestScan.getPolarity();
switch(scanPolarity) {
case POSITIVE:
parameters.getParameter(FormulaPredictionParameters.neutralMass).setIonType(IonizationType.POSITIVE_HYDROGEN);
break;
case NEGATIVE:
parameters.getParameter(FormulaPredictionParameters.neutralMass).setIonType(IonizationType.NEGATIVE_HYDROGEN);
break;
default:
break;
}
}
int charge = row.getBestPeak().getCharge();
if (charge > 0) {
parameters.getParameter(FormulaPredictionParameters.neutralMass).setCharge(charge);
}
ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
if (exitCode != ExitCode.OK) {
return;
}
SingleRowPredictionTask newTask = new SingleRowPredictionTask(parameters.cloneParameterSet(), row);
// execute the sequence
MZmineCore.getTaskController().addTask(newTask);
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class SameRangeTask method fillGap.
private Feature fillGap(PeakListRow row, RawDataFile column) {
SameRangePeak newPeak = new SameRangePeak(column);
Range<Double> mzRange = null, rtRange = null;
// Check the peaks for selected data files
for (RawDataFile dataFile : row.getRawDataFiles()) {
Feature peak = row.getPeak(dataFile);
if (peak == null)
continue;
if ((mzRange == null) || (rtRange == null)) {
mzRange = peak.getRawDataPointsMZRange();
rtRange = peak.getRawDataPointsRTRange();
} else {
mzRange = mzRange.span(peak.getRawDataPointsMZRange());
rtRange = rtRange.span(peak.getRawDataPointsRTRange());
}
}
assert mzRange != null;
assert rtRange != null;
Range<Double> mzRangeWithTol = mzTolerance.getToleranceRange(mzRange);
// Get scan numbers
int[] scanNumbers = column.getScanNumbers(1, rtRange);
boolean dataPointFound = false;
for (int scanNumber : scanNumbers) {
if (isCanceled())
return null;
// Get next scan
Scan scan = column.getScan(scanNumber);
// Find most intense m/z peak
DataPoint basePeak = ScanUtils.findBasePeak(scan, mzRangeWithTol);
if (basePeak != null) {
if (basePeak.getIntensity() > 0)
dataPointFound = true;
newPeak.addDatapoint(scan.getScanNumber(), basePeak);
} else {
DataPoint fakeDataPoint = new SimpleDataPoint(RangeUtils.rangeCenter(mzRangeWithTol), 0);
newPeak.addDatapoint(scan.getScanNumber(), fakeDataPoint);
}
}
if (dataPointFound) {
newPeak.finalizePeak();
if (newPeak.getArea() == 0)
return null;
return newPeak;
}
return null;
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class SameRangeTask method run.
public void run() {
logger.info("Started gap-filling " + peakList);
setStatus(TaskStatus.PROCESSING);
// Get total number of rows
totalRows = peakList.getNumberOfRows();
// Get feature list columns
RawDataFile[] columns = peakList.getRawDataFiles();
// Create new feature list
processedPeakList = new SimplePeakList(peakList + " " + suffix, columns);
/**
***********************************************************
* Creating a stream to process the data in parallel
*/
processedRowsAtomic = new AtomicInteger(0);
List<PeakListRow> outputList = Collections.synchronizedList(new ArrayList<>());
peakList.parallelStream().forEach(sourceRow -> {
// Canceled?
if (isCanceled())
return;
PeakListRow newRow = new SimplePeakListRow(sourceRow.getID());
// Copy comment
newRow.setComment(sourceRow.getComment());
// Copy identities
for (PeakIdentity ident : sourceRow.getPeakIdentities()) newRow.addPeakIdentity(ident, false);
if (sourceRow.getPreferredPeakIdentity() != null)
newRow.setPreferredPeakIdentity(sourceRow.getPreferredPeakIdentity());
// Copy each peaks and fill gaps
for (RawDataFile column : columns) {
// Canceled?
if (isCanceled())
return;
// Get current peak
Feature currentPeak = sourceRow.getPeak(column);
// If there is a gap, try to fill it
if (currentPeak == null)
currentPeak = fillGap(sourceRow, column);
// If a peak was found or created, add it
if (currentPeak != null)
newRow.addPeak(column, currentPeak);
}
outputList.add(newRow);
processedRowsAtomic.getAndAdd(1);
});
outputList.stream().forEach(newRow -> {
processedPeakList.addRow((PeakListRow) newRow);
});
// Canceled?
if (isCanceled())
return;
// Append processed feature list to the project
project.addPeakList(processedPeakList);
// Add quality parameters to peaks
QualityParameters.calculateQualityParameters(processedPeakList);
// Add task description to peakList
processedPeakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Gap filling using RT and m/z range", parameters));
// Remove the original peaklist if requested
if (removeOriginal)
project.removePeakList(peakList);
setStatus(TaskStatus.FINISHED);
logger.info("Finished gap-filling " + peakList);
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class PeakListBlankSubtractionMasterTask method checkBlankSelection.
private boolean checkBlankSelection(PeakList aligned, RawDataFile[] blankRaws) {
RawDataFile[] flRaws = aligned.getRawDataFiles();
for (int i = 0; i < blankRaws.length; i++) {
boolean contained = false;
for (RawDataFile flRaw : flRaws) {
if (blankRaws[i] == flRaw)
contained = true;
}
if (contained == false) {
logger.info("Peak list " + aligned.getName() + " does not contain raw data files " + blankRaws[i].getName());
return false;
}
}
logger.info("Peak list " + aligned.getName() + " contains all selected blank raw data files.");
return true;
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class PeakFilterTask method filterPeakList.
/**
* Filter the feature list.
*
* @param peakList feature list to filter.
* @return a new feature list with entries of the original feature list that pass the filtering.
*/
private PeakList filterPeakList(final PeakList peakList) {
// Make a copy of the peakList
final PeakList newPeakList = new SimplePeakList(peakList.getName() + ' ' + parameters.getParameter(RowsFilterParameters.SUFFIX).getValue(), peakList.getRawDataFiles());
// Get parameters - which filters are active
final boolean filterByDuration = parameters.getParameter(PeakFilterParameters.PEAK_DURATION).getValue();
final boolean filterByArea = parameters.getParameter(PeakFilterParameters.PEAK_AREA).getValue();
final boolean filterByHeight = parameters.getParameter(PeakFilterParameters.PEAK_HEIGHT).getValue();
final boolean filterByDatapoints = parameters.getParameter(PeakFilterParameters.PEAK_DATAPOINTS).getValue();
final boolean filterByFWHM = parameters.getParameter(PeakFilterParameters.PEAK_FWHM).getValue();
final boolean filterByTailingFactor = parameters.getParameter(PeakFilterParameters.PEAK_TAILINGFACTOR).getValue();
final boolean filterByAsymmetryFactor = parameters.getParameter(PeakFilterParameters.PEAK_ASYMMETRYFACTOR).getValue();
final boolean filterByMS2 = parameters.getParameter(PeakFilterParameters.MS2_Filter).getValue();
// Loop through all rows in feature list
final PeakListRow[] rows = peakList.getRows();
totalRows = rows.length;
for (processedRows = 0; !isCanceled() && processedRows < totalRows; processedRows++) {
final PeakListRow row = rows[processedRows];
final RawDataFile[] rawdatafiles = row.getRawDataFiles();
int totalRawDataFiles = rawdatafiles.length;
boolean[] keepPeak = new boolean[totalRawDataFiles];
for (int i = 0; i < totalRawDataFiles; i++) {
// Peak values
keepPeak[i] = true;
final Feature peak = row.getPeak(rawdatafiles[i]);
final double peakDuration = peak.getRawDataPointsRTRange().upperEndpoint() - peak.getRawDataPointsRTRange().lowerEndpoint();
final double peakArea = peak.getArea();
final double peakHeight = peak.getHeight();
final int peakDatapoints = peak.getScanNumbers().length;
final int msmsScanNumber = peak.getMostIntenseFragmentScanNumber();
Double peakFWHM = peak.getFWHM();
Double peakTailingFactor = peak.getTailingFactor();
Double peakAsymmetryFactor = peak.getAsymmetryFactor();
if (peakFWHM == null) {
peakFWHM = -1.0;
}
if (peakTailingFactor == null) {
peakTailingFactor = -1.0;
}
if (peakAsymmetryFactor == null) {
peakAsymmetryFactor = -1.0;
}
// Check Duration
if (filterByDuration) {
final Range<Double> durationRange = parameters.getParameter(PeakFilterParameters.PEAK_DURATION).getEmbeddedParameter().getValue();
if (!durationRange.contains(peakDuration)) {
// Mark peak to be removed
keepPeak[i] = false;
}
}
// Check Area
if (filterByArea) {
final Range<Double> areaRange = parameters.getParameter(PeakFilterParameters.PEAK_AREA).getEmbeddedParameter().getValue();
if (!areaRange.contains(peakArea)) {
// Mark peak to be removed
keepPeak[i] = false;
}
}
// Check Height
if (filterByHeight) {
final Range<Double> heightRange = parameters.getParameter(PeakFilterParameters.PEAK_HEIGHT).getEmbeddedParameter().getValue();
if (!heightRange.contains(peakHeight)) {
// Mark peak to be removed
keepPeak[i] = false;
}
}
// Check # Data Points
if (filterByDatapoints) {
final Range<Integer> datapointsRange = parameters.getParameter(PeakFilterParameters.PEAK_DATAPOINTS).getEmbeddedParameter().getValue();
if (!datapointsRange.contains(peakDatapoints)) {
// Mark peak to be removed
keepPeak[i] = false;
}
}
// Check FWHM
if (filterByFWHM) {
final Range<Double> fwhmRange = parameters.getParameter(PeakFilterParameters.PEAK_FWHM).getEmbeddedParameter().getValue();
if (!fwhmRange.contains(peakFWHM)) {
// Mark peak to be removed
keepPeak[i] = false;
}
}
// Check Tailing Factor
if (filterByTailingFactor) {
final Range<Double> tailingRange = parameters.getParameter(PeakFilterParameters.PEAK_TAILINGFACTOR).getEmbeddedParameter().getValue();
if (!tailingRange.contains(peakTailingFactor)) {
// Mark peak to be removed
keepPeak[i] = false;
}
}
// Check height
if (filterByAsymmetryFactor) {
final Range<Double> asymmetryRange = parameters.getParameter(PeakFilterParameters.PEAK_ASYMMETRYFACTOR).getEmbeddedParameter().getValue();
if (!asymmetryRange.contains(peakAsymmetryFactor)) {
// Mark peak to be removed
keepPeak[i] = false;
}
}
// Check MS/MS filter
if (filterByMS2) {
if (msmsScanNumber < 1)
keepPeak[i] = false;
}
}
// empty row?
boolean isEmpty = Booleans.asList(keepPeak).stream().allMatch(keep -> !keep);
if (!isEmpty)
newPeakList.addRow(copyPeakRow(row, keepPeak));
}
return newPeakList;
}
Aggregations