Skip to content

Commit

Permalink
Use Select so that property map can be passed through to search.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed May 20, 2021
1 parent 9275798 commit d6de54f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
14 changes: 11 additions & 3 deletions python/BioSimSpace/_SireWrappers/_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def toSystem(self):
"""
return _System(self)

def search(self, query):
def search(self, query, property_map={}):
"""Search the molecule for atoms and residues. Search results will be
reduced to their minimal representation, i.e. a residue containing
a single atom will be returned as a atom.
Expand All @@ -469,6 +469,11 @@ def search(self, query):
query : str
The search query.
property_map : dict
A dictionary that maps system "properties" to their user defined
values. This allows the user to refer to properties with their
own naming scheme, e.g. { "charge" : "my-charge" }
Returns
-------
Expand All @@ -495,12 +500,15 @@ def search(self, query):
if type(query) is not str:
raise TypeError("'query' must be of type 'str'")

if type(property_map) is not dict:
raise TypeError("'property_map' must be of type 'dict'")

# Intialise a list to hold the search results.
results = []

try:
# Query the Sire system.
search_result = self._sire_object.search(query)
# Query the Sire molecule.
search_result = _SireMol.Select(query)(self._sire_object, property_map)

except Exception as e:
msg = "'Invalid search query: %r" % query
Expand Down
14 changes: 11 additions & 3 deletions python/BioSimSpace/_SireWrappers/_residue.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def toMolecule(self):
"""
return _Molecule(_SireMol.PartialMolecule(self._sire_object).extract().molecule())

def search(self, query):
def search(self, query, property_map={}):
"""Search the residue for atoms and residues.
Parameters
Expand All @@ -262,6 +262,11 @@ def search(self, query):
query : str
The search query.
property_map : dict
A dictionary that maps system "properties" to their user defined
values. This allows the user to refer to properties with their
own naming scheme, e.g. { "charge" : "my-charge" }
Returns
-------
Expand All @@ -283,12 +288,15 @@ def search(self, query):
if type(query) is not str:
raise TypeError("'query' must be of type 'str'")

if type(property_map) is not dict:
raise TypeError("'property_map' must be of type 'dict'")

# Intialise a list to hold the search results.
results = []

try:
# Query the Sire system.
search_result = self._sire_object.search(query)
# Query the Sire residue.
search_result = _SireMol.Select(query)(self._sire_object, property_map)

except Exception as e:
msg = "'Invalid search query: %r" % query
Expand Down
12 changes: 10 additions & 2 deletions python/BioSimSpace/_SireWrappers/_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def nPerturbableMolecules(self):
"""
return len(self.getPerturbableMolecules())

def search(self, query):
def search(self, query, property_map={}):
"""Search the system for atoms, residues, and molecules. Search results
will be reduced to their minimal representation, i.e. a molecule
containing a single residue will be returned as a residue.
Expand All @@ -693,6 +693,11 @@ def search(self, query):
query : str
The search query.
property_map : dict
A dictionary that maps system "properties" to their user defined
values. This allows the user to refer to properties with their
own naming scheme, e.g. { "charge" : "my-charge" }
Returns
-------
Expand Down Expand Up @@ -728,12 +733,15 @@ def search(self, query):
if type(query) is not str:
raise TypeError("'query' must be of type 'str'")

if type(property_map) is not dict:
raise TypeError("'property_map' must be of type 'dict'")

# Intialise a list to hold the search results.
results = []

try:
# Query the Sire system.
search_result = self._sire_object.search(query)
search_result = _SireMol.Select(query)(self._sire_object, property_map)

except Exception as e:
msg = "'Invalid search query: %r" % query
Expand Down

0 comments on commit d6de54f

Please sign in to comment.