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
4639bcd6
Verified
Commit
4639bcd6
authored
4 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
refactor: add backmapper resname to CLI
parent
65d1b348
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/__main__.py
+6
-25
6 additions, 25 deletions
pycgtool/__main__.py
with
6 additions
and
25 deletions
pycgtool/__main__.py
+
6
−
25
View file @
4639bcd6
...
...
@@ -44,8 +44,8 @@ class PyCGTOOL:
self
.
out_frame
.
save
(
self
.
get_output_filepath
(
'
gro
'
),
frame_number
=
0
)
if
self
.
out_frame
.
n_frames
>
1
:
self
.
train_backmapper
()
if
self
.
config
.
backmapper_resname
and
self
.
out_frame
.
n_frames
>
1
:
self
.
train_backmapper
(
self
.
config
.
resname
)
self
.
bondset
=
None
if
self
.
config
.
bondset
:
...
...
@@ -93,29 +93,14 @@ class PyCGTOOL:
self
.
config
.
out_dir
)
logger
.
info
(
'
Finished writing bond measurements to file
'
)
@staticmethod
def
get_coords
(
frame
:
Frame
,
resname
:
str
)
->
np
.
ndarray
:
return
np
.
concatenate
([
frame
.
_trajectory
.
atom_slice
(
[
atom
.
index
for
atom
in
residue
.
atoms
]).
xyz
for
residue
in
frame
.
_trajectory
.
topology
.
residues
if
residue
.
name
==
resname
])
def
train_backmapper
(
self
):
# resname = 'POPC'
# aa_coords = get_coords(aa_frame, resname)
# cg_coords = get_coords(cg_frame, resname)
sel
=
'
resid 0
'
def
train_backmapper
(
self
,
resname
:
str
):
sel
=
f
'
resname
{
resname
}
'
aa_subset_traj
=
self
.
in_frame
.
_trajectory
.
atom_slice
(
self
.
in_frame
.
_trajectory
.
topology
.
select
(
sel
))
cg_subset_traj
=
self
.
out_frame
.
_trajectory
.
atom_slice
(
self
.
out_frame
.
_trajectory
.
topology
.
select
(
sel
))
cg_subset_traj
.
save
(
'
cg_test.gro
'
)
aa_subset_traj
.
save
(
'
aa_test.gro
'
)
logger
.
info
(
'
Training backmapper
'
)
# Param x_valence is approximate number of bonds per CG bead
# Values greater than 2 fail for small molecules e.g. sugar test case
...
...
@@ -123,12 +108,6 @@ class PyCGTOOL:
backmapper
.
fit
(
cg_subset_traj
.
xyz
,
aa_subset_traj
.
xyz
)
logger
.
info
(
'
Finished training backmapper
'
)
# logger.info('Testing backmapper')
# backmapped = backmapper.transform(cg_subset_traj.xyz)
# aa_subset_traj.xyz = backmapped
# aa_subset_traj.save('backmapped.gro')
# logger.info('Finished testing backmapper')
backmapper
.
save
(
self
.
get_output_filepath
(
'
backmapper.pkl
'
))
...
...
@@ -198,6 +177,8 @@ def parse_arguments(arg_list):
mapping_options
.
add_argument
(
"
--virtual-map-center
"
,
default
=
"
geom
"
,
choices
=
[
"
geom
"
,
"
mass
"
],
help
=
"
Virtual site mapping method
"
)
mapping_options
.
add_argument
(
"
--backmapper-resname
"
,
default
=
None
,
help
=
"
Residue name for which to train a backmapper
"
)
# Bond options
bond_options
=
parser
.
add_argument_group
(
"
bond options
"
)
...
...
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