Convert regular smiles with R group for molecule display.

User 37df300f74

02-01-2013 22:16:03

We are trying to convert a user generated regular smiles like [R1]C1=NC=CC=C1[R2] to marvin image with R group labeled. However when pasting this smiles into Marvin sketch, it converts R1 or R2 to A with (R1) or (R2). How can we fix this molecule usng API? I have trouble to figure out where R1 information was saved in Atom A.


Thanks


hongzhou

ChemAxon 25dcd765a3

03-01-2013 17:01:20

This does not seem to be a regular smiles:


[R1]C1=NC=CC=C1[R2]


There is no R atom in smiles according to the SMILES definition. 


If you paste it to Marvin it is automatically read as SMARTS string where [R1] become any atom with R1 query property.


I would convert these any atoms with "R?" query property to the needed R atom.


Here is a simple code how to do it using the API:


   public static void main(String[] args) throws IOException {
Molecule mol = MolImporter.importMol("[R1]C1=NC=CC=C1[R2]", "smiles");
for (MolAtom a : mol.getAtomArray()) {
   if (a.getAtno() == MolAtom.ANY && a.getQPropAsInt("R") >= 0){
int rgId = a.getQPropAsInt("R");
a.setAtno(MolAtom.RGROUP);
a.setRgroup(rgId);
   }
}
System.out.print(MolExporter.exportToFormat(mol, "mrv"));
    }

 

User 37df300f74

03-01-2013 19:00:33

Thanks for the quick reply. It was user defined smiles as a walk-around without involving more complex format. That sample code you provided solved my issue. Just didn't know where this 1 or 2 of R was stored.


Hongzhou