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
34cb9751
Commit
34cb9751
authored
12 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
remove dependency on mol
parent
97fc2595
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/base/pymod/stutil.py
+0
-43
0 additions, 43 deletions
modules/base/pymod/stutil.py
with
0 additions
and
43 deletions
modules/base/pymod/stutil.py
+
0
−
43
View file @
34cb9751
import
math
from
ost
import
mol
def
FloatValueExtract
(
func
):
"""
Decorator to wrap functions that take a list of float values. In addition to
passing in a list of float values directly, it is possible to extract the
values from attributes or generic properties.
"""
def
_dec
(
xs
,
prop
=
None
,
attr
=
None
):
if
prop
!=
None
:
if
len
(
xs
)
==
0
:
return
func
([])
assert
attr
==
None
level
=
mol
.
Prop
.
Level
.
UNSPECIFIED
if
isinstance
(
xs
[
0
],
mol
.
AtomBase
):
level
=
mol
.
Prop
.
Level
.
ATOM
elif
isinstance
(
xs
[
0
],
mol
.
ResidueBase
):
level
=
mol
.
Prop
.
Level
.
RESIDUE
elif
isinstance
(
xs
[
0
],
mol
.
ChainBase
):
level
=
mol
.
Prop
.
Level
.
CHAIN
epm
=
mol
.
EntityPropertyMapper
(
prop
,
level
)
vals
=
[]
for
x
in
xs
:
try
:
vals
.
append
(
epm
.
Get
(
x
))
except
:
pass
return
func
(
vals
)
if
attr
!=
None
:
vals
=
[]
for
x
in
xs
:
try
:
vals
.
append
(
getattr
(
x
,
attr
))
except
:
pass
return
func
(
vals
)
return
func
(
xs
)
return
_dec
@FloatValueExtract
def
Mean
(
xs
):
"""
Calculate mean of dataset
...
...
@@ -47,7 +8,6 @@ def Mean(xs):
raise
RuntimeError
(
"
Can
'
t calculate mean of empty sequence
"
)
return
float
(
sum
(
xs
))
/
len
(
xs
)
@FloatValueExtract
def
Median
(
xs
):
"""
Calculate median of dataset
...
...
@@ -60,7 +20,6 @@ def Median(xs):
else
:
return
sorted_xs
[(
len
(
xs
)
-
1
)
/
2
]
@FloatValueExtract
def
StdDev
(
xs
):
"""
Calculate standard-deviation of dataset
...
...
@@ -72,11 +31,9 @@ def StdDev(xs):
mean
=
Mean
(
xs
)
return
math
.
sqrt
(
sum
([(
x
-
mean
)
**
2
for
x
in
xs
])
/
len
(
xs
))
@FloatValueExtract
def
Min
(
xs
):
return
min
(
xs
)
@FloatValueExtract
def
Max
(
xs
):
return
max
(
xs
)
...
...
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