Filtering atoms from a Molecule by residue type

User 221559a7ff

15-08-2013 22:21:23

Hi,


I have a situation in which I'd like to take in a Molecule and return a new one that strictly contains atoms that don't have a residue type. For instance, if I have a Molecule where all but two atoms are from ALA, then I want to get back those two atoms that aren't in the ALA. It is important that bonds be kept intact (I don't want to get back a bunch of atoms that have no bonds).


I tried doing something like this:


public static Molecule getNonResidueAtoms(Molecule m) {
Molecule nonResidues = new Molecule();

for (MolAtom atom : m.getAtomArray()) {
if (atom.getResidueType() == 0) {
nonResidues.add(atom);
}
}

return nonResidues;

But the problem with this is that it appears as if I don't get the bonds with it too.


My goal is to eventually do a substructure search based on what's returned by this getNonResidueAtoms method, so I imagine bonds are very important in this case. If there's anything else I need for substucture search to work properly and that isn't covered by this method, I'd like those too.


Thanks!


P.S.: I today discovered how to use the MolSearch#findAll() method and was thoroughly amazed. Thanks to the ChemAxon folks for making such a superb bioinformatics API!


Edit: looking further into the problem, I managed to get a little further by adding in the bonds too. Now my code looks like this:


public static Molecule getNonResidueAtoms(Molecule m) {
Molecule nonResidues = new Molecule();

for (MolAtom atom : m.getAtomArray()) {
if (atom.getResidueType() == 0) {
nonResidues.add(atom);
}
}

for (MolBond bond : m.getAtomArray()) {
if (nonResidues.contains(bond.getAtom1()
&& nonResidues.contains(bond.getAtom2()) {
nonResidues.add(bond);
}
}

return nonResidues;
}

But this too has its issues; the Molecule I pass into this method happens to have a DataSgroup, which appears to be included into the nonResidues file as well. The problem with this is that the DataSgroup refers to an atom that has a residue type, so does not end up in the final molecule. I haven't been able to find methods to strip away DataSgroups from a Molecule. I've attached an example of what I input and what I output.

ChemAxon abe887c64e

16-08-2013 12:36:33

Hi Ulysse,


Before we answer your questions,  please update your profile with company name, institutional mail address for the best support response in the future. These data will not be displayed at the forum.


Thank you,


Krisztina





User 221559a7ff

19-08-2013 13:58:37










kvajda wrote:

Hi Ulysse,


Before we answer your questions,  please update your profile with company name, institutional mail address for the best support response in the future. These data will not be displayed at the forum.


Thank you,


Krisztina






Hi  Krisztina,


I've updated my profile.


Sorry for bombarding you all with my questions lately; I'm just a high schooler and there aren't any people where I am who are familiar with the ChemAxon API. This is my last week here, so I'll get out of your hair shortly.


Thanks,


Ulysse

User 221559a7ff

19-08-2013 17:36:38

For now, I'm just quickly converting the molecule from SMILES and back; it's hacky but it does just get me back the molecule I want.