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
e82f7f90
Commit
e82f7f90
authored
9 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
Made able to map solvent without bonds
Progress bar takes while pre/post tests
parent
1c3f1a0c
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
pycgtool.py
+2
-5
2 additions, 5 deletions
pycgtool.py
pycgtool/bondset.py
+20
-16
20 additions, 16 deletions
pycgtool/bondset.py
pycgtool/forcefield.py
+12
-1
12 additions, 1 deletion
pycgtool/forcefield.py
pycgtool/util.py
+15
-11
15 additions, 11 deletions
pycgtool/util.py
with
49 additions
and
33 deletions
pycgtool.py
+
2
−
5
View file @
e82f7f90
...
@@ -28,18 +28,15 @@ def main(args, config):
...
@@ -28,18 +28,15 @@ def main(args, config):
# Main loop - perform mapping and measurement on every frame in XTC
# Main loop - perform mapping and measurement on every frame in XTC
numframes
=
frame
.
numframes
if
args
.
frames
==
-
1
else
args
.
frames
numframes
=
frame
.
numframes
if
args
.
frames
==
-
1
else
args
.
frames
for
_
in
Progress
(
numframes
):
for
_
in
Progress
(
numframes
,
postwhile
=
frame
.
next_frame
):
if
args
.
map
:
if
args
.
map
:
cgframe
=
mapping
.
apply
(
frame
,
exclude
=
{
"
SOL
"
}
)
cgframe
=
mapping
.
apply
(
frame
)
else
:
else
:
cgframe
=
frame
cgframe
=
frame
if
args
.
bnd
:
if
args
.
bnd
:
bonds
.
apply
(
cgframe
)
bonds
.
apply
(
cgframe
)
if
not
frame
.
next_frame
():
break
if
args
.
map
:
if
args
.
map
:
cgframe
.
output
(
"
out.gro
"
,
format
=
config
[
"
output
"
])
cgframe
.
output
(
"
out.gro
"
,
format
=
config
[
"
output
"
])
...
...
This diff is collapsed.
Click to expand it.
pycgtool/bondset.py
+
20
−
16
View file @
e82f7f90
...
@@ -248,6 +248,7 @@ class BondSet:
...
@@ -248,6 +248,7 @@ class BondSet:
return
ang
if
direction
>
0
else
-
ang
return
ang
if
direction
>
0
else
-
ang
for
prev_res
,
res
,
next_res
in
sliding
(
frame
):
for
prev_res
,
res
,
next_res
in
sliding
(
frame
):
try
:
mol_meas
=
self
.
_molecules
[
res
.
name
]
mol_meas
=
self
.
_molecules
[
res
.
name
]
for
bond
in
mol_meas
:
for
bond
in
mol_meas
:
try
:
try
:
...
@@ -264,6 +265,9 @@ class BondSet:
...
@@ -264,6 +265,9 @@ class BondSet:
# NotImplementedError is raised if form is not implemented
# NotImplementedError is raised if form is not implemented
# TypeError is raised when residues on end of chain calc bond to next
# TypeError is raised when residues on end of chain calc bond to next
pass
pass
except
KeyError
:
# Bonds have not been specified for molecule - probably water
pass
def
boltzmann_invert
(
self
):
def
boltzmann_invert
(
self
):
"""
"""
...
...
This diff is collapsed.
Click to expand it.
pycgtool/forcefield.py
+
12
−
1
View file @
e82f7f90
...
@@ -29,6 +29,11 @@ class ForceField:
...
@@ -29,6 +29,11 @@ class ForceField:
# Copy main MARTINI itp
# Copy main MARTINI itp
shutil
.
copyfile
(
os
.
path
.
join
(
dir_up
(
os
.
path
.
realpath
(
__file__
),
2
),
"
data
"
,
"
martini_v2.2.itp
"
),
shutil
.
copyfile
(
os
.
path
.
join
(
dir_up
(
os
.
path
.
realpath
(
__file__
),
2
),
"
data
"
,
"
martini_v2.2.itp
"
),
os
.
path
.
join
(
self
.
dirname
,
"
martini_v2.2.itp
"
))
os
.
path
.
join
(
self
.
dirname
,
"
martini_v2.2.itp
"
))
# Copy water models
shutil
.
copyfile
(
os
.
path
.
join
(
dir_up
(
os
.
path
.
realpath
(
__file__
),
2
),
"
data
"
,
"
watermodels.dat
"
),
os
.
path
.
join
(
self
.
dirname
,
"
watermodels.dat
"
))
shutil
.
copyfile
(
os
.
path
.
join
(
dir_up
(
os
.
path
.
realpath
(
__file__
),
2
),
"
data
"
,
"
w.itp
"
),
os
.
path
.
join
(
self
.
dirname
,
"
w.itp
"
))
# Create atomtypes.atp required for correct masses with pdb2gmx
# Create atomtypes.atp required for correct masses with pdb2gmx
with
CFG
(
os
.
path
.
join
(
dir_up
(
os
.
path
.
realpath
(
__file__
),
2
),
"
data
"
,
"
martini_v2.2.itp
"
),
allow_duplicate
=
True
)
as
cfg
,
\
with
CFG
(
os
.
path
.
join
(
dir_up
(
os
.
path
.
realpath
(
__file__
),
2
),
"
data
"
,
"
martini_v2.2.itp
"
),
allow_duplicate
=
True
)
as
cfg
,
\
...
@@ -52,9 +57,15 @@ class ForceField:
...
@@ -52,9 +57,15 @@ class ForceField:
# TODO print everything to file
# TODO print everything to file
with
open
(
os
.
path
.
join
(
self
.
dirname
,
name
),
"
w
"
)
as
rtp
:
with
open
(
os
.
path
.
join
(
self
.
dirname
,
name
),
"
w
"
)
as
rtp
:
print
(
"
[ bondedtypes ]
"
,
file
=
rtp
)
print
(
"
[ bondedtypes ]
"
,
file
=
rtp
)
print
((
"
{:4d}
"
*
4
).
format
(
1
,
1
,
1
,
1
),
file
=
rtp
)
print
((
"
{:4d}
"
*
8
).
format
(
1
,
1
,
1
,
1
,
1
,
1
,
0
,
0
),
file
=
rtp
)
for
mol
in
mapping
:
for
mol
in
mapping
:
try
:
bonds
[
mol
]
except
KeyError
:
# Skip molecules without bonds
continue
print
(
"
[ {0} ]
"
.
format
(
mol
),
file
=
rtp
)
print
(
"
[ {0} ]
"
.
format
(
mol
),
file
=
rtp
)
print
(
"
[ atoms ]
"
,
file
=
rtp
)
print
(
"
[ atoms ]
"
,
file
=
rtp
)
...
...
This diff is collapsed.
Click to expand it.
pycgtool/util.py
+
15
−
11
View file @
e82f7f90
...
@@ -9,7 +9,7 @@ np.seterr(all="raise")
...
@@ -9,7 +9,7 @@ np.seterr(all="raise")
class
Progress
:
class
Progress
:
def
__init__
(
self
,
maxits
,
length
=
20
):
def
__init__
(
self
,
maxits
,
length
=
20
,
prewhile
=
None
,
postwhile
=
None
):
"""
"""
Class to handle printing of a progress bar within loops.
Class to handle printing of a progress bar within loops.
...
@@ -18,6 +18,8 @@ class Progress:
...
@@ -18,6 +18,8 @@ class Progress:
"""
"""
self
.
_maxits
=
maxits
self
.
_maxits
=
maxits
self
.
_length
=
length
self
.
_length
=
length
self
.
_prewhile
=
prewhile
self
.
_postwhile
=
postwhile
self
.
_its
=
0
self
.
_its
=
0
def
__enter__
(
self
):
def
__enter__
(
self
):
...
@@ -30,23 +32,25 @@ class Progress:
...
@@ -30,23 +32,25 @@ class Progress:
return
self
return
self
def
__next__
(
self
):
def
__next__
(
self
):
if
self
.
_postwhile
is
not
None
and
self
.
_its
>
0
and
not
self
.
_postwhile
():
self
.
_stop
()
if
self
.
_prewhile
is
not
None
and
not
self
.
_prewhile
():
self
.
_stop
()
self
.
_its
+=
1
self
.
_its
+=
1
if
self
.
_its
%
10
==
0
:
if
self
.
_its
%
10
==
0
:
self
.
_display
()
self
.
_display
()
if
self
.
_its
>=
self
.
_maxits
:
if
self
.
_its
>
self
.
_maxits
:
self
.
_display
()
self
.
_stop
()
print
()
raise
StopIteration
return
self
.
_its
return
self
.
_its
def
iteration
(
self
):
def
_stop
(
self
):
self
.
_its
+=
1
if
self
.
_its
%
10
==
0
or
self
.
_its
==
self
.
_maxits
:
self
.
_display
()
self
.
_display
()
if
self
.
_its
==
self
.
_maxits
:
print
()
print
()
raise
StopIteration
def
_display
(
self
):
def
_display
(
self
):
done
=
int
(
self
.
_length
*
(
self
.
_its
/
self
.
_maxits
))
done
=
int
(
self
.
_length
*
(
self
.
_its
/
self
.
_maxits
))
...
...
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