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
569e2840
Commit
569e2840
authored
8 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
Code cleaning in ForceField
parent
9ddf1f99
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pycgtool/forcefield.py
+21
-28
21 additions, 28 deletions
pycgtool/forcefield.py
pycgtool/pycgtool.py
+1
-2
1 addition, 2 deletions
pycgtool/pycgtool.py
with
22 additions
and
30 deletions
pycgtool/forcefield.py
+
21
−
28
View file @
569e2840
...
...
@@ -46,7 +46,11 @@ class ForceField:
with
open
(
os
.
path
.
join
(
self
.
dirname
,
"
forcefield.doc
"
),
"
w
"
)
as
doc
:
print
(
"
PyCGTOOL produced MARTINI force field - {0}
"
.
format
(
name
),
file
=
doc
)
def
write_rtp
(
self
,
filename
,
mapping
,
bonds
):
def
write
(
self
,
filename
,
mapping
,
bonds
):
nterms
,
cterms
,
bothterms
=
self
.
_write_rtp
(
filename
,
mapping
,
bonds
)
self
.
_write_r2b
(
filename
,
nterms
,
cterms
,
bothterms
)
def
_write_rtp
(
self
,
filename
,
mapping
,
bonds
):
"""
Write a GROMACS .rtp file.
...
...
@@ -82,9 +86,6 @@ class ForceField:
else
:
return
any
(
map
(
recurse
,
iterable
))
def
strip_polymer_bonds
(
bonds
,
char
):
return
[
bond
for
bond
in
bonds
if
not
any_starts_with
(
bond
,
char
)]
def
write_residue
(
name
,
rtp
,
strip
=
None
,
prepend
=
""
):
print
(
"
[ {0} ]
"
.
format
(
prepend
+
name
),
file
=
rtp
)
...
...
@@ -97,24 +98,16 @@ class ForceField:
needs_terminal_entry
=
[
False
,
False
]
bond_tmp
=
bonds
.
get_bond_lengths
(
name
,
with_constr
=
True
)
if
strip
is
not
None
:
bond_tmp
=
strip_polymer_bonds
(
bond_tmp
,
strip
)
write_bond_angle_dih
(
bond_tmp
,
"
bonds
"
,
rtp
)
needs_terminal_entry
[
0
]
|=
any_starts_with
(
bond_tmp
,
"
-
"
)
needs_terminal_entry
[
1
]
|=
any_starts_with
(
bond_tmp
,
"
+
"
)
bond_tmp
=
bonds
.
get_bond_angles
(
name
)
if
strip
is
not
None
:
bond_tmp
=
strip_polymer_bonds
(
bond_tmp
,
strip
)
write_bond_angle_dih
(
bond_tmp
,
"
angles
"
,
rtp
)
needs_terminal_entry
[
0
]
|=
any_starts_with
(
bond_tmp
,
"
-
"
)
needs_terminal_entry
[
1
]
|=
any_starts_with
(
bond_tmp
,
"
+
"
)
get_bond_functions
=
[(
"
bonds
"
,
functools
.
partial
(
bonds
.
get_bond_lengths
,
with_constr
=
True
)),
(
"
angles
"
,
bonds
.
get_bond_angles
),
(
"
dihedrals
"
,
bonds
.
get_bond_dihedrals
)]
bond_tmp
=
bonds
.
get_bond_dihedrals
(
name
)
for
get_bond
in
get_bond_functions
:
bond_tmp
=
get_bond
[
1
](
name
)
if
strip
is
not
None
:
bond_tmp
=
strip_polymer_bonds
(
bond_tmp
,
strip
)
write_bond_angle_dih
(
bond_tmp
,
"
dihedrals
"
,
rtp
,
multiplicity
=
1
)
bond_tmp
=
[
bond
for
bond
in
bond_tmp
if
not
any_starts_with
(
bond
,
strip
)]
write_bond_angle_dih
(
bond_tmp
,
get_bond
[
0
],
rtp
,
multiplicity
=
1
if
get_bond
[
0
]
==
"
dihedrals
"
else
None
)
needs_terminal_entry
[
0
]
|=
any_starts_with
(
bond_tmp
,
"
-
"
)
needs_terminal_entry
[
1
]
|=
any_starts_with
(
bond_tmp
,
"
+
"
)
...
...
@@ -140,11 +133,11 @@ class ForceField:
if
needs_terminal_entry
[
1
]:
write_residue
(
mol
,
rtp
,
strip
=
"
+
"
,
prepend
=
"
C
"
)
c_terms
.
add
(
mol
)
if
needs_terminal_entry
[
0
]
:
if
all
(
needs_terminal_entry
)
:
write_residue
(
mol
,
rtp
,
strip
=
(
"
-
"
,
"
+
"
),
prepend
=
"
2
"
)
both_terms
.
add
(
mol
)
self
.
_write_r2b
(
filename
,
n_terms
,
c_terms
,
both_terms
)
return
n_terms
,
c_terms
,
both_terms
def
_write_r2b
(
self
,
filename
,
n_terms
,
c_terms
,
both_terms
):
with
open
(
os
.
path
.
join
(
self
.
dirname
,
filename
+
"
.r2b
"
),
"
w
"
)
as
r2b
:
...
...
This diff is collapsed.
Click to expand it.
pycgtool/pycgtool.py
+
1
−
2
View file @
569e2840
...
...
@@ -65,8 +65,7 @@ def main(args, config):
bonds
.
boltzmann_invert
(
progress
=
True
)
if
config
.
output_forcefield
:
logger
.
info
(
"
Creating GROMACS forcefield directory
"
)
ff
=
ForceField
(
config
.
output_name
)
ff
.
write_rtp
(
config
.
output_name
,
mapping
,
bonds
)
ForceField
(
config
.
output_name
).
write
(
config
.
output_name
,
mapping
,
bonds
)
logger
.
info
(
"
GROMACS forcefield directory created
"
)
else
:
bonds
.
write_itp
(
config
.
output_name
+
"
.itp
"
,
mapping
=
mapping
)
...
...
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