DrugBank (indra.sources.drugbank)

This module provides an API and processor for DrugBank content. It builds on the XML-formatted data schema of DrugBank and expects the XML file to be available locally. The full DrugBank download can be obtained at: https://www.drugbank.ca/releases/latest. Once the XML file is decompressed, it can be processed using the process_xml function.

Alternatively, the latest DrugBank data can be automatically loaded via drugbank_downloader with the following code after doing pip install drugbank_downloader bioversions:

import pickle
import indra.sources.drugbank
processor = indra.sources.drugbank.get_drugbank_processor()
with open('drugbank_indra_statements.pkl', 'wb') as file:
    pickle.dump(processor.statements, file, protocol=pickle.HIGHEST_PROTOCOL)

DrugBank API (indra.sources.drugbank.api)

indra.sources.drugbank.api.process_element_tree(et)[source]

Return a processor by extracting Statement from DrugBank XML.

Parameters

et (xml.etree.ElementTree) – An ElementTree loaded from the DrugBank XML file to process.

Returns

A DrugbankProcessor instance which contains a list of INDRA Statements in its statements attribute that were extracted from the given ElementTree.

Return type

DrugbankProcessor

indra.sources.drugbank.api.process_from_web(username=None, password=None, version=None, prefix=None)[source]

Get a processor using process_xml() with drugbank_downloader.

Parameters
  • username (Optional[str]) – The DrugBank username. If not passed, looks up in the environment DRUGBANK_USERNAME. If not found, raises a ValueError.

  • password (Optional[str]) – The DrugBank password. If not passed, looks up in the environment DRUGBANK_PASSWORD. If not found, raises a ValueError.

  • version (Optional[str]) – The DrugBank version. If not passed, uses bioversions to look up the most recent version.

  • prefix (Union[None, str, Sequence[str]]) – The prefix and subkeys passed to pystow.ensure() to specify a non-default location to download the data to.

Returns

A DrugbankProcessor instance which contains a list of INDRA Statements in its statements attribute that were extracted from the given DrugBank version

Return type

DrugbankProcessor

indra.sources.drugbank.api.process_xml(fname)[source]

Return a processor by extracting Statements from DrugBank XML.

Parameters

fname (str) – The path to a DrugBank XML file to process.

Returns

A DrugbankProcessor instance which contains a list of INDRA Statements in its statements attribute that were extracted from the given XML file.

Return type

DrugbankProcessor

DrugBank Processor (indra.sources.drugbank.processor)

class indra.sources.drugbank.processor.DrugbankProcessor(xml_tree)[source]

Processor to extract INDRA Statements from DrugBank content.

The processor assumes that an ElementTree is available which it then traverses to find drug-target information.

Parameters

xml_tree (xml.etree.ElementTree.ElementTree) – An XML ElementTree representing DrugBank XML content.

statements

A list of INDRA Statements that were extracted from DrugBank content.

Type

list of indra.statements.Statement