1
2
3
4
5
6
7 import Geometry
8 from Numeric import *
9 import Chem
10 from Chem import ChemicalFeatures
11
13 - def __init__(self, feats,initMats=True):
14 self._initializeFeats(feats)
15 nf = len(feats)
16 self._boundsMat = zeros((nf, nf), Float)
17 self._boundsMat2D = zeros((nf, nf), Int)
18 if initMats:
19 self._initializeMatrices()
20
31
33
34 nf = len(self._feats)
35 for i in range(1, nf):
36 loci = self._feats[i].GetPos()
37 for j in range(i):
38 locj = self._feats[j].GetPos()
39 dist = loci.Distance(locj)
40 self._boundsMat[i,j] = dist
41 self._boundsMat[j,i] = dist
42 for i in range(nf):
43 for j in range(i+1,nf):
44 self._boundsMat2D[i,j] = 1000
45
46
49
52
54 if (i > j):
55 j,i = i,j
56 return self._boundsMat[i, j]
57
59 if (j > i):
60 j,i = i,j
61 return self._boundsMat[i,j]
62
64 " raises ValueError on failure "
65 nf = len(self._feats)
66 if (i < 0) or (i >= nf):
67 raise ValueError, "Index out of bound"
68 if (j < 0) or (j >= nf):
69 raise ValueError, "Index out of bound"
70 return True
71
73 if (checkBounds): self._checkBounds(i,j)
74 if (i > j):
75 j,i = i,j
76 self._boundsMat[i,j] = val
77
79 if (checkBounds): self._checkBounds(i,j)
80 if (j > i):
81 j,i = i,j
82 self._boundsMat[i,j] = val
83
85 if (i > j):
86 j,i = i,j
87 return self._boundsMat2D[i, j]
88
90 if (j > i):
91 j,i = i,j
92 return self._boundsMat2D[i,j]
93
94
96 if (checkBounds): self._checkBounds(i,j)
97 if (i > j):
98 j,i = i,j
99 self._boundsMat2D[i,j] = val
100
102 if (checkBounds): self._checkBounds(i,j)
103 if (j > i):
104 j,i = i,j
105 self._boundsMat2D[i,j] = val
106
108 res = ' '*13
109 for i,iFeat in enumerate(self._feats):
110 res += '% 12s '%iFeat.GetFamily()
111 res += '\n'
112 for i,iFeat in enumerate(self._feats):
113 res += '% 12s '%iFeat.GetFamily()
114 for j,jFeat in enumerate(self._feats):
115 if j<i:
116 res += '% 12.3f '%self.getLowerBound(i,j)
117 elif j>i:
118 res += '% 12.3f '%self.getUpperBound(i,j)
119 else:
120 res += '% 12.3f '%0.0
121 res += '\n'
122 return res
123