add option to specify charges and masses for .gro files
This commit is contained in:
parent
dee05b44f6
commit
fc975aef0c
@ -15,7 +15,7 @@ __version__ = '22.6.dev1'
|
||||
|
||||
|
||||
def open(directory='', topology='*.tpr', trajectory='*.xtc', cached=False,
|
||||
nojump=False, index_file=None):
|
||||
nojump=False, index_file=None, charges=None, masses=None):
|
||||
"""
|
||||
Open a simulation from a directory.
|
||||
|
||||
@ -70,7 +70,8 @@ def open(directory='', topology='*.tpr', trajectory='*.xtc', cached=False,
|
||||
raise FileNotFoundError('Trajectory file could not be identified.')
|
||||
|
||||
atom_set, frames = reader.open_with_mdanalysis(
|
||||
top_file, traj_file, cached=cached, index_file=index_file
|
||||
top_file, traj_file, cached=cached, index_file=index_file,
|
||||
charges=charges, masses=masses
|
||||
)
|
||||
coords = coordinates.Coordinates(frames, atom_subset=atom_set)
|
||||
if nojump:
|
||||
|
@ -34,7 +34,8 @@ class NojumpError(Exception):
|
||||
class WrongTopologyError(Exception):
|
||||
pass
|
||||
|
||||
def open_with_mdanalysis(topology, trajectory, cached=False, index_file=None):
|
||||
def open_with_mdanalysis(topology, trajectory, cached=False, index_file=None,
|
||||
charges=None, masses=None):
|
||||
"""Open a the topology and trajectory with mdanalysis."""
|
||||
uni = mdanalysis.Universe(topology, trajectory, convert_units=False)
|
||||
if cached is not False:
|
||||
@ -50,8 +51,8 @@ def open_with_mdanalysis(topology, trajectory, cached=False, index_file=None):
|
||||
charges = uni.atoms.charges
|
||||
masses = uni.atoms.masses
|
||||
elif topology.endswith('.gro'):
|
||||
charges = None
|
||||
masses = None
|
||||
charges = charges
|
||||
masses = masses
|
||||
else:
|
||||
raise WrongTopologyError('Topology file should end with ".tpr" or ".gro"')
|
||||
indices = None
|
||||
|
Loading…
Reference in New Issue
Block a user