Python-Ref > Cheminformatics > OASA > Periodic table and summary formulas
 
 

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

Periodic table and summary formulas

Some useful functionality to parse summary formulas and work with periodic table.
Expand/Shrink
Zdroj: (oasa3-1.py)
  1   from oasa import periodic_table
  2   
  3   for symbol,data in periodic_table.periodic_table.iteritems():
  4     print symbol, data
stdout:
Ni {'els': 8, 'ord': 28, 'en': 1.9099999999999999, 'weight': 58.693399999999997, 'valency': (2, 3)}
Pd {'els': 8, 'ord': 46, 'en': 2.2000000000000002, 'weight': 106.42, 'valency': (2, 4)}
Pt {'els': 8, 'ord': 78, 'en': 2.2799999999999998, 'weight': 195.078, 'valency': (2, 4)}
Ru {'els': 8, 'ord': 44, 'en': 2.2000000000000002, 'weight': 101.06999999999999, 'valency': (3, 4, 6, 8)}
Na {'els': 1, 'ord': 11, 'en': 0.93000000000000005, 'weight': 22.989799999999999, 'valency': (1,)}
Nb {'els': 5, 'ord': 41, 'en': 1.6000000000000001, 'weight': 92.906400000000005, 'valency': (3, 5)}
Mg {'els': 2, 'ord': 12, 'en': 1.3100000000000001, 'weight': 24.305, 'valency': (2,)}
Li {'els': 1, 'ord': 3, 'en': 0.97999999999999998, 'weight': 6.9409999999999998, 'valency': (1,)}
Pb {'els': 4, 'ord': 82, 'en': 2.3300000000000001, 'weight': 207.19999999999999, 'valency': (2, 4)}
Y {'els': 3, 'ord': 39, 'en': 1.22, 'weight': 88.905900000000003, 'valency': (3,)}
Tl {'els': 3, 'ord': 81, 'en': 2.04, 'weight': 204.38329999999999, 'valency': (1, 3)}
Ra {'els': 2, 'ord': 88, 'en': 0.90000000000000002, 'weight': 226.02539999999999, 'valency': (2,)}
Rb {'els': 1, 'ord': 37, 'en': 0.81999999999999995, 'weight': 85.467799999999997, 'valency': (1,)}
Ti {'els': 4, 'ord': 22, 'en': 1.54, 'weight': 47.866999999999997, 'valency': (4, 3)}
Rn {'els': 8, 'ord': 86, 'en': 0.0, 'weight': 222.01759999999999, 'valency': (0, 2)}
Te {'els': 6, 'ord': 52, 'en': 2.1000000000000001, 'weight': 127.59999999999999, 'valency': (2, 4, 6)}
Rh {'els': 8, 'ord': 45, 'en': 2.2799999999999998, 'weight': 102.9055, 'valency': (3, 4)}
Tc {'els': 7, 'ord': 43, 'en': 1.8999999999999999, 'weight': 98.906300000000002, 'valency': (5, 7)}
Ta {'els': 5, 'ord': 73, 'en': 1.5, 'weight': 180.9479, 'valency': (5,)}
Be {'els': 2, 'ord': 4, 'en': 1.5700000000000001, 'weight': 9.0122, 'valency': (2,)}
Xe {'els': 8, 'ord': 54, 'en': 2.6000000000000001, 'weight': 131.29300000000001, 'valency': (0, 2)}
Ba {'els': 2, 'ord': 56, 'en': 0.89000000000000001, 'weight': 137.23699999999999, 'valency': (2,)}
Bi {'els': 5, 'ord': 83, 'en': 2.02, 'weight': 208.9804, 'valency': (3, 5)}
La {'els': 3, 'ord': 57, 'en': 1.1000000000000001, 'weight': 138.90549999999999, 'valency': (3,)}
Si {'els': 4, 'ord': 14, 'en': 1.9099999999999999, 'weight': 28.0855, 'valency': (4,)}
As {'els': 5, 'ord': 33, 'en': 2.1800000000000002, 'weight': 74.921599999999998, 'valency': (3, 5)}
Po {'els': 6, 'ord': 84, 'en': 2.0, 'weight': 208.98240000000001, 'valency': (2, 4, 6)}
Q {'query': True, 'ord': 301, 'weight': 0, 'valency': (1, 2, 3, 4)}
Fe {'els': 8, 'ord': 26, 'en': 1.8300000000000001, 'weight': 55.844999999999999, 'valency': (0, 2, 3)}
Br {'els': 7, 'ord': 35, 'en': 2.96, 'weight': 79.903999999999996, 'valency': (1, 3, 5)}
Sr {'els': 2, 'ord': 38, 'en': 0.94999999999999996, 'weight': 87.620000000000005, 'valency': (2,)}
Hf {'els': 4, 'ord': 72, 'en': 1.3, 'weight': 178.49000000000001, 'valency': (4,)}
Mo {'els': 6, 'ord': 42, 'en': 2.1600000000000001, 'weight': 95.939999999999998, 'valency': (3, 5, 6)}
He {'els': 8, 'ord': 2, 'en': 0.0, 'weight': 4.0026000000000002, 'valency': (0, 2)}
A {'query': True, 'ord': 302, 'weight': 0, 'valency': (1, 2, 3, 4)}
C {'els': 4, 'ord': 6, 'en': 2.5499999999999998, 'weight': 12.0107, 'valency': (4, 2)}
B {'els': 3, 'ord': 5, 'en': 2.04, 'weight': 10.811, 'valency': (3,)}
F {'els': 7, 'ord': 9, 'en': 3.98, 'weight': 18.9984, 'valency': (1,)}
I {'els': 7, 'ord': 53, 'en': 2.6600000000000001, 'weight': 126.9045, 'valency': (1, 3, 5, 7)}
H {'els': 1, 'ord': 1, 'en': 2.1000000000000001, 'weight': 1.0079, 'valency': (1,)}
K {'els': 1, 'ord': 19, 'en': 0.81999999999999995, 'weight': 39.098300000000002, 'valency': (1,)}
Mn {'els': 7, 'ord': 25, 'en': 1.55, 'weight': 54.938000000000002, 'valency': (2, 3, 4, 6, 7)}
O {'els': 6, 'ord': 8, 'en': 3.4399999999999999, 'weight': 15.9994, 'valency': (2,)}
Ne {'els': 8, 'ord': 10, 'en': 0.0, 'weight': 20.1797, 'valency': (0, 2)}
X {'query': True, 'ord': 300, 'weight': 0, 'valency': (1,)}
P {'els': 5, 'ord': 15, 'en': 2.1899999999999999, 'weight': 30.973800000000001, 'valency': (3, 5)}
S {'els': 6, 'ord': 16, 'en': 2.5800000000000001, 'weight': 32.064999999999998, 'valency': (2, 4, 6)}
R {'query': True, 'ord': 303, 'weight': 0, 'valency': (1, 2, 3, 4)}
Re {'els': 7, 'ord': 75, 'en': 1.8999999999999999, 'weight': 186.20699999999999, 'valency': (7,)}
Kr {'els': 8, 'ord': 36, 'en': 0.0, 'weight': 83.799999999999997, 'valency': (0, 2)}
W {'els': 6, 'ord': 74, 'en': 2.3599999999999999, 'weight': 183.84, 'valency': (6,)}
V {'els': 5, 'ord': 23, 'en': 1.6299999999999999, 'weight': 50.941499999999998, 'valency': (2, 4, 5)}
Sc {'els': 3, 'ord': 21, 'en': 1.3600000000000001, 'weight': 44.9559, 'valency': (3, 1)}
Sb {'els': 5, 'ord': 51, 'en': 2.0499999999999998, 'weight': 121.76000000000001, 'valency': (3, 5)}
N {'els': 5, 'ord': 7, 'en': 3.04, 'weight': 14.0067, 'valency': (3, 5)}
Os {'els': 8, 'ord': 76, 'en': 2.2000000000000002, 'weight': 190.22999999999999, 'valency': (4, 6, 8)}
Se {'els': 6, 'ord': 34, 'en': 2.5499999999999998, 'weight': 78.959999999999994, 'valency': (2, 4, 6)}
Hg {'els': 2, 'ord': 80, 'en': 2.0, 'weight': 200.59, 'valency': (1, 2)}
Zn {'els': 2, 'ord': 30, 'en': 1.6499999999999999, 'weight': 65.390000000000001, 'valency': (2,)}
Co {'els': 8, 'ord': 27, 'en': 1.8799999999999999, 'weight': 58.933199999999999, 'valency': (2, 3)}
Ag {'els': 1, 'ord': 47, 'en': 1.9299999999999999, 'weight': 107.8682, 'valency': (1,)}
Cl {'els': 7, 'ord': 17, 'en': 3.1600000000000001, 'weight': 35.453000000000003, 'valency': (1, 3, 5, 7)}
Ca {'els': 2, 'ord': 20, 'en': 1.0, 'weight': 40.078000000000003, 'valency': (2,)}
Ir {'els': 8, 'ord': 77, 'en': 2.2000000000000002, 'weight': 192.21700000000001, 'valency': (3, 4, 6)}
U {'els': 6, 'ord': 92, 'en': 1.3799999999999999, 'weight': 238.02889999999999, 'valency': (3, 4, 5, 6)}
Al {'els': 3, 'ord': 13, 'en': 1.6100000000000001, 'weight': 26.9815, 'valency': (3,)}
Cd {'els': 2, 'ord': 48, 'en': 1.6899999999999999, 'weight': 112.411, 'valency': (2,)}
Ge {'els': 4, 'ord': 32, 'en': 2.0099999999999998, 'weight': 72.640000000000001, 'valency': (4,)}
Ar {'els': 8, 'ord': 18, 'en': 0.0, 'weight': 39.948, 'valency': (0, 2)}
Au {'els': 1, 'ord': 79, 'en': 2.54, 'weight': 196.9665, 'valency': (1, 3)}
Zr {'els': 4, 'ord': 40, 'en': 1.3300000000000001, 'weight': 91.224000000000004, 'valency': (4,)}
Ga {'els': 3, 'ord': 31, 'en': 1.8100000000000001, 'weight': 69.722999999999999, 'valency': (3,)}
In {'els': 3, 'ord': 49, 'en': 1.78, 'weight': 114.818, 'valency': (3,)}
Cs {'els': 1, 'ord': 55, 'en': 0.79000000000000004, 'weight': 132.90549999999999, 'valency': (1,)}
Cr {'els': 6, 'ord': 24, 'en': 1.6599999999999999, 'weight': 51.996099999999998, 'valency': (2, 3, 6)}
At {'els': 7, 'ord': 85, 'en': 2.2000000000000002, 'weight': 209.9871, 'valency': (1, 7)}
Cu {'els': 1, 'ord': 29, 'en': 1.8999999999999999, 'weight': 63.545999999999999, 'valency': (0, 1, 2)}
Sn {'els': 4, 'ord': 50, 'en': 1.96, 'weight': 118.70999999999999, 'valency': (2, 4)}
Doba běhu: 128.2 ms
Expand/Shrink
Zdroj: (oasa3-2.py)
  1   from oasa import periodic_table
  2   
  3   fd = periodic_table.formula_dict( "C6H6")
  4   print fd
  5   
  6   # formula_dict is a dict inside
  7   print fd['H']
  8   print fd.keys()
  9   
 10   # formula_dict can be created from a dictionary
 11   fd2 = periodic_table.formula_dict( {"C":1,"H":4,"O":1})
 12   print fd2
 13   
 14   # summary formulas may be summed
 15   print fd+fd2
 16   
 17   # sorting is always according to Hill's order
 18   fd3 = periodic_table.formula_dict( "OCH")
 19   print fd3
 20   
 21   # even += works
 22   fd += fd3
 23   print fd
stdout:
C6H6
6
['H', 'C']
CH4O
C7H10O
CHO
C7H7O
Doba běhu: 127.4 ms
Expand/Shrink
Zdroj: (oasa3-3.py)
  1   from oasa import periodic_table
  2   
  3   fd = periodic_table.formula_dict( "C6H5O2Cl")
  4   print fd
  5   print fd.get_html_repr_as_string()
  6   
  7   print fd.get_molecular_weight()
  8   print fd.get_element_fraction( "C")
  9   
 10   for element in fd.keys():
 11     print element, fd.get_element_fraction( element)
stdout:
C6H5ClO2
C<sub>6</sub>H<sub>5</sub>ClO<sub>2</sub>
144.5555
0.49852271273
H 0.0348620426065
C 0.49852271273
O 0.221359962091
Cl 0.245255282573
Doba běhu: 141.9 ms