Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
3a3b9263
Commit
3a3b9263
authored
12 years ago
by
Niklaus Johner
Browse files
Options
Downloads
Patches
Plain Diff
Added a function to calculate a Distance Difference Matrix from two
EntityViews.
parent
5a553966
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/mol/alg/pymod/structure_analysis.py
+30
-0
30 additions, 0 deletions
modules/mol/alg/pymod/structure_analysis.py
with
30 additions
and
0 deletions
modules/mol/alg/pymod/structure_analysis.py
+
30
−
0
View file @
3a3b9263
...
@@ -129,3 +129,33 @@ def CalculateHelixAxis(sele1):
...
@@ -129,3 +129,33 @@ def CalculateHelixAxis(sele1):
f
=
GetFrameFromEntity
(
eh
)
f
=
GetFrameFromEntity
(
eh
)
return
f
.
FitCylinder
(
sele1
)
return
f
.
FitCylinder
(
sele1
)
def
CalculateDistanceDifferenceMatrix
(
sele1
,
sele2
):
"""
This function calculates the pairwise distance differences between two EntityViews.
The two EntityViews should have the same number of atoms
It returns an NxN DistanceDifferenceMatrix M (where N is the number of atoms in sele1)
where M[i,j]=(sele2.atoms[i].pos-sele2.atoms[j].pos)-(sele1.atoms[i].pos-sele1.atoms[j].pos)
"""
try
:
import
numpy
as
npy
except
ImportError
:
LogError
(
"
Function needs numpy, but I could not import it.
"
)
raise
if
not
sele1
.
IsValid
()
and
sele2
.
IsValid
():
print
'
invalid view
'
return
if
not
sele1
.
GetAtomCount
()
==
sele2
.
GetAtomCount
():
print
'
The two views must have the same number of atoms
'
return
n_atoms
=
sele1
.
GetAtomCount
()
M
=
npy
.
zeros
([
n_atoms
,
n_atoms
])
for
i
,
a1
in
enumerate
(
sele1
.
atoms
):
for
j
,
a2
in
enumerate
(
sele2
.
atoms
):
if
i
>=
j
:
continue
d1
=
geom
.
Distance
(
a1
.
pos
,
a2
.
pos
)
d2
=
geom
.
Distance
(
sele2
.
atoms
[
i
].
pos
,
sele2
.
atoms
[
j
].
pos
)
M
[
i
,
j
]
=
d2
-
d1
M
[
j
,
i
]
=
d2
-
d1
return
M
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment