Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pycgtool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James Graham
pycgtool
Commits
0f2ae012
Commit
0f2ae012
authored
9 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
Fixed failing import if mdtraj not present
parent
7f1b1ae2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pycgtool/frame.py
+17
-6
17 additions, 6 deletions
pycgtool/frame.py
with
17 additions
and
6 deletions
pycgtool/frame.py
+
17
−
6
View file @
0f2ae012
...
...
@@ -11,7 +11,11 @@ import numpy as np
from
simpletraj
import
trajectory
try
:
from
mdtraj.formats
import
XTCTrajectoryFile
except
ImportError
:
pass
from
.util
import
backup_file
from
.parsers.cfg
import
CFG
...
...
@@ -162,6 +166,8 @@ class Frame:
raise
FileNotFoundError
(
xtc
)
from
e
e
.
args
=
(
"
Error opening file
'
{0}
'"
.
format
(
xtc
),)
raise
except
NameError
as
e
:
raise
ImportError
(
"
No module named
'
mdtraj
'"
)
from
e
else
:
xyz
,
time
,
step
,
box
=
self
.
xtc
.
read
(
n_frames
=
1
)
natoms
=
len
(
xyz
[
0
])
...
...
@@ -215,6 +221,8 @@ class Frame:
raise
def
_next_frame_mdtraj
(
self
,
exclude
=
None
):
if
XTCTrajectoryFile
is
None
:
raise
ImportError
(
"
No module named
'
mdtraj
'"
)
try
:
# self.xtc.seek(self.number)
i
=
0
...
...
@@ -292,6 +300,7 @@ class Frame:
def
flush_xtc_buffer
(
self
,
filename
):
if
self
.
_xtc_buffer
is
not
None
:
try
:
xtc
=
XTCTrajectoryFile
(
filename
,
mode
=
"
w
"
)
xyz
,
step
,
box
=
self
.
_xtc_buffer
()
...
...
@@ -299,6 +308,8 @@ class Frame:
xtc
.
close
()
self
.
_xtc_buffer
=
None
except
NameError
as
e
:
raise
ImportError
(
"
No module named
'
mdtraj
'"
)
from
e
def
write_xtc
(
self
,
filename
):
if
self
.
_xtc_buffer
is
None
:
...
...
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