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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James Graham
pycgtool
Commits
81c6efcf
Verified
Commit
81c6efcf
authored
4 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
refactor: rename top and traj inputs
parent
4aa4d83a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pycgtool/__main__.py
+12
-10
12 additions, 10 deletions
pycgtool/__main__.py
test/test_pycgtool.py
+12
-9
12 additions, 9 deletions
test/test_pycgtool.py
with
24 additions
and
19 deletions
pycgtool/__main__.py
+
12
−
10
View file @
81c6efcf
...
...
@@ -42,7 +42,7 @@ def measure_bonds(frame: Frame, mapping: typing.Optional[Mapping],
logger
.
info
(
"
Bond measurements will be made
"
)
bonds
.
apply
(
frame
)
if
config
.
map
and
config
.
xtc
:
if
config
.
map
and
config
.
trajectory
:
# Only perform Boltzmann Inversion if we have a mapping and a trajectory.
# Otherwise we get infinite force constants.
logger
.
info
(
"
Beginning Boltzmann Inversion
"
)
...
...
@@ -87,8 +87,8 @@ def full_run(config):
:param config: Program arguments from argparse
"""
frame
=
Frame
(
topology_file
=
config
.
gro
,
trajectory_file
=
config
.
xtc
,
# May be None
topology_file
=
config
.
topology
,
trajectory_file
=
config
.
trajectory
,
# May be None
frame_start
=
config
.
begin
,
frame_end
=
config
.
end
)
...
...
@@ -110,18 +110,20 @@ def full_run(config):
def
parse_arguments
(
arg_list
):
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
description
=
"
Perform coarse-grain mapping of atomistic trajectory
"
)
description
=
"
Generate coarse-grained molecular dynamics models from atomistic trajectories.
"
)
# yapf: disable
# Input files
input_files
=
parser
.
add_argument_group
(
"
input files
"
)
input_files
.
add_argument
(
'
-g
'
,
'
--gro
'
,
type
=
str
,
required
=
True
,
help
=
"
GROMACS GRO file
"
)
input_files
.
add_argument
(
'
topology
'
,
type
=
str
,
help
=
"
AA simulation topology - e.g. PDB, GRO, etc.
"
)
input_files
.
add_argument
(
'
trajectory
'
,
type
=
str
,
nargs
=
'
?
'
,
help
=
"
AA simulation trajectory - e.g. XTC, DCD, etc.
"
)
input_files
.
add_argument
(
'
-m
'
,
'
--map
'
,
type
=
str
,
help
=
"
Mapping file
"
)
input_files
.
add_argument
(
'
-x
'
,
'
--xtc
'
,
type
=
str
,
help
=
"
GROMACS XTC file
"
)
input_files
.
add_argument
(
'
-b
'
,
'
--bnd
'
,
type
=
str
,
help
=
"
Bonds file
"
)
input_files
.
add_argument
(
'
-i
'
,
'
--itp
'
,
type
=
str
,
...
...
@@ -222,8 +224,8 @@ def validate_arguments(args):
def
main
():
args
=
parse_arguments
(
sys
.
argv
[
1
:])
print
(
"
Using GRO: {0}
"
.
format
(
args
.
gro
))
print
(
"
Using XTC: {0}
"
.
format
(
args
.
xtc
))
print
(
"
Using GRO: {0}
"
.
format
(
args
.
topology
))
print
(
"
Using XTC: {0}
"
.
format
(
args
.
trajectory
))
if
args
.
profile
:
with
cProfile
.
Profile
()
as
profiler
:
...
...
This diff is collapsed.
Click to expand it.
test/test_pycgtool.py
+
12
−
9
View file @
81c6efcf
...
...
@@ -14,16 +14,20 @@ import pycgtool.__main__ as main
def
get_args
(
name
,
out_dir
,
extra
:
typing
.
Optional
[
typing
.
Mapping
]
=
None
):
data_dir
=
pathlib
.
Path
(
'
test/data
'
)
args
=
{
'
-g
'
:
data_dir
.
joinpath
(
f
'
{
name
}
.gro
'
),
'
-x
'
:
data_dir
.
joinpath
(
f
'
{
name
}
.xtc
'
),
args
=
[
data_dir
.
joinpath
(
f
'
{
name
}
.gro
'
),
data_dir
.
joinpath
(
f
'
{
name
}
.xtc
'
),
]
kwargs
=
{
'
-m
'
:
data_dir
.
joinpath
(
f
'
{
name
}
.map
'
),
'
-b
'
:
data_dir
.
joinpath
(
f
'
{
name
}
.bnd
'
),
'
--out-dir
'
:
out_dir
,
}
parsed_args
=
main
.
parse_arguments
(
itertools
.
chain
(
*
[[
key
,
str
(
value
)]
for
key
,
value
in
args
.
items
()]))
itertools
.
chain
(
map
(
str
,
args
),
*
[[
key
,
str
(
value
)]
for
key
,
value
in
kwargs
.
items
()]))
if
extra
is
not
None
:
for
key
,
value
in
extra
.
items
():
...
...
@@ -45,15 +49,14 @@ class PycgtoolTest(unittest.TestCase):
def
test_parse_arguments
(
self
):
args
=
main
.
parse_arguments
([
'
-g
'
,
'
GRO
'
,
'
TOPOLOGY
'
,
'
-m
'
,
'
MAP
'
,
'
--begin
'
,
'
1000
'
,
])
self
.
assertEqual
(
'
GRO
'
,
args
.
gro
)
self
.
assertEqual
(
'
TOPOLOGY
'
,
args
.
topology
)
self
.
assertEqual
(
'
MAP
'
,
args
.
map
)
self
.
assertEqual
(
1000
,
args
.
begin
)
...
...
@@ -97,7 +100,7 @@ class PycgtoolTest(unittest.TestCase):
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
tmp_path
=
pathlib
.
Path
(
tmpdir
)
args
=
get_args
(
'
sugar
'
,
tmp_path
,
extra
=
{
'
xtc
'
:
None
,
'
trajectory
'
:
None
,
})
main
.
full_run
(
args
)
...
...
@@ -115,7 +118,7 @@ class PycgtoolTest(unittest.TestCase):
tmp_path
=
pathlib
.
Path
(
tmpdir
)
args
=
get_args
(
'
sugar
'
,
tmp_path
,
extra
=
{
'
map
'
:
None
,
'
xtc
'
:
None
,
'
trajectory
'
:
None
,
})
main
.
full_run
(
args
)
...
...
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