nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
659 stars 168 forks source link

Detect rings in groups/residues #179

Closed arose closed 7 years ago

arose commented 7 years ago

Up to 6 (or 7?) ring members.

Atoms can belong to multiple rings. Data can be stored in ResidueType instances.

arose commented 7 years ago

@fredludlow how far are we from supporting that?

fredludlow commented 7 years ago

Was looking at this when originally thinking about the reference atoms for bond shifts stuff. I guess "find all the rings" is not quite the same algorithm I'm using for "find the smallest ring containing this bond" (just DFS), I can have a look at what RDKit or another permissively-licensed chemoinformatics toolkit does.

I was looking at refactoring the reference atom stuff and I think these various features would benefit from a really quick way to traverse the molecule - BondHash nearly does that, but it gives you a bond Index and have to work out what the "other" atom is (sorry, late here and not explaining well). That could be on-the-fly: BondProxy.getOtherAtom(atomproxy) or AtomProxy.getBondedAtom(bondproxy); or could have another array in BondHash of "otherAtomIndex" - (increases storage, most of which never accessed...)

arose commented 7 years ago

Was looking at this when originally thinking about the reference atoms for bond shifts stuff. I guess "find all the rings" is not quite the same algorithm I'm using for "find the smallest ring containing this bond" (just DFS), I can have a look at what RDKit or another permissively-licensed chemoinformatics toolkit does.

Actually I currently only need a flag per atom indication if it is member of a ring or not. So I would welcome that as a first step :-)

That could be on-the-fly: BondProxy.getOtherAtom(atomproxy) or AtomProxy.getBondedAtom(bondproxy); or could have another array in BondHash of "otherAtomIndex" - (increases storage, most of which never accessed...)

Or AtomProxy.eachBondedAtom( callback )?

fredludlow commented 7 years ago

Actually I currently only need a flag per atom indication if it is member of a ring or not. So I would welcome that as a first step :-)

In that case this should do it: RDKit's fastFindRings...That method doesn't find all rings but does find all ring atoms, if that makes sense.

Actually, storing the rings also simplifies the reference atom stuff.

Or AtomProxy.eachBondedAtom( callback )?

Yup. why don't I do that and ResidueType.assignRings and if that's any good I'll use them for the multiple bond stuff (I've got a first attempt at the asymmetric offset bonds thing, will get it out tomorrow)