Python-Ref > Cheminformatics > OASA > Linear formulas
 
 

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

Linear formulas

Parsing of linear formulas, such as CH3CH2COOCH3.
Expand/Shrink
Zdroj: (oasa4-1.py)
  1   from oasa import linear_formula, cairo_out, coords_generator
  2   
  3   lf = linear_formula.linear_formula( "CH3CH2COOH")
  4   print lf.molecule
  5   
  6   mol = lf.molecule
  7   coords_generator.calculate_coords( mol)
  8   mol.normalize_bond_length( 30)
  9   cairo_out.mol_to_png( mol, "linear_formula1.png")
stdout:
molecule, 5 atoms, 4 bonds
output image linear_formula1.png
Doba běhu: 150.1 ms
Expand/Shrink
Zdroj: (oasa4-2.py)
  1   from oasa import linear_formula, cairo_out, coords_generator
  2   
  3   for i, mf in enumerate( ["CH3CH(COOCH3)2","PhCl","CBr4"]):
  4     lf = linear_formula.linear_formula( mf)
  5     mol = lf.molecule
  6     print mol
  7     
  8     coords_generator.calculate_coords( mol)
  9     mol.normalize_bond_length( 30)
 10     cairo_out.mol_to_png( mol, "linear_formula2-%d.png"%i)
stdout:
molecule, 10 atoms, 9 bonds
molecule, 7 atoms, 7 bonds
molecule, 5 atoms, 4 bonds
output image linear_formula2-1.png
output image linear_formula2-2.png
output image linear_formula2-0.png
Doba běhu: 180.6 ms