@@ -29,18 +29,18 @@ class BeadMap(Atom):
29
29
"""
30
30
__slots__ = ["name" , "type" , "atoms" , "charge" , "mass" , "weights" , "weights_dict" ]
31
31
32
- def __init__ (self , name = None , type = None , atoms = None , charge = 0 , mass = 0 ):
32
+ def __init__ (self , name , num , type = None , atoms = None , charge = 0 , mass = 0 ):
33
33
"""
34
- Create a single bead mapping
35
-
36
- :param name: The name of the bead
37
- :param type : The bead type
38
- :param atoms : The atom names from which the bead is made up
39
- :param charge : The net charge on the bead
40
- :param mass : The total bead mass
41
- :return: Instance of BeadMap
34
+ Create a single bead mapping.
35
+
36
+ :param str name: The name of the bead
37
+ :param int num : The number of the bead
38
+ :param str type : The bead type
39
+ :param List[str] atoms : The atom names from which the bead is made up
40
+ :param float charge : The net charge on the bead
41
+ :param float mass: The total bead mass
42
42
"""
43
- Atom .__init__ (self , name = name , type = type , charge = charge , mass = mass )
43
+ Atom .__init__ (self , name , num , type = type , charge = charge , mass = mass )
44
44
self .atoms = atoms
45
45
# NB: Mass weights are added in Mapping.__init__ if an itp file is provided
46
46
self .weights_dict = {"geom" : np .array ([[1. / len (atoms )] for _ in atoms ], dtype = np .float32 ),
@@ -92,7 +92,7 @@ def __init__(self, filename, options, itp=None):
92
92
self ._mappings [mol_name ] = []
93
93
self ._manual_charges [mol_name ] = False
94
94
molmap = self ._mappings [mol_name ]
95
- for name , typ , first , * atoms in mol_section :
95
+ for i , ( name , typ , first , * atoms ) in enumerate ( mol_section ) :
96
96
charge = 0
97
97
try :
98
98
# Allow optional charge in mapping file
@@ -101,7 +101,7 @@ def __init__(self, filename, options, itp=None):
101
101
except ValueError :
102
102
atoms .insert (0 , first )
103
103
assert atoms , "Bead {0} specification contains no atoms" .format (name )
104
- newbead = BeadMap (name = name , type = typ , atoms = atoms , charge = charge )
104
+ newbead = BeadMap (name , i , type = typ , atoms = atoms , charge = charge )
105
105
molmap .append (newbead )
106
106
107
107
# TODO this only works with one moleculetype in one itp - extend this
@@ -202,7 +202,7 @@ def _cg_frame_setup(self, aa_residues, name=None):
202
202
continue
203
203
204
204
cgres = Residue (name = aares .name , num = aares .num )
205
- cgres .atoms = [Atom (name = bmap .name , type = bmap .type , charge = bmap .charge , mass = bmap .mass , coords = np .zeros (3 )) for bmap in molmap ]
205
+ cgres .atoms = [Atom (bmap .name , bmap . num , type = bmap .type , charge = bmap .charge , mass = bmap .mass , coords = np .zeros (3 )) for bmap in molmap ]
206
206
207
207
for i , (bead , bmap ) in enumerate (zip (cgres , molmap )):
208
208
cgres .name_to_num [bead .name ] = i
0 commit comments