Skip to content

Commit

Permalink
fixed the system error
Browse files Browse the repository at this point in the history
added run_system to annotate_mut_mod to get rid of undesired errors. Have broken the test.
  • Loading branch information
csbrasnett committed Dec 13, 2023
1 parent bae3e3b commit 70c3b27
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions vermouth/processors/annotate_mut_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,25 +210,30 @@ def annotate_modifications(molecule, modifications, mutations):
(mutations, 'mutation', molecule.force_field.blocks)]

residue_graph = make_residue_graph(molecule)
residue = {key: residue_graph.nodes[0].get(key)
for key in 'chain resid resname insertion_code'.split()}
chain = residue['chain']

for mutmod, key, library in associations:
for resspec, mod in mutmod:
mod_found = False
for res_idx in residue_graph:
if residue_matches(resspec, residue_graph, res_idx):
mod_found = True
if mod != 'none' and mod not in library:
raise NameError('{} is not known as a {} for '
'force field {}'
''.format(mod, key, molecule.force_field.name))
res = residue_graph.nodes[res_idx]
LOGGER.debug('Annotating {} with {} {}',
_format_resname(res), key, mod)
for node_idx in res['graph']:
molecule.nodes[node_idx][key] = molecule.nodes[node_idx].get(key, []) + [mod]
if mod_found == False:
LOGGER.warning('Mutation "{}" not found. '
'Check target resid!'
''.format(_format_resname(resspec)))
if resspec.get('chain') == chain:
mod_found = False
for res_idx in residue_graph:
if residue_matches(resspec, residue_graph, res_idx):
mod_found = True
if mod != 'none' and mod not in library:
raise NameError('{} is not known as a {} for '
'force field {}'
''.format(mod, key, molecule.force_field.name))
res = residue_graph.nodes[res_idx]
LOGGER.debug('Annotating {} with {} {}',
_format_resname(res), key, mod)
for node_idx in res['graph']:
molecule.nodes[node_idx][key] = molecule.nodes[node_idx].get(key, []) + [mod]
if mod_found == False:
LOGGER.warning('Mutation "{}" not found. '
'Check target resid!'
''.format(_format_resname(resspec)))

class AnnotateMutMod(Processor):
"""
Expand Down Expand Up @@ -259,3 +264,10 @@ def __init__(self, modifications=None, mutations=None):
def run_molecule(self, molecule):
annotate_modifications(molecule, self.modifications, self.mutations)
return molecule
def run_system(self, system):
print(self.mutations)
mols = []
for molecule in system.molecules:
mols.append(self.run_molecule(molecule))
system.molecules = mols

0 comments on commit 70c3b27

Please sign in to comment.