| BiodbFactory | R Documentation |
A class for constructing biodb objects.
A class for constructing biodb objects.
This class is responsible for the creation of database connectors and
database entries. You must go through the single instance of this class to
create and get connectors, as well as instantiate entries. To get the single
instance of this class, call the getFactory() method of class
BiodbMain.
new()New instance initializer. The BiodbFactory class must not be instantiated directly. Instead, call the getFactory() method from the BiodbMain instance.
BiodbFactory$new(bdb)
bdbThe BiodbMain instance.
Nothing.
getBiodb()Returns the biodb main class instance to which this object is attached.
BiodbFactory$getBiodb()
The main biodb instance.
createConn()Creates a connector to a database.
BiodbFactory$createConn( db.class, url = NULL, token = NA_character_, fail.if.exists = TRUE, get.existing.conn = TRUE, conn.id = NULL, cache.id = NULL )
db.classThe type of a database. The list of types can be obtained from the class BiodbDbsInfo.
urlAn URL to the database for which to create a connection. Each database connector is configured with a default URL, but some allow you to change it.
tokenA security access token for the database. Some database require such a token for all or some of their webservices. Usually you obtain the token through your account on the database website.
fail.if.existsIf set to TRUE, the method will fail if a connector for
get.existing.connThis argument will be used only if fail.if.exists is set to FALSE and an identical connector already exists. If it set to TRUE, the existing connector instance will be returned, otherwise NULL will be returned.
conn.idIf set, this identifier will be used for the new connector. An error will be raised in case another connector already exists with this identifier.
cache.idIf set, this ID will be used as the cache ID for the new connector. An error will be raised in case another connector already exists with this cache identifier.
An instance of the requested connector class.
connExists()Tests if a connector exists.
BiodbFactory$connExists(conn.id)
conn.idA connector ID.
TRUE if a connector with this ID exists, FALSE otherwise.
deleteConn()Deletes an existing connector.
BiodbFactory$deleteConn(conn)
connA connector instance or a connector ID.
Nothing.
deleteConnByClass()Deletes all existing connectors from a same class.
BiodbFactory$deleteConnByClass(db.class)
db.classThe type of a database. All connectors of this database type will be deleted.
Nothing.
getAllConnectors()Gets all connectors.
BiodbFactory$getAllConnectors()
A list of all created connectors.
deleteAllConnectors()Deletes all connectors.
BiodbFactory$deleteAllConnectors()
Nothing.
getConn()Gets an instantiated connector instance, or create a new one.
BiodbFactory$getConn(conn.id, class = TRUE, create = TRUE)
conn.idAn existing connector ID.
classIf set to TRUE, and \"conn.id\" does not correspond to any instantiated connector, then interpret \"conn.id\" as a database class and looks for the first instantiated connector of that class.
createIf set to TRUE, and \"class\" is also set to TRUE, and no suitable instantiated connector was found, then creates a new connector instance of the class specified by \"conn.id\".
The connector instance corresponding to the connector ID or to the database ID submitted (if class \"parameter\" is set to TRUE).
getEntry()Retrieves database entry objects from IDs (accession numbers), for the specified connector.
BiodbFactory$getEntry(conn.id, id, drop = TRUE, no.null = FALSE, limit = 0)
conn.idAn existing connector ID.
idA character vector containing database entry IDs (accession numbers).
dropIf set to TRUE and the list of entries contains only one element, then returns this element instead of the list. If set to FALSE, then returns always a list.
no.nullSet to TRUE to remove NULL entries.
limitSet to a positive value to limit the number of entries returned.
A list of BiodbEntry objects, the same length as id. A
NULL value is put into the list for each invalid ID of id.
createNewEntry()Creates a new empty entry object from scratch. This entry is not stored in cache, and is directly attached to the factory instance instead of a particular connector.
BiodbFactory$createNewEntry(db.class)
db.classA database ID.
A new BiodbEntry object.
createEntryFromContent()Creates an entry instance from a content.
BiodbFactory$createEntryFromContent(conn.id, content, drop = TRUE)
conn.idA valid BiodbConn identifier.
contentA list or character vector of contents to parse to create the entries.
dropIf set to TRUE
A list of new BiodbEntry objects.
getAllCacheEntries()For a connector, gets all entries stored in the cache.
BiodbFactory$getAllCacheEntries(conn.id)
conn.idA connector ID.
A list of BiodbEntry objects.
deleteAllEntriesFromVolatileCache()Deletes all entries stored in the cache of the given connector. This method is deprecated, please use deleteAllEntriesFromVolatileCache() instead.
BiodbFactory$deleteAllEntriesFromVolatileCache(conn.id)
conn.idA connector ID.
Nothing.
deleteAllCacheEntries()Deletes all entries stored in the cache of the given connector.
BiodbFactory$deleteAllCacheEntries(conn.id)
conn.idA connector ID.
Nothing.
print()Prints information about this instance.
BiodbFactory$print()
Nothing.
clone()The objects of this class are cloneable with this method.
BiodbFactory$clone(deep = FALSE)
deepWhether to make a deep clone.
BiodbMain, BiodbConn and
BiodbEntry.
# Create a BiodbMain instance with default settings:
mybiodb <- biodb::newInst()
# Obtain the factory instance:
factory <- mybiodb$getFactory()
# Get a compound CSV file database
chebi.tsv <- system.file("extdata", "chebi_extract.tsv", package='biodb')
# Create a connector:
conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi.tsv)
# Get a database entry:
entry <- conn$getEntry(conn$getEntryIds(1))
# Terminate instance.
mybiodb$terminate()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.