use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class RowVsRowDistanceProvider method getScore.
public RowVsRowScoreGC getScore(int row_id, int aligned_row_id, double mzMaxDiff, double rtMaxDiff) {
PeakListRow peakListRow = full_rows_list.get(row_id);
PeakListRow alignedRow = full_rows_list.get(aligned_row_id);
RowVsRowScoreGC score = new // useOldestRDFancestor,
RowVsRowScoreGC(// useOldestRDFancestor,
project, // ,
peakListRow, // ,
alignedRow, // ,
mzMaxDiff, // ,
mzWeight, // ,
rtMaxDiff, // ,
rtWeight, // ,
0.0d);
return score;
}
use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class PeakListTreeModel method addObject.
/**
* This method must be called from Swing thread
*/
public void addObject(final Object object) {
assert object != null;
if (!SwingUtilities.isEventDispatchThread()) {
throw new IllegalStateException("This method must be called from Swing thread");
}
// Create new node
final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(object);
treeObjects.put(object, newNode);
if (object instanceof PeakList) {
int childCount = getChildCount(rootNode);
insertNodeInto(newNode, rootNode, childCount);
final PeakList peakList = (PeakList) object;
PeakListRow[] rows = peakList.getRows();
for (int i = 0; i < rows.length; i++) {
DefaultMutableTreeNode rowNode = new DefaultMutableTreeNode(rows[i]);
treeObjects.put(rows[i], rowNode);
insertNodeInto(rowNode, newNode, i);
}
}
if (object instanceof MassList) {
Scan scan = ((MassList) object).getScan();
final DefaultMutableTreeNode scNode = treeObjects.get(scan);
assert scNode != null;
int index = scNode.getChildCount();
insertNodeInto(newNode, scNode, index);
}
}
use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class PeakListTreeModel method notifyObjectChanged.
public void notifyObjectChanged(Object object, boolean structureChanged) {
if (rootNode.getUserObject() == object) {
if (structureChanged)
nodeStructureChanged(rootNode);
else
nodeChanged(rootNode);
return;
}
Enumeration<?> nodes = rootNode.breadthFirstEnumeration();
while (nodes.hasMoreElements()) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement();
if (node.getUserObject() == object) {
if (structureChanged) {
if (object instanceof PeakList) {
node.removeAllChildren();
PeakList peakList = (PeakList) object;
PeakListRow[] rows = peakList.getRows();
for (int i = 0; i < rows.length; i++) {
DefaultMutableTreeNode rowNode = new DefaultMutableTreeNode(rows[i]);
treeObjects.put(rows[i], rowNode);
insertNodeInto(rowNode, node, i);
}
}
nodeStructureChanged(node);
} else
nodeChanged(node);
return;
}
}
}
use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class ProjectTreeMouseHandler method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("SHOW_TIC")) {
RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
TICVisualizerModule.setupNewTICVisualizer(selectedFiles);
}
if (command.equals("SHOW_SPECTRUM")) {
RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
SpectraVisualizerModule module = MZmineCore.getModuleInstance(SpectraVisualizerModule.class);
ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(SpectraVisualizerModule.class);
parameters.getParameter(SpectraVisualizerParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
if (exitCode == ExitCode.OK)
module.runModule(project, parameters, new ArrayList<Task>());
}
if (command.equals("SHOW_IDA")) {
RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
if (selectedFiles.length == 0)
return;
MsMsVisualizerModule.showIDAVisualizerSetupDialog(selectedFiles[0]);
}
if (command.equals("SHOW_2D")) {
RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
if (selectedFiles.length == 0)
return;
TwoDVisualizerModule.show2DVisualizerSetupDialog(selectedFiles[0]);
}
if (command.equals("SHOW_3D")) {
RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
if (selectedFiles.length == 0)
return;
Fx3DVisualizerModule.setupNew3DVisualizer(selectedFiles[0]);
}
if (command.equals("SORT_FILES")) {
// save current selection
TreePath[] savedSelection = tree.getSelectionPaths();
RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
SortDataFilesModule module = MZmineCore.getModuleInstance(SortDataFilesModule.class);
ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(SortDataFilesModule.class);
params.getParameter(SortDataFilesParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
// restore selection
tree.setSelectionPaths(savedSelection);
}
if (command.equals("REMOVE_EXTENSION")) {
RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
for (RawDataFile file : selectedFiles) {
file.setName(FilenameUtils.removeExtension(file.toString()));
}
tree.updateUI();
}
if (command.equals("EXPORT_FILE")) {
RawDataExportModule exportModule = MZmineCore.getModuleInstance(RawDataExportModule.class);
ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(RawDataExportModule.class);
ExitCode ec = params.showSetupDialog(null, true);
if (ec == ExitCode.OK) {
ParameterSet parametersCopy = params.cloneParameterSet();
ArrayList<Task> tasks = new ArrayList<>();
MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
exportModule.runModule(project, parametersCopy, tasks);
MZmineCore.getTaskController().addTasks(tasks.toArray(new Task[0]));
}
}
if (command.equals("RENAME_FILE")) {
TreePath path = tree.getSelectionPath();
if (path == null)
return;
else
tree.startEditingAtPath(path);
}
if (command.equals("REMOVE_FILE")) {
RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
PeakList[] allPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
for (RawDataFile file : selectedFiles) {
for (PeakList peakList : allPeakLists) {
if (peakList.hasRawDataFile(file)) {
String msg = "Cannot remove file " + file.getName() + ", because it is present in the feature list " + peakList.getName();
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), msg);
return;
}
}
MZmineCore.getProjectManager().getCurrentProject().removeFile(file);
}
}
if (command.equals("SHOW_SCAN")) {
Scan[] selectedScans = tree.getSelectedObjects(Scan.class);
for (Scan scan : selectedScans) {
SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(), scan.getScanNumber());
}
}
if (command.equals("EXPORT_SCAN")) {
Scan[] selectedScans = tree.getSelectedObjects(Scan.class);
ExportScansModule.showSetupDialog(selectedScans);
}
if (command.equals("SHOW_MASSLIST")) {
MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
for (MassList massList : selectedMassLists) {
Scan scan = massList.getScan();
SpectraVisualizerWindow window = SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(), scan.getScanNumber());
MassListDataSet dataset = new MassListDataSet(massList);
window.addDataSet(dataset, Color.green);
}
}
if (command.equals("REMOVE_MASSLIST")) {
MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
for (MassList massList : selectedMassLists) {
Scan scan = massList.getScan();
scan.removeMassList(massList);
}
}
if (command.equals("REMOVE_ALL_MASSLISTS")) {
MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
for (MassList massList : selectedMassLists) {
String massListName = massList.getName();
RawDataFile[] dataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
for (RawDataFile dataFile : dataFiles) {
int[] scanNumbers = dataFile.getScanNumbers();
for (int scanNum : scanNumbers) {
Scan scan = dataFile.getScan(scanNum);
MassList ml = scan.getMassList(massListName);
if (ml != null)
scan.removeMassList(ml);
}
}
}
}
if (command.equals("SHOW_PEAKLIST_TABLES")) {
PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
for (PeakList peakList : selectedPeakLists) {
PeakListTableModule.showNewPeakListVisualizerWindow(peakList);
}
}
if (command.equals("SHOW_PEAKLIST_INFO")) {
PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
for (PeakList peakList : selectedPeakLists) {
InfoVisualizerModule.showNewPeakListInfo(peakList);
}
}
if (command.equals("SHOW_SCATTER_PLOT")) {
PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
for (PeakList peakList : selectedPeakLists) {
ScatterPlotVisualizerModule.showNewScatterPlotWindow(peakList);
}
}
if (command.equals("SORT_PEAKLISTS")) {
// save current selection
TreePath[] savedSelection = tree.getSelectionPaths();
PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
SortPeakListsModule module = MZmineCore.getModuleInstance(SortPeakListsModule.class);
ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(SortPeakListsModule.class);
params.getParameter(SortPeakListsParameters.peakLists).setValue(PeakListsSelectionType.SPECIFIC_PEAKLISTS, selectedPeakLists);
module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
// restore selection
tree.setSelectionPaths(savedSelection);
}
if (command.equals("RENAME_FEATURELIST")) {
TreePath path = tree.getSelectionPath();
if (path == null)
return;
else
tree.startEditingAtPath(path);
}
if (command.equals("REMOVE_PEAKLIST")) {
PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
for (PeakList peakList : selectedPeakLists) MZmineCore.getProjectManager().getCurrentProject().removePeakList(peakList);
}
if (command.equals("SHOW_PEAK_SUMMARY")) {
PeakListRow[] selectedRows = tree.getSelectedObjects(PeakListRow.class);
for (PeakListRow row : selectedRows) {
PeakSummaryVisualizerModule.showNewPeakSummaryWindow(row);
}
}
}
use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class ProjectTreeMouseHandler method handlePopupTriggerEvent.
private void handlePopupTriggerEvent(MouseEvent e) {
TreePath clickedPath = tree.getPathForLocation(e.getX(), e.getY());
if (clickedPath == null)
return;
DefaultMutableTreeNode node = (DefaultMutableTreeNode) clickedPath.getLastPathComponent();
Object clickedObject = node.getUserObject();
if (clickedObject instanceof RawDataFile)
dataFilePopupMenu.show(e.getComponent(), e.getX(), e.getY());
if (clickedObject instanceof Scan)
scanPopupMenu.show(e.getComponent(), e.getX(), e.getY());
if (clickedObject instanceof MassList)
massListPopupMenu.show(e.getComponent(), e.getX(), e.getY());
if (clickedObject instanceof PeakList)
peakListPopupMenu.show(e.getComponent(), e.getX(), e.getY());
if (clickedObject instanceof PeakListRow)
peakListRowPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}
Aggregations