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(butane_cids.tolist())
[7843, 6360, 161897780, 161295599, 158934736, 158271732, 157632982, 19048342, 19029854, 18402699]
>>> # 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', 'methylcyclopropane;molecular hydrogen', 'carbanylium;propane', 'carbanide;propane', 'acetylene;methane', 'cyclobutane;molecular hydrogen', 'cyclopropane;methane', 'ethane;ethene', 'methane;prop-1-ene']