use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class FragmentSearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Starting fragments search in " + peakList);
PeakListRow[] rows = peakList.getRows();
totalRows = rows.length;
// Start with the highest peaks
Arrays.sort(rows, new PeakListRowSorter(SortingProperty.Height, SortingDirection.Descending));
// Compare each two rows against each other
for (int i = 0; i < totalRows; i++) {
for (int j = i + 1; j < rows.length; j++) {
// Task canceled?
if (isCanceled())
return;
// smaller one may be a fragment
if (rows[i].getAverageMZ() > rows[j].getAverageMZ()) {
if (checkFragment(rows[i], rows[j]))
addFragmentInfo(rows[i], rows[j]);
} else {
if (checkFragment(rows[j], rows[i]))
addFragmentInfo(rows[j], rows[i]);
}
}
finishedRows++;
}
// Add task description to peakList
((SimplePeakList) peakList).addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Identification of fragments", parameters));
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
setStatus(TaskStatus.FINISHED);
logger.info("Finished fragments search in " + peakList);
}
use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class PeakListIdentificationTask method retrieveIdentification.
/**
* Search the database for the peak's identity.
*
* @param row the feature list row.
* @throws IOException if there are i/o problems.
*/
private void retrieveIdentification(final PeakListRow row) throws IOException {
currentRow = row;
// Determine peak charge.
final Feature bestPeak = row.getBestPeak();
int charge = bestPeak.getCharge();
if (charge <= 0) {
charge = 1;
}
// Calculate mass value.
final double massValue = row.getAverageMZ() * (double) charge - ionType.getAddedMass();
// Isotope pattern.
final IsotopePattern rowIsotopePattern = bestPeak.getIsotopePattern();
// Process each one of the result ID's.
final String[] findCompounds = gateway.findCompounds(massValue, mzTolerance, numOfResults, db.getParameterSet());
for (int i = 0; !isCanceled() && i < findCompounds.length; i++) {
final DBCompound compound = gateway.getCompound(findCompounds[i], db.getParameterSet());
// In case we failed to retrieve data, skip this compound
if (compound == null)
continue;
final String formula = compound.getPropertyValue(PeakIdentity.PROPERTY_FORMULA);
// If required, check isotope score.
if (isotopeFilter && rowIsotopePattern != null && formula != null) {
// First modify the formula according to ionization.
final String adjustedFormula = FormulaUtils.ionizeFormula(formula, ionType, charge);
LOG.finest("Calculating isotope pattern for compound formula " + formula + " adjusted to " + adjustedFormula);
// Generate IsotopePattern for this compound
final IsotopePattern compoundIsotopePattern = IsotopePatternCalculator.calculateIsotopePattern(adjustedFormula, MIN_ABUNDANCE, charge, ionType.getPolarity());
// Check isotope pattern match
boolean check = IsotopePatternScoreCalculator.checkMatch(rowIsotopePattern, compoundIsotopePattern, isotopeFilterParameters);
if (!check)
continue;
}
// Add the retrieved identity to the feature list row
row.addPeakIdentity(compound, false);
// Notify the GUI about the change in the project
MZmineCore.getProjectManager().getCurrentProject().notifyObjectChanged(row, false);
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
}
}
use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class Ms2SearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Starting MS2 similarity search between " + peakList1 + " and " + peakList2 + " with mz tolerance:" + mzTolerance.getPpmTolerance());
Ms2SearchResult searchResult;
PeakListRow[] rows1 = peakList1.getRows();
PeakListRow[] rows2 = peakList2.getRows();
int rows1Length = rows1.length;
int rows2Length = rows2.length;
totalRows = rows1Length;
for (int i = 0; i < rows1Length; i++) {
for (int j = 0; j < rows2Length; j++) {
Feature featureA = rows1[i].getBestPeak();
Feature featureB = rows2[j].getBestPeak();
// Complication. The "best" peak, may not have the "best" fragmentation
Scan scanA = rows1[i].getBestFragmentation();
Scan scanB = rows2[j].getBestFragmentation();
searchResult = simpleMS2similarity(scanA, scanB, intensityThreshold, mzTolerance, massListName);
// Report the final score to the peaklist identity
if (searchResult != null && searchResult.getScore() > scoreThreshold && searchResult.getNumIonsMatched() >= minimumIonsMatched)
this.addMS2Identity(rows1[i], featureA, featureB, searchResult);
if (isCanceled())
return;
}
// Update progress bar
finishedRows++;
}
// Add task description to peakList
((SimplePeakList) peakList1).addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Identification of similar MS2s", parameters));
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
setStatus(TaskStatus.FINISHED);
logger.info("Finished MS2 similarity search for " + peakList1 + "against" + peakList2);
}
use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class CustomDBSearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
try {
// read database contents in memory
FileReader dbFileReader = new FileReader(dataBaseFile);
databaseValues = CSVParser.parse(dbFileReader, fieldSeparator.charAt(0));
if (ignoreFirstLine)
finishedLines++;
for (; finishedLines < databaseValues.length; finishedLines++) {
if (isCanceled()) {
dbFileReader.close();
return;
}
try {
processOneLine(databaseValues[finishedLines]);
} catch (Exception e) {
// ignore incorrect lines
}
}
dbFileReader.close();
} catch (Exception e) {
logger.log(Level.WARNING, "Could not read file " + dataBaseFile, e);
setStatus(TaskStatus.ERROR);
setErrorMessage(e.toString());
return;
}
// Add task description to peakList
peakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Peak identification using database " + dataBaseFile, parameters));
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class AdductSearchTask method run.
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
LOG.info("Starting adducts search in " + peakList);
try {
// Search the feature list for adducts.
searchAdducts();
if (!isCanceled()) {
// Add task description to peakList.
peakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Identification of adducts", parameters));
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
// Done.
setStatus(TaskStatus.FINISHED);
LOG.info("Finished adducts search in " + peakList);
}
} catch (Throwable t) {
LOG.log(Level.SEVERE, "Adduct search error", t);
setStatus(TaskStatus.ERROR);
setErrorMessage(t.getMessage());
}
}
Aggregations