@@ -84,12 +84,12 @@ class NameQuery(Query):
84
84
--------
85
85
86
86
>>> print(search(NameQuery("Alanine")))
87
- [5950, 602, 71080 ]
87
+ [5950, 449619, 7311724, 155817681 ]
88
88
"""
89
89
90
90
def __init__ (self , name ):
91
91
self ._name = name
92
-
92
+
93
93
def get_input_url_path (self ):
94
94
return "compound/name"
95
95
@@ -107,7 +107,7 @@ class SmilesQuery(Query):
107
107
----------
108
108
smiles : str
109
109
The *SMILES* string.
110
-
110
+
111
111
Examples
112
112
--------
113
113
@@ -117,7 +117,7 @@ class SmilesQuery(Query):
117
117
118
118
def __init__ (self , smiles ):
119
119
self ._smiles = smiles
120
-
120
+
121
121
def get_input_url_path (self ):
122
122
return "compound/smiles"
123
123
@@ -134,7 +134,7 @@ class InchiQuery(Query):
134
134
----------
135
135
inchi : str
136
136
The *InChI* string.
137
-
137
+
138
138
Examples
139
139
--------
140
140
@@ -144,7 +144,7 @@ class InchiQuery(Query):
144
144
145
145
def __init__ (self , inchi ):
146
146
self ._inchi = inchi
147
-
147
+
148
148
def get_input_url_path (self ):
149
149
return "compound/inchi"
150
150
@@ -161,7 +161,7 @@ class InchiKeyQuery(Query):
161
161
----------
162
162
inchi_key : str
163
163
The *InChI* key.
164
-
164
+
165
165
Examples
166
166
--------
167
167
@@ -171,7 +171,7 @@ class InchiKeyQuery(Query):
171
171
172
172
def __init__ (self , inchi_key ):
173
173
self ._inchi_key = inchi_key
174
-
174
+
175
175
def get_input_url_path (self ):
176
176
return "compound/inchikey"
177
177
@@ -199,7 +199,7 @@ class FormulaQuery(Query):
199
199
The maximum number of matches that this query may return.
200
200
By default, the *PubChem* default value is used, which can be
201
201
considered unlimited.
202
-
202
+
203
203
Examples
204
204
--------
205
205
@@ -214,7 +214,7 @@ def __init__(self, formula, allow_other_elements=False, number=None):
214
214
self ._formula = formula
215
215
self ._allow_other_elements = allow_other_elements
216
216
self ._number = number
217
-
217
+
218
218
@staticmethod
219
219
def from_atoms (atoms , allow_other_elements = False , number = None ):
220
220
"""
@@ -247,7 +247,7 @@ def from_atoms(atoms, allow_other_elements=False, number=None):
247
247
for element in sorted_elements :
248
248
formula += _format_element (element , element_counter [element ])
249
249
return FormulaQuery (formula , allow_other_elements , number )
250
-
250
+
251
251
def get_input_url_path (self ):
252
252
# The 'fastformula' service seems not to accept the formula
253
253
# in the parameter section of the request
@@ -287,7 +287,7 @@ class StructureQuery(Query, metaclass=abc.ABCMeta):
287
287
sdf : str, optional
288
288
A query structure as SDF formatted string.
289
289
Usually :meth:`from_atoms()` is used to create the SDF from an
290
- :class:`AtomArray`.
290
+ :class:`AtomArray`.
291
291
cid : int, optional
292
292
The query structure given as CID.
293
293
number : int, optional
@@ -351,7 +351,7 @@ def from_atoms(cls, atoms, *args, **kwargs):
351
351
sdf = "\r \n " .join (mol_file .lines ) + "\r \n $$$$\r \n " ,
352
352
** kwargs
353
353
)
354
-
354
+
355
355
def get_input_url_path (self ):
356
356
input_string = f"compound/{ self .search_type ()} /{ self ._query_key } "
357
357
if self ._query_key == "cid" :
@@ -384,7 +384,7 @@ def get_files(self):
384
384
return {"sdf" : self ._query_val }
385
385
else :
386
386
return {}
387
-
387
+
388
388
@abc .abstractmethod
389
389
def search_type (self ):
390
390
"""
@@ -434,7 +434,7 @@ class SuperOrSubstructureQuery(StructureQuery, metaclass=abc.ABCMeta):
434
434
sdf : str, optional
435
435
A query structure as SDF formatted string.
436
436
Usually :meth:`from_atoms()` is used to create the SDF from an
437
- :class:`AtomArray`.
437
+ :class:`AtomArray`.
438
438
cid : int, optional
439
439
The query structure given as CID.
440
440
number : int, optional
@@ -463,7 +463,7 @@ class SuperOrSubstructureQuery(StructureQuery, metaclass=abc.ABCMeta):
463
463
stereo : {'ignore', 'exact', 'relative', 'nonconflicting'}, optional
464
464
How to handle stereo.
465
465
(Default: 'ignore')
466
-
466
+
467
467
Notes
468
468
-----
469
469
Optional parameter descriptions are taken from the *PubChem* REST
@@ -488,7 +488,7 @@ def __init__(self, **kwargs):
488
488
self ._options [option ] = value
489
489
del kwargs [option ]
490
490
super ().__init__ (** kwargs )
491
-
491
+
492
492
def search_options (self ):
493
493
return self ._options
494
494
@@ -514,7 +514,7 @@ class SuperstructureQuery(SuperOrSubstructureQuery):
514
514
sdf : str, optional
515
515
A query structure as SDF formatted string.
516
516
Usually :meth:`from_atoms()` is used to create the SDF from an
517
- :class:`AtomArray`.
517
+ :class:`AtomArray`.
518
518
cid : int, optional
519
519
The query structure given as CID.
520
520
number : int, optional
@@ -543,7 +543,7 @@ class SuperstructureQuery(SuperOrSubstructureQuery):
543
543
stereo : {'ignore', 'exact', 'relative', 'nonconflicting'}, optional
544
544
How to handle stereo.
545
545
(Default: 'ignore')
546
-
546
+
547
547
Notes
548
548
-----
549
549
Optional parameter descriptions are taken from the *PubChem* REST
@@ -587,7 +587,7 @@ class SubstructureQuery(SuperOrSubstructureQuery):
587
587
sdf : str, optional
588
588
A query structure as SDF formatted string.
589
589
Usually :meth:`from_atoms()` is used to create the SDF from an
590
- :class:`AtomArray`.
590
+ :class:`AtomArray`.
591
591
cid : int, optional
592
592
The query structure given as CID.
593
593
number : int, optional
@@ -616,7 +616,7 @@ class SubstructureQuery(SuperOrSubstructureQuery):
616
616
stereo : {'ignore', 'exact', 'relative', 'nonconflicting'}, optional
617
617
How to handle stereo.
618
618
(Default: 'ignore')
619
-
619
+
620
620
Notes
621
621
-----
622
622
Optional parameter descriptions are taken from the *PubChem* REST
@@ -666,22 +666,22 @@ class SimilarityQuery(StructureQuery):
666
666
sdf : str, optional
667
667
A query structure as SDF formatted string.
668
668
Usually :meth:`from_atoms()` is used to create the SDF from an
669
- :class:`AtomArray`.
669
+ :class:`AtomArray`.
670
670
cid : int, optional
671
671
The query structure given as CID.
672
672
number : int, optional
673
673
The maximum number of matches that this query may return.
674
674
By default, the *PubChem* default value is used, which can
675
675
be considered unlimited.
676
-
676
+
677
677
Notes
678
678
-----
679
679
The conformation based similarity measure uses *shape-Tanimoto* and
680
680
*color-Tanimoto* scores :footcite:`Kim2018`.
681
681
682
682
References
683
683
----------
684
-
684
+
685
685
.. footbibliography::
686
686
687
687
Examples
@@ -700,11 +700,11 @@ def __init__(self, threshold=0.9, conformation_based=False, **kwargs):
700
700
self ._threshold = threshold
701
701
self ._conformation_based = conformation_based
702
702
super ().__init__ (** kwargs )
703
-
703
+
704
704
def search_type (self ):
705
705
dim = "3d" if self ._conformation_based else "2d"
706
706
return f"fastsimilarity_{ dim } "
707
-
707
+
708
708
def search_options (self ):
709
709
return {"threshold" : int (round (self ._threshold * 100 ))}
710
710
@@ -730,14 +730,14 @@ class IdentityQuery(StructureQuery):
730
730
sdf : str, optional
731
731
A query structure as SDF formatted string.
732
732
Usually :meth:`from_atoms()` is used to create the SDF from an
733
- :class:`AtomArray`.
733
+ :class:`AtomArray`.
734
734
cid : int, optional
735
735
The query structure given as CID.
736
736
number : int, optional
737
737
The maximum number of matches that this query may return.
738
738
By default, the *PubChem* default value is used, which can
739
739
be considered unlimited.
740
-
740
+
741
741
Examples
742
742
--------
743
743
@@ -753,28 +753,28 @@ class IdentityQuery(StructureQuery):
753
753
def __init__ (self , identity_type = "same_stereo_isotope" , ** kwargs ):
754
754
self ._identity_type = identity_type
755
755
super ().__init__ (** kwargs )
756
-
756
+
757
757
def search_type (self ):
758
758
return "fastidentity"
759
-
759
+
760
760
def get_params (self ):
761
761
# Use 'get_params()' instead of 'search_options()', since the
762
762
# parameter 'identity_type' in the REST API is *snake case*
763
763
# -> Conversion to *camel case* is undesirable
764
764
params = super ().get_params ()
765
765
params ["identity_type" ] = self ._identity_type
766
766
return params
767
-
767
+
768
768
769
769
770
770
771
771
def search (query , throttle_threshold = 0.5 , return_throttle_status = False ):
772
772
"""
773
773
Get all CIDs that meet the given query requirements,
774
774
via the PubChem REST API.
775
-
775
+
776
776
This function requires an internet connection.
777
-
777
+
778
778
Parameters
779
779
----------
780
780
query : Query
@@ -787,7 +787,7 @@ def search(query, throttle_threshold=0.5, return_throttle_status=False):
787
787
If ``None`` is given, the execution is never halted.
788
788
return_throttle_status : float, optional
789
789
If set to true, the :class:`ThrottleStatus` is also returned.
790
-
790
+
791
791
Returns
792
792
-------
793
793
ids : list of int
@@ -796,12 +796,12 @@ def search(query, throttle_threshold=0.5, return_throttle_status=False):
796
796
The :class:`ThrottleStatus` obtained from the server response.
797
797
This can be used for custom request throttling, for example.
798
798
Only returned, if `return_throttle_status` is set to true.
799
-
799
+
800
800
Examples
801
801
--------
802
802
803
803
>>> print(search(NameQuery("Alanine")))
804
- [5950, 602, 71080 ]
804
+ [5950, 449619, 7311724, 155817681 ]
805
805
"""
806
806
# Use POST to be compatible with the larger payloads
807
807
# of structure searches
0 commit comments