The core package#
The core classes and functions of biobuild
The Molecule module#
The Molecule is the heart of the biobuild package. It is a class that handles molecular structures and allows the user to easily assemble them into larger constructs. The Molecule is a child of the BaseEntity class that provides most of the functionality. The Molecule module defines additionally a number of toplevel functions to easily create new molecules by querying databases or reading files.
The Molecule class is a wrapper around a biopython structure and a core part of biobuild functionality. It provides a convenient interface to molecular structures and their properties, such as atoms, bonds, residues, chains, etc.
Note
To help with identifying individual atoms, residues, etc. biobuild uses a different identification scheme than biopython does. Therefore biobuild comes with its own child classes of the biopython classes that are used to represent the structure. These classes are called Atom, Residue, Chain, etc. and can be used as drop-in replacements for the biopython classes and should not break any existing code. However, in case any incompatibility is observed anyway, the classes are equipped with a to_biopython method that will remove the biobuild overhead and return pure biopython objects (this is not an in-place operation, however, and will return a new object).
Making Molecules#
The easiest way to make a new molecule is to use the toplevel molecule function, which will automatically try to detect the type of user provided input and generate a molecule from it. Currently supported inputs are: - A biopython structure - A PDB id - A PDB file - A CIF file - A SMILES string - An InChI string - An IUPAC name or abbreviation, or any name that matches a known compound synonym that is associated with the PubChem database
from biobuild import molecule
my_glucose = molecule("GLC") # use the PDB id
# or
my_glucose = molecule("GLC.pdb") # use the PDB file
# or
my_glucose = molecule("alpha-d-glucose") # use the name
# ...
Since the molecule function is a try-and-error function it is convenient but not the most efficient. Hence, the Molecule class offers already a number of convenient methods to easily generate molecules directly from specified data sources. Available methods are:
Molecule.from_pdb to generate a molecule from a PDB file
Molecule.from_cif to generate a molecule from a CIF file
Molecule.from_smiles to generate a molecule from a SMILES string
Molecule.from_pubchem to generate a molecule from a PubChem entry
Molecule.from_compound to generate a molecule from a PDBECompounds entry
Molecule.from_rdkit to generate a molecule from an RDKit molecule object
Hence, if we know that “glucose” is already available in our local PDBECompounds database, we can generate the molecule also as follows:
from biobuild import Molecule
my_glucose = Molecule.from_compound("GLC") # use the PDB id
The quickest way to query the local PDBECompounds database is to use the PDB Id of the desired compounds. However, the from_compound accepts other inputs as well. The database is queried using the by parameter, which can be one of the following: - “id” for the PDB id (default) - “name” for the name of the compound (must match any known synonym of the iupac name) - “formula” for the chemical formula (usually ambiguous and will therefore often raise an error) - “smiles” for the SMILES string (also accepts InChI)
# create a new glucose molecule
glc = Molecule.from_compound("alpha-d-glucose", by="name") # use the name
Saving Molecules#
If a molecule is created from a large PDB file and has undergone a lot of preprocessing, it may be useful to save the molecule to a pickle file which can be loaded again later to avoid repeated preprocessing. This can be done using the save and load methods.
# save the molecule to a pickle file
my_molecule.save("my_molecule.pkl")
# load the molecule from the pickle file
my_molecule = Molecule.load("my_molecule.pkl")
Modifying Molecules#
Once a molecule is created, it can be modified in a number of ways. The most common modifications are - adding bonds (because when loading from a PDB file, bonds are not inferred automatically!) - adding additional residues and atoms - removing residues and atoms - adjusting labelling (e.g. changing the chain names and residue seqids)
Adding bonds#
To add a bond between two atoms, we use the add_bond method, which expects two arguments for the two connected atoms. The atoms can be specified by their full_id tuple, their id string, their serial_number (always starting at 1) or directly (the biopython.Atom object).
glc = Molecule.from_compound("GLC")
# add a bond between the first and second atom
glc.add_bond(1, 2)
# and also add a bond between "O1" and "HO1" atoms
glc.add_bond("O1", "HO1")
Already for small molecules such as glucose with only 24 atoms, it would be very tedious to add all bonds manually. Good thing that the molecules created using from_compound or from_pdb already contain all the default bonds!
However, in case the bonds are missing, or the PDB file did not specify any to begin with, the Molecule class offers two methods: apply_standard_bonds and infer_bonds. The former uses reference connectivity information from the PDBECompounds database or CHARMMTopology to add all bonds that are known for the compound (if it exists in the database). The latter will use a simple distance-based approach to infer bonds between atoms that are closer than a specified threshold (default: 1.6 Å), which can be restricted further to a min-max window.
# add all standard bonds for Glucose
glc.apply_standard_bonds()
# add all bonds that are closer than 1.6 Å
glc.infer_bonds(bond_length=1.6)
# add all bonds that are closer than 1.6 Å, but not closer than 1.0 Å
glc.infer_bonds(bond_length=(1.0, 1.6))
Note
By default infer_bonds will not attempt to add bonds between atoms that belong to different residues. This is because in cases of suboptimal conformations or in very large structures atoms that are close in space may not be connected in the structure. To override this behaviour, set the restrict_residues parameter to False.
# add all bonds that are closer than 1.6 Å, even if they belong to different residues
glc.infer_bonds(bond_length=1.6, restrict_residues=False)
Residue Connections#
Alternatively, instead of infer_bonds one may use infer_residue_connections to get bonds that connect different residues. This method will infer all bonds between atoms from different residues based on the distance between them. The inferred bonds are saved in the Molecule and also returned in a list. If the optional argument triplet is set to True, the methodd will also return the bonds immediately adjacent to the inferred bonds.
Take the following example of a molecule with two residues A and B that are connected by a bond between OA and (1)CB:
connection --> OA OB --- H
/ \ /
(1)CA --- (2)CA (1)CB
/ \ \
(6)CA (3)CA (2)CB --- (3)CB
\ /
(5)CA --- (4)CA
If triplet=False the method will only return the bond between OA and (1)CB. However, if triplet=True it will also return the bond between (2)CA and OA - thus forming a triplet of atoms (2)CA, OA and (1)CB that connect the two residues A and B.
# infer all bonds between atoms from different residues
>>> glc.infer_residue_connections(triplet=False)
[(OA, (1)CB)]
>>> glc.infer_residue_connections(triplet=True)
[(OA, (1)CB), ((2)CA, OA)]
Adding residues and atoms#
To add one or more new residue(s), we use the add_residues method, which expects a number biobuild.Residue objects as unnamed arguments. Similarly, to add one or more new atom(s), we use the add_atoms method, which expects a number of biobuild.Atom objects as unnamed arguments. Both methods allow to specify the parent object (chain or residue) via an optional argument and will automatically choose the last chain or residue if none is specified.
from biobuild import Residue, Atom
new_residue = Residue("XYZ", 1, " ")
# do things with the residue here
# ...
# add the residue to the molecule
# (add it to the last chain, whichever that may be)
glc.add_residues(new_residue)
new_atom = Atom("X", [0, 0, 0])
# add the atom to the first residue in the `glc` molecule
glc.add_atoms(new_atom, residue=1)
Removing residues and atoms#
In order to remove residues or atoms or bonds, we can use the remove_residues, remove_atoms and remove_bond`(yes, singluar!) methods. They work exactly like their `add_ counterparts, but instead of adding, they remove the specified objects.
# remove the first residue
glc.remove_residues(1)
# remove the first atom
glc.remove_atoms(1)
# remove the bond between the first and second atom
glc.remove_bond(1, 2)
Warning
When adding and removing atoms and residues, the Molecule object will not automatically update the biopython.Structure object as well as its internal connectivity graph (the AtomGraph). However, if the user chooses to edit the biopython structure directly, the AtomGraph will not be updated automatically! In this case, the user must call the update_atom_graph method to update the AtomGraph manually.
# add a new residue to the molecule
glc.add_residues(new_residue)
# now add atoms into the residue directly instead of via `add_atoms`
new_residue.add(new_atom)
# now update the graph
glc.update_atom_graph()
Adjusting labelling#
Single-residue molecules that were loaded from a PDB file may not use the same atom labelling as the PDBE and CHARMM databases. In order to quickly adjust the labelling, a method autolabel exists. autolabel uses the atom connectivity and a rule-based algorithm to infer the most likely atom labels. However, since this method is not perfect, it is recommended to check the labelling afterwards and adjust it manually if necessary.
If working with large molecules that follow another labelling scheme it may be more efficient to simply define your own linkage recipies or patches (see the documentation of linkages) that use the the appropriate labelling scheme.
# load a molecule from a PDB file
glc = Molecule.from_pdb("glucose.pdb")
# adjust the labelling
glc.autolabel()
# save the molecule to a new PDB file
glc.to_pdb("glucose_autolabelled.pdb")
Another common operation is the adjustment of chain names and residue seqids. This can be done using the reindex method. This method accepts three starting values for the chain name, residue seqid and atom serial number and will then reindex all chains, residues and atoms to ensure they are continuously numbered and labelled. Some internal methods used when connecting different molecules are reliant on a continuous numbering scheme, so this method should be called before connecting molecules that were loaded from PDB files.
# load a molecule from a PDB file
glc = Molecule.from_pdb("glucose.pdb")
# reindex the molecule
glc.reindex()
We can also use one molecule as a “reference” for reindexing another molecule to make sure there are now labelling conflicts between them in case we want to connect them together later (this is usually done internally by _biobuild_ automatically).
# load a molecule from a PDB file
glc = Molecule.from_pdb("glucose.pdb")
# load another molecule from a PDB file
cel = Molecule.from_pdb("cellulose.pdb")
cel.reindex() # make sure we have a continuous numbering scheme
# reindex the glucose molecule using the cellulose molecule as a reference
cel.adjust_indexing(glc)
Connecting Molecules#
Since most modifications are not simply single residues but rather complex structures, the second main purpose of a Molecule is to be easily connected to other Molecules to form a larger structure. To this end, the Molecule class provides a number of methods to easily assemble complex structures from small single residue molecules.
Forming Polymers#
The simplest way to generate a large structure is probably the repeat method, which will repeat the given molecule n times to form a homo-polymer.
# create a glucose molecule
glc = Molecule.from_compound("GLC")
# create cellulose from glucose
# using a 1-4 beta-beta glycosidic linkage
# which is pre-defined in the default CHARMMTopology
glc.repeat(10, "14bb")
# Now we have a cellulose of 10 glucoses
In the above example we used the repeat method explicitly, but we could also achieve the same with the short-hand *=. For this to work, we need to specify the linkage type beforehand. We do this by setting the patch attribute before using any operator.
# specify the "default" linkage type for connecting
# other molecules to this glucose
glc.linkage = "14bb"
# now make a cellulose by multiplying glucoses
glc *= 20
# Now we have a cellulose of 20 glucoses
If we wish to keep glc as a single residue Glucose and still get our desired cellulose, we can set inplace=False when calling repeat or simply use the * operator, both of which will have the same effect of creating a new copy that houses the appropriate residues.
cel = glc.repeat(10, "14bb", inplace=False)
# or (equivalently)
glc.patch = "14bb"
cel = glc * 10
Connecting different Molecules#
What if we want to connect different molecules? For example, we may want to connect a Galactose to a Glucose to form Lactose. This can be achieved using the attach method, which will attach a given molecule to to another molecule.
glc = Molecule.from_compound("GLC")
gal = Molecule.from_compound("GAL")
# attach the galactose to the glucose
# (we want a copy, so we set inplace=False just like with 'repeat')
lac = glc.attach(gal, "14bb", inplace=False)
# Now we have a lactose molecule
In the above example, the attach method is used to attach the galactose molecule to the glucose, but for those among us who prefer a more shorty syntax, the + operator will do the same thing.
# specify that incoming molecules shall be
# attached using a 1-4 beta linkage
glc.linkage = "14bb"
# now attach the galactose to the glucose
lac = glc + gal
Of course, if there is a + operator there should also be a += operator, which is simply the equivalent of attach with inplace=True.
glc.linkage = "14bb"
glc += gal
# Now 'glc' is a lactose molecule
Setting default Modifiers#
So far, we have always worked with a 1-4 beta-beta glycosidic linkage, which we apparently could select using the string “14bb”. But what if we want to use a different linkage type? For example, a 1-4 alpha-beta glycosidic linkage? You of course noticed, that attach and repeat accept an argument link which allows you to specify the linkage type, and that if you leave it blank the default linkage type is used. But how do we set the default linkage type?
Let’s first check what linkage types are available by default anyway. Have you noticed an argument named _topology at the end of the attach or repeat methods? The topology refers to the underlying _CHARMM_ topology which hosts the linkage type information. By default a topology is already loaded in _biobuild_’s framework so it is not necessary for the user to specify anything here, but we can check which linkage types are available by:
import biobuild as bb
# get the default topology
topology = bb.get_default_topology()
print(topology.patches)
Any of these linkages can be referenced by their name, e.g. “14bb” or “14ab”.
Wait a second, my desired linkage is not in the list! What now?! Well, you can always define a new Linkage to suit your needs. Check out the documentation on linkages for more information on how to do this. If you have your desired linkage ready to go, set it as the default by:
my_molecule.linkage = my_linkage
# or if you feel "super correct"
my_molecule.set_linkage(my_linkage)
# or if you feel "extra cocky"
my_molecule % my_linkage # <- the modulo operator assignes the "modifier" to the molecule
Now any call to attach, repeat, or any of its operator proxies will use your defined linkage by default.
Setting the default Residue for attachment#
When defining a Linkage we specify which atoms are supposed to be connected and removed, but we do not specify which residues these atoms belong to. We specify this as arguments inside the attach method for instance, but we can also leave this blank, in which case the last residue in the molecule is used by default. This is obviously not always what we want, however! Hence, if we do not want to specify the residue for attachment at every attach call or if we want to use the + operator, we can set the default residue for attachment by setting the attach_residue attribute:
# set the default attachment residue to the first residue
my_molecule.attach_residue = 1
# or
my_molecule.set_attach_residue(1)
# or (if you feel "extra cocky")
my_molecule @ 1 # <- the 'at' operator sets the attachment residue
# serial number indexing also works in reverse
# (set the second last residue as the default attachment residue)
my_molecule.attach_residue = -2
- class biobuild.core.Molecule.Molecule(structure, root_atom: str | int | Atom = None, model: int = 0, chain: str = None)[source]#
Bases:
BaseEntityA molecule to add onto a scaffold. A molecule consists of a single chain.
- Parameters:
structure (bio.PDB.Structure) – A biopython structure object
root_atom (str or int or Atom) – The id or the serial number of the root atom at which the molecule would be attached to a another structure such as protein scaffold or another Molecule.
model (int) – The model to use from the structure. Defaults to 0. This may be any valid identifier for a model in the structure, such as an integer or string.
chain (str) – The chain to use from the structure. Defaults to the first chain in the structure.
- attach(other: Molecule, link: str | Linkage = None, at_residue: int | Residue = None, other_residue: int | Residue = None, use_patch: bool = True, inplace: bool = True, other_inplace: bool = False, _topology=None)[source]#
Attach another structure to this one using a Patch or a Recipe.
- Parameters:
other (Molecule) – The other molecule to attach to this one
link (str or Linkage) – Either a Patch to apply when attaching or a Recipe to use when stitching. If None is defined, the default patch or recipe that was set earlier on the molecule is used.
at_residue (int or Residue) – The residue to attach the other molecule to. If None, the defined attach_residue is used.
other_residue (int or Residue) – The residue in the other molecule to attach this molecule to. If None, the defined attach_residue of the other molecule is used.
use_patch (bool) – If the specified linkage is a patch (has internal coordinates) it can and is by default applied as a patch. However, it can also be used as a recipe. Set this to false if you want to use the patch as a recipe.
inplace (bool) – If True the molecule is directly modified, otherwise a copy of the molecule is returned.
other_inplace (bool) – All atoms from the other molecule are integrated into this one. Hence, the other molecule is left empty. If False, a copy of the other molecule is used. Thus leaving the original molecule intact.
_topology (Topology) – The topology to use when attaching. If None, the topology of the molecule is used. Only used if the patch is a string.
- classmethod empty(id: str = None) Molecule[source]#
Create an empty Molecule object
- Parameters:
id (str) – The id of the Molecule. By default an id is inferred from the filename.
- Returns:
An empty Molecule object
- Return type:
- classmethod from_compound(compound: str, by: str = 'id', root_atom: str | int = None) Molecule[source]#
Create a Molecule from a reference compound from the PDBECompounds database
- Parameters:
compound (str) – The compound to search for
by (str) – The field to search by. This can be - “id” for the PDB id - “name” for the name of the compound (must match any known synonym of the iupac name) - “formula” for the chemical formula - “smiles” for the SMILES string (also accepts InChI)
root_atom (str or int) – The id or the serial number of the root atom (optional)
- classmethod from_pdb(filename: str, root_atom: str | int = None, id: str = None, model: int = 0, chain: str = None) Molecule[source]#
Read a Molecule from a PDB file
- Parameters:
filename (str) – Path to the PDB file
root_atom (str or int) – The id or the serial number of the root atom (optional)
id (str) – The id of the Molecule. By default an id is inferred from the filename.
model (int) – The model to use from the structure. Defaults to 0. This may be any valid identifier for a model in the structure, such as an integer or string.
chain (str) – The chain to use from the structure. Defaults to the first chain in the structure.
- Returns:
The Molecule object
- Return type:
- classmethod from_pubchem(query: str, root_atom: str | int = None, by: str = 'name', idx: int = 0) Molecule[source]#
Create a Molecule from PubChem
Note
PubChem follows a different atom labelling scheme than the CHARMM force field! This means that atom names may not match the names required by the default patches that are integrated in biobuild. It is advisable to run autolabel or relabel_hydrogens on the molecule. Naturally, custom patches or recipies working with adjusted atom names will always work.
- Parameters:
query (str) – The query to search for in the PubChem database
root_atom (str or int) – The id or the serial number of the root atom (optional)
by (str) – The method to search by. This can be any of the following: - cid - name - smiles - sdf - inchi - inchikey - formula
idx (int) – The index of the result to use if multiple are found. By default, the first result is used.
- Returns:
The Molecule object
- Return type:
- classmethod from_smiles(smiles: str, id: str = None, root_atom: str | int = None, add_hydrogens: bool = True) Molecule[source]#
Read a Molecule from a SMILES string
- Parameters:
smiles (str) – The SMILES string
id (str) – The id of the Molecule. By default the provided smiles string is used.
root_atom (str or int) – The id or the serial number of the root atom (optional)
add_hydrogens (bool) – Whether to add hydrogens to the molecule
- Returns:
The Molecule object
- Return type:
- get_residue_connections(residue_a=None, residue_b=None, triplet: bool = True, direct_by: str = None)[source]#
Get bonds between atoms that connect different residues in the structure This method is different from infer_residue_connections in that it works with the already present bonds in the molecule instead of computing new ones.
- Parameters:
residue_a (Union[int, str, tuple, bio.Residue.Residue]) – The residues to consider. If None, all residues are considered. Otherwise, only between the specified residues are considered.
residue_b (Union[int, str, tuple, bio.Residue.Residue]) – The residues to consider. If None, all residues are considered. Otherwise, only between the specified residues are considered.
triplet (bool) – Whether to include bonds between atoms that are in the same residue but neighboring a bond that connects different residues. This is useful for residues that have a side chain that is connected to the main chain. This is mostly useful if you intend to use the returned list for some purpose, because the additionally returned bonds are already present in the structure from inference or standard-bond applying and therefore do not actually add any particular information to the Molecule object itself.
direct_by (str) – The attribute to sort by. Can be either “serial”, “resid” or “root”. In the case of “serial”, the bonds are sorted by the serial number of the first atom. In the case of “resid”, the bonds are sorted by the residue id of the first atom. In the case of “root”, the bonds are sorted by the root atom of the first atom. Set to None to not sort the bonds.
- Returns:
A set of tuples of atom pairs that are bonded and connect different residues
- Return type:
set
- optimize(residue_graph: bool = None, algorithm: str = None, rotatron: str = None, rotatron_kws: dict = None, algorithm_kws: dict = None, inplace: bool = True)[source]#
Optimize the molecule’s conformation. This is a convenience method with less customizability than a manual optimization using the optimizers module.
- Parameters:
residue_graph (bool) – Whether to use the residue graph or the full atom graph for optimization. The residue graph is faster but less accurate. If the molecule is larger than 100 atoms, the residue graph is used by default.
algorithm (str) – The optimization algorithm to use. If not provided, an algorithm is determined based on the molecule’s size. This can be one of the following: - “genetic” for a genetic algorithm - “scipy” for a scipy-implemented gradient-based optimization - “swarm” for a particle swarm optimization - “anneal” for a simulated annealing optimization - “rdkit” for an RDKit-implemented force-field-based optimization (if RDKit is installed)
rotatron (str) – The rotatron to use. This can be one of the following: - “distance” for a distance-based rotatron (default) - “overlap” for an overlap-based rotatron
algorithm_kws (dict) – Keyword arguments to pass to the optimization algorithm
rotatron_kws (dict) – Keyword arguments to pass to the rotatron
inplace (bool) – Whether to optimize the molecule in place or return a copy.
- Returns:
The optimized molecule (either the original object or a copy)
- Return type:
molecule
- patch_attach(other: Molecule, patch: Linkage | str = None, at_residue: int | Residue = None, other_residue: int | Residue = None, _topology=None)[source]#
Attach another structure to this one using a Patch.
- Parameters:
other (Molecule) – The other molecule to attach to this one
patch (str or Linkage) – A linkage to apply when attaching. If none is given, the default link that was set earlier on the molecule is used. If no patch was set, an AttributeError is raised. If a string is given, it is interpreted as the name of a patch in the topology.
at_residue (int or Residue) – The residue to attach the other molecule to. If None, the last residue of the molecule.
other_residue (int or Residue) – The residue of the other molecule to attach. If None, the first residue of the other molecule.
_topology – A specific topology to use for referencing. If None, the default CHARMM topology is used.
- repeat(n: int, link=None, inplace: bool = True)[source]#
Repeat the molecule n times into a homo-polymer.
- Parameters:
n (int) – The number or units of the final polymer.
link (str or Patch or Recipe) – The patch or recipe to use when patching individual units together. If noe is given, the default patch or recipe is used (if defined).
inplace (bool) – If True the molecule is directly modified, otherwise a copy of the molecule is returned.
- Returns:
The modified molecule (either the original object or a copy)
- Return type:
molecule
- stitch_attach(other: Molecule, recipe: Linkage = None, remove_atoms=None, other_remove_atoms=None, at_atom=None, other_at_atom=None, at_residue=None, other_residue=None)[source]#
Stitch two molecules together by removing atoms and connecting them with a bond. This works without a pre-defined patch.
- Parameters:
other (Molecule) – The other molecule to attach to this one
recipe (Recipe) – The recipe to use when stitching. If None, the default recipe that was set earlier on the molecule is used (if defined).
remove_atoms (list of int) – The atoms to remove from this molecule. Only used if no recipe is provided.
other_remove_atoms (list of int) – The atoms to remove from the other molecule. Only used if no recipe is provided.
at_atom (int or str or Bio.PDB.Atom) – The atom forming the bond in this molecule. If a string is provided, an at_residue needs to be defined from which to get the atom. If None is provided, the root atom is used (if defined). Only used if no recipe is provided.
other_at_atom (int or str or Bio.PDB.Atom) – The atom to attach to in the other molecule. If a string is provided, an other_residue needs to be defined from which to get the atom. If None is provided, the root atom is used (if defined). Only used if no recipe is provided.
at_residue (int or Residue) – The residue to attach the other molecule to. If None, the attach_residue is used. Only used if a recipe is provided and the atoms
- to_smiles(isomeric: bool = True, write_hydrogens: bool = False) str[source]#
Convert the molecule to a SMILES string
- Parameters:
isomeric (bool) – Whether to include stereochemistry information in the SMILES string
write_hydrogens (bool) – Whether to include hydrogens in the SMILES string
- Returns:
The SMILES string
- Return type:
str
- biobuild.core.Molecule.connect(mol_a: Molecule, mol_b: Molecule, link: str | Linkage, at_residue_a: int | Residue = None, at_residue_b: int | Residue = None, copy_a: bool = True, copy_b: bool = True, _topology=None, use_patch: bool = True) Molecule[source]#
Connect two molecules together
- Parameters:
mol_a (Molecule) – The first (target) molecule
mol_b (Molecule) – The second (source) molecule
link (Linkage or str) – The linkage to use for connection. This can be either an instance of the Linkage class or a string identifier of a pre-defined patch in the (currently loaded default or specified) CHARMMTopology.
at_residue_a (int or bio.PDB.Residue) – The residue of the first molecule to connect to. If an integer is provided, the seqid must be used, starting at 1.
at_residue_b (int or bio.PDB.Residue) – The residue of the second molecule to connect to. If an integer is provided, the seqid must be used, starting at 1.
copy_a (bool) – Whether to copy the first molecule before connecting
copy_b (bool) – Whether to copy the second molecule before connecting. If False, all atoms of the second molecule will be added to the first molecule.
_topology (CHARMMTopology) – A specific topology to use in case a pre-existing patch is used as link and only the string identifier is supplied.
use_patch (bool) – If the linkage has internal coordinates available (i.e. is a “patch”) these are used by default. Set this to False to force-use stitching and its associated conformational optimization instead.
- Returns:
The connected molecule
- Return type:
- biobuild.core.Molecule.make_smiles(mol: Molecule, isomeric: bool = True, write_hydrogens: bool = False) str[source]#
Generate a SMILES string from a molecule.
- Parameters:
mol (Molecule) – The molecule
isomeric (bool) – Whether to include stereochemistry information
write_hydrogens (bool) – Whether to include hydrogens in the SMILES string
- Returns:
smiles – The SMILES string
- Return type:
str
- biobuild.core.Molecule.molecule(mol=None) Molecule[source]#
Generate a molecule from an input. If the input is a string, the string can be a PDB id, some filename, SMILES or InChI string, IUPAC name or abbreviation. This function will try its best to automatically generate the molecule with minimal user effort. However, using a dedicated classmethod is recommended for more efficient and predictable results.
- Parameters:
mol (str or structure-like object) – An input string or structure-like object such as a BioPython Structure or RDKit Molecule, etc. If nothing is provided, a new empty molecule is generated.
- Returns:
molecule – The generated molecule
- Return type:
Examples
>>> from biobuild import molecule >>> mol = molecule("GLC") >>> mol = molecule("GLC.pdb") >>> mol = molecule("alpha-d-glucose")
- biobuild.core.Molecule.phosphorylate(mol: Molecule, at_atom: int | str | Atom, delete: int | str | Atom = None, inplace: bool = True) Molecule[source]#
Phosphorylate a molecule at a specific atom
- Parameters:
mol (Molecule) – The molecule to phosphorylate
at_atom (int or str or Atom) – The atom to phosphorylate. If an integer is provided, the atom seqid must be used, starting at 1.
delete (int or str or Atom) – The atom to delete. If an integer is provided, the atom seqid must be used, starting at 1. If not provided, any Hydrogen atom attached to the phosphorylated atom will be deleted.
inplace (bool) – Whether to phosphorylate the molecule in place or return a new molecule
- Returns:
The phosphorylated molecule
- Return type:
- biobuild.core.Molecule.polymerize(mol: Molecule, n: int, link: str | Linkage = None, inplace: bool = False) Molecule[source]#
Polymerize a molecule
- Parameters:
- Returns:
The polymerized molecule
- Return type:
- biobuild.core.Molecule.query_pubchem(query: str, by: str = 'name') Molecule[source]#
Query the PubChem database for a given query string to obtain a Molecule object.
- Parameters:
query (str) – The query string
by (str) –
The type of query to perform. Can be one of: he method to search by. This can be any of the following:
cid
name
smiles
sdf
inchi
inchikey
formula
- Returns:
The molecule or None if no match was found
- Return type:
Molecule or None
- biobuild.core.Molecule.read_cif(filename: str, id: str = None) Molecule[source]#
Read a CIF file and return a molecule.
- Parameters:
filename (str) – The path to the CIF file
id (str) – The id of the molecule
- Returns:
molecule – The molecule
- Return type:
- biobuild.core.Molecule.read_pdb(filename: str, id: str = None) Molecule[source]#
Read a PDB file and return a molecule.
- Parameters:
filename (str) – The path to the PDB file
id (str) – The id of the molecule
- Returns:
molecule – The molecule
- Return type:
- biobuild.core.Molecule.read_smiles(smiles: str, id: str = None) Molecule[source]#
Read a SMILES string and return a molecule.
- Parameters:
smiles (str) – The SMILES string
- Returns:
molecule – The molecule
- Return type:
The Linkage module#
The Linkage module defines the Linkage class that is used to connect two molecules in a specific way.
Linkage definitions#
A linkage is a connection between two _molecules_. At its core each linkage simply defines two atoms that should be connected, and what atoms to remove in the process. It is a “pseudo” chemical reaction, so to speak.
Building on the CHARMM force field, biobuild distinguishes two kinds of linkages: patches and recipies.
A patch is a linkage that can be applied purely geometrically and does not require numeric optimization. This is because a patch includes geometric data in form of _internal coordinates_ of the atoms in the immediate vicinity of the newly formed bond. Using this data, biobuild is able to attach molecule to one another through simple matrix transformations. Conesquently, patches are the most efficient way to connect molecules and are preferable to recipes - the other type of linkage.
A recipe on the other hand is a linkage that requires numeric optimization. This is because a recipe does not include any geometric data, but only the atoms that should be connected. The numeric optimization is then used to find the optimal (or at least suitable) conformation. This is useful for most users who wish to define their own linkage types, but who will likely not wish to painstakingly define the detailed geometry of angles and dihedrals of the atom neighborhood.
The distinction between patches and recipies is purely nominal, as both are represented by the Linkage class. However, there are functional wrappers available to create either a patch or recipe, respectively, which require different arguments (to make sure they are not forgotten and to make the code more readable).
from biobuild import recipe
# Create a custom recipe
my_link = recipe(
atom1 = "C1",
atom2 = "O4",
delete_in_target = ["O1", "HO1"],
delete_in_source = ["HO4"],
id = "my_link"
)
Pre-defined patches#
biobuild comes with a number of pre-defined patches from the CHARMM force field. These can be accessed through the resources module:
from biobuild import resources
# Get a list of all pre-defined patches
patches = resources.available_patches()
# Check for a specific patch
resources.has_patch("some_patch")
# Get a specific patch
my_patch = resources.get_patch("some_patch")
A custom linkage can be added to the list of pre-defined patches by using the add_patch function:
# add the above defined my_link to the list of pre-defined patches
resources.add_patch(my_link)
Note
Despite the use of “patch” in the function nomenclature, there is no difference between a patch and a recipe in terms of how they are used. Patches and Recipies are represented by the same data class and thus behave identically. Hence, there are also functional wrappers with the “linkage” available that can be used instead (if a user feels more comfortable with this) - they perform the same function.
resources.add_linkage(my_link)
# performs the same as
resources.add_patch(my_link)
# check for a specific linkage
resources.has_linkage("my_link")
# performs the same as
resources.has_patch("my_link")
# etc.
Pre-defined patches can be accessed directly by their id and need not be obtained first through the resources module. They can be directly passed
to the Molecule’s attach method or any other function that requires a linkage:
import biobuild as bb
mol1 = bb.read_pdb("my_molecule.pdb")
mol2 = bb.read_pdb("my_other_molecule.pdb")
# Attach mol2 to mol1 using the pre-defined patch "some_patch"
mol1.attach(mol2, "some_patch")
# works the same as doing
some_patch = bb.get_patch("some_patch")
mol1.attach(mol2, some_patch)
- class biobuild.core.Linkage.Linkage(id=None, description: str = None)[source]#
Bases:
AbstractEntity_with_ICUsing the Linkage class, a template reaction instruction is stored for attaching molecules to one another.
- Parameters:
id (str, optional) – The ID of the linkage.
description (str, optional) – An additional description of the linkage.
- id#
The ID of the linkage.
- Type:
str
- bond#
The bond to form between the two molecules.
- Type:
tuple of str
- internal_coordinates#
The internal coordinates of the atoms in the immediate vicinity of the newly formed bond.
- Type:
list of InternalCoordinate
- deletes#
The atom IDs to delete in a tuple of lists where the first list contains the atom IDs to delete from the first structure (target) and the second one from the second structure (source)
- Type:
tuple of list of str
- atoms#
The atom IDs of the atoms in the linkage.
- Type:
list of str
- add_delete(id, _from: str = None)[source]#
Add an atom ID to delete
- Parameters:
id (str) – The atom ID to delete.
_from (str, optional) – The structure from which to delete the atom. Can be either “source” or “target”. If not provided, the structure is inferred from the atom ID, in which case either 1 (target) or 2 (source) must be the first character of the ID.
- add_id_to_delete(id, _from: str = None)#
Add an atom ID to delete
- Parameters:
id (str) – The atom ID to delete.
_from (str, optional) – The structure from which to delete the atom. Can be either “source” or “target”. If not provided, the structure is inferred from the atom ID, in which case either 1 (target) or 2 (source) must be the first character of the ID.
- property atom1: str#
The atom ID of the first atom in the bond.
- property atom2: str#
The atom ID of the second atom in the bond.
- property bond: tuple#
The bond to form between the two molecules.
- property deletes#
Returns the atom IDs to delete in a tuple of lists where the first list contains the atom IDs to delete from the first structure (target) and the second one from the second structure (source)
- biobuild.core.Linkage.linkage(atom1, atom2, delete_in_target=None, delete_in_source=None, internal_coordinates: dict = None, id: str = None, description: str = None) Linkage[source]#
Make a new Linkage instance to connect two molecules together.
- Parameters:
atom1 (str or tuple of str) – The atom in the first (target) molecule to connect.
atom2 (str or tuple of str) – The atom in the second (source) molecule to connect.
delete_in_target (str or tuple of str, optional) – The atom(s) in the first molecule to delete. If not provided, any Hydrogen atom bound to atom1 will be deleted.
delete_in_source (str or tuple of str, optional) – The atom(s) in the second molecule to delete. If not provided, any Hydrogen atom bound to atom2 will be deleted.
internal_coordinates (dict, optional) –
The internal coordinates of the atoms in the immediate vicinity of the newly formed bond. If provided, the link can be applied purely geometrically and will not require numeric optimization. If provided, this must be a dictionary where keys are tuples of four atoms ids and values tuples containing (in order):
the bond length between the first and second atom (first and third in case of an improper)
the bond length between the third and fourth atom
the bond angle between the first, second and third atom
the bond angle between the second, third and fourth atom
the dihedral angle between the first, second, third and fourth atom
True if the internal coordinate is improper, False otherwise
id (str, optional) – The ID of the linkage.
description (str, optional) – A description of the linkage.
- Returns:
The new linkage instance.
- Return type:
- biobuild.core.Linkage.patch(atom1, atom2, delete_in_target, delete_in_source, internal_coordinates: dict, id: str = None, description: str = None) Linkage[source]#
Make a new Linkage instance that describes a “patch” between two molecules. A patch is a linkage that can be applied purely geometrically and does not require numeric optimization. As such, it requires the internal coordinates of the atoms in the immediate vicinity of the newly formed bond.
- Parameters:
atom1 (str or tuple of str) – The atom in the first (target) molecule to connect.
atom2 (str or tuple of str) – The atom in the second (source) molecule to connect.
delete_in_target (str or tuple of str) – The atom(s) in the first molecule to delete.
delete_in_source (str or tuple of str) – The atom(s) in the second molecule to delete.
internal_coordinates (dict, optional) –
The internal coordinates of the atoms in the immediate vicinity of the newly formed bond. If provided, the link can be applied purely geometrically and will not require numeric optimization. If provided, this must be a dictionary where keys are tuples of four atoms ids and values tuples containing (in order):
the bond length between the first and second atom (first and third in case of an improper)
the bond length between the third and fourth atom
the bond angle between the first, second and third atom
the bond angle between the second, third and fourth atom
the dihedral angle between the first, second, third and fourth atom
True if the internal coordinate is improper, False otherwise
id (str, optional) – The id of the linkage.
description (str, optional) – A description of the linkage.
- Returns:
The new linkage.
- Return type:
- biobuild.core.Linkage.recipe(atom1, atom2, delete_in_target=None, delete_in_source=None, id: str = None, description: str = None) Linkage[source]#
Make a new Linkage instance that describes a “recipe” to connect two molecules. A recipe is a linkage that can be applied numerically and requires numeric optimization as it does not have the internal coordinates of the atoms in the immediate vicinity of the newly formed bond.
- Parameters:
atom1 (str or tuple of str) – The atom in the first (target) molecule to connect.
atom2 (str or tuple of str) – The atom in the second (source) molecule to connect.
delete_in_target (str or tuple of str) – The atom(s) in the first molecule to delete. If not provided, any Hydrogen atom bound to atom1 will be deleted.
delete_in_source (str or tuple of str) – The atom(s) in the second molecule to delete. If not provided, any Hydrogen atom bound to atom2 will be deleted.
id (str, optional) – The id of the linkage.
description (str, optional) – A description of the linkage.
- Returns:
The new linkage.
- Return type:
The base module#
The entity module defines the BaseEntity class that is the base class for Molecules (and whatever other classes a user may wish to define that are similar in concept).
The BaseEntity class
- class biobuild.core.entity.BaseEntity(structure, model: int = 0)[source]#
Bases:
objectTHe Base class for all classes that store and handle biopython structures, namely the Molecule class.
- Parameters:
structure (Structure or Bio.PDB.Structure) – The biopython structure
model (int) – The index of the model to use (default: 0)
- add_atoms(*atoms: Atom, residue=None, _copy: bool = False)[source]#
Add atoms to the structure. This will automatically adjust the atom’s serial number to fit into the structure.
- Parameters:
atoms (base_classes.Atom) – The atoms to add
residue (int or str) – The residue to which the atoms should be added, this may be either the seqid or the residue name, if None the atoms are added to the last residue. Note, that if multiple identically named residues are present, the first one is chosen, so using the seqid is a safer option!
_copy (bool) – If True, the atoms are copied and then added to the structure. This will leave the original atoms (and their parent structures) untouched.
- add_bond(atom1: int | str | tuple | Atom, atom2: int | str | tuple | Atom, order: int = 1)[source]#
Add a bond between two atoms
- Parameters:
atom1 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
atom2 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
order (int) – The order of the bond, i.e. 1 for single, 2 for double, 3 for triple, etc.
- add_bonds(*bonds)[source]#
Add multiple bonds at once
- Parameters:
bonds – The bonds to add, each bond is a tuple of two atoms. Each atom may be specified directly (biopython object) or by providing the serial number, the full_id or the id of the atoms.
- add_chains(*chains: Chain, adjust_seqid: bool = True, _copy: bool = False)[source]#
Add chains to the structure
- Parameters:
chains (base_classes.Chain) – The chains to add
adjust_seqid (bool) – If True, the seqid of the chains is adjusted to match the current number of chains in the structure (i.e. a new chain can be given seqid A, and it will be adjusted to the correct value of C if there are already two other chains in the molecule).
_copy (bool) – If True, the chains are copied before adding them to the molecule. This is useful if you want to add the same chain to multiple molecules, while leaving them and their original parent structures intakt.
- add_residues(*residues: Residue, adjust_seqid: bool = True, _copy: bool = False)[source]#
Add residues to the structure
- Parameters:
residues (base_classes.Residue) – The residues to add
adjust_seqid (bool) – If True, the seqid of the residues is adjusted to match the current number of residues in the structure (i.e. a new residue can be given seqid 1, and it will be adjusted to the correct value of 3 if there are already two other residues in the molecule).
_copy (bool) – If True, the residues are copied before adding them to the molecule. This is useful if you want to add the same residue to multiple molecules, while leaving them and their original parent structures intakt.
- adjust_indexing(mol)[source]#
Adjust the indexing of a molecule to match the scaffold index
- Parameters:
mol (Molecule) – The molecule to adjust the indexing of
- apply_standard_bonds(_compounds=None) list[source]#
Get the standard bonds for the structure
- Parameters:
_compounds – The compounds to use for the standard bonds. If None, the default compounds are used.
- Returns:
A list of tuples of atom pairs that are bonded
- Return type:
list
- property atoms#
A sorted list of all atoms in the structure
- property attach_residue#
The residue at which to attach other molecules to this one.
- autolabel()[source]#
Automatically label atoms in the structure to match the CHARMM force field atom nomenclature. This is useful if you want to use some pre-generated PDB file that may have used a different labelling scheme for atoms.
Note
The labels are infererred and therefore may occasionally not be “correct”. It is advisable to check the labels after using this method.
- property bonds#
All bonds in the structure
- property chains#
A sorted list of all chains in the structure
- compute_angle(atom1: str | int | Atom, atom2: str | int | Atom, atom3: str | int | Atom)[source]#
Compute the angle between three atoms where atom2 is the middle atom.
- Parameters:
atom1 – The first atom
atom2 – The second atom
atom3 – The third atom
- Returns:
The angle in degrees
- Return type:
float
- compute_angles()[source]#
Compute all angles of consecutively bonded atom triplets within the molecule.
- Returns:
angles – A dictionary of the form {atom_triplet: angle}
- Return type:
dict
- compute_dihedral(atom1: str | int | Atom, atom2: str | int | Atom, atom3: str | int | Atom, atom4: str | int | Atom)[source]#
Compute the dihedral angle between four atoms
- Parameters:
atom1 – The first atom
atom2 – The second atom
atom3 – The third atom
atom4 – The fourth atom
- Returns:
The dihedral angle in degrees
- Return type:
float
- compute_dihedrals()[source]#
Compute all dihedrals of consecutively bonded atom quartets within the molecule.
- Returns:
dihedrals – A dictionary of the form {atom_quartet: dihedral}
- Return type:
dict
- count_atoms() int[source]#
Count the number of atoms in the structure
- Returns:
The number of atoms
- Return type:
int
- count_bonds() int[source]#
Count the number of bonds in the structure
- Returns:
The number of bonds
- Return type:
int
- count_chains() int[source]#
Count the number of chains in the structure
- Returns:
The number of chains
- Return type:
int
- count_clashes(clash_threshold: float = 0.9) int[source]#
Count all clashes in the molecule.¨
- Parameters:
clash_threshold (float, optional) – The minimal allowed distance between two atoms (in Angstrom).
- Returns:
The number of clashes.
- Return type:
int
- count_residues() int[source]#
Count the number of residues in the structure
- Returns:
The number of residues
- Return type:
int
- draw(residue_graph: bool = False)[source]#
Prepare a view of the molecule in 3D using Plotly but do not open a browser window.
- Parameters:
residue_graph (bool) – If True, a residue graph is shown instead of the full structure.
- Returns:
viewer – The viewer object
- Return type:
- find_clashes(clash_threshold: float = 0.9) list[source]#
Find all clashes in the molecule.
- Parameters:
clash_threshold (float, optional) – The minimal allowed distance between two atoms (in Angstrom).
- Returns:
A list of tuples of atoms that clash.
- Return type:
list
- classmethod from_cif(filename: str, id: str = None)[source]#
Load a Molecule from a CIF file
- Parameters:
filename (str) – Path to the CIF file
id (str) – The id of the Molecule. By default an id is inferred from the filename.
- classmethod from_json(filename: str)[source]#
Make a Molecule from a JSON file
- Parameters:
filename (str) – Path to the JSON file
- classmethod from_molfile(filename: str)[source]#
Make a Molecule from a molfile
- Parameters:
filename (str) – Path to the molfile
- classmethod from_openmm(topology, positions)[source]#
Load a Molecule from an OpenMM topology and positions
- Parameters:
topology (simtk.openmm.app.Topology) – The OpenMM topology
positions (simtk.unit.Quantity) – The OpenMM positions
- classmethod from_pdb(filename: str, id: str = None)[source]#
Read a Molecule from a PDB file
- Parameters:
filename (str) – Path to the PDB file
root_atom (str or int) – The id or the serial number of the root atom (optional)
id (str) – The id of the Molecule. By default an id is inferred from the filename.
- classmethod from_pybel(mol)[source]#
Load a Molecule from a Pybel molecule
- Parameters:
mol (pybel.Molecule) – The Pybel molecule
- classmethod from_rdkit(mol, id: str = None)[source]#
Load a Molecule from an RDKit molecule
- Parameters:
mol (rdkit.Chem.rdchem.Mol) – The RDKit molecule
id (str) – The id of the Molecule. By default an id is inferred from the “_Name” property of the mol object (if present).
- get_ancestors(atom1: str | int | Atom, atom2: str | int | Atom)[source]#
Get the atoms upstream of a bond. This will return the set of all atoms that are connected before the bond atom1-atom2 in the direction of atom1, the selection can be reversed by reversing the order of atoms (atom2-atom1).
- Parameters:
atom1 – The first atom
atom2 – The second atom
- Returns:
A set of atoms
- Return type:
set
Examples
OH
/
- (1)CH3 — CH
CH2 — (2)CH3
``` >>> mol.get_ancestors(“(1)CH3”, “CH”) set() >>> mol.get_ancestors(“CH”, “CH2”) {“(1)CH3”, “OH”} >>> mol.get_ancestors(“CH2”, “CH”) {“(2)CH3”}
- get_atom(atom: int | str | tuple, by: str = None, residue: int | Residue = None)[source]#
Get an atom from the structure either based on its id, serial number or full_id. Note, if multiple atoms match the requested criteria, for instance there are multiple ‘C1’ from different residues, only the first one is returned. To get all atoms matching the criteria, use the get_atoms method.
- Parameters:
atom – The atom id, serial number, full_id tuple, or element symbol.
by (str) – The type of parameter to search for. Can be either ‘id’, ‘serial’, ‘full_id’, or ‘element’. Because this looks for one specific atom, this parameter can be inferred from the datatype of the atom parameter. If it is an integer, it is assumed to be the serial number, if it is a string, it is assumed to be the atom id and if it is a tuple, it is assumed to be the full_id.
residue (int or Residue) – A specific residue to search in. If None, the entire structure is searched.
- Returns:
atom – The atom
- Return type:
- get_atom_graph(_copy: bool = True)[source]#
Get an AtomGraph for the Molecule
- Parameters:
_copy (bool) – If True, not the “original” AtomGraph object that the Molecule relies on is returned but a new one. However, the molecule will still be linked to the new graph. This is useful if you want to make changes to the graph itself (not including changes to the graph nodes, i.e. the atoms itself, such as rotations).
- Returns:
The generated graph
- Return type:
- get_atom_quartets() list[source]#
Compute quartets of four consequtively bonded atoms
- Returns:
atom_quartets – A list of atom quartets
- Return type:
list
- get_atoms(*atoms: int | str | tuple, by: str = None) list[source]#
Get one or more atoms from the structure either based on their id, serial number or full_id. Note, if multiple atoms match the requested criteria, for instance there are multiple ‘C1’ from different residues all of them are returned in a list. It is a safer option to use the full_id or serial number to retrieve a specific atom. If no search parameters are provided, the underlying iterator of the structure is returned.
Note
This does not support mixed queries. I.e. you cannot query for an atom with id ‘C1’ and serial number 1 at the same time. Each call can only query for one type of parameter.
- Parameters:
atoms – The atom id, serial number, full_id tuple, or element string symbol. This supports multiple atoms to search for. However, only one type of parameter is supported per call. If left empty, the underlying generator is returned.
by (str) – The type of parameter to search for. Can be either ‘id’, ‘serial’ or ‘full_id’ If None is given, the parameter is inferred from the datatype of the atoms argument ‘serial’ in case of int, ‘id’ in case of str, full_id in case of a tuple.
- Returns:
atom – The atom(s)
- Return type:
list or generator
- get_attach_residue()[source]#
Get the residue that is used for attaching other molecules to this one.
- get_bond(atom1: int | str | tuple | Atom, atom2: int | str | tuple | Atom, add_if_not_present: bool = True) Bond[source]#
Get/make a bond between two atoms.
- get_bonds(atom1: int | str | tuple | Atom | Residue = None, atom2: int | str | tuple | Atom = None, residue_internal: bool = True, either_way: bool = True)[source]#
Get one or multiple bonds from the molecule. If only one atom is provided, all bonds that are connected to that atom are returned.
- Parameters:
atom1 – The atom id, serial number or full_id tuple of the first atom. This may also be a residue, in which case all bonds between atoms in that residue are returned.
atom2 – The atom id, serial number or full_id tuple of the second atom
residue_internal (bool) – If True, only bonds where both atoms are in the given residue (if atom1 is a residue) are returned. If False, all bonds where either atom is in the given residue are returned.
either_way (bool) – If True, the order of the atoms does not matter, if False, the order of the atoms does matter. By setting this to false, it is possible to also search for bonds that have a specific atom in position 1 or 2 depending on which argument was set, while leaving the other input as none.
- Returns:
bond – The bond(s). If no input is given, all bonds are returned as a generator.
- Return type:
list or generator
- get_chain(chain: str)[source]#
Get a chain from the structure either based on its name.
- Parameters:
chain – The chain id
- Returns:
chain – The chain
- Return type:
- get_descendants(atom1: str | int | Atom, atom2: str | int | Atom)[source]#
Get the atoms downstream of a bond. This will return the set of all atoms that are connected after the bond atom1-atom2 in the direction of atom2, the selection can be reversed by reversing the order of atoms (atom2-atom1).
- Parameters:
atom1 – The first atom
atom2 – The second atom
- Returns:
A set of atoms
- Return type:
set
Examples
OH
/
- (1)CH3 — CH
CH2 — (2)CH3
``` >>> mol.get_descendants(“(1)CH3”, “CH”) {“OH”, “CH2”, “(2)CH3”} >>> mol.get_descendants(“CH”, “CH2”) {“(2)CH3”} >>> mol.get_descendants(“CH2”, “CH”) {“OH”, “(1)CH3”}
- get_linkage()[source]#
Get the linkage that is currently set as default attachment specication for this molecule
- get_neighbors(atom: int | str | tuple | Atom, n: int = 1, mode: str = 'upto')[source]#
Get the neighbors of an atom.
- Parameters:
atom – The atom
n – The number of bonds that may separate the atom from its neighbors.
mode – The mode to use. Can be “upto” or “at”. If upto, all neighbors that are at most n bonds away are returned. If at, only neighbors that are exactly n bonds away are returned.
- Returns:
A set of atoms
- Return type:
set
Examples
O — (2)CH2
/
- (1)CH3 — CH OH
(1)CH2 — (2)CH3
``` >>> mol.get_neighbors(“(2)CH2”, n=1) {“O”, “OH”} >>> mol.get_neighbors(“(2)CH2”, n=2, mode=”upto”) {“O”, “OH”, “CH”} >>> mol.get_neighbors(“(2)CH2”, n=2, mode=”at”) {“CH”}
- get_residue(residue: int | str | tuple | Residue, by: str = None, chain=None)[source]#
Get a residue from the structure either based on its name, serial number or full_id. Note, if multiple residues match the requested criteria, for instance there are multiple ‘MAN’ from different chains, only the first one is returned.
- Parameters:
residue – The residue id, seqid or full_id tuple
by (str) – The type of parameter to search for. Can be either ‘name’, ‘seqid’ or ‘full_id’ By default, this is inferred from the datatype of the residue parameter. If it is an integer, it is assumed to be the sequence identifying number, if it is a string, it is assumed to be the residue name and if it is a tuple, it is assumed to be the full_id.
chain (str) – Further restrict to a residue from a specific chain.
- Returns:
residue – The residue
- Return type:
- get_residue_connections(residue_a=None, residue_b=None, triplet: bool = True, rotatable_only: bool = False)[source]#
Get bonds between atoms that connect different residues in the structure This method is different from infer_residue_connections in that it works with the already present bonds in the molecule instead of computing new ones.
- Parameters:
residue_a (Union[int, str, tuple, base_classes.Residue]) – The residues to consider. If None, all residues are considered. Otherwise, only between the specified residues are considered.
residue_b (Union[int, str, tuple, base_classes.Residue]) – The residues to consider. If None, all residues are considered. Otherwise, only between the specified residues are considered.
triplet (bool) – Whether to include bonds between atoms that are in the same residue but neighboring a bond that connects different residues. This is useful for residues that have a side chain that is connected to the main chain. This is mostly useful if you intend to use the returned list for some purpose, because the additionally returned bonds are already present in the structure from inference or standard-bond applying and therefore do not actually add any particular information to the Molecule object itself.
rotatable_only (bool) – Whether to only return bonds that are rotatable. This is useful if you want to use the returned bonds for optimization.
- Returns:
A set of tuples of atom pairs that are bonded and connect different residues
- Return type:
list
- get_residue_graph(detailed: bool = False, locked: bool = True)#
Generate a ResidueGraph for the Molecule
- Parameters:
detailed (bool) – If True the graph will include the residues and all atoms that form bonds connecting different residues. If False, the graph will only include the residues and their connections without factual bonds between any existing atoms.
locked (bool) – If True, the graph will also migrate the information on any locked bonds into the graph. This is only relevant if detailed is True.
- get_residues(*residues: int | str | tuple | Residue, by: str = None, chain=None)[source]#
Get residues from the structure either based on their name, serial number or full_id.
- Parameters:
residues – The residues’ id, seqid or full_id tuple. If None is passed, the iterator over all residues is returned.
by (str) – The type of parameter to search for. Can be either ‘name’, ‘seqid’ or ‘full_id’ By default, this is inferred from the datatype of the residue parameter. If it is an integer, it is assumed to be the sequence identifying number, if it is a string, it is assumed to be the residue name and if it is a tuple, it is assumed to be the full_id.
chain (str) – Further restrict to residues from a specific chain.
- Returns:
The residue(s)
- Return type:
list or generator
- get_root() Atom[source]#
Get the root atom of the molecule. The root atom is the atom at which it is attached to another molecule.
- property id#
- infer_bonds(max_bond_length: float = None, restrict_residues: bool = True) list[source]#
Infer bonds between atoms in the structure
- Parameters:
max_bond_length (float) – The maximum distance between atoms to consider them bonded. If None, the default value is 1.6 Angstroms.
restrict_residues (bool) – Whether to restrict bonds to only those in the same residue. If False, bonds between atoms in different residues are also inferred.
- Returns:
A list of tuples of atom pairs that are bonded
- Return type:
list
- infer_residue_connections(bond_length: float | tuple = None, triplet: bool = True) list[source]#
Infer bonds between atoms that connect different residues in the structure
- Parameters:
bond_length (float or tuple) – If a float is given, the maximum distance between atoms to consider them bonded. If a tuple, the minimal and maximal distance between atoms. If None, the default value is min 0.8 Angstrom, max 1.6 Angstroms.
triplet (bool) – Whether to include bonds between atoms that are in the same residue but neighboring a bond that connects different residues. This is useful for residues that have a side chain that is connected to the main chain. This is mostly useful if you intend to use the returned list for some purpose, because the additionally returned bonds are already present in the structure from inference or standard-bond applying and therefore do not actually add any particular information to the Molecule object itself.
- Returns:
A list of tuples of atom pairs that are bonded and considered residue connections.
- Return type:
list
Examples
For a molecule with the following structure: ```
- connection –> OA OB — H
/ /
- (1)CA — (2)CA (1)CB
/
- (6)CA (3)CA (2)CB — (3)CB
/
(5)CA — (4)CA
``` The circular residue A and linear residue B are connected by a bond between (1)CA and the oxygen OA and (1)CB. By default, because OA originally is associated with residue A, only the bond OA — (1)CB is returned. However, if triplet=True, the bond OA — (1)CA is also returned, because the entire connecting “bridge” between residues A and B spans either bond around OA. >>> mol.infer_residue_connections(triplet=False) [(“OA”, “(1)CB”)] >>> mol.infer_residue_connections(triplet=True) [(“OA”, “(1)CB”), (“OA”, “(2)CA”)]
- is_locked(atom1: int | str | tuple | Atom, atom2: int | str | tuple | Atom)[source]#
Check if a bond is locked
- Parameters:
atom1 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
atom2 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
- Returns:
True if the bond is locked, False otherwise
- Return type:
bool
- property linkage#
The patch or recipe to use for attaching other molecules to this one
- classmethod load(filename: str)[source]#
Load a Molecule from a pickle file
- Parameters:
filename (str) – Path to the file
- lock_bond(atom1: int | str | tuple | Atom, atom2: int | str | tuple | Atom)[source]#
Lock a bond between two atoms
- Parameters:
atom1 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
atom2 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
- property locked_bonds#
All bonds that are locked and cannot be rotated around.
- make_atom_graph(_copy: bool = True)#
Get an AtomGraph for the Molecule
- Parameters:
_copy (bool) – If True, not the “original” AtomGraph object that the Molecule relies on is returned but a new one. However, the molecule will still be linked to the new graph. This is useful if you want to make changes to the graph itself (not including changes to the graph nodes, i.e. the atoms itself, such as rotations).
- Returns:
The generated graph
- Return type:
- make_residue_graph(detailed: bool = False, locked: bool = True)[source]#
Generate a ResidueGraph for the Molecule
- Parameters:
detailed (bool) – If True the graph will include the residues and all atoms that form bonds connecting different residues. If False, the graph will only include the residues and their connections without factual bonds between any existing atoms.
locked (bool) – If True, the graph will also migrate the information on any locked bonds into the graph. This is only relevant if detailed is True.
- property model#
The biopython model
- property patch#
The patch to use for attaching other molecules to this one (synonym for recipe)
- purge_bonds(atom: int | str | Atom = None)[source]#
Remove all bonds connected to an atom
- Parameters:
atom – The atom to remove the bonds from, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms. If None, all bonds are removed.
- quartet(atom1: str | int | Atom, atom2: str | int | Atom, atom3: str | int | Atom, atom4: str | int | Atom)[source]#
Make an atom quartet from four atoms.
- Parameters:
atom1 – The four atoms that make up the quartet.
atom2 – The four atoms that make up the quartet.
atom3 – The four atoms that make up the quartet.
atom4 – The four atoms that make up the quartet.
- property recipe#
The recipe to use for stitching other molecules to this one (synonym for patch)
- reindex(start_chainid: int = 1, start_resid: int = 1, start_atomid: int = 1)[source]#
Reindex the atoms and residues in the structure. You can use this method if you made substantial changes to the molecule and want to be sure that there are no gaps in the atom and residue numbering.
- Parameters:
start_chainid (int) – The starting chain id (default: 1=A, 2=B, …, 26=Z, 27=AA, 28=AB, …)
start_resid (int) – The starting residue id
start_atomid (int) – The starting atom id
- relabel_hydrogens()[source]#
Relabel hydrogen atoms in the structure to match the standard labelling according to the CHARMM force field. This is useful if you want to use some pre-generated PDB file that may have used a different labelling scheme for atoms.
- remove_atoms(*atoms: int | str | tuple | Atom) list[source]#
Remove one or more atoms from the structure
- Parameters:
atoms – The atoms to remove, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
- Returns:
The removed atoms
- Return type:
list
- remove_bond(atom1: int | str | tuple | Atom, atom2: int | str | tuple | Atom)[source]#
Remove a bond between two atoms
- Parameters:
atom1 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
atom2 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
- remove_residues(*residues: int | Residue) list[source]#
Remove residues from the structure
- Parameters:
residues (int or base_classes.Residue) – The residues to remove, either the object itself or its seqid
- Returns:
The removed residues
- Return type:
list
- rename_atom(atom: int | Atom, name: str, residue: int | Residue = None)[source]#
Rename an atom
- Parameters:
atom (int or base_classes.Atom) – The atom to rename, either the object itself or its serial number
name (str) – The new name (id)
residue (int or base_classes.Residue) – The residue to which the atom belongs, either the object itself or its seqid. Useful when giving a possibly redundant id as identifier in multi-residue molecules.
- rename_chain(chain: str | Chain, name: str)[source]#
Rename a chain
- Parameters:
chain (str or Chain) – The chain to rename, either the object itself or its id
name (str) – The new name
- rename_residue(residue: int | Residue, name: str)[source]#
Rename a residue
- Parameters:
residue (int or Residue) – The residue to rename, either the object itself or its seqid
name (str) – The new name
- property residues#
A sorted list of all residues in the structure
- property root_atom#
The root atom of this molecule/scaffold at which it is attached to another molecule/scaffold
- property root_residue#
The residue of the root atom
- rotate_ancestors(atom1: str | int | Atom, atom2: str | int | Atom, angle: float, angle_is_degrees: bool = True)[source]#
Rotate all ancestor atoms (atoms before atom1) of a bond
- Parameters:
atom1 (Union[str, int, base_classes.Atom]) – The first atom (whose upstream neighbors are rotated)
atom2 (Union[str, int, base_classes.Atom]) – The second atom
angle (float) – The angle to rotate by
angle_is_degrees (bool) – Whether the angle is given in degrees (default) or radians
- rotate_around_bond(atom1: str | int | Atom, atom2: str | int | Atom, angle: float, descendants_only: bool = False, angle_is_degrees: bool = True)[source]#
Rotate the structure around a bond
- Parameters:
atom1 – The first atom
atom2 – The second atom
angle – The angle to rotate by in degrees
descendants_only – Whether to only rotate the descendants of the bond, i.e. only atoms that come after atom2 (sensible only for linear molecules, or bonds that are not part of a circular structure).
angle_is_degrees – Whether the angle is given in degrees (default) or radians
Examples
For a molecule starting as: ```
OH
/
- (1)CH3 — CH
CH2 — (2)CH3
``` we can rotate around the bond (1)CH3 — CH by 180° using
>>> import numpy as np >>> angle = 180 >>> mol.rotate_around_bond("(1)CH3", "CH", angle)
and thus achieve the following: ```
CH2 — (2)CH3
/
- (1)CH3 — CH
OH
- rotate_descendants(atom1: str | int | Atom, atom2: str | int | Atom, angle: float, angle_is_degrees: bool = True)[source]#
Rotate all descendant atoms (atoms after atom2) of a bond.
- Parameters:
atom1 (Union[str, int, base_classes.Atom]) – The first atom
atom2 (Union[str, int, base_classes.Atom]) – The second atom (whose downstream neighbors are rotated)
angle (float) – The angle to rotate by
angle_is_degrees (bool) – Whether the angle is given in degrees (default) or radians
- save(filename: str)[source]#
Save the object to a pickle file
- Parameters:
filename (str) – Path to the PDB file
- set_attach_residue(residue: int | Residue = None)[source]#
Set the residue that is used for attaching other molecules to this one.
- Parameters:
residue – The residue to be used for attaching other molecules to this one
- set_linkage(link: str | Linkage = None, _topology=None)[source]#
Set a linkage to be used for attaching other molecules to this one
- Parameters:
link (str or Linkage) – The linkage to be used. Can be either a string with the name of a known Linkage in the loaded topology, or an instance of the Linkage class. If None is given, the currently loaded default linkage is removed.
_topology – The topology to use for referencing the link.
- set_root(atom)[source]#
Set the root atom of the molecule
- Parameters:
atom (Atom or int or str or tuple) – The atom to be used as the root atom. This may be an Atom object, an atom serial number, an atom id (must be unique), or the full-id tuple.
- show(residue_graph: bool = False)[source]#
Open a browser window to view the molecule in 3D using Plotly
- Parameters:
residue_graph (bool) – If True, a residue graph is shown instead of the full structure.
- property structure#
The biopython structure
- to_biopython()[source]#
Convert the molecule to a Biopython structure
- Returns:
The Biopython structure
- Return type:
Bio.PDB.Structure.Structure
- to_cif(filename: str)[source]#
Write the molecule to a CIF file
- Parameters:
filename (str) – Path to the CIF file
- to_json(filename: str, type: str = None, names: list = None, identifiers: list = None, one_letter_code: str = None, three_letter_code: str = None)[source]#
Write the molecule to a JSON file
- Parameters:
filename (str) – Path to the JSON file
type (str) – The type of the molecule to be written to the JSON file (e.g. “protein”, “ligand”, etc.).
names (list) – A list of names of the molecules to be written to the JSON file.
identifiers (list) – A list of identifiers of the molecules to be written to the JSON file (e.g. SMILES, InChI, etc.).
one_letter_code (str) – A one-letter code for the molecule to be written to the JSON file.
three_letter_code (str) – A three-letter code for the molecule to be written to the JSON file.
- to_molfile(filename: str)[source]#
Write the molecule to a Molfile
- Parameters:
filename (str) – Path to the Mol file
- to_openmm()[source]#
Convert the molecule to an OpenMM Topology
- Returns:
The OpenMM topology
- Return type:
openmm.app.Topology
- to_pdb(filename: str, symmetric: bool = True)[source]#
Write the molecule to a PDB file
- Parameters:
filename (str) – Path to the PDB file
symmetric (bool) – If True, bonds are written symmetrically - i.e. if atom A is bonded to atom B, then atom B is also bonded to atom A, and both atoms will get an entry in the “CONECT” section. If False, only one of the atoms will get an entry in the “CONECT” section.
- to_pybel()[source]#
Convert the molecule to a Pybel molecule
- Returns:
The Pybel molecule
- Return type:
pybel.Molecule
- to_rdkit()[source]#
Convert the molecule to an RDKit molecule
- Returns:
The RDKit molecule
- Return type:
rdkit.Chem.rdchem.Mol
- unlock_bond(atom1: int | str | tuple | Atom, atom2: int | str | tuple | Atom)[source]#
Unlock a bond between two atoms
- Parameters:
atom1 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
atom2 – The atoms to bond, which can either be directly provided (biopython object) or by providing the serial number, the full_id or the id of the atoms.
- update_atom_graph()[source]#
Generate a new up-to-date AtomGraph after any manual changes were done to the Molecule’s underlying biopython structure.
- vet(clash_range: tuple = (0.6, 1.7), angle_range: tuple = (90, 180)) bool[source]#
Vet the structural integrity of a molecule. This will return True if there are no clashes and all angles of adjacent atom triplets are within a tolerable range, False otherwise.
- Parameters:
clash_range (tuple, optional) – The minimal and maximal allowed distances for two bonded atoms (in Angstrom). The minimal distance is also used for non-bonded atoms.
angle_range (tuple, optional) – The minimal and maximal allowed angles between tree adjacent bonded atoms (in degrees).
- Returns:
True if the structure is alright, False otherwise.
- Return type:
bool
In addition the base_classes module defines biobuil’d wrappers around native BioPython classes such as Atom, Residue, etc. These classes are used by biobuild in order to facilitate atom identifcation in situations where multiple identical molecules are connected to each other. All these classes support a from_biopython and to_biopython conversion.
The base_classes module
The base_classes are deriviatives of the original Biopython classes, but with the change that they use a UUID4 as their identifier (full_id) instead of a hierarchical tuple. This makes each object unique and allows for easy comparison where a == b is akin to a is b. Consequently, the __hash__ method is overwritten to use the UUID4 as the hash.
Warning
Each class has its own copy method that returns a deep copy of the object with a new UUID4. So a.copy() == a is False, while a standard deepcopy(a) == a is True since the UUID4 will not have been updated automatically.
Converting to and from biopython#
Each biobuild class can be generated from a biopython class using the from_biopython class method. And each biobuild class has a to_biopython method that returns the pure-biopython equivalent. It is important to note, that for most purposes, however, the biobuild classes should work fine as trop-in replacements for the original biopython classes.
import Bio.PDB as bio
from biobuild.core.base_classes import Atom
bio_atom = bio.Atom("CA", (0, 0, 0))
atom = Atom.from_biopython(bio_atom)
assert atom == bio_atom # False since atom uses a UUID4 as its identifier
assert atom.to_biopython() == bio_atom # True
The conversion from and to biopython works hierarchically, so if an entire biopython structure is converted to biobuild then all atoms, residues, chains and models will be converted to their biobuild equivalents.
import Bio.PDB as bio
from biobuild.core.base_classes import Structure
bio_structure = bio.PDBParser().get_structure("test", "test.pdb")
structure = Structure.from_biopython(bio_structure)
atoms = list(structure.get_atoms())
bio_atoms = list(bio_structure.get_atoms())
assert len(atoms) == len(bio_atoms) # True
- class biobuild.core.base_classes.Atom(id: str, coord: ndarray, serial_number: int = 1, bfactor: float = 0.0, occupancy: float = 1.0, fullname: str = None, element: str = None, altloc=' ', pqr_charge=None, radius=None)[source]#
Bases:
ID,AtomAn Atom object that inherits from Biopython’s Atom class.
- Parameters:
id (str) – The atom identifier
coord (ndarray) – The atom coordinates
serial_number (int, optional) – The atom serial number. The default is 1.
bfactor (float, optional) – The atom bfactor. The default is 0.0.
occupancy (float, optional) – The atom occupancy. The default is 1.0.
fullname (str, optional) – The atom fullname. The default is None, in which case the id is used again.
element (str, optional) – The atom element. The default is None, in which case it is inferred based on the id.
altloc (str, optional) – The atom altloc. The default is “ “.
pqr_charge (float, optional) – The atom pqr_charge. The default is None.
radius (float, optional) – The atom radius. The default is None.
- altloc#
- anisou_array#
- bfactor#
- coord#
- disordered_flag#
- element#
- classmethod from_biopython(atom) Atom[source]#
Convert a Biopython atom to an Atom object
- Parameters:
atom – The Biopython atom
- Returns:
The Atom object
- Return type:
- property full_id#
A self-adjusting full_id for an Biopython Atom
- fullname#
- id#
- level#
- mass#
- name#
- occupancy#
- parent#
- pqr_charge#
- radius#
- serial_number#
- sigatm_array#
- siguij_array#
- to_biopython()[source]#
Convert the Atom object to a Biopython atom
- Returns:
The Biopython atom
- Return type:
- xtra#
- class biobuild.core.base_classes.Bond(*atoms)[source]#
Bases:
objectA class representing a bond between two atoms.
- atom1#
- atom2#
- compute_length() float[source]#
Compute the bond length.
- Returns:
The bond length.
- Return type:
float
- is_double() bool[source]#
Check if the bond is a double bond.
- Returns:
True if the bond is a double bond, False otherwise.
- Return type:
bool
- is_single() bool[source]#
Check if the bond is a single bond.
- Returns:
True if the bond is a single bond, False otherwise.
- Return type:
bool
- is_triple() bool[source]#
Check if the bond is a triple bond.
- Returns:
True if the bond is a triple bond, False otherwise.
- Return type:
bool
- order#
- class biobuild.core.base_classes.Chain(id)[source]#
Bases:
ID,ChainA Chain object that inherits from Biopython’s Chain class.
- Parameters:
id (str) – The chain identifier
- child_dict#
- child_list#
- classmethod from_biopython(chain) Chain[source]#
Convert a BioPython Chain object to a Chain object.
- Parameters:
chain (BioPython Chain object) – The chain to convert.
- Returns:
The converted chain.
- Return type:
- property full_id#
A self-adjusting full_id for an Biopython Chain
- internal_coord#
- level#
- parent#
- to_biopython() Chain[source]#
Convert a Chain object to a pure BioPython Chain object.
- Parameters:
with_children (bool, optional) – Whether to convert the residues of the chain as well. The default is True.
- Returns:
The converted chain.
- Return type:
bio.Chain.Chain
- xtra#
- class biobuild.core.base_classes.Model(id)[source]#
Bases:
Model,IDA Model object that inherits from Biopython’s Model class.
- Parameters:
id (int or str) – The model identifier
- child_dict#
- child_list#
- classmethod from_biopython(model)[source]#
Convert a BioPython Model object to a Model object.
- Parameters:
model (BioPython Model object) – The model to convert.
- Returns:
The converted model.
- Return type:
- property full_id#
A self-adjusting full_id for an Biopython Model
- level#
- parent#
- property serial_num#
- property serial_number#
- to_biopython()[source]#
Convert a Model object to a pure BioPython Model object.
- Returns:
The converted model.
- Return type:
bio.Model.Model
- xtra#
- class biobuild.core.base_classes.Residue(resname, segid, icode)[source]#
Bases:
ID,ResidueA Residue object that inherits from Biopython’s Residue class.
- Parameters:
resname (str) – The residue name
segid (str) – The residue segid.
icode (int) – The residue icode. This is the residue serial number.
- add(atom)[source]#
Add an Atom object.
Checks for adding duplicate atoms, and raises a PDBConstructionException if so.
- child_dict#
- child_list#
- property coord#
- disordered#
- classmethod from_biopython(residue) Residue[source]#
Convert a BioPython Residue object to a Residue object.
- Parameters:
residue (BioPython Residue object) – The residue to convert.
- Returns:
The converted residue
- Return type:
- property full_id#
A self-adjusting full_id for an Biopython Residue
- property id#
Return identifier.
- internal_coord#
- level#
- parent#
- resname#
- segid#
- to_biopython() Residue[source]#
Convert a Residue object to a pure BioPython Residue object.
- Returns:
The converted residue.
- Return type:
bio.Residue.Residue
- xtra#
- class biobuild.core.base_classes.Structure(id)[source]#
Bases:
ID,StructureA Structure object that inherits from Biopython’s Structure class.
- Parameters:
id (str) – The structure identifier
- child_dict#
- child_list#
- classmethod from_biopython(structure: Structure) Structure[source]#
Convert a BioPython Structure object to a Structure object.
- Parameters:
structure (BioPython Structure object) – The structure to convert.
- Returns:
The converted structure.
- Return type:
- property full_id#
- level#
- parent#
- to_biopython() Structure[source]#
Convert a Structure object to a pure BioPython Structure object.
- Returns:
The converted structure.
- Return type:
bio.Structure.Structure
- xtra#