Hi John, I took a look at the CDK source. Sure enough, the pattern generator just uses the element symbol to pull the generic isotopes from the atom (see lines 139-141 here https://github.com/cdk/cdk/blob/ce36b8af886e08e6015d15a2724001193f71be76/tool/formula/src/main/java/org/openscience/cdk/formula/IsotopePatternGenerator.java#L135 ).
That will always overwrite any custom isotopes you have. On Tue, Mar 22, 2022 at 3:59 PM Rob Smith <2robsm...@gmail.com> wrote: > I'm happy to. Just to clear up that I'm not doing something stupid, here's > a gist. Let me know and I can still put it up on github. > > I've chopped my code down to a minimal example below. The formula > generator search below will return hits that include 16C and 17C (though > this snippet just calls getNextFormula once, so it returns just one). The > masses of these hits will be in the correct range (626.75-626.9). But if > you print the isotope pattern generated, you will get masses outside of > that range, because they correspond to the same molecular formula (e.g., > O38 or O39) with the normal C isotopes (12C, 13C, etc), and therefore > incorrect masses for each of the isotope pattern masses. In other words, if > you were to create a vanilla O38 or O39 molecule and generate the isotope > pattern (which, presumably uses the naturally-occuring ratio of 12C : 13C : > 14C, > 98.9 : 1.1 : 0.0001) you will get the same result as you do below when you > generate the isotope patterns for nonstandard isotopes (here, O38 is 16C : > 17C, 36:3). This suggests to me that the IsotopePatternGenerator does not > actually use the isotope objects in the IMolecularFormula provided, but > rather goes off the natural abundances of the atoms in the formula, > irrespective of the isotopes set in the IMolecularFormula. > > public class FormulaGenerator { > public static void main(String[] args){ > IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); > MolecularFormulaRange mfRange = new MolecularFormulaRange(); > > try{ > IsotopeFactory isotopeFactory = Isotopes.getInstance(); > > IIsotope i = isotopeFactory.getIsotope("O", "15.99491462", 1.0); > mfRange.addIsotope(i, isotope.min, isotope.max); > > i = isotopeFactory.getIsotope("O", "16.9991317", 1.0); > mfRange.addIsotope(i, isotope.min, isotope.max); > } catch (IOException e){ > System.exit(0); > } > > MolecularFormulaGenerator generator = new > MolecularFormulaGenerator(builder, 626.75, 626.9, mfRange); > IMolecularFormulaSet formulaSet = new MolecularFormulaSet(); > > IMolecularFormula formula = generator.getNextFormula(); > > IsotopePatternGenerator isotope_pattern_generator = new > IsotopePatternGenerator(0.01); > IsotopePattern isotope_pattern = > isotope_pattern_generator.getIsotopes(formula); > for (IsotopeContainer isotope_container : > isotope_pattern.getIsotopes()) { > System.out.println("Isotope: mass:" + isotope_container.getMass() + > " intensity:" + isotope_container.getIntensity()); > } > } > } > > On Tue, Mar 22, 2022 at 3:19 PM John Mayfield <john.wilkinson...@gmail.com> > wrote: > >> Sounds like a possible bug, but not completely clear what you're trying >> to do could you post an issue with example code on GitHub? >> >> Thanks, >> John >> >> On Tue, 22 Mar 2022 at 21:06, Rob Smith <2robsm...@gmail.com> wrote: >> >>> Hello, >>> I've built a cdk workflow to generate IMolecularFormulas from a mass. >>> The workflow allows ranges of counts of different isotopes for different >>> atoms. So far, so good. >>> >>> The next step of the workflow is to generate IsotopePatterns for each >>> generated IMolecularFormula. >>> >>> I'm probably missing something, but I have spent quite some time writing >>> different approaches and verifications of what is happening. >>> >>> I have confirmed that the IMolecularFormulas outputted from the formula >>> generator step are producing non-natural isotope abundances as expected to >>> fit the range criteria. However, the IsotopePatternGenerator seems to >>> ignore these isotopes and print the pattern as if only natural abundances >>> are being used. >>> >>> Does the IsotopePatternGenerator not support non-standard isotope >>> abundances? Or am I missing a step here? >>> >>> I'd appreciate any insight anyone may have, as I've exhausted all code >>> permutations I can think of. >>> >>> Thank you for your time. >>> -Rob >>> _______________________________________________ >>> Cdk-user mailing list >>> Cdk-user@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/cdk-user >>> >>
_______________________________________________ Cdk-user mailing list Cdk-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cdk-user