Skip to content
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

CanonicalRankAtoms doesn't output smiles atom orders #794

Closed
bp-kelley opened this issue Feb 27, 2016 · 7 comments
Closed

CanonicalRankAtoms doesn't output smiles atom orders #794

bp-kelley opened this issue Feb 27, 2016 · 7 comments
Labels

Comments

@bp-kelley
Copy link
Contributor

CanonicalRankAtoms could be more useful if it output the "smiles" order (with perhaps, -1, for atoms that are not output in the smiles string like Hydrogens). The CanonicalRank is interesting, but it isn't very useful I think.

Currently, there is no simple way to write out coordinates for the canonicalized smiles string in the atom order of the string.

I would tend to think this is a bug, but it may be an enhancement.

@greglandrum
Copy link
Member

The SMILES output order is available from the property "_smilesAtomOutputOrder:

In [5]: m = Chem.MolFromSmiles('C1C(OC)C1CC')

In [6]: Chem.MolToSmiles(m)
Out[6]: 'CCC1CC1OC'

In [7]: m.GetProp('_smilesAtomOutputOrder')
Out[7]: '[6,5,4,0,1,2,3,]'

CanonicalRankAtoms() is useful if you just want a canonical ordering as input to some other algorithm and don't want to first have to generate SMILES.

@bp-kelley
Copy link
Contributor Author

I might go ahead and encapsulate this.

vector<int> CanonicalAtomOutputOrder(ROMol &)

to make it more explicit.

@greglandrum
Copy link
Member

greglandrum commented Feb 27, 2016 via email

@thegodone
Copy link
Contributor

Hi Greg, Is Smiles generation has this extra argument specially for doRandom = True ?

@greglandrum
Copy link
Member

@thegodone : I'm afraid I don't understand the question

@thegodone
Copy link
Contributor

I try your code and yes order change correctly with doRandom:
smile = Chem.MolToSmiles(mol,doRandom=True)
order = mol.GetProp('_smilesAtomOutputOrder')
atomorder = [int(i) for i in order.replace(bracket[0],'').replace(bracket[1],'').split(',') if i != '''''']
orderarray = np.array(atomorder)
but the order string output need to be parse

@greglandrum
Copy link
Member

Ah, you are asking if the extra argument has been added or not?
Nope, it isn't there yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants