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
c638290d
Commit
c638290d
authored
8 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
Make certain parameters to __init__ functions required where this makes sense
parent
52f23554
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/bondset.py
+4
-4
4 additions, 4 deletions
pycgtool/bondset.py
pycgtool/frame.py
+11
-1
11 additions, 1 deletion
pycgtool/frame.py
pycgtool/mapping.py
+13
-13
13 additions, 13 deletions
pycgtool/mapping.py
test/test_frame.py
+3
-3
3 additions, 3 deletions
test/test_frame.py
with
31 additions
and
21 deletions
pycgtool/bondset.py
+
4
−
4
View file @
c638290d
...
@@ -33,13 +33,13 @@ class Bond:
...
@@ -33,13 +33,13 @@ class Bond:
"""
"""
__slots__
=
[
"
atoms
"
,
"
atom_numbers
"
,
"
values
"
,
"
eqm
"
,
"
fconst
"
,
"
_func_form
"
]
__slots__
=
[
"
atoms
"
,
"
atom_numbers
"
,
"
values
"
,
"
eqm
"
,
"
fconst
"
,
"
_func_form
"
]
def
__init__
(
self
,
atoms
=
None
,
atom_numbers
=
None
,
func_form
=
None
):
def
__init__
(
self
,
atoms
,
atom_numbers
=
None
,
func_form
=
None
):
"""
"""
Create a single bond definition.
Create a single bond definition.
:param atoms: List of atom names defining the bond
:param
List[str]
atoms: List of atom names defining the bond
:param atom_numbers: List of atom numbers defining the bond
:param
List[int]
atom_numbers: List of atom numbers defining the bond
:
return: Instance of Bond
:
param func_form: Functional form to use for Boltzmann Inversion
"""
"""
self
.
atoms
=
atoms
self
.
atoms
=
atoms
self
.
atom_numbers
=
atom_numbers
self
.
atom_numbers
=
atom_numbers
...
...
This diff is collapsed.
Click to expand it.
pycgtool/frame.py
+
11
−
1
View file @
c638290d
...
@@ -37,7 +37,17 @@ class Atom:
...
@@ -37,7 +37,17 @@ class Atom:
"""
"""
__slots__
=
[
"
name
"
,
"
num
"
,
"
type
"
,
"
mass
"
,
"
charge
"
,
"
coords
"
]
__slots__
=
[
"
name
"
,
"
num
"
,
"
type
"
,
"
mass
"
,
"
charge
"
,
"
coords
"
]
def
__init__
(
self
,
name
=
None
,
num
=
None
,
type
=
None
,
mass
=
None
,
charge
=
None
,
coords
=
None
):
def
__init__
(
self
,
name
,
num
,
type
=
None
,
mass
=
None
,
charge
=
None
,
coords
=
None
):
"""
Create an atom.
:param str name: The name of the atom
:param int num: The atom number
:param str type: The atom type
:param float mass: The mass of the atom
:param float charge: The charge of the atom
:param coords: The coordinates of the atom
"""
self
.
name
=
name
self
.
name
=
name
self
.
num
=
num
self
.
num
=
num
self
.
type
=
type
self
.
type
=
type
...
...
This diff is collapsed.
Click to expand it.
pycgtool/mapping.py
+
13
−
13
View file @
c638290d
...
@@ -29,18 +29,18 @@ class BeadMap(Atom):
...
@@ -29,18 +29,18 @@ class BeadMap(Atom):
"""
"""
__slots__
=
[
"
name
"
,
"
type
"
,
"
atoms
"
,
"
charge
"
,
"
mass
"
,
"
weights
"
,
"
weights_dict
"
]
__slots__
=
[
"
name
"
,
"
type
"
,
"
atoms
"
,
"
charge
"
,
"
mass
"
,
"
weights
"
,
"
weights_dict
"
]
def
__init__
(
self
,
name
=
None
,
type
=
None
,
atoms
=
None
,
charge
=
0
,
mass
=
0
):
def
__init__
(
self
,
name
,
num
,
type
=
None
,
atoms
=
None
,
charge
=
0
,
mass
=
0
):
"""
"""
Create a single bead mapping
Create a single bead mapping
.
:param name: The name of the bead
:param
str
name: The name of the bead
:param
type: The bead type
:param
int num: The number of the bead
:param
atoms: The atom names from which the bead is made up
:param
str type: The bead type
:param
charge: The net charge on the bead
:param
List[str] atoms: The atom names from which the bead is made up
:param
mass: The total bead mass
:param
float charge: The net charge on the bead
:
return: Instance of BeadMap
:
param float mass: The total bead mass
"""
"""
Atom
.
__init__
(
self
,
name
=
name
,
type
=
type
,
charge
=
charge
,
mass
=
mass
)
Atom
.
__init__
(
self
,
name
,
num
,
type
=
type
,
charge
=
charge
,
mass
=
mass
)
self
.
atoms
=
atoms
self
.
atoms
=
atoms
# NB: Mass weights are added in Mapping.__init__ if an itp file is provided
# NB: Mass weights are added in Mapping.__init__ if an itp file is provided
self
.
weights_dict
=
{
"
geom
"
:
np
.
array
([[
1.
/
len
(
atoms
)]
for
_
in
atoms
],
dtype
=
np
.
float32
),
self
.
weights_dict
=
{
"
geom
"
:
np
.
array
([[
1.
/
len
(
atoms
)]
for
_
in
atoms
],
dtype
=
np
.
float32
),
...
@@ -92,7 +92,7 @@ class Mapping:
...
@@ -92,7 +92,7 @@ class Mapping:
self
.
_mappings
[
mol_name
]
=
[]
self
.
_mappings
[
mol_name
]
=
[]
self
.
_manual_charges
[
mol_name
]
=
False
self
.
_manual_charges
[
mol_name
]
=
False
molmap
=
self
.
_mappings
[
mol_name
]
molmap
=
self
.
_mappings
[
mol_name
]
for
name
,
typ
,
first
,
*
atoms
in
mol_section
:
for
i
,
(
name
,
typ
,
first
,
*
atoms
)
in
enumerate
(
mol_section
)
:
charge
=
0
charge
=
0
try
:
try
:
# Allow optional charge in mapping file
# Allow optional charge in mapping file
...
@@ -101,7 +101,7 @@ class Mapping:
...
@@ -101,7 +101,7 @@ class Mapping:
except
ValueError
:
except
ValueError
:
atoms
.
insert
(
0
,
first
)
atoms
.
insert
(
0
,
first
)
assert
atoms
,
"
Bead {0} specification contains no atoms
"
.
format
(
name
)
assert
atoms
,
"
Bead {0} specification contains no atoms
"
.
format
(
name
)
newbead
=
BeadMap
(
name
=
name
,
type
=
typ
,
atoms
=
atoms
,
charge
=
charge
)
newbead
=
BeadMap
(
name
,
i
,
type
=
typ
,
atoms
=
atoms
,
charge
=
charge
)
molmap
.
append
(
newbead
)
molmap
.
append
(
newbead
)
# TODO this only works with one moleculetype in one itp - extend this
# TODO this only works with one moleculetype in one itp - extend this
...
@@ -202,7 +202,7 @@ class Mapping:
...
@@ -202,7 +202,7 @@ class Mapping:
continue
continue
cgres
=
Residue
(
name
=
aares
.
name
,
num
=
aares
.
num
)
cgres
=
Residue
(
name
=
aares
.
name
,
num
=
aares
.
num
)
cgres
.
atoms
=
[
Atom
(
name
=
bmap
.
n
ame
,
type
=
bmap
.
type
,
charge
=
bmap
.
charge
,
mass
=
bmap
.
mass
,
coords
=
np
.
zeros
(
3
))
for
bmap
in
molmap
]
cgres
.
atoms
=
[
Atom
(
bmap
.
name
,
bmap
.
n
um
,
type
=
bmap
.
type
,
charge
=
bmap
.
charge
,
mass
=
bmap
.
mass
,
coords
=
np
.
zeros
(
3
))
for
bmap
in
molmap
]
for
i
,
(
bead
,
bmap
)
in
enumerate
(
zip
(
cgres
,
molmap
)):
for
i
,
(
bead
,
bmap
)
in
enumerate
(
zip
(
cgres
,
molmap
)):
cgres
.
name_to_num
[
bead
.
name
]
=
i
cgres
.
name_to_num
[
bead
.
name
]
=
i
...
...
This diff is collapsed.
Click to expand it.
test/test_frame.py
+
3
−
3
View file @
c638290d
...
@@ -22,13 +22,13 @@ class AtomTest(unittest.TestCase):
...
@@ -22,13 +22,13 @@ class AtomTest(unittest.TestCase):
self
.
assertEqual
(
"
Type
"
,
atom
.
type
)
self
.
assertEqual
(
"
Type
"
,
atom
.
type
)
def
test_atom_add_missing_data
(
self
):
def
test_atom_add_missing_data
(
self
):
atom1
=
Atom
(
name
=
"
Name
"
,
num
=
0
,
type
=
"
Type
"
)
atom1
=
Atom
(
"
Name
1
"
,
0
,
type
=
"
Type
"
)
atom2
=
Atom
(
mass
=
1
)
atom2
=
Atom
(
"
Name2
"
,
0
,
mass
=
1
)
with
self
.
assertRaises
(
AssertionError
):
with
self
.
assertRaises
(
AssertionError
):
atom1
.
add_missing_data
(
atom2
)
atom1
.
add_missing_data
(
atom2
)
atom2
=
Atom
(
name
=
"
Name
"
,
num
=
0
,
mass
=
1
)
atom2
=
Atom
(
"
Name
1
"
,
0
,
mass
=
1
)
atom1
.
add_missing_data
(
atom2
)
atom1
.
add_missing_data
(
atom2
)
self
.
assertEqual
(
1
,
atom1
.
mass
)
self
.
assertEqual
(
1
,
atom1
.
mass
)
...
...
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