예제 #1
0
파일: tests.py 프로젝트: caiyingchun/OASA
def test_multimol_molfile2():
    import molfile, smiles
    mols = [smiles.text_to_mol(t) for t in ["CCC(=O)[O-].[K+]"]]
    for mol in mols:
        mol.remove_zero_order_bonds()
    m = molfile.converter()
    text = m.mols_to_text(mols)
    f = file("multi2.mol", "w")
    f.write(text)
    f.close()
    f = file("prase.sdf", "r")
    for mol in m.read_text(text):
        print smiles.mol_to_text(mol)
    f.close()
예제 #2
0
파일: tests.py 프로젝트: Robot-Will/OASA
def test_multimol_molfile2():
    import molfile, smiles
    mols = [smiles.text_to_mol( t) for t in ["CCC(=O)[O-].[K+]"]]
    for mol in mols:
        mol.remove_zero_order_bonds()
    m = molfile.converter()
    text = m.mols_to_text( mols)
    f = file("multi2.mol","w")
    f.write( text)
    f.close()
    f = file("prase.sdf","r")
    for mol in m.read_text( text):
        print smiles.mol_to_text( mol)
    f.close()
예제 #3
0
 def find_rings_in_mol(self, mol, detect_aromatic=True):
     hits = []
     if detect_aromatic:
         # this is necessary to correctly process fused aromatic rings
         # with improperly localized bonds
         mol.mark_aromatic_bonds()
     for ering in mol.get_smallest_independent_cycles_e():
         vring = mol.edge_subgraph_to_vertex_subgraph(ering)
         ring_mol = mol.get_new_induced_subgraph(vring, ering)
         # here we need to take care of aromatic bonds
         # this is needed to properly match naphthalene, etc.
         if detect_aromatic:
             for e in ring_mol.edges:
                 if e.aromatic:
                     e.order = 4
             ring_mol.localize_aromatic_bonds()
         ring_hash = ring_mol.get_structure_hash()
         if ring_hash in self.rings:
             hit = ring_match(vring, self.rings[ring_hash])
         else:
             ring_obj = ring(None,
                             smiles.mol_to_text(ring_mol),
                             ring_hash=ring_hash)
             self.rings[ring_hash] = ring_obj
             hit = ring_match(vring, ring_obj)
         hits.append(hit)
     return hits
예제 #4
0
 def find_rings_in_mol( self, mol, detect_aromatic=True):
   hits = []
   if detect_aromatic:
     # this is necessary to correctly process fused aromatic rings
     # with improperly localized bonds
     mol.mark_aromatic_bonds()
   for ering in mol.get_smallest_independent_cycles_e():
     vring = mol.edge_subgraph_to_vertex_subgraph( ering)
     ring_mol = mol.get_new_induced_subgraph( vring, ering)
     # here we need to take care of aromatic bonds
     # this is needed to properly match naphthalene, etc.
     if detect_aromatic:
       for e in ring_mol.edges:
         if e.aromatic:
           e.order = 4
       ring_mol.localize_aromatic_bonds()
     ring_hash = ring_mol.get_structure_hash()
     if ring_hash in self.rings:
       hit = ring_match( vring, self.rings[ ring_hash])
     else:
       ring_obj = ring( None, smiles.mol_to_text( ring_mol), ring_hash=ring_hash)
       self.rings[ ring_hash] = ring_obj
       hit = ring_match( vring, ring_obj)
     hits.append( hit)
   return hits
예제 #5
0
파일: tests.py 프로젝트: caiyingchun/OASA
def test_fullerene_lockdown():
    import inchi
    import smiles
    from time import time
    t = time()
    #mol = inchi.text_to_mol( "InChI=1/C60/c1-2-5-6-3(1)8-12-10-4(1)9-11-7(2)17-21-13(5)23-24-14(6)22-18(8)28-20(12)30-26-16(10)15(9)25-29-19(11)27(17)37-41-31(21)33(23)43-44-34(24)32(22)42-38(28)48-40(30)46-36(26)35(25)45-39(29)47(37)55-49(41)51(43)57-52(44)50(42)56(48)59-54(46)53(45)58(55)60(57)59")
    string = "C12=C3C4=C5C6=C1C7=C8C9=C1C%10=C%11C(=C29)C3=C2C3=C4C4=C5C5=C9C6=C7C6=C7C8=C1C1=C8C%10=C%10C%11=C2C2=C3C3=C4C4=C5C5=C%11C%12=C(C6=C95)C7=C1C1=C%12C5=C%11C4=C3C3=C5C(=C81)C%10=C23"
    #string = "C12C3C2C13"
    string = "c1=%31c%25c8c%23c%19c%18c7c8c%17c%25c%29C=%21C=%31c%12c2-c%11c=%21c%20c%24c=4c%11C=6c2c9c(c5%28)c%12c1c%23c5c%19c3c%16c%18c%14c7c(c%17c%10c%20%29)c%22c%10c%24c%26c-%13c%22c%14c(c-%13c%15=C%27C=4%26)c%16c(c%15=%30)=c3c%28=C9C=%30C=6%27"
    mol = smiles.text_to_mol(string, calc_coords=True)
    print time() - t
    t = time()
    #print mol.get_all_cycles()
    print smiles.mol_to_text(mol)
    print time() - t
    print mol
