Bio2BEL DrugBank

Installation

bio2bel_drugbank can be installed easily from PyPI with the following code in your favorite terminal:

$ python3 -m pip install bio2bel_drugbank

or from the latest code on GitHub with:

$ python3 -m pip install git+https://github.com/bio2bel/drugbank.git@master

Setup

Warning

DrugBank requires a bit of downloading and file organization. Will be documented soon.

Python REPL

>>> import bio2bel_drugbank
>>> drugbank_manager = bio2bel_drugbank.Manager()
>>> drugbank_manager.populate()

Command Line Utility

bio2bel_drugbank populate

Manager

Defines the Bio2BEL DrugBank manager.

class bio2bel_drugbank.manager.Manager(*args, **kwargs)[source]

Manager for Bio2BEL DrugBank.

namespace_model

alias of bio2bel_drugbank.models.Drug

get_type_by_name(name: str) → Optional[bio2bel_drugbank.models.Type][source]

Get a Type by name.

get_or_create_type(name: str) → bio2bel_drugbank.models.Type[source]

Get or create a Type by name.

list_groups() → List[bio2bel_drugbank.models.Group][source]

List all chemical groups.

get_group_by_name(name: str) → Optional[bio2bel_drugbank.models.Group][source]

Get a Group by name.

get_or_create_group(name: str) → bio2bel_drugbank.models.Group[source]

Get or create a Group by name.

get_species_by_name(name: str) → Optional[bio2bel_drugbank.models.Species][source]

Get a Species by name.

get_or_create_species(name: str) → bio2bel_drugbank.models.Species[source]

Get or create a Species by name.

get_category_by_name(name: str) → Optional[bio2bel_drugbank.models.Category][source]

Get a Category by name.

get_or_create_category(name: str, **kwargs) → bio2bel_drugbank.models.Category[source]

Get or create a Category by name.

get_or_create_patent(country: str, patent_id: str, **kwargs) → bio2bel_drugbank.models.Patent[source]

Get or creates a Patent.

is_populated() → bool[source]

Check if the database is populated by counting the drugs.

populate(url: Optional[str] = None) → None[source]

Populate DrugBank.

Parameters:url – Path to the DrugBank XML
count_drugs() → int[source]

Count the number of drugs in the database.

list_drugs() → List[bio2bel_drugbank.models.Drug][source]

List all drugs in the database.

count_types() → int[source]

Count the number of types in the database.

count_aliases() → int[source]

Count the number of aliases in the database.

count_atc_codes() → int[source]

Count the number of ATC codes in the database.

count_groups() → int[source]

Count the number of groups in the database.

count_categories() → int[source]

Count the number of categories in the database.

count_drugs_categories() → int[source]

Count the number of drug-category relations in the database.

count_drugs_groups() → int[source]

Count the number of drug-group relations in the database.

count_patents() → int[source]

Count the number of patents in the database.

list_patents() → List[bio2bel_drugbank.models.Patent][source]

List the patents in the database.

count_xrefs() → int[source]

Count the number of cross-references in the database.

list_drug_protein_interactions() → List[bio2bel_drugbank.models.DrugProteinInteraction][source]

List drug-protein interactions.

summarize() → Dict[str, int][source]

Summarize the database.

enrich_targets(graph: pybel.struct.graph.BELGraph) → None[source]

Enrich the protein targets in the graph with Drug-Protein interactions from DrugBank.

lookup_drug(node: pybel.dsl.node_classes.BaseEntity) → Optional[bio2bel_drugbank.models.Drug][source]

Try and look up a drug.

enrich_drug_inchi(graph: pybel.struct.graph.BELGraph) → None[source]

Enrich drugs in the graph with their InChI equivalent nodes.

enrich_drug_equivalences(graph: pybel.struct.graph.BELGraph) → None[source]

Enrich drugs in the graph with their equivalent nodes.

enrich_drugs(graph: pybel.struct.graph.BELGraph) → None[source]

Enrich drugs in the graph with their targets.

to_bel() → pybel.struct.graph.BELGraph[source]

Export DrugBank as BEL.

get_hgnc_id_to_drugs() → Dict[str, List[str]][source]

Get a dictionary of HGNC identifiers (not prepended with HGNC:) to list of drug names.

get_drug_to_hgnc_ids(cache=True, recalculate=False) → Dict[str, List[str]][source]

Get a dictionary of drug names to lists HGNC identifiers (not prepended with HGNC:).

get_drug_to_hgnc_symbols(cache=True, recalculate=False) → Dict[str, List[str]][source]

Get a dictionary of drug names to HGNC gene symbols.

get_interactions_by_hgnc_id(hgnc_id: str) → List[bio2bel_drugbank.models.DrugProteinInteraction][source]

Get the drug targets for a given HGNC identifier.

Models

Database models for bio2bel_drugbank.

class bio2bel_drugbank.models.Base(**kwargs)

The most base type

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.Type(**kwargs)[source]

Represents the type of a drug - either small molecule or biologic.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.Drug(**kwargs)[source]

Represents a drug.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

as_bel() → pybel.dsl.node_classes.Abundance[source]

Get this drug as a PyBEL abundance identified by its DrugBank identifier.

as_inchi_bel() → pybel.dsl.node_classes.Abundance[source]

Get this drug as a PyBEL abundance identified by InChI.

as_inchikey_bel() → pybel.dsl.node_classes.Abundance[source]

Get this drug as a PyBEL abundance identified by InChI-key.

as_cas_bel() → pybel.dsl.node_classes.Abundance[source]

Get this drug as a PyBEL abundance identified by its CAS identifier.

class bio2bel_drugbank.models.DrugXref(**kwargs)[source]

Represents a drug’s cross-reference to another database.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.Patent(**kwargs)[source]

Represents a patent.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

google_url

Return the Google Patents URL of this patent.

class bio2bel_drugbank.models.Alias(**kwargs)[source]

Represents an alias of a drug.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.AtcCode(**kwargs)[source]

Represents an ATC code of a drug.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.Group(**kwargs)[source]

Represents a drug group.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.Category(**kwargs)[source]

Represents a drug category.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.Species(**kwargs)[source]

Represents a species.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.Protein(**kwargs)[source]

Represents a protein.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

as_bel() → pybel.dsl.node_classes.Protein[source]

Serialize as a PyBEL node with the UniProt namespace.

class bio2bel_drugbank.models.Action(**kwargs)[source]

Represents the action a drug takes in a drug-protein interaction.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.Article(**kwargs)[source]

Represents an article in PubMed.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class bio2bel_drugbank.models.DrugProteinInteraction(**kwargs)[source]

Represents an interaction between a drug and a protein.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

add_to_graph(graph: pybel.struct.graph.BELGraph) → Set[str][source]

Add this interaction to the graph.

Returns:A set of the hashes of the edges that were added

Indices and tables