The resources package#
External data resource integrations to biobuild.
PDBe Compounds#
The Protein Data Bank in Europe (PDBe) provides a database of small molecules that are found in PDB structures. They are available via the PDBe Component Library . biobuild integrates a subset of the database directly for Molecule creation. Since this database is integrated directly in biobuild it can be used offline.
PubChem#
PubChem maintains an extensive database of small molecules. biobuild integrates the PubChem API for Molecule creation.
Since this database is queried online and not integrated directly in biobuild it requires an internet connection.
PubChem follows a different atom labelling convention than the CHARMM force field. Hence, many compounds may not be compatible
with the pre-set patches in biobuild and may thus not work at all or produce erroneous results. To assist in importing
PubChem compounds anyway, biobuild provides a function pubchem_to_cif that can be used to convert PubChem compound
data into a CIF file which can be more easily edited and subsequently loaded into biobuild using the PDBECompounds class
or using Molecule.from_cif(). Also methods such as Molecule.autolabel() are designed to assist in the conversion of PubChem
compounds into CHARMM-compatible molecules.
CHARMM#
CHARMM is a molecular simulation software that is widely used in the field of computational chemistry. It is developed and maintained by the CHARMM Development Project. biobuild integrates the CHARMM force field for pre-defined molecular linkages.
This module defines File parsers and data classes to work with the CHARMM force field
CHARMM files can be read using the CHARMMParser class. Which implements a child-class CHARMMTopology that is used to read and store CHARMM topology files. Specifically, the CHARMMTopology stores the linkage (patches) data from the topology file.
Reading CHARMM files#
The quickest way to read a CHARMM topology file is to use the read_topology function.
import biobuild as bb
charmm_topology_file = "top_all36_prot.rtf"
# read a CHARMM topology file
top = bb.read_topology(charmm_topology_file)
There is an optional argument set_default that is set to True by default. If set to True the parsed object is set as the default object for the current session.
Alternatively, the CHARMMTopology class can be used to read a CHARMM topology file.
from biobuild.resources import CHARMMTopology
# read a CHARMM topology file
top = CHARMMTopology.from_file(charmm_topology_file)
# works the same as
# top = bb.read_topology(charmm_topology_file)
Note
There is currently no implementation of a CHARMM parameter file parser, because biobuild does not use this data. However, the CHARMMParser can be used as a base class to implement a custom parser for CHARMM parameter files.
Saving and loading CHARMM objects#
Because parsing can be a time intensive task, it is recommended to save the parsed objects to a pickle file for later use. In this case a pre-parsed topology object can be loaded using the load method. Both methods accept a file path as argument, and both also have a functional equivalent called save_topology and read_topology (yes, that’s the same as above).
# save the parsed objects to a pickle file
bb.save_topology(top, "top_all36_prot.pkl")
# or
top.save("top_all36_prot.pkl")
# load a CHARMM topology file
top = bb.read_topology("top_all36_prot.pkl")
# or
top = CHARMMTopology.load("top_all36_prot.pkl")
Topologies also support an encoding agnosting export to JSON format using the to_json method (function export_topology). This is useful for sharing topologies with other users who may be using a different version of biobuild and therefore could potentially have issues with pickled objects, or for programmatic creation of new topologies (since JSON is an easier format to work with than the CHARMM topology file format itself).
# export a CHARMM topology file to JSON
top.to_json("top_all36_prot.json")
# or
bb.export_topology(top, "top_all36_prot.json")
Working with CHARMM objects#
Naturally, the CHARMMTopology class includes methods to work with the parsed data, such as has_linkage or get_linkage. They also support adding new data via the the add_linkage method. For these as well (you guessed it) there are functional equivalents, which only work for the currently loaded default topology, however!
# check if a given topology has a linkage
top.has_linkage("DISU") # use a specific topology
# or
bb.has_linkage("DISU") # use the default topology
# get a linkage
top.get_linkage("DISU") # use a specific topology
# or
bb.get_linkage("DISU") # use the default topology
# add a linkage
my_linkage = bb.linkage(...)
top.add_linkage(my_linkage) # use a specific topology
# or
bb.add_linkage(my_linkage) # use the default topology
Setting default CHARMM objects#
biobuild pre-loads a default CHARMM topology for convenience. Many methods that make use of this object such as the attach method of Molecule instances also accept arguments for custom topology objects. For convenience, a custom object can be set as the default, however, using the set_default_topology function.
# set a custom topology object as the default
bb.set_default_topology(top)
Warning
The set_default_{…} functions include an argument overwrite that is set to False by default. If set to True the default object is permanently overwritten and will be used for all future sessions. If set to False (default), the default object is only set for the current session and any future sessions will use the original defaults. In case the defaults were overwritten, they can be reset to the original using the restore_default_{…} functions.
# set a custom topology object as the default
# for the current session only
set_default_topology(top)
# set a custom topology object as the default
# for all future sessions
set_default_topology(top, overwrite=True)
# restore the original default topology object
# for all future sessions
restore_default_topology()
- class biobuild.resources.charmm.CHARMMTopology(id=None)[source]#
Bases:
CHARMMParserA data class and file parser for CHARMM topology files.
- id#
The ID of the topology file
- Type:
str
- patches#
The Linkages (patches, in the CHARMM nomenclature, prefixed with ‘PRES’) in the topology file
- Type:
list of Linkage
- add_patch(patch)[source]#
Add a patch to the topology
- Parameters:
patch (Linkage) – The patch to add
- classmethod from_json(filename: str) CHARMMTopology[source]#
Make a CHARMMTopology from a previously exported JSON file.
- Parameters:
filename (str) – The path to the JSON file
- get_patch(id)[source]#
Get a patch by its ID
- Parameters:
id (str) – The ID of the patch
- Returns:
The patch
- Return type:
- has_patch(id)[source]#
Check if a patch is in the topology
- Parameters:
id (str) – The ID of the patch
- Returns:
True if the patch is in the topology
- Return type:
bool
- property linkages#
- property patches#
- biobuild.resources.charmm.add_linkage(patch, overwrite: bool = False)#
Add a patch to the CHARMM topology.
- Parameters:
patch (Patch) – The patch object
overwrite (bool) – If True, the topology with the added patch is saved to a pickle file and will be used as the default topology for all future sessions.
- biobuild.resources.charmm.add_patch(patch, overwrite: bool = False)[source]#
Add a patch to the CHARMM topology.
- Parameters:
patch (Patch) – The patch object
overwrite (bool) – If True, the topology with the added patch is saved to a pickle file and will be used as the default topology for all future sessions.
- biobuild.resources.charmm.available_linkages()#
Get a list of available patches.
- Returns:
A list of available patches
- Return type:
list
- biobuild.resources.charmm.available_patches()[source]#
Get a list of available patches.
- Returns:
A list of available patches
- Return type:
list
- biobuild.resources.charmm.export_topology(filename: str, topology: CHARMMTopology = None)[source]#
Export a CHARMM topology to a JSON file.
- Parameters:
filename (str) – The name of the topology file
topology (CHARMMTopology) – The topology object. If None, the default topology is used.
- biobuild.resources.charmm.get_default_topology() CHARMMTopology[source]#
Get the default CHARMMTopology object
- Returns:
The default CHARMMTopology object
- Return type:
- biobuild.resources.charmm.get_linkage(name: str)#
Get a patch from the CHARMM topology file.
- Parameters:
name (str) – The name/id of the patch
- Returns:
The patch object
- Return type:
Patch
- biobuild.resources.charmm.get_patch(name: str)[source]#
Get a patch from the CHARMM topology file.
- Parameters:
name (str) – The name/id of the patch
- Returns:
The patch object
- Return type:
Patch
- biobuild.resources.charmm.has_linkage(name: str) bool#
Check if a patch is defined in the CHARMM topology file.
- Parameters:
name (str) – The name of the patch
- Returns:
True if the patch is defined, False otherwise
- Return type:
bool
- biobuild.resources.charmm.has_patch(name: str) bool[source]#
Check if a patch is defined in the CHARMM topology file.
- Parameters:
name (str) – The name of the patch
- Returns:
True if the patch is defined, False otherwise
- Return type:
bool
- biobuild.resources.charmm.read_topology(filename: str, set_default: bool = True) CHARMMTopology[source]#
Make a CHARMMTopology from a CHARMM topology file, a JSON file or a pickle file.
- Parameters:
filename (str) – The name of the topology file
set_default (bool) – If True, the topology is set as the default topology
- Returns:
The parsed topology object
- Return type:
- biobuild.resources.charmm.restore_default_topology(overwrite: bool = True)[source]#
Restore the default CHARMMTopology object from the backup file
- Parameters:
overwrite (bool) – If set to True, the backup is permanently set as the default again.
- biobuild.resources.charmm.save_topology(filename: str, topology: CHARMMTopology = None)[source]#
Save a CHARMMTopology to a pickle file.
- Parameters:
filename (str) – The name of the topology file
topology (CHARMMTopology) – The topology object. If None, the default topology is used.
- biobuild.resources.charmm.set_default_topology(obj, overwrite: bool = False)[source]#
Set a CHARMMTopology object as the new default.
- Parameters:
obj (CHARMMTopology) – The CHARMMTopology object to set as the new default
overwrite (bool) – If set to True, the new object will be permanently saved as the default. Otherwise, the new object will only be used for the current session.
This module defines a Parser to extract information from the PDBE compound library.
Reading the PDBE Compound Library#
The PDBE Compound Library is a database of small molecules that are found in PDB structures. It can be downloaded as an mmCIF file. biobuild provides a parser to extract information from the mmCIF file.
To parse a PDBE Compound Library file, we can use the toplevel function read_compounds or use the PDBECompounds class directly
import biobuild
from biobuild.resources import PDBECompounds
compounds = bb.read_compounds("path/to/pdbe-compounds.cif")
# or
compounds = PDBECompounds.from_file("path/to/pdbe-compounds.cif")
Saving and loading PDBECompounds#
Because parsing may be an intensive operation, the PDBECompounds class implements a save method to save the parsed data to a pickle file. For future sessions the pre-parsed object can be directly loaded using the load method. Naturally, both operations also have a functional equivalent.
# save an existing PDBECompounds object
compounds.save("path/to/pdbe-compounds.pkl")
# or
bb.save_compounds("path/to/pdbe-compounds.pkl", compounds)
# load a pre-parsed PDBECompounds object
compounds = PDBECompounds.load("path/to/pdbe-compounds.pkl")
# or (read_compounds also supports loading)
compounds = bb.read_compounds("path/to/pdbe-compounds.pkl")
In order to export data from the PDBE compounds library, the PDBECompounds class also implements a to_json method to export the data as a JSON file. The JSON file can be loaded again using the from_json class method (or using read_compounds function). This is useful for sharing compound data with others who may use different versions of biobuild and thus may have issues with pickeled objects, or for sharing data with other programs.
# save an existing PDBECompounds object
compounds.to_json("path/to/pdbe-compounds.json")
# or
bb.export_compounds("path/to/pdbe-compounds.json", compounds)
Working with PDBECompounds#
The PDBECompounds class provides a dictionary-like interface to the compounds in the library. It supports a number of query methods unified within the get. Compounds can be obtained from the library from their 3-letter _PDB ID_, their _name_, _chemical formula_, or _SMILES_ or _InChI_ string.
# get a compound by its PDB ID
glc = compounds.get("GLC")
# get a compound by its name
glc = compounds.get("alpha d-glucose", by="name")
# get a compound by its chemical formula
glc = compounds.get("C6 H12 O6", by="formula")
# get a compound by its SMILES string
glc = compounds.get("C([C@@H]1[C@H]([C@@H]([C@H](O[C@@H]1O)O)O)O)O", by="smiles")
# get a compound by its InChI string (note the "InChI=" prefix)
# THIS ALSO USES `by="smiles"`!
glc = compounds.get("InChI=1S/C6H12O6/c7-1-2-3(8)4(9)5(10)6(11)12-2/h2-11H,1H2/t2-,3-,4+,5-,6-/m1/s1", by="smiles")
By default the get method will create a Molecule object from the compound. Other output formats such as biopython.Structure or simple dict are also supported and can be specified using the return_type argument. If multiple compounds match a query, they are returned as a list (unless return_type is a dictionary, in which they are kept as a dictionary).
# get a compound as a `biobuild.Structure` object
glc = compounds.get("GLC", return_type="structure")
# get a compound as a `dict`
glc = compounds.get("GLC", return_type="dict")
Setting default PDBECompounds#
_biobuild_ loads a default PDBECompounds object for convenience. The default instance can be accessed using the get_default_compounds function. A custom instance can be set as the default using the set_default_compounds function.
import biobuild as bb
# get the default PDBECompounds instance
compounds = bb.get_default_compounds()
# ... do something with the compounds
# set a custom PDBECompounds instance as the default
bb.set_default_compounds(compounds)
Warning
The set_default_compounds has an additional keyword argument overwrite which is set to False by default. If set to True the default instance is permanently overwritten by the new one and will be used automatically by all future sessions. This is not recommended as it may lead to unexpected behaviour.
If the user is only interested in working with the default instance rather than a specific PDBECompounds instance, there are a number of toplevel functions available to short-cut the process.
For instance, in order to get the compound glucose from the default instance, we can do
# instead of doing
compounds = bb.get_default_compounds()
glc = compounds.get("GLC", return_type="dict")
# we can do
glc = bb.get_compound("GLC", return_type="dict")
Other toplevel functions indlude has_compound and add_compound.
- class biobuild.resources.pdbe_compounds.PDBECompounds(compounds: dict = None, id=None)[source]#
Bases:
objectThis class wraps a dictionary of PDBE compounds. It facilitates easy data access and searchability for compounds.
- Parameters:
compounds (dict) – A dictionary of PDBE compounds.
id (str, optional) – The ID of the PDBECompounds object. Defaults to None.
- add(mol: Molecule, type: str = None, names: list = None, identifiers: list = None, formula: str = None, one_letter_code: str = None, three_letter_code: str = None)[source]#
Add a compound to the dictionary.
- Parameters:
mol (Molecule) – The compound to add.
type (str, optional) – The type of compound, e.g. “ligand”, “cofactor”, etc.
names (list, optional) – A list of names for the compound.
identifiers (list, optional) – A list of identifiers such as SMILES or InChI for the compound.
formula (str, optional) – The formula of the compound. If not given, it will be calculated from the molecule.
- property formulas: list#
Get a list of all compound formulas.
- Returns:
A list of all compound formulas.
- Return type:
list
- classmethod from_file(filename: str) PDBECompounds[source]#
Create a PDBECompounds object from a cif file.
- Parameters:
filename (str) – The path to the file.
- Returns:
The PDBECompounds object.
- Return type:
- classmethod from_json(filename: str) PDBeCompounds[source]#
Make a PDBECompounds object from a previously exported json file.
- Parameters:
filename (str) – The path to the file.
- Returns:
The PDBECompounds object.
- Return type:
- get(query: str, by: str = 'id', return_type: str = 'molecule')[source]#
Get a compound that matches the given criteria.
- Parameters:
query (str) – The query to search for.
by (str, optional) – The type of query, by default “id”. Possible values are: - “id”: search by compound id - “name”: search by compound name (must match any available synonym exactly) - “formula”: search by compound formula - “smiles”: search by compound smiles (this also works for inchi)
return_type (str, optional) – The type of object to return, by default “molecule”. Possible values are: - “molecule”: return a biobuild Molecule object - “dict”: return a dictionary of the compound data - “structure”: return a biopython Structure object - “residue”: return a biopython Residue object
- Returns:
The object that matches the given criteria, or None if no match was found. If multiple matches are found, a list of objects is returned.
- Return type:
object
- has_residue(query: str, by: str = 'id') bool[source]#
Check if a compound has a residue definition.
- Parameters:
query (str) – The query to search for.
by (str, optional) – The type of query, by default “id”. Possible values are: - “id”: search by compound id - “name”: search by compound name (must match any available synonym exactly) - “formula”: search by compound formula - “smiles”: search by compound smiles (this also works for inchi)
- Returns:
True if the compound has a residue definition, False otherwise.
- Return type:
bool
- property ids: list#
Get a list of all compound ids.
- Returns:
A list of all compound ids.
- Return type:
list
- classmethod load(filename: str) PDBECompounds[source]#
Load a PDBECompounds object from a pickle file.
- Parameters:
filename (str) – The path to the file.
- Returns:
The PDBECompounds object.
- Return type:
- merge(other: PDBECompounds) None[source]#
Merge another compounds dictionary into this one.
- Parameters:
other (PDBECompounds) – The other object.
- relabel_atoms(structure)[source]#
Relabel the atoms of a Molecule object to match the atom names of the given compound.
- Parameters:
structure – A Molecule object or biopython object holding at least one residue.
- Returns:
The object with relabeled atoms.
- Return type:
object
- remove(id: str) None[source]#
Remove a compound from the dictionary.
- Parameters:
id (str) – The id of the compound to remove.
- save(filename: str = None) None[source]#
Save the PDBECompounds object to a pickle file.
- Parameters:
filename (str) – The path to the file. By default the same file used to load the object is used. If no file is available, a ValueError is raised.
- to_json(filename: str = None) None[source]#
Export the PDBECompounds object to a json file.
- Parameters:
filename (str) – The path to the file. By default the same file used to load the object is used. If no file is available, a ValueError is raised.
- biobuild.resources.pdbe_compounds.add_compound(mol: Molecule, type: str = None, names: list = None, identifiers: list = None, formula: str = None, overwrite: bool = False)[source]#
Add a compound to the currently loaded default PDBECompounds instance.
- Parameters:
mol (Molecule) – The molecule to add.
type (str, optional) – The type of compound. For instance protein, dna, rna, ligand, water, ion, other.
names (list, optional) – A list of names for the compound.
identifiers (list, optional) – A list of identifiers for the compound.
formula (str, optional) – The chemical formula of the compound.
overwrite (bool, optional) – Whether to hardcode overwrite the current default PDBECompounds instance. This will make the compound available for all future sessions.
- biobuild.resources.pdbe_compounds.export_compounds(filename: str, compounds: PDBECompounds = None)[source]#
Export the PDBECompounds object to a JSON file.
- Parameters:
filename (str) – The path to the JSON file to save to.
compounds (PDBECompounds, optional) – The PDBECompounds object to save. If not provided, the default PDBECompounds object is used.
- biobuild.resources.pdbe_compounds.get_compound(compound: str, search_by: str = None, return_type: str = 'molecule')[source]#
Get a compound from the currently loaded default PDBECompounds instance.
- Parameters:
compound (str) – The compound to get.
search_by (str, optional) – The type of search to perform. One of id, name, formula, smiles (includes inchi). By default, all search types are used.
return_type (str, optional) – The type of object to return. One of molecule (a biobuild Molecule), structure (a biobuild structure only, does not include connectivity), dict (the compound data and coordinate dictionaries). Defaults to molecule.
- Returns:
The molecule object, structure, or tuple of dictionaries. If multiple compounds are found matching, they are returned as a list.
- Return type:
object or list
- biobuild.resources.pdbe_compounds.get_default_compounds() PDBECompounds[source]#
Get the currently loaded default PDBECompounds instance.
- Returns:
The currently loaded default PDBECompounds instance.
- Return type:
- biobuild.resources.pdbe_compounds.has_compound(compound: str, search_by: str = None) bool[source]#
Checks if a given compound is available in the currently loaded default PDBECompounds instance.
- Parameters:
compound (str) – The compound to check.
search_by (str, optional) – The type of search to perform. One of id, name, formula, smiles (includes inchi). By default, all search types are used.
- biobuild.resources.pdbe_compounds.load_all_compounds()[source]#
Load all available components into the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.load_amino_acids()[source]#
Load amino acid components into the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.load_lipids()[source]#
Load lipid components into the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.load_nucleotides()[source]#
Load nucleotide components into the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.load_small_molecules()[source]#
Load small molecule components into the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.load_sugars()[source]#
Load sugar components into the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.read_compounds(filename: str, set_default: bool = True) PDBECompounds[source]#
Reads a PDBECompounds object from a CIF, JSON, or pickle file.
- Parameters:
filename (str) – The path to the file to read.
set_default (bool, optional) – Whether to set the read PDBECompounds object as the default. Defaults to True.
- Returns:
The PDBECompounds object parsed from the file.
- Return type:
- biobuild.resources.pdbe_compounds.restore_default_compounds(overwrite: bool = True)[source]#
Restore the default PDBECompounds object from the backup file
- Parameters:
overwrite (bool) – If set to True, the backup file will be permanently saved as the default again.
- biobuild.resources.pdbe_compounds.save_as_default_compounds(obj)[source]#
Save a PDBECompounds object as the new default. This will leave the currently active default object unchanged, but will overwrite the default file for any future sessions.
- Parameters:
obj (PDBECompounds) – The PDBECompounds object to set as the new default
- biobuild.resources.pdbe_compounds.save_compounds(filename: str, compounds: PDBECompounds = None)[source]#
Saves a PDBECompounds object to a file.
- Parameters:
filename (str) – The path to the pickle file to save to.
compounds (PDBECompounds, optional) – The PDBECompounds object to save. If not provided, the default PDBECompounds object is used.
- biobuild.resources.pdbe_compounds.set_default_compounds(obj, overwrite: bool = False)[source]#
Set a PDBECompounds object as the new default.
- Parameters:
obj (PDBECompounds) – The PDBECompounds object to set as the new default
overwrite (bool) – If set to True, the new object will be permanently saved as the default. Otherwise, the new object will only be used for the current session.
- biobuild.resources.pdbe_compounds.subset_compounds_by_types(*t: str) PDBECompounds[source]#
Get a new PDBECompounds object containing only compounds from the currently loaded default compounds of the given types.
- Parameters:
t (str) – The types to include.
- Returns:
A new PDBECompounds object containing only compounds of the given types.
- Return type:
- biobuild.resources.pdbe_compounds.unload_all_compounds()[source]#
Unload all available components from the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.unload_amino_acids()[source]#
Unload amino acid components from the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.unload_by_types(*t: str)[source]#
Unload all loaded compounds from the default PDBECompounds instance of a given types.
- Parameters:
t (str) – The types to unload.
- biobuild.resources.pdbe_compounds.unload_lipids()[source]#
Unload lipid components from the default PDBECompounds instance.
- biobuild.resources.pdbe_compounds.unload_nucleotides()[source]#
Unload nucleotide components from the default PDBECompounds instance.
This module contains functions for interacting with PubChem.
Remotely accessing PubChem#
The query function can be used to query PubChem for a compound. It returns the 2D and 3D
representations of the compound as pubchempy.Compound objects. The pubchempy package is
used to perform the query. The query function takes a query string and a query type as
input. The query type can be one of “name”, “cid”, “smiles”, “inchi”, “inchikey”.
The returned outputs can be used to create Molecule objects using a function biobuild.Molecule._molecule_from_pubchem which is by default integrated
into the biobuild.Molecule.Molecule.from_pubchem class method.
Converting PubChem data to CIF#
PubChem allows data downloads in the form of JSON and SDF files. The JSON file contains the descriptive data of a chemical compound while the SDF contains
the 3D conformer of the compound. The pubchem_to_cif function can be used to convert these files into a CIF file which can be used to load the compound
into biobuild using the PDBECompounds class. The function takes the paths to the JSON and SDF files as input and optionally an ID for the compound
and a path to the CIF file to write. If no ID is specified, the function will try to infer an ID from the JSON file.
from biobuild.resources import pubchem
# ... download JSON and SDF files from PubChem for some compound
json_file = "some_compound.json"
sdf_file = "some_compound.sdf"
# convert to CIF
pubchem.pubchem_to_cif(json_file, sdf_file, id="SOMECOMPOUND", cif_file="some_compound.cif")
- biobuild.resources.pubchem.pubchem_to_cif(json_file: str, sdf_file: str, id: str = None, cif_file: str = None)[source]#
Convert a downloaded PubChem data entry to a CIF file. This is useful for preparing a PubChem component for use in biobuild - i.e. to relabel atoms as required by the CHARMM force field. Simply download the PubChem data for a molecule in form of the JSON data and the 3D conformer SDF file and pass the file names to this function to generate a CIF file from them which can be loaded into biobuild using the PDBECompounds class.
- Parameters:
json_file (str) – The path to the JSON file containing the PubChem data of the molecule.
sdf_file (str) – The path to the SDF file containing the 3D conformer of the molecule.
id (str, optional) – The ID of the molecule. If not specified, an id will be inferred from the JSON file.
cif_file (str, optional) – The path to the CIF file to write. If not specified, the CIF file will be written to the same directory as the JSON file with the same name (but adjusted suffix).
- biobuild.resources.pubchem.query(_query: str, by: str = 'name', idx: int = 0)[source]#
Query PubChem for a compound.
- Parameters:
_query (str) – The query string
by (str, optional) – The type of query to perform. One of “name”, “cid”, “smiles”, “inchi”, “inchikey”. Defaults to “name”.
idx (int, optional) – The index of the compound to return if multiple compounds are found. Defaults to 0. Only one compound will be returned at a time.
- Returns:
The 2D and 3D representations of the compound
- Return type:
tuple