Package {dbparser}


Title: Drugs Databases Parser
Version: 2.3.0
Description: Parses drug and gene databases from their downloaded files: the 'DrugBank' XML database https://go.drugbank.com/, the 'OnSIDES' and 'TWOSIDES' adverse drug event databases, Human Phenotype Ontology ('HPO') gene-phenotype associations, the 'HGNC' gene nomenclature files, Health Canada's Drug Product Database ('DPD') data extract, and the 'openFDA' 'Drugs@FDA' and 'NDC' directory downloads. The parsed tables are returned in an 'R' object called 'dvobject', which records the source release, licence and file hashes.
License: MIT + file LICENSE
Encoding: UTF-8
Imports: data.table, dplyr, jsonlite, progress, purrr, tibble, tools, utils, XML
Suggests: canvasXpress, knitr, rmarkdown, testthat, tidyr
VignetteBuilder: knitr
URL: https://docs.ropensci.org/dbparser/, https://github.com/ropensci/dbparser, https://interstellar-egypt.com
BugReports: https://github.com/ropensci/dbparser/issues
Depends: R (≥ 3.5)
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-11-08 02:31:10 UTC; mohammed
Author: Mohammed Ali [aut, cre], Ali Ezzat [aut], Hao Zhu [rev], Emma Mendelsohn [rev], Interstellar [cph, fnd] (Interstellar for Consultation Services, URL: https://interstellar-egypt.com)
Maintainer: Mohammed Ali <mohammed.ali@interstellar-egypt.com>
Repository: CRAN
Date/Publication: 2026-11-08 21:30:08 UTC

dbparser: A package for reading and parsing DrugBank xml database.

Description

The main purpose of the 'dbparser' package is to parse [DrugBank](https://go.drugbank.com/) database which is downloadable in XML format from [this link](https://go.drugbank.com/releases/latest).

Details

The parsed data can then be explored and analyzed.

To achieve this purpose, 'dbparser“ package provides three main categories of functions:

- xml db reader,

- DrugBank elements parsers,

For more information kindly check the reference/index (https://docs.ropensci.org/dbparser/reference/index.html)

xml db reader functions

Reads DrugBank xml database and build drug elements full tree in memory

parsers functions

Each parser function is responsible of parsing certain drug element and returning its tibble.

Check this tutorial (https://docs.ropensci.org/dbparser/articles/dbparser.html)

Author(s)

Maintainer: Mohammed Ali mohammed.ali@interstellar-egypt.com

Authors:

Other contributors:

See Also

Useful links:


Generic fallback: search an object tree for a data frame with required columns

Description

Generic fallback: search an object tree for a data frame with required columns

Usage

.find_table_with_columns(obj, required_cols, max_depth = 5L)

Arguments

obj

A list (possibly nested).

required_cols

Character vector of column names that must all be present.

max_depth

Integer. Maximum recursion depth.

Value

A tibble or NULL.


Resolve drug name lookup from a DrugBank dvobject

Description

Returns a two-column tibble: drugbank_id, drug_name. Navigates: $drugs$general_information

Usage

.resolve_drug_names(drugbank_db)

Arguments

drugbank_db

A DrugBank dvobject.

Value

A tibble or NULL.


Resolve polypeptides general_information table

Description

Navigates: $cett$targets$polypeptides$general_information Contains: gene_name, target_id, polypeptide_id, name, ...

Usage

.resolve_polypeptides_gi(drugbank_db)

Arguments

drugbank_db

A DrugBank dvobject.

Value

A tibble or NULL.


Resolve targets general_information table

Description

Navigates: $cett$targets$general_information Contains: target_id, drugbank_id, name, organism, ...

Usage

.resolve_targets_gi(drugbank_db)

Arguments

drugbank_db

A DrugBank dvobject.

Value

A tibble or NULL.


add_database_info Assign passed databases db metadata to passed dvobject

Description

add_database_info Assign passed databases db metadata to passed dvobject

Usage

add_database_info(
  dvobject,
  db_type = "DrugBank",
  db_version = NULL,
  db_exported_date = NULL
)

Arguments

dvobject

dvobject to assign metadata to it

db_type

database type (defualt="DrugBank")

db_version

database version as string

db_exported_date

database official export date

Value

dvobject

See Also

Other utility: get_genes_for_phenotype(), get_source_metadata(), search_phenotypes(), show_dvobject_metadata(), subset_drugbank_dvobject(), subset_onsides_dvobject()


Drugs/ Carriers/ Enzymes/ Targets/ Transporters articles element parser

Description

Return a list of articles that were used as references for drugs carriers

Usage

drugs_articles()

carriers_articles()

enzymes_articles()

targets_articles()

transporters_articles()

Value

a tibble with 4 variables:

ref-id

Identifier for the article being referenced. This is unique across all reference types (books, links, article, attachments).

pubmed-id

The PubMed identifier for the article.

citation

Article citation in a standard format.

parent_id

drug/carrier/target/enzyme/transporter id


Drugs/ Carriers/ Enzymes/ Targets/ Transporters attachments element parser

Description

Return a list of attachment that were used as references for drugs carriers

Usage

drugs_attachments()

carriers_attachments()

enzymes_attachments()

targets_attachments()

transporters_attachments()

Value

a tibble with 4 variables:

ref-id

Identifier for the article being referenced. This is unique across all reference types (books, links, article, attachments).

title

The title of the attachment.

url

The url to download the attachment from.

parent_id

drug/carrier/target/enzyme/transporter id


Drugs/ Carriers/ Enzymes/ Targets/ Transporters books element parser

Description

Return a list of text books that were used as references for drugs, carriers, enzymes, targets or transporters

Usage

drugs_textbooks()

carriers_textbooks()

enzymes_textbooks()

targets_textbooks()

transporters_textbooks()

Value

a tibble with 4 variables:

ref-id

Identifier for the article being referenced. This is unique across all reference types (books, links, article, attachments).

isbn

ISBN identifying the textbook.

citation

A Textbook citation in a standard format.

parent_id

drug/ carrier/ target/ enzyme/ transporter id


Build the HGNC gene_name table

Description

Build the HGNC gene_name table

Usage

build_hgnc_gene_names(gene)

Arguments

gene

tibble from read_hgnc_complete_set()

Value

tibble with hgnc_id, kind and name


Build Metadata Data Frame

Description

Build Metadata Data Frame

Usage

build_metadata(attrs, has_second_db, second_db_name)

Arguments

attrs

Attributes list

has_second_db

Logical indicating if second database exists

second_db_name

Name of second database attribute

Value

Data.frame with database metadata


Carriers/ Enzymes/ Targets/ Transporters Actions parsers

Description

Collection of related actions

Usage

carriers_actions()

enzymes_actions()

targets_actions()

transporters_actions()

Value

a tibble with 2 variables:

action

describe related action

parent_id

carrier/ target/ enzyme/ transporter id


Carriers/ Enzymes/ Targets/ Transporters parsers

Description

Protein targets of drug action, enzymes that are inhibited/induced or involved in metabolism, and carrier or transporter proteins involved in movement of the drug across biological membranes.

Usage

carriers()

enzymes()

targets()

transporters()

Value

a tibble with 6 variables (8 for enzymes):

id

Universal Protein Resource (UniProt) Identifier for the record

name

related name

organism

Organism that the protein comes from.

known_action

Whether the pharmacological action of the drug is due to this target interaction.

inhibition-strength

Whether the strength of enzyme inhibition is strong, moderate, or unknown. Only applies to enzymes

induction-strength

Whether the strength of enzyme induction is strong or unknown. Only applies to enzymes

position

related position

parent_id

drugbank id


Carriers/ Enzymes/ Targets/ Transporters Polypeptide External Identifiers parsers

Description

Extract descriptions of identified polypeptide external identifiers for targets, enzymes, carriers, or transporters.

Usage

carriers_polypep_ex_ident()

enzymes_polypep_ex_ident()

targets_polypep_ex_ident()

transporters_polypep_ex_ident()

Value

a tibble with 3 variables:

resource

Name of the source database.

identifier

Identifier for this drug in the given resource.

parent_key

polypeptide id


Carriers/ Enzymes/ Targets/ Transporters Polypeptide GO Classifier parsers

Description

Extract descriptions of identified polypeptide go classifier for targets, enzymes, carriers, or transporters.

Usage

carriers_polypeptides_go()

enzymes_polypeptides_go()

targets_polypeptides_go()

transporters_polypeptides_go()

Value

a tibble with 3 variables:

category
description
parent_key

polypeptide id


returns carriers, enzymes,targets and transporters node valid options.

Description

returns carriers, enzymes,targets and transporters node valid options.

Usage

cett_nodes_options()

Value

list of CETT valid options

See Also

Other parsers: drug_node_options(), parseDrugBank(), parseHGNC(), parseHPO(), parseHealthCanadaDPD(), parseOnSIDES(), parseOpenFDA(), parseTWOSIDES(), references_node_options()


Carriers/ Enzymes/ Targets/ Transporters Polypeptide parsers

Description

Extract descriptions of identified polypeptide targets, enzymes, carriers, or transporters.

Usage

carriers_polypeptides()

enzymes_polypeptides()

targets_polypeptides()

transporters_polypeptides()

Value

a tibble with 20 variables:

id

Universal Protein Resource (UniProt) identifier

source

Specifies whether the identified polypeptide ID is associated with any of the following UniProt knowledge bases: Swiss-Prot, which is manually annotated and reviewed, or TrEMBL, which is automatically annotated and not reviewed.

name
general_function

General summary of the physiological function of the polypeptide

specific_function

A more specific description of the polypeptide’s physiological function within the cell.

gene_name

The short name commonly associated with the associated gene. Eg. PTGS1.

locus

The specific chromosomal location or position of the gene’s sequence on a chromosome.

cellular_location

The cellular location of the polypeptide.

transmembrane_regions

Areas of the polypeptide sequence that span a biological membrane.

signal_regions

Location of any signal peptides within the polypeptide sequence.

theoretical_pi

Theoretical isoelectric point.

molecular_weight

The molecular weight of the polypeptide.

chromosome_location

The chromosomal location of the polypeptide gene

organism

The organism in which this polypeptide functions.

organism_ncbi_taxonomy_id
amino_acid_sequence

The amino acid sequence of the polypeptide

amino_acid_format
gene_sequence

The sequence of the associated gene.

gene_format
parent_key

carrier/ target/ enzyme/ transporter id


Carriers/ Enzymes/ Targets/ Transporters Polypeptide PFAMS parsers

Description

Extract descriptions of identified polypeptide PFAMS targets, enzymes, carriers, or transporters.

Usage

carriers_polypeptides_pfams()

enzymes_polypeptides_pfams()

targets_polypeptides_pfams()

transporters_polypeptides_pfams()

Value

a tibble with 3 variables:

name

The sequence of the associated gene.

identifier
parent_key

polypeptide id


Carriers/ Enzymes/ Targets/ Transporters Polypeptide Synonyms parsers

Description

Extract descriptions of identified polypeptide synonyms for targets, enzymes, carriers, or transporters.

Usage

carriers_polypeptides_syn()

enzymes_polypeptides_syn()

targets_polypeptides_syn()

transporters_polypeptides_syn()

Value

a tibble with 2 variables:

synonym
parent_key

polypeptide id


Check DPD keys

Description

drug_code is unique in drug_product, and every other table's drug_code is a product.

Usage

check_dpd_tables(tables)

Arguments

tables

named list of DPD tables

Value

NULL, invisibly; stops on a failed check


Check an HGNC input path

Description

Check an HGNC input path

Usage

check_hgnc_path(path, arg)

Arguments

path

value passed by the caller

arg

argument name, for the error message

Value

NULL, invisibly; stops on a bad path


Check openFDA keys and references

Description

Check openFDA keys and references

Usage

check_openfda_tables(tables)

Arguments

tables

named list of shaped tables

Value

NULL, invisibly; stops on a failed check


Count Top Level Lists

Description

Count Top Level Lists

Usage

count_top_level_lists(obj)

Arguments

obj

Object to analyze

Value

Integer count of top-level lists (excluding data.frames)


DPD product sets: folder (and zip) name and file-name suffix

Description

DPD product sets: folder (and zip) name and file-name suffix

Usage

dpd_extract_folders()

Value

named list


DPD tables as in Health Canada's read-me

Description

File stem, columns in file order (read-me names, lower case), integer and date columns. The read-me calls the biosimilar files bios*.txt; the zips hold biosimilar*.txt. The therapeutic class files hold one unnamed field after the three named ones, which must be empty.

Usage

dpd_table_specs()

Value

named list of table specs


Drug Affected Organism parser

Description

Organisms in which the drug may display activity; activity may depend on local susceptibility patterns and resistance.

Usage

drug_affected_organisms()

Value

a tibble with 2 variables:

affected-organism

affected-organism name

drugbank_id

drugbank id


Drug ahfs-codes parser

Description

The American Hospital Formulary Service (AHFS) identifier for this drug.

Usage

drug_ahfs_codes()

Value

a tibble with the following variables:

ahfs-code
drugbank_id

drugbank id


Drug ATC Codes element parser

Description

The Anatomical Therapeutic Classification (ATC) code for the drug assigned by the World Health Organization Anatomical Chemical Classification System.

Usage

drug_atc_codes()

Details

Each 'atc-code“ row has one or more level. The atc-code and level> have a code the code assigned by the World Health Organization Anatomical Therapeutic Chemical Classification system.

Value

a tibble with 10 variables


Drug Calculated Properties parser

Description

Drug properties that have been predicted by ChemAxon or ALOGPS based on the imputed chemical structure. Associated links below will redirect to descriptions of the specific term.

Usage

drug_calc_prop()

Value

a tibble with 4 variables:

kind

Name of the property.

value

Predicted physicochemical properties; obtained by the use of prediction software such as ALGOPS and ChemAxon.

source

Name of the software used to calculate this property, either ChemAxon or ALOGPS.

drugbank_id

drugbank id


Drug Categories parser

Description

General categorizations of the drug.

Usage

drug_categories()

Value

a tibble with 2 variables:

category

category name

mesh-id

The Medical Subjects Headings (MeSH) identifier for the category.

drugbank_id

drugbank id


Drug Classification parser

Description

A description of the hierarchical chemical classification of the drug; imported from ClassyFire.

Usage

drug_classification()

Value

a tibble with 9 variables:

description
direct-parent
kingdom
superclass
class
subclass
alternative-parent

One or more alternative parents

substituent

One or more substituents

drugbank_id

drugbank id


Drug Dosages parser

Description

A list of the commercially available dosages of the drug.

Usage

drug_dosages()

Value

a tibble with the following variables:

form

The pharmaceutical formulation by which the drug is introduced into the body

route

The path by which the drug or product is taken into the body.

strength

The amount of active drug ingredient provided in the dosage

drugbank_id

drugbank id


Drug External Identifiers parser

Description

Identifiers used in other websites or databases providing information about this drug.

Usage

drug_ex_identity()

Value

a tibble with the following variables:

resource

Name of the source database.

identifier

Identifier for this drug in the given resource.

drugbank_id

drugbank id


Drug Experimental Properties parser

Description

Drug properties that have been experimentally proven

Usage

drug_exp_prop()

Value

a tibble with the following variables:

kind

Name of the property.

value

Drug properties that have been experimentally proven.

source

Reference to the source of this experimental data.

drugbank_id

drugbank id

The following experimental properties are provided:

Water Solubility

The experimentally determined aqueous solubility of the molecule.

Molecular Formula

Protein formula of Biotech drugs

Molecular Weight

Protein weight of Biotech drugs.

Melting Point

The experimentally determined temperature at which the drug molecule changes from solid to liquid at atmospheric temperature.

Boiling Point

The experimentally determined temperature at which the drug molecule changes from liquid to gas at atmospheric temperature.

Hydrophobicity

The ability of a molecule to repel water rather than absorb or dissolve water.

Isoelectric Point

The pH value at which the net electric charge of a molecule is zero.

caco2 Permeability

A continuous line of heterogenous human epithelial colorectal adenocarcinoma cells, CAC02 cells are employed as a model of human intestinal absorption of various drugs and compounds. CAC02 cell permeability is ultimately an assay to measure drug absorption.

pKa

The experimentally determined pka value of the molecule

logP

The experimentally determined partition coefficient (LogP) based on the ratio of solubility of the molecule in 1-octanol compared to water.

logS

The intrinsic solubility of a given compound is the concentration in equilibrium with its solid phase that dissolves into solution, given as the natural logarithm (LogS) of the concentration.

Radioactivity

The property to spontaneously emit particles (alpha, beta, neutron) or radiation (gamma, K capture), or both at the same time, from the decay of certain nuclides.


Description

Links to other websites or databases providing information about this drug.

Usage

drug_external_links()

Value

a tibble with the following variables:

resource

Name of the source website.

identifier

Identifier for this drug in the given resource

drugbank_id

drugbank id


Drug Groups parser

Description

Food that may interact with this drug.

Usage

drug_food_interactions()

Value

a tibble with the following variables:

food-interaction
drugbank_id

drugbank id


Drugs General Information parser

Description

A description of the hierarchical chemical classification of the drug; imported from ClassyFire.

Usage

drug_general_information()

Value

a tibble with 15 variables:

primary_key

DrugBank id

other_keys

Other identifiers that may be associated with the drug

type

Either small molecule, or biotech. Biotech is used for any drug that is derived from living systems or organisms, usually composed of high molecular weight mixtures of protein, while small molecule describes a low molecular weight organic compound.

name
created

Date that this drug was first added to DrugBank.

updated

Denotes when this drug was last updated in DrugBank.

description

Descriptions of drug chemical properties, history and regulatory status.

cas_number

The Chemical Abstracts Service (CAS) registry number assigned to the drug.

unii

Unique Ingredient Identifier (UNII) of this drug.

average_mass

The weighted average of the isotopic masses of the drug

state

One of solid, liquid, or gas

monoisotopic_mass

The mass of the most abundant isotope of the drug

synthesis_reference

Citation for synthesis of the drug molecule.

fda_label

Contains a URL for accessing the uploaded United States Food and Drug Administration (FDA) Monograph for this drug.

msds

Contains a URL for accessing the Material Safety Data Sheet (MSDS) for this drug.


Drug Groups parser

Description

Groups that this drug belongs to. May include any of: approved, vet_approved, nutraceutical, illicit, withdrawn, investigational, and experimental.

Usage

drug_groups()

Value

a tibble with 2 variables:

group
drugbank_id

drugbank id


Drug Interactions parser

Description

Drug-drug interactions detailing drugs that, when administered concomitantly with the drug of interest, will affect its activity or result in adverse effects. These interactions may be synergistic or antagonistic depending on the physiological effects and mechanism of action of each drug.

Usage

drug_interactions()

Value

a tibble with the following variables:

drugbank-id

DrugBank ID of the interacting drug.

name

Name of the interacting drug.

description

Textual description of the physiological consequences of the drug interaction

drugbank_id

parent drugbank id


Drug International Brands parser

Description

The proprietary names used by the manufacturers for commercially available forms of the drug, focusing on brand names for products that are available in countries other than Canada and the Unites States.

Usage

drug_intern_brand()

Value

a tibble with 4 variables:

brand

The proprietary, well-known name for given to this drug by a manufacturer.

company

The company or manufacturer that uses this name.

drugbank_id

drugbank id


Drug Manufacturers parser

Description

A list of companies that are manufacturing the commercially available forms of this drug that are available in Canada and the Unites States.

Usage

drug_manufacturers()

Value

a tibble with the following variables:

generic

A list of companies that are manufacturing the generic form of the drug.

url

A link to the companies that are manufacturing the drug.

drugbank_id

drugbank id


Drug Mixtures parser

Description

All commercially available products in which this drug is available in combination with other drug molecules

Usage

drug_mixtures()

Value

a tibble with 4 variables:

name

The proprietary name provided by the manufacturer for this combination product.

ingredients

A list of ingredients, separated by addition symbols

supplemental-ingredients

List of additional active ingredients which are not clinically relevant to the main indication of the product, separated by addition symbols.

drugbank_id

drugbank id


returns drug node valid options.

Description

returns drug node valid options.

Usage

drug_node_options()

Value

list of drug valid options

See Also

Other parsers: cett_nodes_options(), parseDrugBank(), parseHGNC(), parseHPO(), parseHealthCanadaDPD(), parseOnSIDES(), parseOpenFDA(), parseTWOSIDES(), references_node_options()


Drug Packagers parser

Description

A list of companies that are packaging the drug for re-distribution.

Usage

drug_packagers()

Value

a tibble with 2 variables:

name
url

A link to any companies that are packaging the drug for re-distribution.

drugbank_id

drugbank id


Drug Patents parser A property right issued by the United States Patent and Trademark Office (USPTO) to an inventor for a limited time, in exchange for public disclosure of the invention when the patent is granted. Drugs may be issued multiple patents.

Description

Drug Patents parser A property right issued by the United States Patent and Trademark Office (USPTO) to an inventor for a limited time, in exchange for public disclosure of the invention when the patent is granted. Drugs may be issued multiple patents.

Usage

drug_patents()

Value

a tibble with the following variables:

number

The patent number(s) associated with the drug.

country

The country that issued the patent rights.

approved

The date that the patent request was filed.

expires

The date that the patent rights expire.

pediatric-extension

Indicates whether or not a pediatric extension has been approved for the patent. Granted pediatric extensions provide an additional 6 months of market protection.

drugbank_id

drugbank id


Drug Pathway parser

Description

Metabolic, disease, and biological pathways that the drug is involved in, as identified by the Small Molecule Protein Database (SMPDB).

Usage

drug_pathway()

Value

a tibble with the following variables:

smpdb-id

Small Molecule Pathway Database identifier for this pathway.

name

Pathway name

category

Pathway category

drugbank_id

drugbank id


Drug Pathway Drugs parser

Description

Drugs involved in this pathway.

Usage

drug_pathway_drugs()

Value

a tibble with pathway drugs properties


Drug Pathway Enzymes parser

Description

Enzymes involved in this pathway.

Usage

drug_pathway_enzyme()

Value

a tibble with pathway properties


Drug pdb-entries parser

Description

Protein Data Bank (PDB) identifiers for this drug.

Usage

drug_pdb_entries()

Value

a tibble with the following variables:

pdb-entry
drugbank_id

drugbank id


Drug Pharmacology parser

Description

Describes the use, mechanism of action, pharmacokinetics, pharmacodynamics, and physiological or biochemical effects in the body.

Usage

drug_pharmacology()

Value

a tibble with the following variables:

indication

The approved conditions, diseases, or states for which a drug can safely and effectively be used. An indication is considered to be FDA-approved when it has any of the following designations: NDA, ANDA, BLA, or OTC. May also include indications in other countries, such as Canada (through Health Canada) or in Europe (through the European Medicines Agency).

pharmacodynamics

A description of how the drug modifies or affects the organism it is being used in. May include effects in the body that are desired (enzyme or protein targets for example) and undesired (also known as “side effects”). This is in contrast to pharmacokinetics, which describes how the body modifies the drug being used.

mechanism_of_action

A component of pharmacodynamics that describes the biochemical interaction through which a drug produces its intended effect. May include the exact molecular protein or enzyme targets and/or a description of the physiological effects produced.

toxicity

Any adverse reaction, or side effect, that may or may not occur with use of the drug. May be attributed to a number of effects including: an enhanced therapeutic effect, rare anaphylactic reactions, interactions with other medications, or unanticipated binding of the molecule at different sites within the body.

metabolism

A description of the chemical degradation of the drug molecule within the body; most commonly by enzymes from the Cytochrome P450 (CYP) system in the liver.

absorption

A description of the movement of the drug from the site of administration into the bloodstream or target tissue. Common pharmacokinetic metrics used to evaluate absorption include Area Under the Curve (AUC), bioavailability (F), maximum concentration (Cmax), and time to maximum concentration (Tmax).

half-life

The period of time it takes for the amount of drug in the body to be reduced by one half. Provides a description of how quickly the drug is being eliminated and how much is available in the bloodstream.

protein-binding

A description of the drug’s affinity for plama proteins and the proportion of the drug that is bound to them when in circulation within the body.

route_of_elimination

A description of the pathway that is used to excrete the drug from the body. Common pharmacokinetic parameters used to evaluate excretion include elimination half life, renal clearance, and tracking of radiolabelled compounds through the renal and GI system.

volume_of_distribution

The Vd of a drug represents the degree to which it is distributed into body tissue compared to the plasma.

clearance

A pharmacokinetic measurement of the rate of removal of the drug from plasma, expressed as mL/min; reflects the rate of elimination of the drug.

drugbank_id

drugbank id


Drug Prices Parsers

Description

Unit drug prices

Usage

drug_prices()

Value

a tibble with 5 variables:

description
cost

Drug price per unit

currency

Currency of price, example: US.

unit
parent_id

drugbank id


Drug Products parser

Description

A list of commercially available products in Canada and the United States that contain the drug.

Usage

drug_products()

Value

a tibble with 32 variables:

name

The proprietary name(s) provided by the manufacturer for any commercially available products containing this drug.

labeller

The corporation responsible for labelling this product.

ndc-id

The National Drug Code (NDC) identifier of the drug

ndc-product-code

The National Drug Code (NDC) product code from the FDA National Drug Code directory.

dpd-id

Drug Product Database (DPD) identification number (a.k.a. DIN) from the Canadian Drug Product Database. Only present for drugs that are marketed in Canada

ema-product-code

EMA product code from the European Medicines Agency Database. Only present for products that are authorized by central procedure for marketing in the European Union.

ema-ma-number

EMA marketing authorization number from the European Medicines Agency Database. Only present for products that are authorized by central procedure for marketing in the European Union.

started-marketing-on

The starting date for market approval.

ended-marketing-on

The ending date for market approval.

dosage-form

The pharmaceutical formulation by which the drug is introduced into the body.

strength

The amount of active drug ingredient provided in the dosage

route

The path by which the drug or product is taken into the body

fda-application-number

The New Drug Application [NDA] number assigned to this drug by the FDA.

over-the-counter

A list of Over The Counter (OTC) forms of the drug.

generic

Whether this product is a generic drug.

approved

Indicates whether this drug has been approved by the regulating government.

country

The country where this commercially available drug has been approved.

source

Source of this product information. For example, a value of DPD indicates this information was retrieved from the Canadian Drug Product Database.

standing

One of good, discordant, or deprecated. Distinguishes products with up to date ingredient information (good) from products with conflicting information (discordant) or products that have been removed from an active label (deprecated).

standing-updated-on

The date on which the standing was last updated

standing-reason

Explains the non-good standing of the product. One of: ingredient_change, code_duplication, invalid, or removed.

jurisdiction-marketing-category

The marketing category of this product in its jurisdiction

branded

Whether this product has a named brand

prescription

Whether this product is only available with a prescription

unapproved

Whether this product is not approved in its jurisdiction

vaccine

Whether this product is a vaccine

allergenic

Whether this product is used in allergenic testing

cosmetic

Whether this product is a cosmetic, such as sunscreen

kit

Whether this product is a kit composed of multiple distinct parts

solo

Whether this product has only a single active ingredient

available

Whether this product can be sold in its jurisdiction

drugbank_id

drugbank id


Drug Reactions Parsers

Description

Extract the sequential representation of the metabolic reactions that this drug molecule is involved in. Depending on available information, this may include metabolizing enzymes, reaction type, substrates, products, pharmacological activity of metabolites, and a structural representation of the biochemical reactions.

Usage

drug_reactions()

Value

a tibble with 5 variables:

sequence

Reactions are displayed within a numerical sequence

left_drugbank_name

The substrate of the reaction. Maybe a drug or a metabolite.

rightt_drugbank_name

The product of the reaction. Maybe a drug or a metabolite.

left_drugbank_id
right_drugbank_id
parent_id

drugbank id


Drug Reactions Enzymes Parsers

Description

Enzymes involved in metabolizing this drug

Usage

drug_reactions_enzymes()

Value

a tibble with 3 variables:

name
uniprot-id
parent_id

drugbank id


Drug Salts parser

Description

Available salt forms of the drug. Ions such as hydrochloride, sodium, and sulfate are often added to the drug molecule to increase solubility, dissolution, or absorption.

Usage

drug_salts()

Value

a tibble with 1 variables:

drugbank-id

DrugBank identifiers of the available salt form(s).

name

Name of the available salt form(s)

unii

Unique Ingredient Identifier (UNII) of the available salt form(s).

cas-number

Chemical Abstracts Service (CAS) registry number assigned to the salt form(s) of the drug.

inchikey

IUPAC International Chemical Identifier (InChi) key identifier for the available salt form(s).

average-mass

Average molecular mass: the weighted average of the isotopic masses of the salt.

monoisotopic-mass

The mass of the most abundant isotope of the salt

smiles

The simplified molecular-input line-entry system (SMILES) is a line notation used for describing the structure of chemical species using short ASCII strings; calculated by ChemAxon.

inchi

A prediction of the IUPAC International Chemical Identifier (InChI); imported by ChemAxon.

formula

Indicates the simple numbers of each type of atom within the molecule; calculated by ChemAxon.

drugbank_id

parent drugbank id


Drug Sequences parser

Description

The amino acid sequence; provided if the drug is a peptide.

Usage

drug_sequences()

Details

Describes peptide sequences of biotech drugs

Value

a tibble with the following variables:

sequence

a textual representation of the sequence

format

Currently, only the FASTA format is used

drugbank_id

drugbank id


Drug SNP Adverse Drug Reactions parser

Description

The adverse drug reactions that may occur as a result of the listed single nucleotide polymorphisms (SNPs)

Usage

drug_snp_adverse_reactions()

Value

a tibble with the following variables:

protein-name

Proteins involved in this SNP.

gene-symbol

Genes involved in this SNP.

uniprot-id

Universal Protein Resource (UniProt) identifiers for proteins involved in this pathway.

rs-id

The SNP Database identifier for this single nucleotide polymorphism.

allele

The alleles associated with the identified SNP.

adverse-reaction
description
pubmed-id

Reference to PubMed article.

drugbank_id

drugbank id


Drug SNP Effects parser

Description

A list of single nucleotide polymorphisms (SNPs) relevant to drug activity or metabolism, and the effects these may have on pharmacological activity. SNP effects in the patient may require close monitoring, an increase or

Usage

drug_snp_effects()

Value

a tibble with the following variables:

protein-name

Proteins involved in this SNP.

gene-symbol

Genes involved in this SNP.

uniprot-id

Universal Protein Resource (UniProt) identifiers for proteins involved in this pathway.

rs-id

The SNP Database identifier for this single nucleotide polymorphism.

allele

The alleles associated with the identified SNP.

defining-change
description

A written description of the SNP effects.

pubmed-id

Reference to PubMed article.

drugbank_id

drugbank id


Drug Synonyms parser

Description

Other names or identifiers that are associated with this drug.

Usage

drug_syn()

Value

a tibble with 3 variables:

language

Names of the drug in languages other than English.

coder

Organization or source providing the synonym. For example, INN indicates the synonym is an International Nonproprietary Name, while IUPAC indicates the synonym is the nomenclature designated by the International Union of Pure and Applied Chemistry.

drugbank_id

drugbank id


Find All Data Frames Recursively

Description

Find All Data Frames Recursively

Usage

find_dataframes_recursive(x, prefix = "")

Arguments

x

Object to search

prefix

Current path prefix

Value

Data.frame with paths, dimensions, and sizes


Find Second Database in Attributes

Description

Find Second Database in Attributes

Usage

find_second_database(attrs)

Arguments

attrs

Attributes list

Value

List with has_second_db (logical) and second_db_name (character)


Drugs@FDA records into their tables

Description

Drugs@FDA records into their tables

Usage

flatten_drugsfda(records)

Arguments

records

parsed results

Value

named list of data.frames


NDC directory records into their tables

Description

NDC directory records into their tables

Usage

flatten_ndc(records)

Arguments

records

parsed results

Value

named list of data.frames


Get Genes Associated with a Phenotype

Description

Returns the genes associated with a phenotype, given either its HPO identifier (e.g. "HP:0001250") or its name.

Usage

get_genes_for_phenotype(hpo_db, phenotype, exact = FALSE)

Arguments

hpo_db

An HPO dvobject returned by parseHPO.

phenotype

Character. An HPO identifier or a phenotype name.

exact

Logical. Used when phenotype is a name. If TRUE, the name must match exactly (ignoring case). If FALSE (default), any phenotype whose name contains phenotype matches.

Value

A tibble with columns gene_symbol, entrez_id, hpo_id, phenotype_name and association_weight, ordered by gene symbol.

See Also

Other utility: add_database_info(), get_source_metadata(), search_phenotypes(), show_dvobject_metadata(), subset_drugbank_dvobject(), subset_onsides_dvobject()

Examples

hpo_db <- parseHPO(system.file("extdata", "hpo_gene_attribute_edges.txt",
                               package = "dbparser"))
get_genes_for_phenotype(hpo_db, "HP:0001250")
get_genes_for_phenotype(hpo_db, "thrombosis")


Get the source metadata of a dvobject

Description

Returns where each source in a dvobject came from: release, dates, URLs, licence, attribution, the parsed files with their SHA-256 hashes, and the dbparser version that parsed them. A merged dvobject has one row per source. Unknown values are NA.

Usage

get_source_metadata(dvobject)

Arguments

dvobject

a dvobject returned by a parser or a merge function

Value

a tibble with one row per source and columns metadata_version, source, source_name, release, release_date, retrieved_at, source_url, licence, licence_url, attribution, files (a list column of data.frames with name and sha256) and parser. It has no rows when the dvobject carries no source metadata (e.g. one saved by an older dbparser version).

See Also

Other utility: add_database_info(), get_genes_for_phenotype(), search_phenotypes(), show_dvobject_metadata(), subset_drugbank_dvobject(), subset_onsides_dvobject()

Examples

drugbank <- parseDrugBank(
  system.file("extdata", "drugbank_record_biotech.xml",
              package = "dbparser"))
get_source_metadata(drugbank)


init_dvobject initialize dvobject

Description

init_dvobject initialize dvobject

Usage

init_dvobject()

Value

dvobject


Description

Return a list of websites that were used as references for Drugs/ Carriers/ Enzymes/ Targets/ Transporters

Usage

drugs_links()

carriers_links()

enzymes_links()

targets_links()

transporters_links()

Value

a tibble with 4 variables:

ref-id

Name of the source website

title

Identifier for this drug in the given resource

url

The url of the website

parent_id

drug/ carrier/ target/ enzyme/ transporter id


Merge DrugBank and HPO Gene-Phenotype Database Objects

Description

Creates an integrated dvobject by linking DrugBank target gene data with HPO gene-phenotype associations using gene symbols as the bridge.

Usage

merge_drugbank_hpo(db_object, hpo_db)

Arguments

db_object

A dvobject from parseDrugBank() OR an existing merged dvobject (containing $drugbank).

hpo_db

A dvobject produced by dbparser::parseHPO().

Details

This function performs the following key steps: 1. Extracts gene names from DrugBank polypeptide data ($cett$targets$polypeptides$general_information). 2. Links gene names to DrugBank IDs via the target_id bridge ($cett$targets$general_information). 3. Optionally resolves DrugBank IDs to drug names. 4. Enriches the HPO gene-phenotype association table by adding drugbank_id and drug_name columns. 5. Assembles a merged object containing all original data plus the enriched table and the gene mapping bridge.

Supports piping and chaining with other merge functions.

Value

A new dvobject containing the integrated data.

See Also

Other mergers: merge_drugbank_onsides(), merge_drugbank_twosides()

Examples

## Not run: 
drugbank <- parseDrugBank("path/to/drugbank.xml")
hpo      <- parseHPO("path/to/gene_attribute_edges.tsv")

# Standalone merge
merged_db <- merge_drugbank_hpo(drugbank, hpo)

# Chained with other merges (any order)
full_db <- drugbank %>%
  merge_drugbank_hpo(hpo) %>%
  merge_drugbank_onsides(onsides) %>%
  merge_drugbank_twosides(twosides)

# --- Example: Find drugs targeting genes associated with seizures ---
seizure_drugs <- full_db$integrated_data$gene_phenotype_enriched %>%
  filter(grepl("seizure", phenotype_name, ignore.case = TRUE)) %>%
  filter(!is.na(drugbank_id)) %>%
  select(drug_name, drugbank_id, gene_symbol, phenotype_name) %>%
  distinct()

## End(Not run)

Merge DrugBank and OnSIDES Database Objects

Description

Creates an integrated dvobject object by linking DrugBank dvobject with OnSIDES dvobject using RxNorm CUIs as the bridge.

Usage

merge_drugbank_onsides(db_object, onsides_db)

Arguments

db_object

A dvobject from 'parseDrugBank()' OR an existing merged dvobject (containing '$drugbank').

onsides_db

A dvobject produced by 'dbparser::parseOnSIDES()'.

Details

This function performs the following key steps: 1. Creates a mapping table between DrugBank IDs and RxNorm CUIs from the DrugBank object. 2. Enriches the relevant OnSIDES tables ('vocab_rxnorm_ingredient' and optionally 'high_confidence') by adding a 'drugbank_id' column. 3. Assembles a new list object containing all original tables plus the enriched ones and the ID mapping table itself.

The resulting object allows for powerful queries that span both mechanistic data from DrugBank and clinical side-effect data from OnSIDES. Supports piping and chaining with other merge functions.

Value

A new dvobject containing the integrated data.

See Also

Other mergers: merge_drugbank_hpo(), merge_drugbank_twosides()

Examples

## Not run: 
# First, parse the individual databases
drugbank <- parseDrugBank("path/to/drugbank.xml")
onsides <- parseOnSIDES("path/to/onsides_csvs/")

# Now, merge them into a single, powerful object
merged_db <- merge_drugbank_onsides(drugbank, onsides)

# --- Example Analysis: Find the protein targets of all drugs known to ---
# --- cause the side effect "Hepatitis" with high confidence.        ---

# 1. Find the MedDRA ID for "Hepatitis"
hepatitis_id <- merged_db$onsides$vocab_meddra_adverse_effect %>%
  filter(meddra_name == "Hepatitis") %>%
  pull(meddra_id)

# 2. Find all drug ingredients linked to this effect in the high_confidence table
drug_ids_causing_hepatitis <- merged_db$onsides$high_confidence_enriched %>%
  filter(effect_meddra_id == hepatitis_id) %>%
  pull(drugbank_id) %>%
  na.omit() %>%
  unique()

# 3. Look up the targets for these DrugBank IDs
targets_of_interest <- merged_db$targets %>%
  filter(parent_key %in% drug_ids_causing_hepatitis) %>%
  select(drug_id = parent_key, target_name = name, gene_name)

head(targets_of_interest)

## End(Not run)

Merge a DrugBank dvobject with a TWOSIDES dvobject

Description

Integrates drug-drug interaction data from TWOSIDES with the rich mechanistic information from DrugBank. This function is chainable and can accept a raw DrugBank object or an already-merged dvobject.

Usage

merge_drugbank_twosides(db_object, twosides_db)

Arguments

db_object

A dvobject from 'parseDrugBank()' or an existing merged dvobject.

twosides_db

A dvobject from 'parseTWOSIDES()'.

Value

A new, nested dvobject with the TWOSIDES data added.

See Also

Other mergers: merge_drugbank_hpo(), merge_drugbank_onsides()


metadata_date Date from a Date or a "YYYY-MM-DD" string, else NA with a message

Description

metadata_date Date from a Date or a "YYYY-MM-DD" string, else NA with a message

Usage

metadata_date(x)

Arguments

x

value

Value

Date


metadata_files File names and SHA-256 hashes

Description

metadata_files File names and SHA-256 hashes

Usage

metadata_files(files)

Arguments

files

file paths

Value

data.frame with name and sha256


metadata_text Single string or NA

Description

metadata_text Single string or NA

Usage

metadata_text(x)

Arguments

x

value

Value

character(1)


Each record's openfda block as (key, field, value) rows

Description

Each record's openfda block as (key, field, value) rows

Usage

openfda_annotation_rows(records, key_name)

Arguments

records

list of records

key_name

the record's key field

Value

data.frame


A field's value as text, NA when absent or null

Description

A field's value as text, NA when absent or null

Usage

openfda_field(record, name)

Arguments

record

list

name

field name

Value

character(1)


One row per element of each record's list field

Description

One row per element of each record's list field

Usage

openfda_list_rows(records, keys, list_field, columns)

Arguments

records

list of records

keys

function(record) giving a named list of the parent's keys

list_field

name of the list field, e.g. "products"

columns

fields to take from each element

Value

data.frame, the parent key columns first


openFDA tables: columns in order, date, logical and key columns

Description

openFDA tables: columns in order, date, logical and key columns

Usage

openfda_table_specs()

Value

named list of table specs


parseDrugBank

Description

parses given DrugBank XML database into a dvobject. dvobject is a list of data.frames in which each data.frame represents a part of parsed data (i.e drugs, prices, carriers, ...)

Usage

parseDrugBank(
  db_path,
  drug_options = NULL,
  parse_salts = FALSE,
  parse_products = FALSE,
  references_options = NULL,
  cett_options = NULL
)

Arguments

db_path

string, full path for the DrugBank xml or zip file.

drug_options

character vector, list of sub drug related nodes names options to parse (default = NULL). Check drug_node_options() for all available options. If its value is 'NULL' ONLY 'drug_general_information' will be placed in the returned dvobject.

parse_salts

boolean, parse salts info (default = FALSE)

parse_products

boolean, parse products info (default = FALSE)

references_options

character vector, list of sub references related nodes names options to parse (default = NULL). Check references_node_options() for all available options.

cett_options

character vector, list of sub cett related nodes names options to parse (default = NULL). Check cett_nodes_options() for all available options.

Value

dvobject

See Also

Other parsers: cett_nodes_options(), drug_node_options(), parseHGNC(), parseHPO(), parseHealthCanadaDPD(), parseOnSIDES(), parseOpenFDA(), parseTWOSIDES(), references_node_options()


Parse the HGNC Gene Nomenclature Files

Description

Reads the HUGO Gene Nomenclature Committee (HGNC) complete set (hgnc_complete_set.txt) and, optionally, the withdrawn entries (withdrawn.txt) and returns a dvobject with gene, gene name and withdrawn tables.

Usage

parseHGNC(
  complete_set_path,
  withdrawn_path = NULL,
  release = NULL,
  release_date = NULL,
  retrieved_at = NULL
)

Arguments

complete_set_path

Character. Path to hgnc_complete_set.txt.

withdrawn_path

Character or NULL. Path to withdrawn.txt. When NULL the withdrawn table is not built.

release

Character or NULL. Release label, e.g. "2026-10".

release_date

Date, "YYYY-MM-DD" or NULL. Release date.

retrieved_at

Date, "YYYY-MM-DD" or NULL. Date the files were downloaded.

Details

Both files are tab separated and UTF-8. In the complete set a cell holding several values is pipe separated (a|b) and wrapped in double quotes; the parser strips the wrapper and keeps the pipes. Column names are lower-cased with . and - replaced by _ (pseudogene.org becomes pseudogene_org), and the date_* columns become dates. Every other column stays text as written.

HGNC publishes no release number or date for the current files, so release and release_date are NA unless given (e.g. the month of the download, or the date of an HGNC archive file).

HGNC data are released under CC0; HGNC recommends citing its latest paper, which is recorded in the object's metadata (see get_source_metadata).

Value

A dvobject with tibbles:

gene

One row per approved gene, keyed by hgnc_id, with the file's columns. Multi-valued cells keep the file's a|b text.

gene_name

One row per (hgnc_id, kind, name): each gene's approved symbol (kind "symbol") and name ("name"), and every alias and previous symbol and name ("alias_symbol", "prev_symbol", "alias_name", "prev_name"), split on | and trimmed. Empty values and exact duplicates are dropped; names that differ only in case are kept.

withdrawn

Only when withdrawn_path is given. One row per withdrawn ID and the ID it was merged into or split to (merged_into_hgnc_id, merged_into_symbol, merged_into_status); an entry without a target has one row with these NA. merged_into_report keeps the original cell. Rows are as written in HGNC's file, including any repeated target.

See Also

Other parsers: cett_nodes_options(), drug_node_options(), parseDrugBank(), parseHPO(), parseHealthCanadaDPD(), parseOnSIDES(), parseOpenFDA(), parseTWOSIDES(), references_node_options()

Examples

hgnc_dir <- system.file("extdata", "hgnc", package = "dbparser")
hgnc <- parseHGNC(file.path(hgnc_dir, "hgnc_complete_set.txt"),
                  withdrawn_path = file.path(hgnc_dir, "withdrawn.txt"),
                  release        = "2026-10",
                  retrieved_at   = "2026-10-16")
hgnc$gene_name[hgnc$gene_name$name == "PD1", ]
get_source_metadata(hgnc)


Parse HPO Gene-Phenotype Associations

Description

Reads the Human Phenotype Ontology (HPO) gene-phenotype associations as distributed by Harmonizome (gene_attribute_edges.txt) and returns a dvobject with gene, phenotype and association tables.

Usage

parseHPO(
  filepath,
  minimum_weight = 0,
  db_version = NULL,
  db_exported_date = NULL
)

Arguments

filepath

Character. Path to the Harmonizome HPO gene_attribute_edges.txt file, plain or gzip-compressed.

minimum_weight

Numeric. Minimum association weight to keep. The default 0 keeps all associations.

db_version

Character or NULL. Dataset version, stored in the object metadata.

db_exported_date

Character or NULL. Dataset release date, stored in the object metadata.

Details

The Harmonizome file is tab separated and has two header lines: the column names (source, source_desc, source_id, target, target_desc, target_id, weight) followed by a descriptor row (GeneSym, NA, GeneID, Phenotype, HPOID, NA, weight). The parser drops the descriptor row and renames the columns to domain-specific names. Columns that carry no information in this dataset (source_desc and the -666 placeholder in target_id) are not kept.

Gzip-compressed files (.gz) are read directly.

The resulting object can be linked to DrugBank target genes with merge_drugbank_hpo.

Value

A dvobject with three tibbles:

associations

One row per gene-phenotype pair: gene_symbol, entrez_id, hpo_id, phenotype_name and association_weight.

genes

Unique genes: gene_symbol, entrez_id and n_phenotypes, the number of associated phenotypes.

phenotypes

Unique phenotypes: hpo_id, phenotype_name and n_genes, the number of associated genes.

See Also

Other parsers: cett_nodes_options(), drug_node_options(), parseDrugBank(), parseHGNC(), parseHealthCanadaDPD(), parseOnSIDES(), parseOpenFDA(), parseTWOSIDES(), references_node_options()

Examples

hpo_path <- system.file("extdata", "hpo_gene_attribute_edges.txt",
                        package = "dbparser")
hpo_db <- parseHPO(hpo_path)
hpo_db$phenotypes
show_dvobject_metadata(hpo_db)


Parse the Health Canada Drug Product Database (DPD) Data Extract

Description

Reads Health Canada's Drug Product Database data extract and returns a dvobject with its 13 tables. Each of the four product sets (marketed, approved, cancelled, dormant) is read from its unzipped folder or straight from its zip; the rows of every set go in one table with an extract column.

Usage

parseHealthCanadaDPD(
  dpd_dir,
  extracts = c("marketed", "approved", "cancelled", "dormant"),
  release = NULL,
  release_date = NULL,
  retrieved_at = NULL
)

Arguments

dpd_dir

Character. Folder holding the extract's zips or unzipped folders.

extracts

Character. Product sets to read, any of "marketed", "approved", "cancelled" and "dormant" (all by default).

release

Character or NULL. Release label, e.g. "2026-10". DPD publishes no release number.

release_date

Date, "YYYY-MM-DD" or NULL. Release date.

retrieved_at

Date, "YYYY-MM-DD" or NULL. Date the files were downloaded.

Details

dpd_dir holds the extract as Health Canada distributes it, each product set either as its zip or unzipped into a folder of the same name: allfiles (marketed), allfiles_ap (approved), allfiles_ia (cancelled) and allfiles_dr (dormant), plus inactive (the inactive products list). Zips are extracted to a temporary folder that is removed after reading. When neither inactive nor inactive.zip is there, inactive.txt is read from the cancelled set, which holds the same file.

The files have no header: column names are those of Health Canada's read-me ("Read Me File - Drug Product Database (DPD) Data Extract"), lower case, and table names are the read-me's without QRYM_. Every value is quoted and the files are UTF-8; empty values become NA. Code columns (drug_code, active_ingredient_code, company_code, pharm_form_code, route_of_administration_code, si_code) are integers and the DD-MON-YYYY dates are dates; every other column stays text as written. Dates are kept as written, including two lot expiry dates in the cancelled set written with years 0030 and 0031.

The therapeutic class files hold four fields where the read-me lists seven columns: the three certain ones are kept and the parser stops if the fourth ever holds a value.

The parser groups nothing: status holds every status row as written, with current_status_flag marking each product's current one.

DPD data are published under the Open Government Licence - Canada (version 2.0); the attribution it asks for is recorded in the object's metadata (see get_source_metadata). The DPD extract page also links to Health Canada's website terms; the dataset record on open.canada.ca states the Open Government Licence – Canada.

Value

A dvobject with 13 tibbles, each keyed by drug_code: drug_product, active_ingredients, companies, form, packaging, pharmaceutical_std, route, schedule, status, therapeutic_class, veterinary_species, biosimilars (each with extract) and inactive_products. inactive_products lists cancelled products, so it is built only when extracts includes "cancelled" and an inactive products file is found.

See Also

Other parsers: cett_nodes_options(), drug_node_options(), parseDrugBank(), parseHGNC(), parseHPO(), parseOnSIDES(), parseOpenFDA(), parseTWOSIDES(), references_node_options()

Examples

dpd_dir <- system.file("extdata", "health_canada_dpd", package = "dbparser")
dpd <- parseHealthCanadaDPD(dpd_dir, release = "2026-10",
                            retrieved_at = "2026-10-21")
dpd$drug_product[, c("drug_code", "brand_name", "extract")]
get_source_metadata(dpd)


Parse the OnSIDES Core Relational Database

Description

Parses the core relational tables from the OnSIDES database.

Usage

parseOnSIDES(
  dataDir,
  include_high_confidence = TRUE,
  db_version = NULL,
  db_exported_date = NULL
)

Arguments

dataDir

A string specifying the path to the directory containing the OnSIDES CSV files.

include_high_confidence

Logical. If TRUE (the default), the function will also parse the 'high_confidence.csv' file, which is a pre-aggregated summary of ingredient-to-effect relationships. If the file is not found, a warning is issued.

db_version

used onside version (default = NULL)

db_exported_date

used onside release date (default = NULL)

Value

dvobject

See Also

Other parsers: cett_nodes_options(), drug_node_options(), parseDrugBank(), parseHGNC(), parseHPO(), parseHealthCanadaDPD(), parseOpenFDA(), parseTWOSIDES(), references_node_options()


Parse the openFDA Drugs@FDA and NDC Directory Downloads

Description

Reads openFDA's bulk download files for Drugs@FDA (drug/drugsfda) and the NDC directory (drug/ndc) and returns a dvobject with one table per record level, field names as in the files.

Usage

parseOpenFDA(
  drugsfda_path = NULL,
  ndc_path = NULL,
  release = NULL,
  release_date = NULL,
  retrieved_at = NULL
)

Arguments

drugsfda_path

Character or NULL. Path to the Drugs@FDA download (zip or JSON).

ndc_path

Character or NULL. Path to the NDC directory download (zip or JSON).

release

Character or NULL. Release label, e.g. "2026-10".

release_date

Date, "YYYY-MM-DD" or NULL. Release date; by default the files' export date.

retrieved_at

Date, "YYYY-MM-DD" or NULL. Date the files were downloaded.

Details

Each download is one JSON object, {meta, results}, usually zipped (drug-drugsfda-0001-of-0001.json.zip, drug-ndc-0001-of-0001.json.zip). Zips are read directly, without extracting them to disk; an unzipped .json file works too. The parser checks the number of records against meta.results.total.

Drugs@FDA lists FDA application products (NDA, ANDA, BLA); the NDC directory lists products registered for sale, including products sold under an OTC monograph without an application. Every application, product, submission and listing is kept as the files have it, including tentative approvals (submission_status "TA"); the parser does no status grouping and no matching across sources.

YYYYMMDD dates become dates. NDC packaging dates are written two ways (20220525 and 04-DEC-09) and are kept as text, as written. finished and sample are logical. Every other field stays text. The openfda block of each record is kept as (key, field, value) rows; it is openFDA's annotation, and it can belong to another drug (for example ANDA202111).

release_date defaults to the files' meta.last_updated (the export date) when every file given has the same one.

Parsing the full Drugs@FDA and NDC files takes about a minute and needs roughly 300 MB of memory.

openFDA data are released under CC0 1.0. openFDA asks for credit, which is recorded in the object's metadata (see get_source_metadata), and states: "Do not rely on openFDA to make decisions regarding medical care."

Value

A dvobject with tibbles. From Drugs@FDA: drugsfda_application (key application_number), drugsfda_product (key application and product_number), drugsfda_active_ingredient, drugsfda_submission (key application, submission_type and submission_number), drugsfda_submission_property_type, drugsfda_application_doc and drugsfda_openfda. From the NDC directory: ndc_product (key product_id), ndc_active_ingredient, ndc_route, ndc_pharm_class, ndc_packaging and ndc_openfda. Only the tables of the files given are built.

See Also

Other parsers: cett_nodes_options(), drug_node_options(), parseDrugBank(), parseHGNC(), parseHPO(), parseHealthCanadaDPD(), parseOnSIDES(), parseTWOSIDES(), references_node_options()

Examples

openfda_dir <- system.file("extdata", "openfda", package = "dbparser")
openfda <- parseOpenFDA(
  drugsfda_path = file.path(openfda_dir,
                            "drug-drugsfda-0001-of-0001.json.zip"),
  ndc_path      = file.path(openfda_dir, "drug-ndc-0001-of-0001.json.zip"),
  release       = "2026-10")
openfda$drugsfda_product[, c("application_number", "brand_name",
                             "marketing_status")]
get_source_metadata(openfda)


Parse the TWOSIDES Drug-Drug Interaction Database

Description

Reads the TWOSIDES data file, which contains adverse event data for pairs of drugs taken concurrently (N=2 interactions).

Usage

parseTWOSIDES(twosides_file_path, db_version = NULL, db_exported_date = NULL)

Arguments

twosides_file_path

Path to the TWOSIDES data file (e.g., 'TWOSIDES.csv.gz').

db_version

used twoside version (default = NULL)

db_exported_date

used twoside release date (default = NULL)

Details

TWOSIDES is a database of drug-drug interaction safety signals mined from the FDA's Adverse Event Reporting System using the same approach as is used to generate OffSIDES.

Database fields as follow:

drug_1_rxnorn_id

RxNORM identifier for drug 1

drug_1_concept_name

RxNORM name string for drug 1

drug_2_rxnorm_id

RxNORM identifier for drug 2

drug_2_concept_name

RxNORM name string for drug 3

condition_meddra_id

MedDRA identifier for the side effect

condition_concpet_name

MedDRA name string for the side effect

A

The number of reports for the pair of drugs that report the side effect

B

The number of reports for the pair of drugs that do not report the side effect

C

The number of reports for other PSM matched drugs (including perhaps the single versions of drug 1 or drug 2) that report the side effect

D

The number of reports for other PSM matched drugs and other side effects

PRR

Proportional reporting ratio, PRR=(A/(A+B))/(C/(C+D))

PRR_error

Error estimate of the PRR

mean_reporting_frequency

Proportion of reports for the drug that report the side effect, A/(A+B)

Value

A dvobject of class 'TWOSIDESDB' containing the 'drug_drug_interactions' data frame and associated metadata.

See Also

Other parsers: cett_nodes_options(), drug_node_options(), parseDrugBank(), parseHGNC(), parseHPO(), parseHealthCanadaDPD(), parseOnSIDES(), parseOpenFDA(), references_node_options()


Run all CETT related parsers

Description

Run all parsers that retrieve carriers, enzymes, targets and transporters related information

Usage

parse_cett_node(cett_options)

Value

a list of all drugs parsed tibbles


Parse DPD dates ("22-MAR-2025")

Description

English month abbreviations, whatever the session's locale.

Usage

parse_dpd_date(values, label)

Arguments

values

character vector; NA stays NA

label

where the values come from, for the error

Value

Date; stops when a set value is not a DD-MON-YYYY calendar date


Run all drug related parsers

Description

Run all parsers that retrieve drugs related information

Usage

parse_drug_nodes(drug_options)

Arguments

drug_options

- list of options to parse

Value

a list of all drugs parsed tibbles


Parse openFDA dates (YYYYMMDD)

Description

Parse openFDA dates (YYYYMMDD)

Usage

parse_openfda_date(values, label)

Arguments

values

character vector; NA and "" give NA

label

where the values come from, for the error

Value

Date; stops when a set value is not a YYYYMMDD date


Drugs/ Carriers/ Enzymes/ Targets/ Transporters references element parser

Description

Drugs/ Carriers/ Enzymes/ Targets/ Transporters references element parser

Usage

parse_references_node(references_options)

Value

a list of all references for drugs, carriers, enzymes, targets or transporters


Read one DPD file

Description

No header, every value quoted, UTF-8. Checks the field count against the read-me's columns and the parsed rows against the file's lines.

Usage

read_dpd_file(path, spec)

Arguments

path

file path

spec

one dpd_table_specs() entry

Value

data.frame with the spec's columns


Reads DrugBank xml database and load it into memory.

Description

read_drugbank_xml_db loads DrugBank xml database full tree into memory.

Usage

read_drugbank_xml_db(db_path)

Arguments

db_path

string, full path for the DrugBank xml or zip file.

Details

This functions reads DrugBank xml database and load it into memory for later processing. Hence; this method must be called before any other function in the package and it needs to be called one time only.

It takes one single mandatory argument which is the location of DrugBank db.

Value

loaded DB or NULL


Read hgnc_complete_set.txt

Description

Strips the double-quote wrapper of multi-valued cells, cleans column names and types the date_* columns.

Usage

read_hgnc_complete_set(path)

Arguments

path

file path

Value

tibble, one row per HGNC ID


Read withdrawn.txt

Description

One row per (withdrawn ID, target); targets are HGNC_ID|SYMBOL|STATUS separated by ", ".

Usage

read_hgnc_withdrawn(path)

Arguments

path

file path

Value

tibble


Read an openFDA download (zip or JSON)

Description

A zip is read through a connection, never extracted to disk.

Usage

read_openfda_json(path)

Arguments

path

file path

Value

list(meta, results), parsed without simplification


returns references node valid options.

Description

returns references node valid options.

Usage

references_node_options()

Value

list of references valid options

See Also

Other parsers: cett_nodes_options(), drug_node_options(), parseDrugBank(), parseHGNC(), parseHPO(), parseHealthCanadaDPD(), parseOnSIDES(), parseOpenFDA(), parseTWOSIDES()


Search HPO Phenotypes by Keyword

Description

Finds phenotypes whose name contains a keyword and lists their associated genes. Matching is case-insensitive and treats keyword as a plain string, not a regular expression.

Usage

search_phenotypes(hpo_db, keyword, max_results = 50L)

Arguments

hpo_db

An HPO dvobject returned by parseHPO.

keyword

Character. Search term, e.g. "seizure".

max_results

Integer. Maximum number of phenotypes to return.

Value

A tibble with columns hpo_id, phenotype_name, n_genes and genes (comma-separated gene symbols), ordered by decreasing n_genes.

See Also

Other utility: add_database_info(), get_genes_for_phenotype(), get_source_metadata(), show_dvobject_metadata(), subset_drugbank_dvobject(), subset_onsides_dvobject()

Examples

hpo_db <- parseHPO(system.file("extdata", "hpo_gene_attribute_edges.txt",
                               package = "dbparser"))
search_phenotypes(hpo_db, "seizure")


set_source_metadata Attach a metadata block to a dvobject

Description

Blocks are kept in one attribute, source_metadata, as a list named by each block's source. A block for a source already present replaces it.

Usage

set_source_metadata(dvobject, metadata)

Arguments

dvobject

dvobject to assign metadata to it

metadata

block from source_metadata(), or a named list of blocks (as stored on another dvobject)

Value

dvobject


Shape an openFDA table: its columns in order, dates and logicals typed

Description

Shape an openFDA table: its columns in order, dates and logicals typed

Usage

shape_openfda_table(rows, spec, table)

Arguments

rows

data.frame (possibly with no rows or columns)

spec

one openfda_table_specs() entry

table

table name, for errors

Value

tibble


Display dvobject Metadata

Description

Displays information about passed dbobject object including basic info, database metadata, and all data.frames contained within nested lists.

Usage

show_dvobject_metadata(obj, return_df = FALSE)

Arguments

obj

A dvobject

return_df

Logical. If TRUE, returns metadata data.frame without printing. Default is FALSE.

Value

Invisibly returns a data.frame containing dvobject metadata

See Also

Other utility: add_database_info(), get_genes_for_phenotype(), get_source_metadata(), search_phenotypes(), subset_drugbank_dvobject(), subset_onsides_dvobject()

Examples

drugbank <- parseDrugBank(
  system.file("extdata", "drugbank_record_biotech.xml",
              package = "dbparser"))
show_dvobject_metadata(drugbank)
metadata <- show_dvobject_metadata(drugbank, return_df = TRUE)


source_metadata Build the source metadata block that every parser attaches to its dvobject.

Description

Unknown fields stay NA; nothing is guessed. retrieved_at is never taken from file modification dates. File hashes are SHA-256 and need R >= 4.5.0 (tools::sha256sum()); on older R they are NA.

Usage

source_metadata(
  source,
  source_name = source,
  files = character(),
  release = NA,
  release_date = NA,
  retrieved_at = NA,
  source_url = NA,
  licence = NA,
  licence_url = NA,
  attribution = NA
)

Arguments

source

short source id, e.g. "hgnc"

source_name

full source name

files

paths of the input files that were parsed

release

source release label as published, e.g. "5.1"

release_date

source release date (Date or "YYYY-MM-DD")

retrieved_at

date the files were downloaded (Date or "YYYY-MM-DD")

source_url

source download or home page

licence

SPDX licence id, e.g. "CC0-1.0"

licence_url

licence or terms page

attribution

credit or citation sentence the source asks for

Value

list, the metadata block


Subset a DrugBank dvobject by a vector of DrugBank IDs

Description

Subset a DrugBank dvobject by a vector of DrugBank IDs

Usage

subset_drugbank_dvobject(dvobject, drug_ids)

Arguments

dvobject

The dvobject from 'parseDrugBank()'.

drug_ids

A character vector of 'drugbank_id' values to keep.

Details

Intelligently filters a DrugBank dvobject to retain only the data associated with a specified list of drugbank_ids. It correctly handles the deep, multi-level nested structure of the entire object, including the complex relationships within the 'cett' list.

Value

A new, smaller dvobject with the same structure and attributes.

See Also

Other utility: add_database_info(), get_genes_for_phenotype(), get_source_metadata(), search_phenotypes(), show_dvobject_metadata(), subset_onsides_dvobject()

Examples

## Not run: 
library(dbparser)
one_drug <- subset_drugbank_dvobject(dvobject = dbdataset::drugbank,
                                     drug_ids = "DB00001")

## End(Not run)

Subset an OnSIDES dvobject by a vector of RxNorm Ingredient IDs (Schema-Aware)

Description

Intelligently filters an OnSIDES dvobject by cascading filters through the relational tables, ensuring the final subset is self-consistent.

Usage

subset_onsides_dvobject(dvobject, ingredient_ids)

Arguments

dvobject

A dvobject from 'parseOnSIDES()'.

ingredient_ids

A character vector of RxNorm CUIs (ingredients) to keep.

Value

A new, smaller dvobject with the same structure.

See Also

Other utility: add_database_info(), get_genes_for_phenotype(), get_source_metadata(), search_phenotypes(), show_dvobject_metadata(), subset_drugbank_dvobject()