Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 584 #595

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions vermouth/data/force_fields/martini3001/aminoacids.ff
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,19 @@ scfix true
[ non-edges ]
BB SC1

[ link ]
resname $protein_resnames
[ angles ]
-BB BB SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}

[ link ]
resname $protein_resnames
[ angles ]
#meta {"group": "First SBB regular martini"}
SC1 BB +BB 2 100 25 {"version": 1}
[ non-edges ]
BB -BB

[ link ]
resname $protein_resnames
[ features ]
Expand All @@ -960,20 +973,20 @@ scfix
[ molmeta ]
scfix true
[ angles ]
BB +BB +SC1 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "BB-BB-SC"}

[ link ]
resname $protein_resnames
[ angles ]
-BB BB SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}
SC1 BB +BB 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "SC-BB-BB"}
SC1 BB +BB 2 100 25 {"version": 1, "group": "First SBB regular martini"}
[ non-edges ]
BB -BB

[ link ]
resname $protein_resnames
[ features ]
scfix
[ molmeta ]
scfix true
[ angles ]
#meta {"group": "First SBB regular martini"}
SC1 BB +BB 2 100 25 {"version": 1}
[ non-edges ]
BB -BB
BB +BB +SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}
BB +BB +SC1 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "BB-BB-SC"}

;; Links for the different secondary structures.
;; Setup the bonds. We only have the bonds assuming everything is coil.
Expand Down
33 changes: 23 additions & 10 deletions vermouth/data/force_fields/martini30b32/aminoacids.ff
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,19 @@ scfix true
#meta {"group": "SC-BB-BB-SC scFix"}
SC1 BB +BB +SC1 1 dihphase(SC1,BB,+BB,+SC1|.0f) 75 1

[ link ]
resname $protein_resnames
[ angles ]
-BB BB SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}

[ link ]
resname $protein_resnames
[ angles ]
#meta {"group": "First SBB regular martini"}
SC1 BB +BB 2 100 25 {"version": 1}
[ non-edges ]
BB -BB

[ link ]
resname $protein_resnames
[ features ]
Expand All @@ -546,20 +559,20 @@ scfix
[ molmeta ]
scfix true
[ angles ]
BB +BB +SC1 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "BB-BB-SC"}

[ link ]
resname $protein_resnames
[ angles ]
-BB BB SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}
SC1 BB +BB 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "SC-BB-BB"}
SC1 BB +BB 2 100 25 {"version": 1, "group": "First SBB regular martini"}
[ non-edges ]
BB -BB

[ link ]
resname $protein_resnames
[ features ]
scfix
[ molmeta ]
scfix true
[ angles ]
#meta {"group": "First SBB regular martini"}
SC1 BB +BB 2 100 25 {"version": 1}
[ non-edges ]
BB -BB
BB +BB +SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}
BB +BB +SC1 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "BB-BB-SC"}

;; Links for the different secondary structures.
;; Setup the bonds. We only have the bonds assuming everything is coil.
Expand Down
33 changes: 23 additions & 10 deletions vermouth/data/force_fields/martini30dev/aminoacids.ff
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,19 @@ scfix true
#meta {"group": "SC-BB-BB-SC scFix"}
SC1 BB +BB +SC1 1 dihphase(SC1,BB,+BB,+SC1|.0f) 75 1

[ link ]
resname $protein_resnames
[ angles ]
-BB BB SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}

[ link ]
resname $protein_resnames
[ angles ]
#meta {"group": "First SBB regular martini"}
SC1 BB +BB 2 100 25 {"version": 1}
[ non-edges ]
BB -BB

[ link ]
resname $protein_resnames
[ features ]
Expand All @@ -591,20 +604,20 @@ scfix
[ molmeta ]
scfix true
[ angles ]
BB +BB +SC1 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "BB-BB-SC"}

[ link ]
resname $protein_resnames
[ angles ]
-BB BB SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}
SC1 BB +BB 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "SC-BB-BB"}
SC1 BB +BB 2 100 25 {"version": 1, "group": "First SBB regular martini"}
[ non-edges ]
BB -BB

[ link ]
resname $protein_resnames
[ features ]
scfix
[ molmeta ]
scfix true
[ angles ]
#meta {"group": "First SBB regular martini"}
SC1 BB +BB 2 100 25 {"version": 1}
[ non-edges ]
BB -BB
BB +BB +SC1 2 100 25 {"group": "BBS angles regular martini", "version": 1}
BB +BB +SC1 10 100 15 {"group": "SC-BB-BB and BB-BB-SC scFix", "comment": "BB-BB-SC"}

;; Links for the different secondary structures.
;; Setup the bonds. We only have the bonds assuming everything is coil.
Expand Down
16 changes: 9 additions & 7 deletions vermouth/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def get_interaction(self, type_):
"""
return self.interactions[type_]

def remove_interaction(self, type_, atoms, version=0):
def remove_interaction(self, type_, atoms, version=None):
"""
Removes the specified interaction.

Expand All @@ -587,25 +587,27 @@ def remove_interaction(self, type_, atoms, version=0):
The type of interaction, such as 'bonds' or 'angles'.
atoms: collections.abc.Sequence
The atoms that are involved in this interaction.
version: int
version: Optional[int]
Sometimes there can be multiple distinct interactions between the
same group of atoms. This is reflected with their `version` meta
attribute.
If None, the version is not taken into account.

Raises
------
KeyError
If the specified interaction could not be found
"""
idx = 0
to_remove = []
for idx, interaction in enumerate(self.interactions[type_]):
if interaction.atoms == atoms and interaction.meta.get('version', 0) == version:
break
else: # no break
if interaction.atoms == atoms and (version is None or interaction.meta.get('version', 0) == version):
to_remove.append(idx)
if not to_remove:
msg = ("Can't find interaction of type {} between atoms {} "
"and with version {}")
raise KeyError(msg.format(type_, atoms, version))
del self.interactions[type_][idx]
for idx in reversed(to_remove):
del self.interactions[type_][idx]
if not self.interactions[type_]:
del self.interactions[type_]

Expand Down
7 changes: 7 additions & 0 deletions vermouth/processors/do_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,15 @@
except ValueError:
pass
for inter_type, interactions in link.interactions.items():
interactions_to_add = []

Check warning on line 316 in vermouth/processors/do_links.py

View check run for this annotation

Codecov / codecov/patch

vermouth/processors/do_links.py#L316

Added line #L316 was not covered by tests
for interaction in interactions:
interaction = _build_link_interaction_from(molecule, interaction, match)
interactions_to_add.append(interaction)
try:
molecule.remove_interaction(inter_type, interaction.atoms, version=None)
except KeyError:
pass

Check warning on line 323 in vermouth/processors/do_links.py

View check run for this annotation

Codecov / codecov/patch

vermouth/processors/do_links.py#L319-L323

Added lines #L319 - L323 were not covered by tests
for interaction in interactions_to_add:
molecule.add_or_replace_interaction(inter_type, *interaction, link.citations)

for loglevel, entries in link.log_entries.items():
Expand Down
Loading