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;
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class HistogramPlotDataset method updateHistogramDataset.
public void updateHistogramDataset() {
this.list.clear();
Feature[] peaks;
double[] values = null;
for (RawDataFile dataFile : rawDataFiles) {
peaks = peakList.getPeaks(dataFile);
values = new double[peaks.length];
for (int i = 0; i < peaks.length; i++) {
switch(dataType) {
case AREA:
values[i] = peaks[i].getArea();
break;
case HEIGHT:
values[i] = peaks[i].getHeight();
break;
case MASS:
values[i] = peaks[i].getMZ();
break;
case RT:
values[i] = peaks[i].getRT();
break;
}
}
addSeries(dataFile.getName(), values);
}
}
Aggregations