biotite.database.pubchem.fetch_property

biotite.database.pubchem.fetch_property(cids, name, throttle_threshold=0.5, return_throttle_status=False)[source]

Download the given property for the given CID(s).

This function requires an internet connection.

Parameters
cidsint or iterable object or int

A single compound ID (CID) or a list of CIDs to get the property for.

namestr

The name of the desired property. Valid properties are given in the PubChem REST API documentation.

throttle_thresholdfloat or None, optional

A value between 0 and 1. If the load of either the request time or count exceeds this value the execution is halted. See ThrottleStatus for more information. If None is given, the execution is never halted.

return_throttle_statusfloat, optional

If set to true, the ThrottleStatus of the final request is also returned.

Returns
propertystr or list of str

The requested property for each given CID. If a single CID was given in cids, a single string is returned. If a list (or other iterable object) was given, a list of strings is returned.

throttle_statusThrottleStatus

The ThrottleStatus obtained from the server response. This can be used for custom request throttling, for example. Only returned, if return_throttle_status is set to true.

Examples

>>> butane_cids = np.array(search(FormulaQuery("C4H10")))
>>> # Filter natural isotopes...
>>> n_iso = np.array(fetch_property(butane_cids, "IsotopeAtomCount"), dtype=int)
>>> # ...and neutral compounds
>>> charge = np.array(fetch_property(butane_cids, "Charge"), dtype=int)
>>> butane_cids = butane_cids[(n_iso == 0) & (charge == 0)]
>>> print(sorted(butane_cids.tolist()))
[6360, 7843, 18402699, 19029854, 19048342, 157632982, 158271732, 158934736, 161295599, 161897780]
>>> # Get the IUPAC names for each compound
>>> iupac_names = fetch_property(butane_cids, "IUPACName")
>>> # Compounds with multiple molecules use ';' as separator
>>> print(iupac_names)
['butane', '2-methylpropane', 'methane;prop-1-ene', 'ethane;ethene', 'cyclopropane;methane', 'cyclobutane;molecular hydrogen', 'acetylene;methane', 'carbanide;propane', 'carbanylium;propane', 'methylcyclopropane;molecular hydrogen']