예제 #6
0
파일: tests.py 프로젝트: Robot-Will/OASA
def test_fullerene_lockdown():
    import inchi
    import smiles
    from time import time
    t = time()
    #mol = inchi.text_to_mol( "InChI=1/C60/c1-2-5-6-3(1)8-12-10-4(1)9-11-7(2)17-21-13(5)23-24-14(6)22-18(8)28-20(12)30-26-16(10)15(9)25-29-19(11)27(17)37-41-31(21)33(23)43-44-34(24)32(22)42-38(28)48-40(30)46-36(26)35(25)45-39(29)47(37)55-49(41)51(43)57-52(44)50(42)56(48)59-54(46)53(45)58(55)60(57)59")
    string = "C12=C3C4=C5C6=C1C7=C8C9=C1C%10=C%11C(=C29)C3=C2C3=C4C4=C5C5=C9C6=C7C6=C7C8=C1C1=C8C%10=C%10C%11=C2C2=C3C3=C4C4=C5C5=C%11C%12=C(C6=C95)C7=C1C1=C%12C5=C%11C4=C3C3=C5C(=C81)C%10=C23"
    #string = "C12C3C2C13"
    string = "c1=%31c%25c8c%23c%19c%18c7c8c%17c%25c%29C=%21C=%31c%12c2-c%11c=%21c%20c%24c=4c%11C=6c2c9c(c5%28)c%12c1c%23c5c%19c3c%16c%18c%14c7c(c%17c%10c%20%29)c%22c%10c%24c%26c-%13c%22c%14c(c-%13c%15=C%27C=4%26)c%16c(c%15=%30)=c3c%28=C9C=%30C=6%27"
    mol = smiles.text_to_mol( string, calc_coords=True)
    print time()-t
    t = time()
    #print mol.get_all_cycles()
    print smiles.mol_to_text( mol)
    print time()-t
    print mol
예제 #7
0
파일: inchi.py 프로젝트: Robot-Will/OASA
 def main( text, cycles):
   t1 = time.time()
   for jj in range( cycles):
     mol = text_to_mol( text, calc_coords=True, include_hydrogens=False)
     print map( str, [b for b in mol.bonds if b.order == 0])
     print "  smiles: ", smiles.mol_to_text( mol)
     print "  inchi:  ", generate_inchi( mol, fixed_hs=False, program="/home/beda/bin/stdinchi-1")
     print "  charge: ", sum( [a.charge for a in mol.vertices])
     print "  mw:     ", mol.weight
   print generate_inchi_and_inchikey( mol, fixed_hs=False, program="/home/beda/bin/stdinchi-1")
   t1 = time.time() - t1
   print 'time per cycle', round( 1000*t1/cycles, 2), 'ms'
예제 #8
0
파일: inchi.py 프로젝트: caiyingchun/OASA
 def main(text, cycles):
     t1 = time.time()
     for jj in range(cycles):
         mol = text_to_mol(text, calc_coords=True, include_hydrogens=False)
         print map(str, [b for b in mol.bonds if b.order == 0])
         print "  smiles: ", smiles.mol_to_text(mol)
         print "  inchi:  ", generate_inchi(
             mol, fixed_hs=False, program="/home/beda/bin/stdinchi-1")
         print "  charge: ", sum([a.charge for a in mol.vertices])
         print "  mw:     ", mol.weight
     print generate_inchi_and_inchikey(mol,
                                       fixed_hs=False,
                                       program="/home/beda/bin/stdinchi-1")
     t1 = time.time() - t1
     print 'time per cycle', round(1000 * t1 / cycles, 2), 'ms'
예제 #9
0
파일: tests.py 프로젝트: caiyingchun/OASA
def stereo_from_coords():
    f = file("ez_stereo2.mol", "r")
    mol = molfile.file_to_mol(f)
    f.close()
    mol.detect_stereochemistry_from_coords()
    print smiles.mol_to_text(mol)
예제 #10
0
파일: tests.py 프로젝트: Robot-Will/OASA
def stereo_from_coords():
    f = file( "ez_stereo2.mol", "r")
    mol = molfile.file_to_mol( f)
    f.close()
    mol.detect_stereochemistry_from_coords()
    print smiles.mol_to_text( mol)