Python-Ref > Cheminformatics > Molecular fingerprints > Using fingerprints in OpenBabel
 
 

^^->
Klíčová slova
Moduly
Knihovní funkce

Using fingerprints in OpenBabel

Expand/Shrink
  1   import pybel
  2   
  3   mol = pybel.readstring( "smi", "c1ccccc1C(=O)OCC")
  4   fp = mol.calcfp()
  5   print fp
  6   print fp.bits
  7   print fp.fp
  8   # the following is a list of numbers
  9   # that together make the bits of the fingerprint
 10   print list( fp.fp)
stdout:
0, 3221225472, 131072, 512, 0, 524288, 2147491840, 1024, 4194308, 0, 134351392, 0, 0, 0, 33554432, 131072, 34078728, 0, 65536, 32768, 1073774592, 0, 2112, 256, 0, 0, 16384, 16, 66048, 256, 2048, 0
[63, 64, 82, 106, 180, 206, 224, 235, 259, 279, 326, 330, 332, 338, 348, 474, 498, 516, 532, 538, 593, 624, 656, 671, 711, 716, 745, 847, 869, 906, 913, 937, 972]
<openbabel.vectorUnsignedInt; proxy of <Swig Object of type 'std::vector< unsigned int > *' at 0x621c70> >
[0, 3221225472, 131072, 512, 0, 524288, 2147491840, 1024, 4194308, 0, 134351392, 0, 0, 0, 33554432, 131072, 34078728, 0, 65536, 32768, 1073774592, 0, 2112, 256, 0, 0, 16384, 16, 66048, 256, 2048, 0]
Doba běhu: 191.2 ms
Expand/Shrink
  1   import pybel
  2   
  3   mol = pybel.readstring( "smi", "c1ccccc1C(=O)OCC")
  4   fp = mol.calcfp()
  5   print fp.bits
  6   # below we show that the list of numbers corresponds to fp.bits
  7   for i, num in enumerate( list( fp.fp)):
  8     for bit in range( 32):
  9       if num & 1 << bit:
 10         print i*32+bit+1
stdout:
[63, 64, 82, 106, 180, 206, 224, 235, 259, 279, 326, 330, 332, 338, 348, 474, 498, 516, 532, 538, 593, 624, 656, 671, 711, 716, 745, 847, 869, 906, 913, 937, 972]
63
64
82
106
180
206
224
235
259
279
326
330
332
338
348
474
498
516
532
538
593
624
656
671
711
716
745
847
869
906
913
937
972
Doba běhu: 140.0 ms
Expand/Shrink
  1   import pybel
  2   
  3   for smi in ["c1ccccc1C(=O)OCC","c1ccccc1","C(=O)OCC","C(=O)O","OCC"]:
  4     mol = pybel.readstring( "smi", smi)
  5     fp = mol.calcfp()
  6     print fp.bits
stdout:
[63, 64, 82, 106, 180, 206, 224, 235, 259, 279, 326, 330, 332, 338, 348, 474, 498, 516, 532, 538, 593, 624, 656, 671, 711, 716, 745, 847, 869, 906, 913, 937, 972]
[82, 348, 656, 711, 716, 906]
[106, 332, 498, 516, 532, 624, 656, 671, 906]
[332, 516, 624]
[516, 532, 671]
Doba běhu: 136.1 ms
Expand/Shrink
  1   import pybel
  2   
  3   mol = pybel.readstring( "smi", "c1ccccc1C(=O)OCC")
  4   fp1 = set( mol.calcfp().bits)
  5   
  6   for smi in ["c1ccccc1","C(=O)OCC","C(=O)O","OCC","CCN"]:
  7     mol = pybel.readstring( "smi", smi)
  8     fp2 = set( mol.calcfp().bits)
  9     print fp2 <= fp1
stdout:
True
True
True
True
False
Doba běhu: 137.0 ms