Debian Codegraph @

docs/guide/compound.md

raw
1 (compound)=
2
3 # Compounds
4
5 The {func}`~pubchempy.get_compounds` function returns a list of {class}`~pubchempy.Compound` objects. You can also instantiate a {class}`~pubchempy.Compound` object directly if you know its CID:
6
7 ```python
8 c = pcp.Compound.from_cid(6819)
9 ```
10
11 ## Dictionary representation
12
13 Each {class}`~pubchempy.Compound` has a `record` property, which is a dictionary that contains the all the information about the compound, produced exactly from the JSON response from the PubChem API. All other properties are derived from this record.
14
15 Additionally, each {class}`~pubchempy.Compound` provides a {meth}`~pubchempy.Compound.to_dict` method that returns PubChemPy's own dictionary representation of the Compound data. As well as being more concisely formatted than the raw `record`, this method also takes an optional parameter to filter the list of the desired properties:
16
17 ```pycon
18 >>> c = pcp.Compound.from_cid(962)
19 >>> c.to_dict(properties=["atoms", "bonds", "inchi"])
20 {'atoms': [{'aid': 1, 'element': 'o', 'x': 2.5369, 'y': -0.155},
21 {'aid': 2, 'element': 'h', 'x': 3.0739, 'y': 0.155},
22 {'aid': 3, 'element': 'h', 'x': 2, 'y': 0.155}],
23 'bonds': [{'aid1': 1, 'aid2': 2, 'order': 'single'},
24 {'aid1': 1, 'aid2': 3, 'order': 'single'}],
25 'inchi': u'InChI=1S/H2O/h1H2'}
26 ```
27
28 ## 3D compounds
29
30 By default, compounds are returned with 2D coordinates. Use the `record_type` keyword argument to specify otherwise:
31
32 ```python
33 pcp.get_compounds("Aspirin", "name", record_type="3d")
34 ```
35
36 Many properties are missing from 3D records, and the following properties are *only* available on 3D records:
37
38 - `volume_3d`
39 - `multipoles_3d`
40 - `conformer_rmsd_3d`
41 - `effective_rotor_count_3d`
42 - `pharmacophore_features_3d`
43 - `mmff94_partial_charges_3d`
44 - `mmff94_energy_3d`
45 - `conformer_id_3d`
46 - `shape_selfoverlap_3d`
47 - `feature_selfoverlap_3d`
48 - `shape_fingerprint_3d`