use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class PeakListTablePopupMenu method show.
@Override
public void show(final Component invoker, final int x, final int y) {
// Select the row where clicked?
final Point clickedPoint = new Point(x, y);
final int clickedRow = table.rowAtPoint(clickedPoint);
if (table.getSelectedRowCount() < 2) {
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.setSelectionInterval(clickedRow, clickedRow);
}
// First, disable all the Show... items
show2DItem.setEnabled(false);
show3DItem.setEnabled(false);
manuallyDefineItem.setEnabled(false);
showMSMSItem.setEnabled(false);
showMSMSMirrorItem.setEnabled(false);
showSpectralDBResults.setEnabled(false);
showAllMSMSItem.setEnabled(false);
showIsotopePatternItem.setEnabled(false);
showPeakRowSummaryItem.setEnabled(false);
exportIsotopesItem.setEnabled(false);
exportMSMSItem.setEnabled(false);
exportMenu.setEnabled(false);
// Enable row items if applicable
final int[] selectedRows = table.getSelectedRows();
final boolean rowsSelected = selectedRows.length > 0;
deleteRowsItem.setEnabled(rowsSelected);
clearIdsItem.setEnabled(rowsSelected);
pasteIdsItem.setEnabled(rowsSelected && copiedId != null);
plotRowsItem.setEnabled(rowsSelected);
showMenu.setEnabled(rowsSelected);
idsMenu.setEnabled(rowsSelected);
exportIsotopesItem.setEnabled(rowsSelected);
exportToSirius.setEnabled(rowsSelected);
exportMSMSLibrary.setEnabled(rowsSelected);
exportMS1Library.setEnabled(rowsSelected);
exportMenu.setEnabled(rowsSelected);
final boolean oneRowSelected = selectedRows.length == 1;
searchMenu.setEnabled(true);
// search methods for single rows
onlineDbSearchItem.setEnabled(oneRowSelected);
nistSearchItem.setEnabled(oneRowSelected);
formulaItem.setEnabled(oneRowSelected);
siriusItem.setEnabled(oneRowSelected);
// search methods for single and multiple rows
spectralDbSearchItem.setEnabled(true);
// Find the row and column where the user clicked
clickedDataFile = null;
final int clickedColumn = columnModel.getColumn(table.columnAtPoint(clickedPoint)).getModelIndex();
if (clickedRow >= 0 && clickedColumn >= 0) {
final int rowIndex = table.convertRowIndexToModel(clickedRow);
clickedPeakListRow = getPeakListRow(rowIndex);
allClickedPeakListRows = new PeakListRow[selectedRows.length];
for (int i = 0; i < selectedRows.length; i++) {
allClickedPeakListRows[i] = getPeakListRow(table.convertRowIndexToModel(selectedRows[i]));
}
// Enable items.
show2DItem.setEnabled(oneRowSelected);
show3DItem.setEnabled(oneRowSelected);
showPeakRowSummaryItem.setEnabled(oneRowSelected);
if (clickedPeakListRow.getBestPeak() != null) {
exportMSMSItem.setEnabled(oneRowSelected && clickedPeakListRow.getBestPeak().getMostIntenseFragmentScanNumber() > 0);
}
// If we clicked on data file columns, check the peak
if (clickedColumn >= CommonColumnType.values().length) {
// Enable manual peak picking
manuallyDefineItem.setEnabled(oneRowSelected);
// Find the actual peak, if we have it.
clickedDataFile = peakList.getRawDataFile((clickedColumn - CommonColumnType.values().length) / DataFileColumnType.values().length);
final Feature clickedPeak = getPeakListRow(table.convertRowIndexToModel(clickedRow)).getPeak(clickedDataFile);
// If we have the peak, enable Show... items
if (clickedPeak != null && oneRowSelected) {
showIsotopePatternItem.setEnabled(clickedPeak.getIsotopePattern() != null);
}
} else {
showIsotopePatternItem.setEnabled(clickedPeakListRow.getBestIsotopePattern() != null && oneRowSelected);
}
long nRowsWithFragmentation = Arrays.stream(allClickedPeakListRows).filter(r -> r.getBestFragmentation() != null).count();
// always show for multi MSMS window
showMSMSItem.setEnabled((oneRowSelected && getSelectedPeakForMSMS() != null && getSelectedPeakForMSMS().getMostIntenseFragmentScanNumber() > 0) || (selectedRows.length > 1 && nRowsWithFragmentation > 1));
// always show if at least one fragmentation is available
showAllMSMSItem.setEnabled(clickedPeakListRow.getBestFragmentation() != null && oneRowSelected);
// only show if selected rows == 2 and both have MS2
boolean bothMS2 = selectedRows.length == 2 && nRowsWithFragmentation == 2;
showMSMSMirrorItem.setEnabled(bothMS2);
// has identity of spectral database match
showSpectralDBResults.setEnabled(hasSpectralDBIdentities(clickedPeakListRow));
// open id url if available
PeakIdentity pi = clickedPeakListRow.getPreferredPeakIdentity();
String url = null;
if (pi != null)
url = pi.getPropertyValue(PeakIdentity.PROPERTY_URL);
openCompoundIdUrl.setEnabled(url != null && !url.isEmpty());
}
copyIdsItem.setEnabled(oneRowSelected && allClickedPeakListRows[0].getPreferredPeakIdentity() != null);
super.show(invoker, x, y);
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class MSMSExportModule method exportMSMS.
public static void exportMSMS(PeakListRow row) {
ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(MSMSExportModule.class);
ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
if (exitCode != ExitCode.OK)
return;
File outputFile = parameters.getParameter(MSMSExportParameters.outputFile).getValue();
String massListName = parameters.getParameter(MSMSExportParameters.massList).getValue();
if ((outputFile == null) || (massListName == null))
return;
// Best peak always exists, because feature list row has at least one peak
Feature bestPeak = row.getBestPeak();
// Get the MS/MS scan number
int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
if (msmsScanNumber < 1) {
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no MS/MS scan for peak " + bestPeak);
return;
}
// MS/MS scan must exist, because msmsScanNumber was > 0
Scan msmsScan = bestPeak.getDataFile().getScan(msmsScanNumber);
MassList massList = msmsScan.getMassList(massListName);
if (massList == null) {
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no mass list called " + massListName + " for MS/MS scan #" + msmsScanNumber + " (" + bestPeak.getDataFile() + ")");
return;
}
DataPoint[] peaks = massList.getDataPoints();
try {
FileWriter fileWriter = new FileWriter(outputFile);
BufferedWriter writer = new BufferedWriter(fileWriter);
for (DataPoint peak : peaks) {
writer.write(peak.getMZ() + " " + peak.getIntensity());
writer.newLine();
}
writer.close();
} catch (Exception e) {
e.printStackTrace();
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error writing to file " + outputFile + ": " + ExceptionUtils.exceptionToString(e));
}
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class IntensityPlotTooltipGenerator method generateToolTip.
/**
* @see org.jfree.chart.labels.CategoryToolTipGenerator#generateToolTip(org.jfree.data.category.CategoryDataset,
* int, int)
*/
public String generateToolTip(CategoryDataset dataset, int row, int column) {
Format intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
Feature[] peaks = ((IntensityPlotDataset) dataset).getPeaks(row, column);
RawDataFile[] files = ((IntensityPlotDataset) dataset).getFiles(column);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < files.length; i++) {
sb.append(files[i].getName());
sb.append(": ");
if (peaks[i] != null) {
sb.append(peaks[i].toString());
sb.append(", height: ");
sb.append(intensityFormat.format(peaks[i].getHeight()));
} else {
sb.append("N/A");
}
sb.append("\n");
}
return sb.toString();
}
use of net.sf.mzmine.datamodel.Feature 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.Feature in project mzmine2 by mzmine.
the class PeakListTableModel method getValueAt.
/**
* This method returns the value at given coordinates of the dataset or null if it is a missing
* value
*/
public Object getValueAt(int row, int col) {
PeakListRow peakListRow = peakList.getRow(row);
if (isCommonColumn(col)) {
CommonColumnType commonColumn = getCommonColumn(col);
switch(commonColumn) {
case ROWID:
return new Integer(peakListRow.getID());
case AVERAGEMZ:
return new Double(peakListRow.getAverageMZ());
case AVERAGERT:
if (peakListRow.getAverageRT() <= 0)
return null;
return new Double(peakListRow.getAverageRT());
case COMMENT:
return peakListRow.getComment();
case IDENTITY:
return peakListRow.getPreferredPeakIdentity();
case PEAKSHAPE:
return peakListRow;
}
} else {
DataFileColumnType dataFileColumn = getDataFileColumn(col);
RawDataFile file = getColumnDataFile(col);
Feature peak = peakListRow.getPeak(file);
if (peak == null) {
if (dataFileColumn == DataFileColumnType.STATUS)
return FeatureStatus.UNKNOWN;
else
return null;
}
switch(dataFileColumn) {
case STATUS:
return peak.getFeatureStatus();
case PEAKSHAPE:
return peak;
case MZ:
return peak.getMZ();
case RT:
if (peak.getRT() <= 0)
return null;
return peak.getRT();
case HEIGHT:
if (peak.getHeight() <= 0)
return null;
return peak.getHeight();
case AREA:
return peak.getArea();
case DURATION:
double rtLen = peak.getRawDataPointsRTRange().upperEndpoint() - peak.getRawDataPointsRTRange().lowerEndpoint();
return rtLen;
case CHARGE:
if (peak.getCharge() <= 0)
return null;
return new Integer(peak.getCharge());
case RT_START:
return peak.getRawDataPointsRTRange().lowerEndpoint();
case RT_END:
return peak.getRawDataPointsRTRange().upperEndpoint();
case DATAPOINTS:
return peak.getScanNumbers().length;
case FWHM:
return peak.getFWHM();
case TF:
return peak.getTailingFactor();
case AF:
return peak.getAsymmetryFactor();
case PARENT_ROW_ID:
return peak.getParentChromatogramRowID();
}
}
return null;
}
Aggregations