---
title: "An introduction to biodbExpasy"
author: "Pierrick Roger"
date: "`r BiocStyle::doc_date()`"
package: "`r BiocStyle::pkg_ver('biodbExpasy')`"
abstract: |
  How to use the biodbExpasy connector and its methods.
vignette: |
    %\VignetteIndexEntry{Introduction to the biodbExpasy package.}
    %\VignetteEngine{knitr::rmarkdown}
    %\VignetteEncoding{UTF-8}
output:
    BiocStyle::html_document:
      toc: yes
      toc_depth: 4
      toc_float:
          collapsed: false
    BiocStyle::pdf_document: default
bibliography: references.bib
---

# Introduction

biodbExpasy is a *biodb* extension package that implements a connector to the
[Expasy ENZYME](https://enzyme.expasy.org/) database [@bairoch2000_expasy].

# Installation

Install using Bioconductor:
```{r, eval=FALSE}
if (!requireNamespace("BiocManager", quietly=TRUE))
    install.packages("BiocManager")
BiocManager::install('biodbExpasy')
```

# Initialization

The first step in using *biodbExpasy*, is to create an instance of the biodb
class `Biodb` from the main *biodb* package. This is done by calling the
constructor of the class:
```{r, results='hide'}
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 Expasy ENZYME database.

In *biodb* the connection to a database is handled by a connector instance that
you can get from the factory.
biodbExpasy implements a connector to a remote database.
Here is the code to instantiate a connector:
```{r}
conn <- mybiodb$getFactory()$createConn('expasy.enzyme')
```

# Accessing entries

To get the number of entries stored inside the database, run:
```{r}
conn$getNbEntries()
```

To get some of the first entry IDs (accession numbers) from the database, run:
```{r}
ids <- conn$getEntryIds(2)
ids
```

To retrieve entries, use:
```{r}
entries <- conn$getEntry(ids)
entries
```

To convert a list of entries into a dataframe, run:
```{r}
x <- mybiodb$entriesToDataframe(entries)
x
```

# Running the "wsEnzymeByName" web service

You can access the web service "find" directly with the *wsEnzymeByName* method:
```{r}
conn$wsEnzymeByName(name="Alcohol", retfmt="ids")
```

# Running the "wsEnzymeByComment" web service

You can access the web service "find" directly with the *wsEnzymeByComment* method:
```{r}
conn$wsEnzymeByComment(comment="best", retfmt="ids")
```

# Closing biodb instance

When done with your *biodb* instance you have to terminate it, in order to
ensure release of resources (file handles, database connection, etc):
```{r}
mybiodb$terminate()
```

# Session information

```{r}
sessionInfo()
```

# References
