use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class DuplicateFilterModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
PeakList[] peakLists = parameters.getParameter(DuplicateFilterParameters.peakLists).getValue().getMatchingPeakLists();
for (PeakList peakList : peakLists) {
Task newTask = new DuplicateFilterTask(project, peakList, parameters);
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class LogratioPlotModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
PeakList[] peakLists = parameters.getParameter(CVParameters.peakLists).getValue().getMatchingPeakLists();
for (PeakList pl : peakLists) {
// Create dataset & paint scale
AbstractXYZDataset dataset = new LogratioDataset(pl, parameters);
InterpolatingLookupPaintScale paintScale = new InterpolatingLookupPaintScale();
paintScale.add(-1.00, new Color(0, 255, 0));
paintScale.add(0.00, new Color(0, 0, 0));
paintScale.add(1.00, new Color(255, 0, 0));
// Create & show window
RTMZAnalyzerWindow window = new RTMZAnalyzerWindow(dataset, pl, paintScale);
window.setVisible(true);
}
return ExitCode.OK;
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class CVPlotModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
PeakList[] peakLists = parameters.getParameter(CVParameters.peakLists).getValue().getMatchingPeakLists();
for (PeakList pl : peakLists) {
// Create dataset & paint scale
AbstractXYZDataset dataset = new CVDataset(pl, parameters);
InterpolatingLookupPaintScale paintScale = new InterpolatingLookupPaintScale();
paintScale.add(0.00, new Color(0, 0, 0));
paintScale.add(0.15, new Color(102, 255, 102));
paintScale.add(0.30, new Color(51, 102, 255));
paintScale.add(0.45, new Color(255, 0, 0));
// Create & show window
RTMZAnalyzerWindow window = new RTMZAnalyzerWindow(dataset, pl, paintScale);
window.setVisible(true);
}
return ExitCode.OK;
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class CameraSearchTask method run.
@Override
public void run() {
try {
setStatus(TaskStatus.PROCESSING);
// Check number of raw data files.
if (peakList.getNumberOfRawDataFiles() != 1) {
throw new IllegalStateException("CAMERA can only process feature lists for a single raw data file, i.e. non-aligned feature lists.");
}
// Run the search.
cameraSearch(peakList.getRawDataFile(0));
// Create new list with IsotopePattern information
PeakList newPeakList = null;
if (parameters.getParameter(CameraSearchParameters.CREATE_NEW_LIST).getValue()) {
switch(groupBy) {
case CameraSearchParameters.GROUP_BY_PCGROUP:
newPeakList = groupPeaksByPCGroup(peakList);
break;
default:
newPeakList = groupPeaksByIsotope(peakList);
}
}
if (!isCanceled()) {
if (newPeakList != null) {
project.addPeakList(newPeakList);
QualityParameters.calculateQualityParameters(newPeakList);
}
// Finished.
setStatus(TaskStatus.FINISHED);
LOG.info("CAMERA Search completed");
}
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
} catch (Throwable t) {
LOG.log(Level.SEVERE, "CAMERA Search error", t);
setErrorMessage(t.getMessage());
setStatus(TaskStatus.ERROR);
}
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class CameraSearchTask method groupPeaksByPCGroup.
/**
* Uses PCGroup-field in PeakIdentity to group peaks and build spectrum
*
* @param peakList a PeakList object
* @return a new PeakList object
*/
private PeakList groupPeaksByPCGroup(PeakList peakList) {
// Create new feature list.
final PeakList combinedPeakList = new SimplePeakList(peakList + " " + parameters.getParameter(CameraSearchParameters.SUFFIX).getValue(), peakList.getRawDataFiles());
// Load previous applied methods.
for (final PeakList.PeakListAppliedMethod method : peakList.getAppliedMethods()) {
combinedPeakList.addDescriptionOfAppliedTask(method);
}
// Add task description to feature list.
combinedPeakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Bioconductor CAMERA", parameters));
// --------------------
// Find unique PCGroups
// --------------------
Set<String> pcGroups = new HashSet<>();
for (PeakListRow row : peakList.getRows()) {
PeakIdentity identity = row.getPreferredPeakIdentity();
if (identity == null)
continue;
String groupName = identity.getName();
if (groupName == null || groupName.length() == 0)
continue;
pcGroups.add(groupName);
}
List<PeakListRow> groupRows = new ArrayList<>();
// Set <String> groupNames = new HashSet <> ();
Map<Double, Double> spectrum = new HashMap<>();
List<PeakListRow> newPeakListRows = new ArrayList<>();
for (String groupName : pcGroups) {
// -----------------------------------------
// Find all peaks belonging to isotopeGroups
// -----------------------------------------
groupRows.clear();
// groupNames.clear();
spectrum.clear();
double maxIntensity = 0.0;
PeakListRow groupRow = null;
for (PeakListRow row : peakList.getRows()) {
PeakIdentity identity = row.getPreferredPeakIdentity();
if (identity == null)
continue;
String name = identity.getName();
if (name.equals(groupName)) {
double intensity = row.getAverageHeight();
groupRows.add(row);
// groupNames.add(name);
spectrum.put(row.getAverageMZ(), intensity);
if (intensity > maxIntensity) {
maxIntensity = intensity;
groupRow = row;
}
}
}
if (groupRow == null || spectrum.size() <= 1)
continue;
PeakIdentity identity = groupRow.getPreferredPeakIdentity();
if (identity == null)
continue;
DataPoint[] dataPoints = new DataPoint[spectrum.size()];
int count = 0;
for (Entry<Double, Double> e : spectrum.entrySet()) dataPoints[count++] = new SimpleDataPoint(e.getKey(), e.getValue());
IsotopePattern pattern = new SimpleIsotopePattern(dataPoints, IsotopePatternStatus.PREDICTED, "Spectrum");
groupRow.getBestPeak().setIsotopePattern(pattern);
// combinedPeakList.addRow(groupRow);
newPeakListRows.add(groupRow);
}
// ------------------------------------
// Sort new peak rows by retention time
// ------------------------------------
Collections.sort(newPeakListRows, new Comparator<PeakListRow>() {
@Override
public int compare(PeakListRow row1, PeakListRow row2) {
double retTime1 = row1.getAverageRT();
double retTime2 = row2.getAverageRT();
return Double.compare(retTime1, retTime2);
}
});
for (PeakListRow row : newPeakListRows) combinedPeakList.addRow(row);
return combinedPeakList;
}
Aggregations