rdkit / RDKitjs-legacy

Obsolete codebase, please do not use.
BSD 3-Clause "New" or "Revised" License
32 stars 12 forks source link

Add a molecule from Molfile #3

Closed lpatiny closed 9 years ago

lpatiny commented 9 years ago

Mol2BlockToMol

thegodone commented 9 years ago

do you want to read from molfile / molblock ?

thegodone commented 9 years ago

this is an example of Mol2BlockToMol string is it correct:

"@MOLECULE ACYCLOVIR 27 28 3 0 1 PROTEIN NO_CHARGES

@DICT PROTEIN PROTEIN @ATOM 1 O1 -0.5390 -3.6170 -1.0950 O.3 1 UNK01 0.0000 2 C1 0.6810 -3.4040 -0.3040 C.3 1 UNK01 0.0000 3 C2 0.7340 -1.9900 0.2940 C.3 1 UNK01 0.0000 4 O2 1.9580 -1.8430 1.0940 O.3 1 UNK01 0.0000 5 C3 1.9870 -0.5060 1.7050 C.3 1 UNK01 0.0000 6 N1 1.9210 0.4940 0.6710 N.ar 1 UNK01 0.0000 7 C4 2.9830 0.9620 -0.0400 C.ar 1 UNK01 0.0000 8 N2 2.3890 1.8500 -0.8470 N.ar 1 UNK01 0.0000 9 C5 0.9800 2.0200 -0.7330 C.ar 1 UNK01 0.0000 10 C6 -0.0350 2.7100 -1.2460 C.ar 1 UNK01 0.0000 11 O3 0.2000 3.5890 -2.2160 O.3 1 UNK01 0.0000 12 N3 -1.3000 2.5180 -0.7830 N.ar 1 UNK01 0.0000 13 C7 -1.5230 1.6210 0.2030 C.ar 1 UNK01 0.0000 14 N4 -2.8760 1.3380 0.7800 N.3 1 UNK01 0.0000 15 N5 -0.4970 0.9190 0.7260 N.ar 1 UNK01 0.0000 16 C8 0.7560 1.0680 0.3100 C.ar 1 UNK01 0.0000 17 H1 -0.5410 -3.0250 -1.8390 H 1 UNK01 0.0000 18 H2 1.5760 -3.5690 -0.9510 H 1 UNK01 0.0000 19 H3 0.7120 -4.1420 0.5340 H 2 UNK11 0.0000 20 H4 -0.1570 -1.8270 0.9460 H 1 UNK01 0.0000 21 H5 0.7120 -1.2360 -0.5290 H 1 UNK01 0.0000 22 H6 2.9190 -0.3840 2.2750 H 1 UNK01 0.0000 23 H7 1.1260 -0.3930 2.3810 H 1 UNK01 0.0000 24 H8 4.0290 0.6710 0.0480 H 1 UNK01 0.0000 25 H9 -2.0510 3.0460 -1.1810 H 1 UNK01 0.0000 26 H10 -2.8790 1.5450 1.7990 H 1 UNK01 0.0000 27 H11 -3.1160 0.3340 0.6490 H 3 UNK21 0.0000 @BOND 1 2 1 1
2 3 2 1
3 4 3 1
4 5 4 1
5 6 5 un
6 6 7 ar
7 7 8 ar
8 8 9 ar
9 10 11 1
10 12 10 ar
11 13 12 ar
12 13 14 1
13 15 13 ar
14 16 15 ar
15 2 19 1
16 6 16 ar
17 9 10 ar
18 9 16 ar
19 14 27 1
20 1 17 1
21 2 18 1
22 14 26 1
23 12 25 un
24 7 24 1
25 5 23 1
26 5 22 1
27 3 21 1
28 3 20 1
@SUBSTRUCTURE 1 UNK01 9 RESIDUE 1 A ** 2 ROOT 2 UNK11 19 RESIDUE 1 A ** 1
3 UNK21 27 RESIDUE 1 A ** 1
@SET UNK_ATOMS STATIC ATOMS AMSOM *
* Atom types guessed for these atoms 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16"

thegodone commented 9 years ago

Class function added & compiling without issue but return a illegal error message need to investigate

thegodone commented 9 years ago

this is a javascript issue :

C=" RDKit

3 2 0 0 0 0 0 0 0 0999 V2000 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 2 3 1 0 M END $$$$ " VM6930:2 Uncaught SyntaxError: Unexpected token ILLEGALInjectedScript._evaluateOn @ VM6576:883InjectedScript._evaluateAndWrap @ VM6576:816InjectedScript.evaluate @ VM6576:682

How to convert the mol object to string ?

thegodone commented 9 years ago

Illegal token error removed if we format the file to a line but RDKitjs does not support this format... need to find a solution in c++ to reformate ?

