Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
Fixed showing of isotope patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-pluskal committed Aug 22, 2019
1 parent 934680f commit 52ca7ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.File;
import java.io.FileWriter;
import java.util.Map;
import java.util.logging.Logger;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
Expand All @@ -53,20 +54,22 @@
import net.sf.mzmine.datamodel.RawDataFile;
import net.sf.mzmine.datamodel.impl.SimplePeakIdentity;
import net.sf.mzmine.main.MZmineCore;
import net.sf.mzmine.modules.peaklistmethods.isotopes.isotopeprediction.IsotopePatternCalculator;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerModule;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow;
import net.sf.mzmine.taskcontrol.Task;
import net.sf.mzmine.taskcontrol.TaskStatus;
import net.sf.mzmine.util.ExceptionUtils;
import net.sf.mzmine.util.FormulaUtils;
import net.sf.mzmine.util.GUIUtils;
import net.sf.mzmine.util.components.PercentageCellRenderer;

public class ResultWindow extends JFrame implements ActionListener {

/**
*
*/
private static final long serialVersionUID = 1L;

private Logger logger = Logger.getLogger(this.getClass().getName());

private final JTable resultsTable;
private final ResultTableModel resultsTableModel;
private final TableRowSorter<ResultTableModel> resultsTableSorter;
Expand Down Expand Up @@ -226,6 +229,7 @@ public void actionPerformed(ActionEvent e) {

if (command.equals("SHOW_ISOTOPES")) {

logger.finest("Showing isotope pattern for formula " + formula.getFormulaAsString());
IsotopePattern predictedPattern = formula.getPredictedIsotopes();

if (predictedPattern == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,23 @@ private void checkConstraints(IMolecularFormula cdkFormula) {
}

// Calculate isotope similarity score
IsotopePattern detectedPattern = peakListRow.getBestIsotopePattern();
IsotopePattern predictedIsotopePattern = null;
Double isotopeScore = null;
if ((checkIsotopes) && (detectedPattern != null)) {
final IsotopePattern detectedPattern = peakListRow.getBestIsotopePattern();

String stringFormula = MolecularFormulaManipulator.getString(cdkFormula);
final String stringFormula = MolecularFormulaManipulator.getString(cdkFormula);

String adjustedFormula = FormulaUtils.ionizeFormula(stringFormula, ionType, charge);
final String adjustedFormula = FormulaUtils.ionizeFormula(stringFormula, ionType, charge);

final double isotopeNoiseLevel = isotopeParameters
.getParameter(IsotopePatternScoreParameters.isotopeNoiseLevel).getValue();
final double isotopeNoiseLevel =
isotopeParameters.getParameter(IsotopePatternScoreParameters.isotopeNoiseLevel).getValue();

final double detectedPatternHeight = detectedPattern.getHighestDataPoint().getIntensity();
// Fixed min abundance
final double minPredictedAbundance = 0.00001;

final double minPredictedAbundance = isotopeNoiseLevel / detectedPatternHeight;
final IsotopePattern predictedIsotopePattern = IsotopePatternCalculator.calculateIsotopePattern(
adjustedFormula, minPredictedAbundance, charge, ionType.getPolarity());

predictedIsotopePattern = IsotopePatternCalculator.calculateIsotopePattern(adjustedFormula,
minPredictedAbundance, charge, ionType.getPolarity());
Double isotopeScore = null;
if ((checkIsotopes) && (detectedPattern != null)) {

isotopeScore = IsotopePatternScoreCalculator.getSimilarityScore(detectedPattern,
predictedIsotopePattern, isotopeParameters);
Expand Down

0 comments on commit 52ca7ae

Please sign in to comment.