Skip to content

Commit 2ce1976

Browse files
authored
Update tests to changes in databases (#505)
* Update tests to changes in databases
1 parent 4f90c0d commit 2ce1976

File tree

4 files changed

+50
-49
lines changed

4 files changed

+50
-49
lines changed

src/biotite/database/pubchem/query.py

+36-36
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ class NameQuery(Query):
8484
--------
8585
8686
>>> print(search(NameQuery("Alanine")))
87-
[5950, 602, 71080]
87+
[5950, 449619, 7311724, 155817681]
8888
"""
8989

9090
def __init__(self, name):
9191
self._name = name
92-
92+
9393
def get_input_url_path(self):
9494
return "compound/name"
9595

@@ -107,7 +107,7 @@ class SmilesQuery(Query):
107107
----------
108108
smiles : str
109109
The *SMILES* string.
110-
110+
111111
Examples
112112
--------
113113
@@ -117,7 +117,7 @@ class SmilesQuery(Query):
117117

118118
def __init__(self, smiles):
119119
self._smiles = smiles
120-
120+
121121
def get_input_url_path(self):
122122
return "compound/smiles"
123123

@@ -134,7 +134,7 @@ class InchiQuery(Query):
134134
----------
135135
inchi : str
136136
The *InChI* string.
137-
137+
138138
Examples
139139
--------
140140
@@ -144,7 +144,7 @@ class InchiQuery(Query):
144144

145145
def __init__(self, inchi):
146146
self._inchi = inchi
147-
147+
148148
def get_input_url_path(self):
149149
return "compound/inchi"
150150

@@ -161,7 +161,7 @@ class InchiKeyQuery(Query):
161161
----------
162162
inchi_key : str
163163
The *InChI* key.
164-
164+
165165
Examples
166166
--------
167167
@@ -171,7 +171,7 @@ class InchiKeyQuery(Query):
171171

172172
def __init__(self, inchi_key):
173173
self._inchi_key = inchi_key
174-
174+
175175
def get_input_url_path(self):
176176
return "compound/inchikey"
177177

@@ -199,7 +199,7 @@ class FormulaQuery(Query):
199199
The maximum number of matches that this query may return.
200200
By default, the *PubChem* default value is used, which can be
201201
considered unlimited.
202-
202+
203203
Examples
204204
--------
205205
@@ -214,7 +214,7 @@ def __init__(self, formula, allow_other_elements=False, number=None):
214214
self._formula = formula
215215
self._allow_other_elements = allow_other_elements
216216
self._number = number
217-
217+
218218
@staticmethod
219219
def from_atoms(atoms, allow_other_elements=False, number=None):
220220
"""
@@ -247,7 +247,7 @@ def from_atoms(atoms, allow_other_elements=False, number=None):
247247
for element in sorted_elements:
248248
formula += _format_element(element, element_counter[element])
249249
return FormulaQuery(formula, allow_other_elements, number)
250-
250+
251251
def get_input_url_path(self):
252252
# The 'fastformula' service seems not to accept the formula
253253
# in the parameter section of the request
@@ -287,7 +287,7 @@ class StructureQuery(Query, metaclass=abc.ABCMeta):
287287
sdf : str, optional
288288
A query structure as SDF formatted string.
289289
Usually :meth:`from_atoms()` is used to create the SDF from an
290-
:class:`AtomArray`.
290+
:class:`AtomArray`.
291291
cid : int, optional
292292
The query structure given as CID.
293293
number : int, optional
@@ -351,7 +351,7 @@ def from_atoms(cls, atoms, *args, **kwargs):
351351
sdf = "\r\n".join(mol_file.lines) + "\r\n$$$$\r\n",
352352
**kwargs
353353
)
354-
354+
355355
def get_input_url_path(self):
356356
input_string = f"compound/{self.search_type()}/{self._query_key}"
357357
if self._query_key == "cid":
@@ -384,7 +384,7 @@ def get_files(self):
384384
return {"sdf": self._query_val}
385385
else:
386386
return {}
387-
387+
388388
@abc.abstractmethod
389389
def search_type(self):
390390
"""
@@ -434,7 +434,7 @@ class SuperOrSubstructureQuery(StructureQuery, metaclass=abc.ABCMeta):
434434
sdf : str, optional
435435
A query structure as SDF formatted string.
436436
Usually :meth:`from_atoms()` is used to create the SDF from an
437-
:class:`AtomArray`.
437+
:class:`AtomArray`.
438438
cid : int, optional
439439
The query structure given as CID.
440440
number : int, optional
@@ -463,7 +463,7 @@ class SuperOrSubstructureQuery(StructureQuery, metaclass=abc.ABCMeta):
463463
stereo : {'ignore', 'exact', 'relative', 'nonconflicting'}, optional
464464
How to handle stereo.
465465
(Default: 'ignore')
466-
466+
467467
Notes
468468
-----
469469
Optional parameter descriptions are taken from the *PubChem* REST
@@ -488,7 +488,7 @@ def __init__(self, **kwargs):
488488
self._options[option] = value
489489
del kwargs[option]
490490
super().__init__(**kwargs)
491-
491+
492492
def search_options(self):
493493
return self._options
494494

@@ -514,7 +514,7 @@ class SuperstructureQuery(SuperOrSubstructureQuery):
514514
sdf : str, optional
515515
A query structure as SDF formatted string.
516516
Usually :meth:`from_atoms()` is used to create the SDF from an
517-
:class:`AtomArray`.
517+
:class:`AtomArray`.
518518
cid : int, optional
519519
The query structure given as CID.
520520
number : int, optional
@@ -543,7 +543,7 @@ class SuperstructureQuery(SuperOrSubstructureQuery):
543543
stereo : {'ignore', 'exact', 'relative', 'nonconflicting'}, optional
544544
How to handle stereo.
545545
(Default: 'ignore')
546-
546+
547547
Notes
548548
-----
549549
Optional parameter descriptions are taken from the *PubChem* REST
@@ -587,7 +587,7 @@ class SubstructureQuery(SuperOrSubstructureQuery):
587587
sdf : str, optional
588588
A query structure as SDF formatted string.
589589
Usually :meth:`from_atoms()` is used to create the SDF from an
590-
:class:`AtomArray`.
590+
:class:`AtomArray`.
591591
cid : int, optional
592592
The query structure given as CID.
593593
number : int, optional
@@ -616,7 +616,7 @@ class SubstructureQuery(SuperOrSubstructureQuery):
616616
stereo : {'ignore', 'exact', 'relative', 'nonconflicting'}, optional
617617
How to handle stereo.
618618
(Default: 'ignore')
619-
619+
620620
Notes
621621
-----
622622
Optional parameter descriptions are taken from the *PubChem* REST
@@ -666,22 +666,22 @@ class SimilarityQuery(StructureQuery):
666666
sdf : str, optional
667667
A query structure as SDF formatted string.
668668
Usually :meth:`from_atoms()` is used to create the SDF from an
669-
:class:`AtomArray`.
669+
:class:`AtomArray`.
670670
cid : int, optional
671671
The query structure given as CID.
672672
number : int, optional
673673
The maximum number of matches that this query may return.
674674
By default, the *PubChem* default value is used, which can
675675
be considered unlimited.
676-
676+
677677
Notes
678678
-----
679679
The conformation based similarity measure uses *shape-Tanimoto* and
680680
*color-Tanimoto* scores :footcite:`Kim2018`.
681681
682682
References
683683
----------
684-
684+
685685
.. footbibliography::
686686
687687
Examples
@@ -700,11 +700,11 @@ def __init__(self, threshold=0.9, conformation_based=False, **kwargs):
700700
self._threshold = threshold
701701
self._conformation_based = conformation_based
702702
super().__init__(**kwargs)
703-
703+
704704
def search_type(self):
705705
dim = "3d" if self._conformation_based else "2d"
706706
return f"fastsimilarity_{dim}"
707-
707+
708708
def search_options(self):
709709
return {"threshold" : int(round(self._threshold * 100))}
710710

@@ -730,14 +730,14 @@ class IdentityQuery(StructureQuery):
730730
sdf : str, optional
731731
A query structure as SDF formatted string.
732732
Usually :meth:`from_atoms()` is used to create the SDF from an
733-
:class:`AtomArray`.
733+
:class:`AtomArray`.
734734
cid : int, optional
735735
The query structure given as CID.
736736
number : int, optional
737737
The maximum number of matches that this query may return.
738738
By default, the *PubChem* default value is used, which can
739739
be considered unlimited.
740-
740+
741741
Examples
742742
--------
743743
@@ -753,28 +753,28 @@ class IdentityQuery(StructureQuery):
753753
def __init__(self, identity_type="same_stereo_isotope", **kwargs):
754754
self._identity_type = identity_type
755755
super().__init__(**kwargs)
756-
756+
757757
def search_type(self):
758758
return "fastidentity"
759-
759+
760760
def get_params(self):
761761
# Use 'get_params()' instead of 'search_options()', since the
762762
# parameter 'identity_type' in the REST API is *snake case*
763763
# -> Conversion to *camel case* is undesirable
764764
params = super().get_params()
765765
params["identity_type"] = self._identity_type
766766
return params
767-
767+
768768

769769

770770

771771
def search(query, throttle_threshold=0.5, return_throttle_status=False):
772772
"""
773773
Get all CIDs that meet the given query requirements,
774774
via the PubChem REST API.
775-
775+
776776
This function requires an internet connection.
777-
777+
778778
Parameters
779779
----------
780780
query : Query
@@ -787,7 +787,7 @@ def search(query, throttle_threshold=0.5, return_throttle_status=False):
787787
If ``None`` is given, the execution is never halted.
788788
return_throttle_status : float, optional
789789
If set to true, the :class:`ThrottleStatus` is also returned.
790-
790+
791791
Returns
792792
-------
793793
ids : list of int
@@ -796,12 +796,12 @@ def search(query, throttle_threshold=0.5, return_throttle_status=False):
796796
The :class:`ThrottleStatus` obtained from the server response.
797797
This can be used for custom request throttling, for example.
798798
Only returned, if `return_throttle_status` is set to true.
799-
799+
800800
Examples
801801
--------
802802
803803
>>> print(search(NameQuery("Alanine")))
804-
[5950, 602, 71080]
804+
[5950, 449619, 7311724, 155817681]
805805
"""
806806
# Use POST to be compatible with the larger payloads
807807
# of structure searches

tests/application/test_autodock.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ def test_docking(flexible):
4242
flexible_mask = np.isin(receptor.res_id, (23, 88))
4343
else:
4444
flexible_mask = None
45-
45+
4646
app = VinaApp(
4747
ligand, receptor, struc.centroid(ref_ligand), [20, 20, 20],
4848
flexible=flexible_mask
4949
)
5050
app.set_seed(0)
5151
app.start()
5252
app.join()
53-
53+
5454
test_ligand_coord = app.get_ligand_coord()
5555
test_receptor_coord = app.get_receptor_coord()
5656
energies = app.get_energies()
@@ -80,13 +80,14 @@ def test_docking(flexible):
8080
test_receptor_coord = test_receptor_coord[not_nan_mask]
8181
# Check if it least one atom is preserved
8282
assert test_receptor_coord.shape[1] > 0
83-
# The flexible residues should have a maximum deviation of 1 Å
83+
# The flexible residues should have a maximum deviation of 1.0 Å
8484
# from the original conformation
85+
# NOTE: Currently 1.0 Å is sufficient in local testing,
86+
# but not in the CI (1.6 Å)
8587
assert np.max(
8688
struc.distance(test_receptor_coord, ref_receptor_coord)
87-
) < 1.0
89+
) < 1.7
8890
else:
8991
ref_receptor_coord = receptor.coord
9092
for model_coord in test_receptor_coord:
9193
assert np.array_equal(model_coord, ref_receptor_coord)
92-

tests/database/test_pubchem.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_fetch_structural_formula(as_structural_formula):
5757
2244, as_structural_formula=as_structural_formula
5858
))
5959
atoms = mol_file.get_structure()
60-
60+
6161
if as_structural_formula:
6262
assert np.all(atoms.coord[:, 2] == 0)
6363
else:
@@ -85,7 +85,7 @@ def test_fetch_invalid():
8585
@pytest.mark.parametrize(
8686
"query, ref_ids",
8787
[
88-
(pubchem.NameQuery("Alanine"), [71080, 602, 5950]),
88+
(pubchem.NameQuery("Alanine"), [155817681, 449619, 7311724, 5950]),
8989
(pubchem.SmilesQuery("CCCC"), [7843]),
9090
(pubchem.InchiQuery("InChI=1S/C4H10/c1-3-4-2/h3-4H2,1-2H3"), [7843]),
9191
(pubchem.InchiKeyQuery("IJDNQMDRQITEOD-UHFFFAOYSA-N"), [7843]),
@@ -138,7 +138,7 @@ def test_search_super_and_substructure(cid, from_atoms, query_type):
138138
NUMBER = 5
139139

140140
original_atoms = mol.MOLFile.read(pubchem.fetch(cid)).get_structure()
141-
141+
142142
if from_atoms:
143143
query = query_type.from_atoms(original_atoms, number=NUMBER)
144144
else:
@@ -148,7 +148,7 @@ def test_search_super_and_substructure(cid, from_atoms, query_type):
148148
# Expect number of returned CIDs to be limited by given max number
149149
assert len(cids) == NUMBER
150150
if query_type == pubchem.SubstructureQuery:
151-
# Expect that the input itself is the top hit
151+
# Expect that the input itself is the top hit
152152
assert cid in cids
153153

154154
for result_cid in cids:

0 commit comments

Comments
 (0)