From 692849e2eee68b727bc19b2d7da685681fc9165e Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Tue, 9 Apr 2024 13:07:15 +0100 Subject: [PATCH 1/3] Use list rather than set so search strings are reproducible. [closes #270] --- .../Sandpit/Exscientia/_SireWrappers/_utils.py | 12 ++++++------ python/BioSimSpace/_SireWrappers/_utils.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_utils.py b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_utils.py index 6d735cc65..9f2b3eac3 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_utils.py +++ b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_utils.py @@ -22,8 +22,8 @@ Utilities. """ -# A set of protein residues. Taken from MDAnalysis. -_prot_res = { +# A list of protein residues. Taken from MDAnalysis. +_prot_res = [ # CHARMM top_all27_prot_lipid.rtf "ALA", "ARG", @@ -135,10 +135,10 @@ "CMET", "CME", "ASF", -} +] -# A set of nucleic acid residues. Taken from MDAnalysis. -_nucl_res = { +# A list of nucleic acid residues. Taken from MDAnalysis. +_nucl_res = [ "ADE", "URA", "CYT", @@ -173,7 +173,7 @@ "RU3", "RG3", "RC3", -} +] # A list of ion elements. _ions = [ diff --git a/python/BioSimSpace/_SireWrappers/_utils.py b/python/BioSimSpace/_SireWrappers/_utils.py index 6d735cc65..9f2b3eac3 100644 --- a/python/BioSimSpace/_SireWrappers/_utils.py +++ b/python/BioSimSpace/_SireWrappers/_utils.py @@ -22,8 +22,8 @@ Utilities. """ -# A set of protein residues. Taken from MDAnalysis. -_prot_res = { +# A list of protein residues. Taken from MDAnalysis. +_prot_res = [ # CHARMM top_all27_prot_lipid.rtf "ALA", "ARG", @@ -135,10 +135,10 @@ "CMET", "CME", "ASF", -} +] -# A set of nucleic acid residues. Taken from MDAnalysis. -_nucl_res = { +# A list of nucleic acid residues. Taken from MDAnalysis. +_nucl_res = [ "ADE", "URA", "CYT", @@ -173,7 +173,7 @@ "RU3", "RG3", "RC3", -} +] # A list of ion elements. _ions = [ From 81d82338953c60a787dceb71b991e7c5aa602304 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Tue, 9 Apr 2024 14:50:48 +0100 Subject: [PATCH 2/3] Join protein and nucleic acid residue strings correctly. --- python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py | 2 ++ python/BioSimSpace/_SireWrappers/_system.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py index 56bf3aebe..7dc882868 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py +++ b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py @@ -1888,6 +1888,7 @@ def getRestraintAtoms( string = ( "(not water) and (resname " + ",".join(_prot_res) + + "," + ",".join(_nucl_res) + ") and (atomname N,CA,C,O,P,/C5'/,/C3'/,/O3'/,/O5'/)" ) @@ -1943,6 +1944,7 @@ def getRestraintAtoms( string = ( "(not water) and (resname " + ",".join(_prot_res) + + "," + ",".join(_nucl_res) + ") and (atomname N,CA,C,O,P,/C5'/,/C3'/,/O3'/,/O5'/)" ) diff --git a/python/BioSimSpace/_SireWrappers/_system.py b/python/BioSimSpace/_SireWrappers/_system.py index 380a3b736..2d458890b 100644 --- a/python/BioSimSpace/_SireWrappers/_system.py +++ b/python/BioSimSpace/_SireWrappers/_system.py @@ -1809,6 +1809,7 @@ def getRestraintAtoms( string = ( "(not water) and (resname " + ",".join(_prot_res) + + "," + ",".join(_nucl_res) + ") and (atomname N,CA,C,O,P,/C5'/,/C3'/,/O3'/,/O5'/)" ) @@ -1864,6 +1865,7 @@ def getRestraintAtoms( string = ( "(not water) and (resname " + ",".join(_prot_res) + + "," + ",".join(_nucl_res) + ") and (atomname N,CA,C,O,P,/C5'/,/C3'/,/O3'/,/O5'/)" ) From f44b35ea0b649f0a9a5910bb097fcf3cf1f78abc Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Tue, 9 Apr 2024 15:15:48 +0100 Subject: [PATCH 3/3] Use try/except when matching by coordinates. --- .../Sandpit/Exscientia/_SireWrappers/_molecule.py | 12 ++++++++++-- python/BioSimSpace/_SireWrappers/_molecule.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py index 6de6095dd..b4fa03ab7 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py +++ b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py @@ -792,7 +792,11 @@ def makeCompatibleWith( if len(matches) < num_atoms0: # Atom names or order might have changed. Try to match by coordinates. matcher = _SireMol.AtomCoordMatcher() - matches = matcher.match(mol0, mol1) + + try: + matches = matcher.match(mol0, mol1) + except: + matches = [] # We need to rename the atoms. is_renamed = True @@ -1003,7 +1007,11 @@ def makeCompatibleWith( matcher = _SireMol.AtomCoordMatcher() # Get the matches for this molecule and append to the list. - match = matcher.match(mol0, mol) + try: + match = matcher.match(mol0, mol) + except: + match = [] + matches.append(match) num_matches += len(match) diff --git a/python/BioSimSpace/_SireWrappers/_molecule.py b/python/BioSimSpace/_SireWrappers/_molecule.py index 089c88146..27fa121f0 100644 --- a/python/BioSimSpace/_SireWrappers/_molecule.py +++ b/python/BioSimSpace/_SireWrappers/_molecule.py @@ -748,7 +748,11 @@ def makeCompatibleWith( if len(matches) < num_atoms0: # Atom names or order might have changed. Try to match by coordinates. matcher = _SireMol.AtomCoordMatcher() - matches = matcher.match(mol0, mol1) + + try: + matches = matcher.match(mol0, mol1) + except: + matches = [] # We need to rename the atoms. is_renamed = True @@ -959,7 +963,11 @@ def makeCompatibleWith( matcher = _SireMol.AtomCoordMatcher() # Get the matches for this molecule and append to the list. - match = matcher.match(mol0, mol) + try: + match = matcher.match(mol0, mol) + except: + match = [] + matches.append(match) num_matches += len(match)