2 Some functions for analyzing structures
4 Author: Niklaus Johner (Niklaus.Johner@unibas.ch)
11 This function returns a CoordFrame from an EntityHandle
14 :type eh: :class:`~ost.mol.EntityHandle`
16 :return: :class:`ost.mol.CoordFrame`
22 This function calculates the distance between the centers of mass
23 of **sele1** and **sele2**, two selections from the same Entity.
27 :type sele1: :class:`~ost.mol.EntityView`
28 :type sele2: :class:`~ost.mol.EntityView`
30 :return: :class:`float`
32 if not sele1.IsValid()
and sele2.IsValid():
36 if not eh==sele2.GetHandle():
37 print(
'The two views must be from the same entity')
40 return f.GetDistanceBetwCenterOfMass(sele1,sele2)
44 This function calculates the minimal distance between
45 **sele1** and **sele2**, two selections from the same Entity.
49 :type sele1: :class:`~ost.mol.EntityView`
50 :type sele2: :class:`~ost.mol.EntityView`
52 :return: :class:`float`
54 if not sele1.IsValid()
and sele2.IsValid():
58 if not eh==sele2.GetHandle():
59 print(
'The two views must be from the same entity')
62 return f.GetMinDistance(sele1,sele2)
66 This function calculates the minimal distance between **sele2** and
67 the center of mass of **sele1**, two selections from the same Entity.
69 :param sele1: The selection from which the center of mass is taken
71 :type sele1: :class:`~ost.mol.EntityView`
72 :type sele2: :class:`~ost.mol.EntityView`
74 :return: distance (\\ :class:`float`\\ )
76 if not sele1.IsValid()
and sele2.IsValid():
80 if not eh==sele2.GetHandle():
81 print(
'The two views must be from the same entity')
84 return f.GetMinDistBetwCenterOfMassAndView(sele1,sele2)
89 This function calculates the content of alpha helix in a view.
90 All residues in the view have to ordered and adjacent (no gaps allowed)
93 :type sele1: :class:`~ost.mol.EntityView`
95 :return: :class:`float`
97 if not sele1.IsValid():
102 return f.GetAlphaHelixContent(sele1)
107 This function calculates the best fit line to the atoms in **sele1**.
110 :type sele1: :class:`~ost.mol.EntityView`
112 :return: :class:`~ost.geom.Line3`
114 if not sele1.IsValid():
115 print(
'invalid view')
119 return f.GetODRLine(sele1)
123 This function calculates the best fit plane to the atoms in **sele1**.
126 :type sele1: :class:`~ost.mol.EntityView`
128 :return: :class:`~ost.geom.Plane`
130 if not sele1.IsValid():
131 print(
'invalid view')
135 return f.GetODRPlane(sele1)
139 This function calculates the best fit cylinder to the CA atoms in **sele1**,
140 and returns its axis. Residues should be ordered correctly
144 :type sele1: :class:`~ost.mol.EntityView`
146 :return: :class:`~ost.geom.Line3`
148 if not sele1.IsValid():
149 print(
'invalid view')
153 return f.FitCylinder(sele1)[0]
158 This function calculates the pairwise distance differences between two selections (\\ :class:`~ost.mol.EntityView`\\ ).
159 The two selections should have the same number of atoms
160 It returns an NxN DistanceDifferenceMatrix M (where N is the number of atoms in sele1)
161 where M[i,j]=||(sele2.atoms[i].pos-sele2.atoms[j].pos)||-||(sele1.atoms[i].pos-sele1.atoms[j].pos)||
165 :type sele1: :class:`~ost.mol.EntityView`
166 :type sele2: :class:`~ost.mol.EntityView`
168 :return: NxN numpy matrix
170 try:
import numpy
as npy
172 LogError(
"Function needs numpy, but I could not import it.")
174 if not sele1.IsValid()
and sele2.IsValid():
175 print(
'invalid view')
177 if not sele1.GetAtomCount()==sele2.GetAtomCount():
178 print(
'The two views must have the same number of atoms')
180 n_atoms=sele1.GetAtomCount()
181 M=npy.zeros([n_atoms,n_atoms])
182 for i,a1
in enumerate(sele1.atoms):
183 for j,a2
in enumerate(sele1.atoms):
185 d1=ost.geom.Distance(a1.pos,a2.pos)
186 d2=ost.geom.Distance(sele2.atoms[i].pos,sele2.atoms[j].pos)
def CalculateDistanceDifferenceMatrix(sele1, sele2)
def GetMinDistanceBetweenViews(sele1, sele2)
def CalculateBestFitLine(sele1)
def GetAlphaHelixContent(sele1)
def GetFrameFromEntity(eh)
def GetMinDistBetwCenterOfMassAndView(sele1, sele2)
def CalculateBestFitPlane(sele1)
def CalculateHelixAxis(sele1)
def GetDistanceBetwCenterOfMass(sele1, sele2)
DLLEXPORT_OST_MOL CoordFrame CreateCoordFrame(const geom::Vec3List &atom_pos, const geom::Vec3 &cell_size=geom::Vec3(), const geom::Vec3 &cell_angles=geom::Vec3())