MolAtom has no setSymbol() method

User 7b15d0a49a

26-06-2008 17:04:15

Hi,





I've been doing some file processing for one of our chemists and exporting a generated MOL file from a SMILES string.





It was requested that where a polymer exists as an asterisk in the SMILES string, the MOL file should contain and display Pol instead of A.





I could access this value in the MolAtom object using getSymbol() but there is no setSymbol() method to change the value - I had to resort to setAliasstr() to create an alias, which the chemist said did not fit his requirements.





I think there should be such a method in MolAtom. If there is a way around this, can you tell me what it is?





Thanks


Paul

ChemAxon 25dcd765a3

27-06-2008 14:34:33

Dear Paul,





The atom symbol is connected to the atomic number, so it is not possible to change the symbol of the atom without changing the atomic number. Moreover the number of atom types are limited to the atoms in the periodic system with addition to some query atoms like ANY atom. What you would like to do to introduce a new atom type for which the atomic symbol would be Pol. But this is not possible.





Do you want to change the atomic symbol in the molfile?


Like changing the 'A' to 'Pol' in the following example?
Quote:
Marvin 06270816312D





2 1 0 0 0 0 999 V2000


0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0


0.0000 0.5357 0.0000 A 0 0 0 0 0 0 0 0 0 0 0 0


1 2 1 0 0 0 0


M END


Why don't you use a simple awk script for that?





Andras

User 7b15d0a49a

27-06-2008 14:51:54

Hi,





Yes, I was trying to change the atomic symbol in the molfile. It is being generated by exporting using Molecule.toFormat("MOL"). I did realise that you could just use String.replace() in a string representation of the molfile to do this, but it just seems inelegant and restrictive; if you have special requirements for example that require you to only alter one molfile representation, a setSymbol() method would be useful. It would be easier to do this kind of thing while you have a Molecule/MolAtom objects ready.





Thanks


Paul

ChemAxon 25dcd765a3

27-06-2008 15:16:20

Hi,





I have found the solution:


You should use Pseudo atom type with alias string.


Here is an example code snipplet:


Code:



   Molecule m = new Molecule();


        MolAtom C1 = new MolAtom(0,0);


        MolAtom C2 = new MolAtom(MolAtom.ANY,0, 1, 0);


        m.add(C1);


        m.add(C2);


        m.add(new MolBond(C1, C2));


        // change the first atom


        MolAtom a = m.getAtom(1);


        a.setAtno(MolAtom.PSEUDO);


        a.setAliasstr("Pol");


        System.err.println(m.toFormat("mol"));





and the output:
Quote:



Marvin 06270817152D





2 1 0 0 0 0 999 V2000


0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0


0.0000 0.5357 0.0000 Pol 0 0 0 0 0 0 0 0 0 0 0 0


1 2 1 0 0 0 0


M END

User 7b15d0a49a

27-06-2008 15:20:08

That's exactly what I was looking for!





Thanks very much for your help!





Paul

ChemAxon 25dcd765a3

27-06-2008 16:46:11

You are welcome!





Yes, it took me a little time to understand the problem exactly.


Andras