R.Molecule.MolBlockToMol('ACYCLOVIR\r\nNational University of Singapore, Department of Computational Science\r\n \r\n 27 28 0 0 0 0 0 0 0 0999 V2000\r\n -0.5390 -3.6170 -1.0950 O 0 0 0 0 0 0 0 0 0 1\r\n 0.6810 -3.4040 -0.3040 C 0 0 0 0 0 0 0 0 0 2\r\n 0.7340 -1.9900 0.2940 C 0 0 0 0 0 0 0 0 0 3\r\n 1.9580 -1.8430 1.0940 O 0 0 0 0 0 0 0 0 0 4\r\n 1.9870 -0.5060 1.7050 C 0 0 0 0 0 0 0 0 0 5\r\n 1.9210 0.4940 0.6710 N 0 0 0 0 0 0 0 0 0 6\r\n 2.9830 0.9620 -0.0400 C 0 0 0 0 0 0 0 0 0 7\r\n 2.3890 1.8500 -0.8470 N 0 0 0 0 0 0 0 0 0 8\r\n 0.9800 2.0200 -0.7330 C 0 0 0 0 0 0 0 0 0 9\r\n -0.0350 2.7100 -1.2460 C 0 0 0 0 0 0 0 0 0 10\r\n 0.2000 3.5890 -2.2160 O 0 0 0 0 0 0 0 0 0 11\r\n -1.3000 2.5180 -0.7830 N 0 0 0 0 0 0 0 0 0 12\r\n -1.5230 1.6210 0.2030 C 0 0 0 0 0 0 0 0 0 13\r\n -2.8760 1.3380 0.7800 N 0 0 0 0 0 0 0 0 0 14\r\n -0.4970 0.9190 0.7260 N 0 0 0 0 0 0 0 0 0 15\r\n 0.7560 1.0680 0.3100 C 0 0 0 0 0 0 0 0 0 16\r\n -0.5410 -3.0250 -1.8390 H 0 0 0 0 0 0 0 0 0 17\r\n 1.5760 -3.5690 -0.9510 H 0 0 0 0 0 0 0 0 0 18\r\n -0.1570 -1.8270 0.9460 H 0 0 0 0 0 0 0 0 0 20\r\n 0.7120 -1.2360 -0.5290 H 0 0 0 0 0 0 0 0 0 21\r\n 2.9190 -0.3840 2.2750 H 0 0 0 0 0 0 0 0 0 22\r\n 1.1260 -0.3930 2.3810 H 0 0 0 0 0 0 0 0 0 23\r\n 4.0290 0.6710 0.0480 H 0 0 0 0 0 0 0 0 0 24\r\n -2.0510 3.0460 -1.1810 H 0 0 0 0 0 0 0 0 0 25\r\n -2.8790 1.5450 1.7990 H 0 0 0 0 0 0 0 0 0 26\r\n 0.7120 -4.1420 0.5340 H 0 0 0 0 0 0 0 0 0 19\r\n -3.1160 0.3340 0.6490 H 0 0 0 0 0 0 0 0 0 27\r\n 2 1 1 0 0 0\r\n 3 2 1 0 0 0\r\n 4 3 1 0 0 0\r\n 5 4 1 0 0 0\r\n 6 5 1 0 0 0\r\n 6 7 4 0 0 0\r\n 7 8 4 0 0 0\r\n 8 9 4 0 0 0\r\n 10 11 1 0 0 0\r\n 12 10 4 0 0 0\r\n 13 12 4 0 0 0\r\n 13 14 1 0 0 0\r\n 15 13 4 0 0 0\r\n 16 15 4 0 0 0\r\n 6 16 4 0 0 0\r\n 9 10 4 0 0 0\r\n 9 16 4 0 0 0\r\n 1 17 1 0 0 0\r\n 2 18 1 0 0 0\r\n 14 25 1 0 0 0\r\n 12 24 1 0 0 0\r\n 7 23 1 0 0 0\r\n 5 22 1 0 0 0\r\n 5 21 1 0 0 0\r\n 3 20 1 0 0 0\r\n 3 19 1 0 0 0\r\n 2 26 1 0 0 0\r\n 14 27 1 0 0 0\r\nM END\r\n') rdkit.js:4 Uncaught 6766944___resumeException @ rdkit.js:4Eh @ rdkit.js:21vea @ rdkit.js:31dynCall_iii_99 @ VM7074:2Molecule$MolBlockToMol @ VM7252:6(anonymous function) @ VM7295:2InjectedScript._evaluateOn @ VM7002:883InjectedScript._evaluateAndWrap @ VM7002:816InjectedScript.evaluate @ VM7002:682

lpatiny commented 9 years ago

Indeed we would like molfile and not molblock ... sorry !

lpatiny commented 9 years ago

Could there be an issue with CR + LF, maybe the library only accept LF (\n) as delimiter: Also in your method you give a molfile. There is no confusion between molblock / molfile ?

thegodone commented 9 years ago

it works with \n or \r\n only

T= R.Molecule.MolBlockToMol('CCCO\nJME 2015-05-03 Sat May 16 17:16:55 GMT+200 2015\n \n 4 3 0 0 0 0 0 0 0 0999 V2000\n 3.6373 0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4249 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.2124 0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.0000 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 2 1 1 0 0 0 0\n 3 2 1 0 0 0 0\n 4 3 1 0 0 0 0\nM END\n')