use of io.github.msdk.featuredetection.adap3d.ADAP3DFeatureDetectionMethod in project mzmine2 by mzmine.
the class ADAP3DTask method run.
/**
* @see Runnable#run()
*/
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Started ADAP3D on " + dataFile);
List<Scan> selectedScans = Arrays.asList(scanSelection.getMatchingScans(dataFile));
// Check if we have any scans
if (selectedScans.size() == 0) {
setStatus(TaskStatus.ERROR);
setErrorMessage("No scans match the selected criteria");
return;
}
// Check if the scans are properly ordered by RT
double prevRT = Double.NEGATIVE_INFINITY;
for (Scan s : selectedScans) {
if (s.getRetentionTime() < prevRT) {
setStatus(TaskStatus.ERROR);
final String msg = "Retention time of scan #" + s.getScanNumber() + " is smaller then the retention time of the previous scan." + " Please make sure you only use scans with increasing retention times." + " You can restrict the scan numbers in the parameters, or you can use the Crop filter module";
setErrorMessage(msg);
return;
}
prevRT = s.getRetentionTime();
}
// Run MSDK module
MZmineToMSDKRawDataFile msdkRawDataFile = new MZmineToMSDKRawDataFile(dataFile);
Predicate<MsScan> scanSelectionPredicate = scan -> selectedScans.contains(((MZmineToMSDKMsScan) scan).getMzmineScan());
msdkADAP3DMethod = new ADAP3DFeatureDetectionMethod(msdkRawDataFile, scanSelectionPredicate, new ADAP3DFeatureDetectionParameters());
List<Feature> features = null;
try {
if (isCanceled())
return;
features = msdkADAP3DMethod.execute();
if (isCanceled())
return;
} catch (Exception e) {
e.printStackTrace();
setStatus(TaskStatus.ERROR);
setErrorMessage("Error in ADAP3D: " + e.getMessage());
}
if (features == null)
features = new ArrayList<>(0);
logger.info("ADAP3D detected " + features.size() + " features in " + dataFile + ", converting to MZmine peaklist");
// Create new MZmine 2 feature list
SimplePeakList newPeakList = new SimplePeakList(dataFile + " " + suffix, dataFile);
int rowId = 1;
for (Feature msdkFeature : features) {
if (isCanceled())
return;
SimpleFeature mzmineFeature = new SimpleFeature(dataFile, FeatureStatus.DETECTED, msdkFeature);
PeakListRow row = new SimplePeakListRow(rowId);
row.addPeak(dataFile, mzmineFeature);
newPeakList.addRow(row);
rowId++;
}
// Add new peaklist to the project
project.addPeakList(newPeakList);
// Add quality parameters to peaks
QualityParameters.calculateQualityParameters(newPeakList);
setStatus(TaskStatus.FINISHED);
logger.info("Finished ADAP3D feature detection on " + dataFile);
}
Aggregations