Python-Ref > Cheminformatics > OASA > OASA introduction
 
 

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

OASA introduction

OASA is a cheminformatics library loosely similar to OpenBabel. This library is used behind the scenes in BKChem.
Using OASA feels very similarly to using OpenBabel, however because everything is pure Python, there is not need to distinguish between pybel-like python interface and openbabel-like C++ interface.
Expand/Shrink
Zdroj: (oasa0-1.py)
  1   from oasa import smiles
  2   
  3   mol = smiles.text_to_mol( "c1cc(O)ccc1Cl")
  4   print mol
  5   
  6   for atom in mol.atoms:
  7     print atom
  8   
  9   for bond in mol.bonds:
 10     print bond
 11     print bond.order, bond.aromatic
stdout:
molecule, 8 atoms, 8 bonds
atom 'C'
atom 'C'
atom 'C'
atom 'O'
atom 'C'
atom 'C'
atom 'C'
atom 'Cl'
bond between atom 'C' atom 'C'
1 0
bond between atom 'C' atom 'C'
2 0
bond between atom 'C' atom 'C'
1 0
bond between atom 'C' atom 'Cl'
1 0
bond between atom 'C' atom 'C'
2 0
bond between atom 'C' atom 'C'
1 0
bond between atom 'C' atom 'O'
1 0
bond between atom 'C' atom 'C'
2 0
Doba běhu: 145.9 ms
Expand/Shrink
Zdroj: (oasa0-2.py)
  1   from oasa import smiles
  2   
  3   mol = smiles.text_to_mol( "c1cc(O)ccc1Cl")
  4   
  5   for bond in mol.bonds:
  6     print bond
  7     print bond.order, bond.aromatic
  8   
  9   print "--------------------"
 10   mol.mark_aromatic_bonds()
 11   
 12   for bond in mol.bonds:
 13     print bond
 14     print bond.order, bond.aromatic
stdout:
bond between atom 'C' atom 'C'
2 0
bond between atom 'C' atom 'Cl'
1 0
bond between atom 'C' atom 'C'
1 0
bond between atom 'C' atom 'C'
2 0
bond between atom 'C' atom 'C'
1 0
bond between atom 'C' atom 'O'
1 0
bond between atom 'C' atom 'C'
2 0
bond between atom 'C' atom 'C'
1 0
--------------------
bond between atom 'C' atom 'C'
1 1
bond between atom 'C' atom 'C'
2 1
bond between atom 'C' atom 'C'
1 1
bond between atom 'C' atom 'Cl'
1 0
bond between atom 'C' atom 'C'
2 1
bond between atom 'C' atom 'C'
2 1
bond between atom 'C' atom 'C'
1 1
bond between atom 'C' atom 'O'
1 0
Doba běhu: 142.0 ms
Expand/Shrink
Zdroj: (oasa0-3.py)
  1   from oasa import smiles
  2   
  3   mol = smiles.text_to_mol( "c1cc(O)ccc1Cl")
  4   
  5   for ring in mol.get_smallest_independent_cycles():
  6     print ring
  7     print len( ring)
stdout:
set([<oasa.atom.atom object at 0xb40bd0>, <oasa.atom.atom object at 0xb40910>, <oasa.atom.atom object at 0xb40b50>, <oasa.atom.atom object at 0xb40950>, <oasa.atom.atom object at 0xb409d0>, <oasa.atom.atom object at 0xb40ad0>])
6
Doba běhu: 155.0 ms
Expand/Shrink
Zdroj: (oasa0-4.py)
  1   from oasa import smiles
  2   
  3   mol = smiles.text_to_mol( "c1cc(O)ccc1Cl")
  4   
  5   print mol.atoms[1]
  6   for n in mol.atoms[1].neighbors:
  7     print "Neighbor:", n
  8     for e,n2 in n.get_neighbor_edge_pairs():
  9       print "Neighbor2:", e.order, n2
stdout:
atom 'C'
Neighbor: atom 'C'
Neighbor2: 2 atom 'C'
Neighbor2: 1 atom 'C'
Neighbor: atom 'C'
Neighbor2: 1 atom 'C'
Neighbor2: 1 atom 'O'
Neighbor2: 2 atom 'C'
Doba běhu: 130.6 ms