File: test3D.py

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (52 lines) | stat: -rw-r--r-- 1,389 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from rdkit import Chem
from rdkit import rdBase
from rdkit import RDConfig
import os

from rdkit.Chem import rdMolDescriptors as rdMD
from rdkit.Chem import AllChem

import time

def get3D(m,is3d):
    if not is3d:
        m = Chem.AddHs(m)
        # define the new code from RDKit Molecule 3D ETKDG.
        ps = AllChem.ETKDG()
        ps.randomSeed = 0xf00d
        AllChem.EmbedMolecule(m,ps)
    r= rdMD.CalcAUTOCORR3D(m)+rdMD.CalcRDF(m)+rdMD.CalcMORSE(m)+rdMD.CalcWHIM(m)+rdMD.CalcGETAWAY(m, precision=0.001)
    return r

def generateAll():
    filename='/Users/GVALMTGG/Github/rdkit_mine/Code/GraphMol/Descriptors/test_data/PBF_egfr.sdf'
    suppl = Chem.SDMolSupplier(filename,removeHs=False)
    mols = [x for x in suppl]
    start = time.time()
    for m in mols:
        r= get3D(m,True)
        print(r)
    end = time.time()
    print end-start

def simple_case():
    start = time.time()
    smi = 'CCC(C)COCCCC'
    m = Chem.MolFromSmiles(smi)
    T = get3D(m,False)
    print T
    end = time.time()
    print end-start

if(__name__=='__main__'):
    # FIX: We need to actually add some tests here, but this doees not need to
    # to be done until the C++ code and tests are straightened out.
    generateAll();

    start = time.time()
    smi = 'CCC(C)COCCCC'
    m = Chem.MolFromSmiles(smi)
    T = get3D(m,False)
    print T
    end = time.time()
    print end-start