use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class TwoDBottomPanel method getPeaksInThreshold.
/**
* Returns a feature list different peaks depending on the selected option of the "peak Threshold"
* combo box
*/
PeakList getPeaksInThreshold() {
PeakList selectedPeakList = (PeakList) peakListSelector.getSelectedItem();
PeakThresholdMode mode = (PeakThresholdMode) thresholdCombo.getSelectedItem();
switch(mode) {
case ABOVE_INTENSITY_PEAKS:
double threshold = thresholdSettings.getIntensityThreshold();
return getIntensityThresholdPeakList(threshold);
case ALL_PEAKS:
return selectedPeakList;
case TOP_PEAKS:
case TOP_PEAKS_AREA:
int topPeaks = thresholdSettings.getTopPeaksThreshold();
return getTopThresholdPeakList(topPeaks);
}
return null;
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class GNPSResultsImportModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
// max 1
PeakList peakList = parameters.getParameter(GNPSResultsImportParameters.PEAK_LIST).getValue().getMatchingPeakLists()[0];
Task newTask = new GNPSResultsImportTask(parameters, peakList);
tasks.add(newTask);
return ExitCode.OK;
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class OnlineDBSearchModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
final PeakList[] peakLists = parameters.getParameter(PeakListIdentificationParameters.peakLists).getValue().getMatchingPeakLists();
for (final PeakList peakList : peakLists) {
Task newTask = new PeakListIdentificationTask(parameters, peakList);
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class Fx3DStageController method addMenuItems.
private void addMenuItems() {
removeMenu.getItems().clear();
for (Fx3DAbstractDataset dataset : visualizedMeshPlots) {
MenuItem menuItem = new MenuItem(dataset.getFileName());
removeMenu.getItems().add(menuItem);
menuItem.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent e) {
LOG.finest("Context menu invoked. Remove Data file button clicked. Removing dataset " + dataset.getFileName() + " from the plot.");
visualizedFiles.remove(dataset.getFile());
visualizedMeshPlots.remove(dataset);
updateGraph();
addMenuItems();
}
});
}
addDatafileMenu.getItems().clear();
for (RawDataFile file : allDataFiles) {
if (!visualizedFiles.contains(file)) {
MenuItem menuItem = new MenuItem(file.getName());
addDatafileMenu.getItems().add(menuItem);
final Fx3DStageController controller = this;
menuItem.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent e) {
LOG.finest("Context menu invoked. Add Data file button clicked. Adding dataset " + file.getName() + " to the plot.");
MZmineCore.getTaskController().addTask(new Fx3DSamplingTask(file, scanSel, mzRange, rtResolution, mzResolution, controller), TaskPriority.HIGH);
addMenuItems();
}
});
}
}
addFeatureMenu.getItems().clear();
for (PeakList peakList : allPeakLists) {
Menu peakListMenu = new Menu(peakList.getName());
addFeatureMenu.getItems().add(peakListMenu);
RawDataFile[] dataFiles = peakList.getRawDataFiles();
for (RawDataFile dataFile : dataFiles) {
Menu dataFileMenu = new Menu(dataFile.getName());
peakListMenu.getItems().add(dataFileMenu);
Feature[] features = peakList.getPeaks(dataFile);
for (Feature feature : features) {
if (feature.getRawDataPointsRTRange().lowerEndpoint() >= rtRange.lowerEndpoint() && feature.getRawDataPointsRTRange().upperEndpoint() <= mzRange.upperEndpoint() && feature.getRawDataPointsMZRange().lowerEndpoint() >= mzRange.lowerEndpoint() && feature.getRawDataPointsMZRange().upperEndpoint() <= mzRange.upperEndpoint()) {
if (!visualizedFiles.contains(feature)) {
MenuItem menuItem = new MenuItem(feature.toString());
dataFileMenu.getItems().add(menuItem);
menuItem.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent e) {
LOG.finest("Context menu invoked. Add Feature button clicked. Adding dataset " + feature.toString() + " to the plot.");
PeakListRow row = peakList.getPeakRow(feature);
FeatureSelection featureSelection = new FeatureSelection(peakList, feature, row, dataFile);
Fx3DFeatureDataset featureDataset = new Fx3DFeatureDataset(featureSelection, rtResolution, mzResolution, rtRange, mzRange, maxOfAllBinnedIntensity, Color.rgb(165, 42, 42, 0.9));
addDataset(featureDataset);
addMenuItems();
}
});
}
}
}
}
}
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class ADAP3AlignerTask method alignPeaks.
private PeakList alignPeaks() {
// Collect all data files
List<RawDataFile> allDataFiles = new ArrayList<>(peakLists.length);
for (final PeakList peakList : peakLists) {
RawDataFile[] dataFiles = peakList.getRawDataFiles();
if (dataFiles.length != 1)
throw new IllegalArgumentException("Found more then one data " + "file in some of the peaks lists");
allDataFiles.add(dataFiles[0]);
}
for (int i = 0; i < peakLists.length; ++i) {
PeakList peakList = peakLists[i];
Sample sample = new Sample(i);
for (final PeakListRow row : peakList.getRows()) {
Component component = getComponent(row);
if (component != null)
sample.addComponent(component);
}
alignment.addSample(sample);
}
process();
// Create new feature list
final PeakList alignedPeakList = new SimplePeakList(peakListName, allDataFiles.toArray(new RawDataFile[0]));
int rowID = 0;
List<ReferenceComponent> alignedComponents = alignment.getComponents();
Collections.sort(alignedComponents);
for (final ReferenceComponent referenceComponent : alignedComponents) {
SimplePeakListRow newRow = new SimplePeakListRow(++rowID);
for (int i = 0; i < referenceComponent.size(); ++i) {
Component component = referenceComponent.getComponent(i);
Peak peak = component.getBestPeak();
peak.getInfo().mzValue(component.getMZ());
PeakListRow row = findPeakListRow(referenceComponent.getSampleID(i), peak.getInfo().peakID);
if (row == null)
throw new IllegalStateException(String.format("Cannot find a feature list row for fileId = %d and peakId = %d", referenceComponent.getSampleID(), peak.getInfo().peakID));
RawDataFile file = row.getRawDataFiles()[0];
// Create a new MZmine feature
Feature feature = ADAPInterface.peakToFeature(file, peak);
// Add spectrum as an isotopic pattern
DataPoint[] spectrum = component.getSpectrum().entrySet().stream().map(e -> new SimpleDataPoint(e.getKey(), e.getValue())).toArray(DataPoint[]::new);
feature.setIsotopePattern(new SimpleIsotopePattern(spectrum, IsotopePattern.IsotopePatternStatus.PREDICTED, "Spectrum"));
newRow.addPeak(file, feature);
}
// Save alignment score
SimplePeakInformation peakInformation = (SimplePeakInformation) newRow.getPeakInformation();
if (peakInformation == null)
peakInformation = new SimplePeakInformation();
peakInformation.addProperty("Alignment score", Double.toString(referenceComponent.getScore()));
newRow.setPeakInformation(peakInformation);
alignedPeakList.addRow(newRow);
}
return alignedPeakList;
}
Aggregations