New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IMolecularFormula remove #1022
Comments
removeIsotope, but you need to find the isotope first. Something like this: for (IIsotope iso : mf.isotopes()) {
if (iso.getAtomicNumber() == IAtom.H) {
mf.removeIsotope(iso);
break;
}
} You might need to do it outside of the loop to avoid a concurrent modification exception. |
But this removes all hydrogen atoms, I just want to remove one. e.g.: If I run the code above using isotopes, it yields: |
I worked around it using IAtomContainer
Let me know if you have a better solution, thanks! |
Yes it is odd that you can't seem to explicitly set the count, any ideas @egonw? The going via an AtomContainer is overkill IMHO, perhaps a better question is why do you need to remove the hydrogen? |
Hi,
I have sum-formulas where I want to add and remove certain atoms. Using IMolecularFormula, adding can be easily done by using the add() method. Is there an equally easy method for removing molecular formulas or do I have to manipulate the string in this case?
e.g.:
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("C15H10O5", builder);
IMolecularFormula mfH = MolecularFormulaManipulator.getMolecularFormula("H", builder);
mf.add(mfH);
So if I wanted to remove one H instead, is there a method something like mf.remove(mfH)?
Thanks!
The text was updated successfully, but these errors were encountered: