Introduction

biodbChebi is a biodb extension package that implements a connector to the ChEBI database [@degtyarenko2007_ChEBI; @hastings2012_chebi].

Installation

Install using Bioconductor:

if (!requireNamespace("BiocManager", quietly=TRUE))
    install.packages("BiocManager")
BiocManager::install('biodbChebi')

Initialization

The first step in using biodbChebi, is to create an instance of the biodb class BiodbMain from the main biodb package. This is done by calling the constructor of the class:

mybiodb <- biodb::newInst()

During this step the configuration is set up, the cache system is initialized and extension packages are loaded.

We will see at the end of this vignette that the biodb instance needs to be terminated with a call to the terminate() method.

Creating a connector to ChEBI database

In biodb the connection to a database is handled by a connector instance that you can get from the factory. biodbChebi implements a connector to a local database, thus when creating an instance you must provide a URL that points to your database:

chebi <- mybiodb$getFactory()$createConn('chebi')

Requesting entries

Using accession numbers, we request entries from ChEBI:

entries <- chebi$getEntry(c('2528', '17053', '15440'))

Get entry fields

Getting the values of entry fields are done using getFieldValue() method. Here we retrieve the SMILE field of the first entry from the ChEBI entries obtained previously:

entries[[1]]$getFieldValue('smiles')

Get data frame

We can convert an entry into a data frame:

entries[[1]]$getFieldsAsDataframe()

Building a data frame for a list of entries is also possible:

mybiodb$entriesToDataframe(entries, fields=c('accession', 'formula',
    'molecular.mass', 'inchikey', 'kegg.compound.id'))

Search by name and mass

Searching by name and/or mass is done through the searchCompound().

Searching by name:

chebi$searchCompound(name='aspartic', max.results=3)

Searching by mass:

chebi$searchCompound(mass=133, mass.field='molecular.mass', mass.tol=0.3,
    max.results=3)

Searching by name and mass:

ids <- chebi$searchCompound(name='aspartic', mass=133,
    mass.field='molecular.mass', mass.tol=0.3, max.results=3)

Display results in data frame:

mybiodb$entriesToDataframe(chebi$getEntry(ids), fields=c('accession',
    'molecular.mass', 'name'))

Convert CAS IDs

Converting CAS IDs to ChEBI IDs:

chebi$convCasToChebi(c('87605-72-9', '51-41-2'))

If more than one ChEBI ID is found for a CAS ID, then a list of character vectors is returned:

chebi$convCasToChebi('14215-68-0')

This behaviour can be made the default one by setting simplify parameter to FALSE.

Convert InChI

The method is similar to convCasToChebi().

Converting InChI to ChEBI IDs:

chebi$convInchiToChebi('InChI=1S/C8H11NO3/c9-4-8(12)5-1-2-6(10)7(11)3-5/h1-3,8,10-12H,4,9H2/t8-/m0/s1')

You can also use an InChI key:

chebi$convInchiToChebi('MBDOYVRWFFCFHM-SNAWJCMRSA-N')

Closing biodb instance

Do not forget to terminate your biodb instance once you are done with it:

mybiodb$terminate()

Session information

sessionInfo()

References



pkrog/biodbChebi documentation built on March 29, 2022, 8:40 a.m.