OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
structure_analysis.py
Go to the documentation of this file.
1 """
2 Some functions for analyzing trajectories
3 
4 Author: Niklaus Johner
5 """
6 
7 import os
8 import ost
9 
11  """
12  This function returns a CoordFrame from an EntityHandle
13  Input:
14  eh : EntityHandle
15  """
16  return ost.mol.CreateCoordFrame(eh.GetAtomPosList())
17 
18 def GetDistanceBetwCenterOfMass(sele1,sele2):
19  """
20  This function calculates the distance between the centers of mass
21  of sele1 and sele2, two selections from the same Entity.
22  Input:
23  sele1 : EntityView
24  sele2 : EntityView
25  """
26  if not sele1.IsValid() and sele2.IsValid():
27  print 'invalid view'
28  return
29  eh=sele1.GetHandle()
30  if not eh==sele2.GetHandle():
31  print 'The two views must be from the same entity'
32  return
33  f=GetFrameFromEntity(eh)
34  return f.GetDistanceBetwCenterOfMass(sele1,sele2)
35 
36 def GetMinDistanceBetweenViews(sele1,sele2):
37  """
38  This function calculates the minimal distance between
39  sele1 and sele2, two selections from the same Entity.
40  Input:
41  sele1 : EntityView
42  sele2 : EntityView
43  """
44  if not sele1.IsValid() and sele2.IsValid():
45  print 'invalid view'
46  return
47  eh=sele1.GetHandle()
48  if not eh==sele2.GetHandle():
49  print 'The two views must be from the same entity'
50  return
51  f=GetFrameFromEntity(eh)
52  return f.GetMinDistance(sele1,sele2)
53 
55  """
56  This function calculates the minimal distance between sele2 and
57  the center of mass of sele1, two selections from the same Entity.
58  Input:
59  sele1 : EntityView from which the center of mass is taken
60  sele2 : EntityView
61  """
62  if not sele1.IsValid() and sele2.IsValid():
63  print 'invalid view'
64  return
65  eh=sele1.GetHandle()
66  if not eh==sele2.GetHandle():
67  print 'The two views must be from the same entity'
68  return
69  f=GetFrameFromEntity(eh)
70  return f.GetMinDistBetwCenterOfMassAndView(sele1,sele2)
71 
72 
74  """
75  This function calculates the content of alpha helix in a view.
76  All residues in the view have to ordered and adjacent (no gaps allowed)
77  Input:
78  sele1 : EntityView
79  """
80  if not sele1.IsValid():
81  print 'invalid view'
82  return
83  eh=sele1.GetHandle()
84  f=GetFrameFromEntity(eh)
85  return f.GetAlphaHelixContent(sele1)
86 
87 
89  """
90  This function calculates the best fit line to the atoms in sele1.
91  Input:
92  sele1 : EntityView
93  It returns a geom::Line3
94  """
95  if not sele1.IsValid():
96  print 'invalid view'
97  return
98  eh=sele1.GetHandle()
99  f=GetFrameFromEntity(eh)
100  return f.GetODRLine(sele1)
101 
103  """
104  This function calculates the best fit plane to the atoms in sele1.
105  Input:
106  sele1 : EntityView
107  It returns a geom::Plane
108  """
109  if not sele1.IsValid():
110  print 'invalid view'
111  return
112  eh=sele1.GetHandle()
113  f=GetFrameFromEntity(eh)
114  return f.GetODRPlane(sele1)
115 
117  """
118  This function calculates the best fit cylinder to the CA atoms in sele1,
119  and returns its axis as a Line3. residues should be ordered correctly
120  in the EntityView.
121  Input:
122  sele1 : EntityView
123  It returns a geom::Line3
124  """
125  if not sele1.IsValid():
126  print 'invalid view'
127  return
128  eh=sele1.GetHandle()
129  f=GetFrameFromEntity(eh)
130  return f.FitCylinder(sele1)
131