/** * Constructor for the IsotopePatternRule object. */ public IsotopePatternRule() { isotopeGe = new IsotopePatternGenerator(0.01); is = new IsotopePatternSimilarity(); is.seTolerance(toleranceMass); }
/** * Adds an Isotope to this MolecularFormula one time. * * @param isotope The isotope to be added to this MolecularFormula * @see #addIsotope(IIsotope, int) */ @Override public IMolecularFormula addIsotope(IIsotope isotope) { return this.addIsotope(isotope, 1); }
/** * Returns a Map with the IChemObject's properties.I should * integrate into ChemObject. * *@return The object's properties as an Hashtable *@see #setProperties */ @Override public Map<Object, Object> getProperties() { return lazyProperties(); }
/** * Calculate isotopes for C10000 (failed in CDK 1.5.12). */ @Test public void testCalculateIsotopesC10000() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C10000", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.1); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(44, isos.getNumberOfIsotopes()); for (int i = 0; i < isos.getNumberOfIsotopes(); i++) Assert.assertTrue(isos.getIsotope(i).getMass() > 120085); }
/** * Validate the isotope pattern of this IMolecularFormula. Important, first * you have to add with the {@link #setParameters(Object[])} a IMolecularFormulaSet * which represents the isotope pattern to compare. * * @param formula Parameter is the IMolecularFormula * @return A double value meaning 1.0 True, 0.0 False */ @Override public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ", formula); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.1); IsotopePattern patternIsoPredicted = isotopeGe.getIsotopes(formula); IsotopePattern patternIsoNormalize = IsotopePatternManipulator.normalize(patternIsoPredicted); return is.compare(pattern, patternIsoNormalize); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testGetMonoIsotope() { IsotopePattern isoP = new IsotopePattern(); IsotopeContainer isoC = new IsotopeContainer(); isoP.setMonoIsotope(isoC); Assert.assertEquals(isoC, isoP.getMonoIsotope()); }
/** * Return the isotope pattern sorted and normalized by intensity * to the highest abundance. * * @param isotopeP The IsotopePattern object to sort * @return The IsotopePattern sorted */ public static IsotopePattern sortAndNormalizedByIntensity(IsotopePattern isotopeP) { IsotopePattern isoNorma = normalize(isotopeP); return sortByIntensity(isoNorma); }
/** * Get the isotope instance given an IIsotope. The instance is those * that has the isotope with the same symbol, natural abundance and * exact mass. * * @param isotope The IIsotope for looking for * @return The IIsotope instance * @see #isotopes */ private IIsotope getIsotope(IIsotope isotope) { for (IIsotope thisIsotope : isotopes()) { if (isTheSame(isotope, thisIsotope)) return thisIsotope; } return null; }
private void computeLCMs() { final ChemicalElement first = weights.get(0); first.setL(1); first.setLcm(first.getIntegerMass()); for (int i = 1; i < weights.size(); i++) { final ChemicalElement weight = weights.get(i); int temp = first.getIntegerMass() / gcd(first.getIntegerMass(), weight.getIntegerMass()); weight.setL(temp); weight.setLcm(temp * weight.getIntegerMass()); } }
/** * Test empty molecular formula range * */ @Test(expected = IllegalArgumentException.class) public void testEmptyMFRange() throws Exception { new MolecularFormulaGenerator(builder, 0, 100, new MolecularFormulaRange()); }
/** * @see MolecularFormulaGenerator#getNextFormula() */ @Override public synchronized IMolecularFormula getNextFormula() { if (!done && decomposer.next()) { this.lastDecomposition = decomposer.getCurrentCompomere(); return decomposer.generateCurrentMolecularFormula(builder); } else { done = true; return null; } }
private void divideByGCD() { if (weights.size() > 0) { int d = gcd(weights.get(0).getIntegerMass(), weights.get(1).getIntegerMass()); for (int i = 2; i < weights.size(); ++i) { d = gcd(d, weights.get(i).getIntegerMass()); if (d == 1) return; } precision *= d; for (ChemicalElement weight : weights) { weight.setIntegerMass(weight.getIntegerMass() / d); } } }
private void discretizeMasses() { // compute integer masses for (final ChemicalElement weight : weights) { weight.setIntegerMass((int) (weight.getMass() / precision)); } }
boolean next() { while (decomposeRangeIntegerMass()) { if (checkCompomere()) return true; } return false; }
/** * Returns a value between 0.0 and 1.0 indicating what portion of the search * space has been examined so far by this MolecularFormulaGenerator. Before * the first call to {@link MolecularFormulaGenerator#getNextFormula()}, this method returns 0. After * all possible formulas are generated, this method returns 1.0 (the exact * returned value might be slightly off due to rounding errors). This method * can be called from any thread. */ @Override public double getFinishedPercentage() { return formulaGenerator.getFinishedPercentage(); }
/** * {@inheritDoc} */ @Override public String toString() { return "IsotopeContainer{" + "mass=" + masOs + ", intensity=" + inte + ", MF=" + getFormulasString() + '}'; } }
/** * Returns next generated formula or null in case no new formula was found * (search is finished). There is no guaranteed order in which the formulas * are generated. */ @Override public IMolecularFormula getNextFormula() { return formulaGenerator.getNextFormula(); }
/** * Cancel the current search. This method can be called from any thread. If * another thread is executing the {@link MolecularFormulaGenerator#getNextFormula()} method, that * method call will return immediately with null return value. If another * thread is executing the {@link MolecularFormulaGenerator#getAllFormulas()} method, that method call * will return immediately, returning all formulas generated until this * moment. The search cannot be restarted once canceled - any subsequent * calls to {@link MolecularFormulaGenerator#getNextFormula()} will return null. */ @Override public void cancel() { formulaGenerator.cancel(); }
/** * Adds an Isotope to this MolecularFormula one time. * * @param isotope The isotope to be added to this MolecularFormula * @see #addIsotope(IIsotope, int) */ @Override public IMolecularFormula addIsotope(IIsotope isotope) { return this.addIsotope(isotope, 1); }
/** * Returns a Map with the IChemObject's properties.I should * integrate into ChemObject. * *@return The object's properties as an Hashtable *@see #setProperties */ @Override public Map<Object, Object> getProperties() { return lazyProperties(); }