Skip to content

Commit baab28e

Browse files
committed
starting to sphinxify things
1 parent fddb342 commit baab28e

10 files changed

+841
-569
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test/ligand.xyz
88
/AaronTools.egg-info
99
/build
1010
/dist
11-
/doc
11+
/docs
1212
/test/*.xyz
1313
test/.coverage
1414
/test/htmlcov/

atoms.py

+103-73
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,20 @@ def get(cls, a1, a2):
7575
class Atom:
7676
"""
7777
Attributes:
78-
element str
79-
coords np.array(float)
80-
flag bool true if frozen, false if relaxed
81-
name str form of \d+(\.\d+)*
82-
tags set
83-
charge float
84-
connected set(Atom)
85-
constraint set(Atom) for determining constrained bonds
86-
_rank
87-
_radii float for calculating if bonded
88-
_connectivity int max connections without hypervalence
89-
_saturation int max connections without hypervalence or charges
78+
79+
* element str
80+
* coords np.array(float)
81+
* flag bool true if frozen, false if relaxed
82+
* name str form of \d+(\.\d+)*
83+
* tags set
84+
* charge float
85+
* connected set(Atom)
86+
* constraint set(Atom) for determining constrained bonds
87+
* _rank
88+
* _radii float for calculating if bonded
89+
* _connectivity int max connections without hypervalence
90+
* _saturation int max connections without hypervalence or charges
91+
9092
"""
9193

9294
LOG = None
@@ -96,6 +98,16 @@ class Atom:
9698
def __init__(
9799
self, element="", coords=None, flag=False, name="", tags=None, charge=None, mass=None
98100
):
101+
"""
102+
:param element str: element symbol
103+
:param coords np.ndarray: position
104+
:param flag: whether atom is frozen
105+
:param name str: name of atom
106+
:param tags list: misc. data
107+
:param charge float: partial charge of atom
108+
:param mass float: mass of atom
109+
"""
110+
99111
super().__setattr__("_hashed", False)
100112
if coords is None:
101113
coords = []
@@ -242,7 +254,9 @@ def _set_vdw(self):
242254
return
243255

244256
def _set_connectivity(self):
245-
"""Sets theoretical maximum connectivity.
257+
"""
258+
Sets theoretical maximum connectivity.
259+
246260
If # connections > self._connectivity, then atom is hyper-valent
247261
"""
248262
try:
@@ -255,7 +269,9 @@ def _set_connectivity(self):
255269
return
256270

257271
def _set_saturation(self):
258-
"""Sets theoretical maximum connectivity without the atom having a formal charge.
272+
"""
273+
Sets theoretical maximum connectivity without the atom having a formal charge.
274+
259275
If # connections > self._saturation, then atom is hyper-valent or has a non-zero formal charge
260276
"""
261277
try:
@@ -298,13 +314,14 @@ def add_tag(self, *args):
298314

299315
def get_invariant(self):
300316
"""
301-
gets initial invariant
302-
(1) number of non-hydrogen connections (\d{1}): nconn
303-
(2) sum of bond order of non-hydrogen bonds * 10 (\d{2}): nB
304-
(3) atomic number (\d{3}): z
305-
#(4) sign of charge (\d{1})
306-
#(5) absolute charge (\d{1})
307-
(6) number of attached hydrogens (\d{1}): nH
317+
gets initial invariant, which is formulated using:
318+
319+
# number of non-hydrogen connections (\d{1}): nconn
320+
# sum of bond order of non-hydrogen bonds * 10 (\d{2}): nB
321+
# atomic number (\d{3}): z
322+
# sign of charge (\d{1}) (not used)
323+
# absolute charge (\d{1}) (not used)
324+
# number of attached hydrogens (\d{1}): nH
308325
"""
309326
heavy = set([x for x in self.connected if x.element != "H"])
310327
# number of non-hydrogen connections:
@@ -381,7 +398,8 @@ def is_connected(self, other, tolerance=None):
381398
def dist_is_connected(self, other, dist_to_other, tolerance):
382399
"""
383400
determines if distance between atoms is small enough to be bonded
384-
used to optimize connected checks when distances can be quickly precalculated
401+
402+
used to optimize connected checks when distances can be quickly precalculated,
385403
like with scipy.spatial.distance_matrix
386404
"""
387405
if tolerance is None:
@@ -464,51 +482,55 @@ def bond_order(self, other):
464482

465483
@classmethod
466484
def get_shape(cls, shape_name):
467-
"""returns dummy atoms in an idealized vsepr geometry
485+
"""
486+
returns dummy atoms in an idealized vsepr geometry
487+
468488
shape_name can be:
469-
point
470-
linear 1
471-
linear 2
472-
bent 2 tetrahedral
473-
bent 2 planar
474-
trigonal planar
475-
bent 3 tetrahedral
476-
t shaped
477-
tetrahedral
478-
sawhorse
479-
seesaw
480-
square planar
481-
trigonal pyramidal
482-
trigonal bipyramidal
483-
square pyramidal
484-
pentagonal
485-
hexagonal
486-
trigonal prismatic
487-
pentagonal pyramidal
488-
octahedral
489-
capped octahedral
490-
hexagonal pyramidal
491-
pentagonal bipyramidal
492-
capped trigonal prismatic
493-
heptagonal
494-
hexagonal bipyramidal
495-
heptagonal pyramidal
496-
octagonal
497-
square antiprismatic
498-
trigonal dodecahedral
499-
capped cube
500-
biaugmented trigonal prismatic
501-
cubic
502-
elongated trigonal bipyramidal
503-
capped square antiprismatic
504-
enneagonal
505-
heptagonal bipyramidal
506-
hula-hoop
507-
triangular cupola
508-
tridiminished icosahedral
509-
muffin
510-
octagonal pyramidal
511-
tricapped trigonal prismatic
489+
490+
* point
491+
* linear 1
492+
* linear 2
493+
* bent 2 tetrahedral
494+
* bent 2 planar
495+
* trigonal planar
496+
* bent 3 tetrahedral
497+
* t shaped
498+
* tetrahedral
499+
* sawhorse
500+
* seesaw
501+
* square planar
502+
* trigonal pyramidal
503+
* trigonal bipyramidal
504+
* square pyramidal
505+
* pentagonal
506+
* hexagonal
507+
* trigonal prismatic
508+
* pentagonal pyramidal
509+
* octahedral
510+
* capped octahedral
511+
* hexagonal pyramidal
512+
* pentagonal bipyramidal
513+
* capped trigonal prismatic
514+
* heptagonal
515+
* hexagonal bipyramidal
516+
* heptagonal pyramidal
517+
* octagonal
518+
* square antiprismatic
519+
* trigonal dodecahedral
520+
* capped cube
521+
* biaugmented trigonal prismatic
522+
* cubic
523+
* elongated trigonal bipyramidal
524+
* capped square antiprismatic
525+
* enneagonal
526+
* heptagonal bipyramidal
527+
* hula-hoop
528+
* triangular cupola
529+
* tridiminished icosahedral
530+
* muffin
531+
* octagonal pyramidal
532+
* tricapped trigonal prismatic
533+
512534
"""
513535
if shape_name == "point":
514536
return cls.linear_shape()[0:1]
@@ -983,12 +1005,15 @@ def tricapped_trigonal_prismatic_shape(cls):
9831005

9841006
@staticmethod
9851007
def new_shape(old_shape, new_connectivity, bond_change):
986-
"""returns the name of the expected vsepr geometry when the number of bonds
1008+
"""
1009+
returns the name of the expected vsepr geometry when the number of bonds
9871010
changes by +/- 1
9881011
989-
old_shape - :str: vsepr geometry name
990-
new_connectivity - :int: connectivity (see Atom._connectivity)
991-
bond_change - :int: +1 or -1, indicating that the number of bonds is changing by 1"""
1012+
:param old_shape str: vsepr geometry name
1013+
:param new_connectivity int: connectivity (see Atom._connectivity)
1014+
:param bond_change int: +1 or -1, indicating that the number of bonds is changing by 1
1015+
1016+
"""
9921017
if old_shape == "point":
9931018
if bond_change == 1:
9941019
return "linear 1"
@@ -1072,10 +1097,15 @@ def new_shape(old_shape, new_connectivity, bond_change):
10721097
raise RuntimeError("no shape method is defined for %s" % old_shape)
10731098

10741099
def get_vsepr(self):
1075-
"""determine vsepr geometry around an atom
1076-
returns shape as a string and the score assigned to that shape
1077-
returns None if self has > 6 bonds
1100+
"""
1101+
determine vsepr geometry around an atom
1102+
1103+
:returns:
1104+
* :shape, score: as a string and the score assigned to that shape
1105+
* :None: if self has > 6 bonds
1106+
10781107
scores > 0.5 are generally questionable
1108+
10791109
see atom.get_shape for a list of shapes
10801110
"""
10811111

0 commit comments

Comments
 (0)