Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
mmtk
Commits
a09f317d
Commit
a09f317d
authored
Dec 11, 2017
by
eric pellegrini
Browse files
removed oldnumeric deps from ProteinFriction, Subspace, Utility, Visualization, XML
parent
93907630
Changes
5
Hide whitespace changes
Inline
Side-by-side
MMTK/ProteinFriction.py
View file @
a09f317d
...
...
@@ -9,8 +9,9 @@ A friction constant model for |C_alpha| models of proteins
__docformat__
=
'restructuredtext'
import
numpy
import
MMTK.ParticleProperties
from
Scientific
import
N
def
calphaFrictionConstants
(
protein
,
set
=
2
):
"""
...
...
@@ -27,7 +28,7 @@ def calphaFrictionConstants(protein, set=2):
for
residue
in
chain
:
a
=
residue
.
peptide
.
C_alpha
m
=
atoms
.
selectShell
(
a
.
position
(),
radius
).
mass
()
d
=
3.
*
m
/
(
4.
*
N
.
pi
*
radius
**
3
)
d
=
3.
*
m
/
(
4.
*
numpy
.
pi
*
radius
**
3
)
if
set
==
1
:
# linear fit to initial slope
f
[
a
]
=
max
(
1000.
,
121.2
*
d
-
8600
)
elif
set
==
2
:
# exponential fit 400 steps
...
...
MMTK/Subspace.py
View file @
a09f317d
...
...
@@ -17,26 +17,22 @@ calculations or for analyzing complex motions. For an explanation, see:
__docformat__
=
'restructuredtext'
import
numpy
from
MMTK
import
Utility
,
ParticleProperties
from
Scientific.Geometry
import
Vector
,
ex
,
ey
,
ez
from
Scientific
import
N
import
copy
#
# Import LAPACK routines
#
try
:
array_package
=
N
.
package
except
AttributeError
:
array_package
=
"Numeric"
dgesdd
=
None
try
:
if
array_package
==
"Numeric"
:
from
lapack_lite
import
dgesdd
,
LapackError
else
:
from
numpy.linalg.lapack_lite
import
dgesdd
,
LapackError
except
ImportError
:
pass
from
numpy.linalg.lapack_lite
import
dgesdd
,
LapackError
except
ImportError
:
pass
if
dgesdd
is
None
:
try
:
# PyLAPACK
...
...
@@ -44,19 +40,18 @@ if dgesdd is None:
except
ImportError
:
pass
if
dgesdd
:
n
=
1
array
=
N
.
zeros
((
n
,
n
),
N
.
F
loat
)
sv
=
N
.
zeros
((
n
,),
N
.
F
loat
)
u
=
N
.
zeros
((
n
,
n
),
N
.
F
loat
)
vt
=
N
.
zeros
((
n
,
n
),
N
.
F
loat
)
work
=
N
.
zeros
((
1
,),
N
.
F
loat
)
int_types
=
[
N
.
Int
,
N
.
Int8
,
N
.
Int16
,
N
.
I
nt32
]
array
=
numpy
.
zeros
((
n
,
n
),
numpy
.
f
loat
)
sv
=
numpy
.
zeros
((
n
,),
numpy
.
f
loat
)
u
=
numpy
.
zeros
((
n
,
n
),
numpy
.
f
loat
)
vt
=
numpy
.
zeros
((
n
,
n
),
numpy
.
f
loat
)
work
=
numpy
.
zeros
((
1
,),
numpy
.
f
loat
)
int_types
=
[
numpy
.
int
,
numpy
.
int8
,
numpy
.
int16
,
numpy
.
i
nt32
]
try
:
int_types
.
append
(
N
.
Int64
)
int_types
.
append
(
N
.
Int128
)
int_types
.
append
(
numpy
.
int64
)
except
AttributeError
:
pass
for
int_type
in
int_types
:
iwork
=
N
.
zeros
((
1
,),
int_type
)
iwork
=
numpy
.
zeros
((
1
,),
int_type
)
try
:
dgesdd
(
'S'
,
n
,
n
,
array
,
n
,
sv
,
u
,
n
,
vt
,
n
,
work
,
-
1
,
iwork
,
0
)
break
...
...
@@ -73,13 +68,13 @@ class ParticleVectorSet(object):
def
__init__
(
self
,
universe
,
data
):
self
.
universe
=
universe
if
type
(
data
)
==
N
.
array
type
:
if
type
(
data
)
==
numpy
.
nd
array
:
self
.
n
=
data
.
shape
[
0
]
self
.
array
=
data
else
:
self
.
n
=
data
self
.
array
=
N
.
zeros
((
self
.
n
,
universe
.
numberOfAtoms
(),
3
),
N
.
F
loat
)
self
.
array
=
numpy
.
zeros
((
self
.
n
,
universe
.
numberOfAtoms
(),
3
),
numpy
.
f
loat
)
def
__len__
(
self
):
return
self
.
n
...
...
@@ -128,38 +123,38 @@ class Subspace(object):
:returns: the basis
"""
if
self
.
_basis
is
None
:
basis
=
N
.
array
([
v
.
array
for
v
in
self
.
vectors
],
N
.
F
loat
)
basis
=
numpy
.
array
([
v
.
array
for
v
in
self
.
vectors
],
numpy
.
f
loat
)
shape
=
basis
.
shape
nvectors
=
shape
[
0
]
natoms
=
shape
[
1
]
basis
.
shape
=
(
nvectors
,
3
*
natoms
)
sv
=
N
.
zeros
((
min
(
nvectors
,
3
*
natoms
),),
N
.
F
loat
)
sv
=
numpy
.
zeros
((
min
(
nvectors
,
3
*
natoms
),),
numpy
.
f
loat
)
min_n_m
=
min
(
3
*
natoms
,
nvectors
)
vt
=
N
.
zeros
((
nvectors
,
min_n_m
),
N
.
F
loat
)
work
=
N
.
zeros
((
1
,),
N
.
F
loat
)
iwork
=
N
.
zeros
((
8
*
min_n_m
,),
int_type
)
vt
=
numpy
.
zeros
((
nvectors
,
min_n_m
),
numpy
.
f
loat
)
work
=
numpy
.
zeros
((
1
,),
numpy
.
f
loat
)
iwork
=
numpy
.
zeros
((
8
*
min_n_m
,),
int_type
)
if
3
*
natoms
>=
nvectors
:
result
=
dgesdd
(
'O'
,
3
*
natoms
,
nvectors
,
basis
,
3
*
natoms
,
sv
,
basis
,
3
*
natoms
,
vt
,
min_n_m
,
work
,
-
1
,
iwork
,
0
)
work
=
N
.
zeros
((
int
(
work
[
0
]),),
N
.
F
loat
)
work
=
numpy
.
zeros
((
int
(
work
[
0
]),),
numpy
.
f
loat
)
result
=
dgesdd
(
'O'
,
3
*
natoms
,
nvectors
,
basis
,
3
*
natoms
,
sv
,
basis
,
3
*
natoms
,
vt
,
min_n_m
,
work
,
work
.
shape
[
0
],
iwork
,
0
)
u
=
basis
else
:
u
=
N
.
zeros
((
min_n_m
,
3
*
natoms
),
N
.
F
loat
)
u
=
numpy
.
zeros
((
min_n_m
,
3
*
natoms
),
numpy
.
f
loat
)
result
=
dgesdd
(
'S'
,
3
*
natoms
,
nvectors
,
basis
,
3
*
natoms
,
sv
,
u
,
3
*
natoms
,
vt
,
min_n_m
,
work
,
-
1
,
iwork
,
0
)
work
=
N
.
zeros
((
int
(
work
[
0
]),),
N
.
F
loat
)
work
=
numpy
.
zeros
((
int
(
work
[
0
]),),
numpy
.
f
loat
)
result
=
dgesdd
(
'S'
,
3
*
natoms
,
nvectors
,
basis
,
3
*
natoms
,
sv
,
u
,
3
*
natoms
,
vt
,
min_n_m
,
work
,
work
.
shape
[
0
],
iwork
,
0
)
if
result
[
'info'
]
!=
0
:
raise
ValueError
(
'Lapack SVD: '
+
`result['info']`
)
svmax
=
N
.
maximum
.
reduce
(
sv
)
nvectors
=
N
.
add
.
reduce
(
N
.
greater
(
sv
,
1.e-10
*
svmax
))
svmax
=
numpy
.
maximum
.
reduce
(
sv
)
nvectors
=
numpy
.
add
.
reduce
(
numpy
.
greater
(
sv
,
1.e-10
*
svmax
))
u
=
u
[:
nvectors
]
u
.
shape
=
(
nvectors
,
natoms
,
3
)
self
.
_basis
=
ParticleVectorSet
(
self
.
universe
,
u
)
...
...
@@ -173,9 +168,9 @@ class Subspace(object):
"""
vector
=
vector
.
array
basis
=
self
.
getBasis
().
array
p
=
N
.
zeros
(
vector
.
shape
,
N
.
F
loat
)
p
=
numpy
.
zeros
(
vector
.
shape
,
numpy
.
f
loat
)
for
bv
in
basis
:
N
.
add
(
N
.
add
.
reduce
(
N
.
ravel
(
bv
*
vector
))
*
bv
,
p
,
p
)
numpy
.
add
(
numpy
.
add
.
reduce
(
numpy
.
ravel
(
bv
*
vector
))
*
bv
,
p
,
p
)
return
ParticleProperties
.
ParticleVector
(
self
.
universe
,
p
)
def
projectionComplementOf
(
self
,
vector
):
...
...
@@ -317,7 +312,7 @@ class RigidMotionSubspace(Subspace):
v
=
ParticleProperties
.
ParticleVector
(
universe
)
for
a
in
rb_atoms
:
v
[
a
]
=
d
vectors
.
append
(
v
/
N
.
sqrt
(
len
(
rb_atoms
)))
vectors
.
append
(
v
/
numpy
.
sqrt
(
len
(
rb_atoms
)))
if
len
(
rb_atoms
)
>
1
:
center
=
o
.
centerOfMass
()
iv
=
len
(
vectors
)
-
3
...
...
@@ -327,7 +322,7 @@ class RigidMotionSubspace(Subspace):
v
[
a
]
=
d
.
cross
(
a
.
position
()
-
center
)
for
vt
in
vectors
[
iv
:]:
v
-=
v
.
dotProduct
(
vt
)
*
vt
norm_sq
=
N
.
sqrt
(
v
.
dotProduct
(
v
))
norm_sq
=
numpy
.
sqrt
(
v
.
dotProduct
(
v
))
if
norm_sq
>
0.
:
vectors
.
append
(
v
/
norm_sq
)
...
...
MMTK/Utility.py
View file @
a09f317d
...
...
@@ -5,7 +5,8 @@
#
import
os
,
sys
from
Scientific
import
N
import
numpy
# Constants
...
...
@@ -154,7 +155,7 @@ def isSequenceObject(obj):
def
isDefinedPosition
(
p
):
if
p
is
None
:
return
False
if
N
.
add
.
reduce
(
N
.
greater
(
p
.
array
,
undefined_limit
))
>
0
:
if
numpy
.
add
.
reduce
(
numpy
.
greater
(
p
.
array
,
undefined_limit
))
>
0
:
return
False
return
True
...
...
@@ -180,17 +181,10 @@ def warning(text):
# Pickler and unpickler taking care of non-pickled objects
#
try
:
array_package
=
N
.
package
except
AttributeError
:
array_package
=
'Numeric'
if
array_package
==
'Numeric'
:
BasePickler
=
N
.
Pickler
BaseUnpickler
=
N
.
Unpickler
else
:
from
pickle
import
Pickler
as
BasePickler
from
pickle
import
Unpickler
as
BaseUnpickler
del
array_package
from
pickle
import
Pickler
as
BasePickler
from
pickle
import
Unpickler
as
BaseUnpickler
from
pickle
import
UnpicklingError
class
Pickler
(
BasePickler
):
...
...
MMTK/Visualization.py
View file @
a09f317d
...
...
@@ -34,8 +34,9 @@ directory specification.
__docformat__
=
'restructuredtext'
import
numpy
from
MMTK
import
Units
,
Utility
from
Scientific
import
N
import
subprocess
,
sys
,
tempfile
,
os
#
...
...
@@ -174,8 +175,8 @@ class Viewable(object):
if
color
is
None
:
color_values
=
options
.
get
(
'color_values'
,
None
)
if
color_values
is
not
None
:
lower
=
N
.
minimum
.
reduce
(
color_values
.
array
)
upper
=
N
.
maximum
.
reduce
(
color_values
.
array
)
lower
=
numpy
.
minimum
.
reduce
(
color_values
.
array
)
upper
=
numpy
.
maximum
.
reduce
(
color_values
.
array
)
options
[
'color_scale'
]
=
module
.
ColorScale
((
lower
,
upper
))
try
:
distance_fn
=
self
.
universe
().
distanceVector
...
...
MMTK/XML.py
View file @
a09f317d
...
...
@@ -12,11 +12,11 @@ be considered experimental and subject to change.
__docformat__
=
'restructuredtext'
import
numpy
import
MMTK
from
MMTK.MoleculeFactory
import
MoleculeFactory
from
xml.etree.ElementTree
import
iterparse
from
Scientific
import
N
class
XMLMoleculeFactory
(
MoleculeFactory
):
...
...
@@ -104,5 +104,5 @@ class XMLMoleculeFactory(MoleculeFactory):
array
[:,
0
]
=
x
array
[:,
1
]
=
y
array
[:,
2
]
=
z
N
.
multiply
(
array
,
factor
,
array
)
numpy
.
multiply
(
array
,
factor
,
array
)
self
.
universe
=
universe
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment