Title: | biodb, a library and a development framework for connecting to chemical and biological databases |
---|---|
Description: | The biodb package provides access to standard remote chemical and biological databases (ChEBI, KEGG, HMDB, ...), as well as to in-house local database files (CSV, SQLite), with easy retrieval of entries, access to web services, search of compounds by mass and/or name, and mass spectra matching for LCMS and MSMS. Its architecture as a development framework facilitates the development of new database connectors for local projects or inside separate published packages. |
Authors: | Pierrick Roger [aut, cre] , Alexis Delabrière [ctb] |
Maintainer: | Pierrick Roger <[email protected]> |
License: | AGPL-3 |
Version: | 1.15.0 |
Built: | 2024-11-19 03:11:42 UTC |
Source: | https://github.com/bioc/biodb |
The biodb package provides access to standard remote chemical and biological databases (ChEBI, KEGG, HMDB, ...), as well as to in-house local database files (CSV, SQLite), with easy retrieval of entries, access to web services, search of compounds by mass and/or name, and mass spectra matching for LCMS and MSMS. Its architecture as a development framework facilitates the development of new database connectors for local projects or inside separate published packages.
To get a presentation of the biodb package and get started with it, please see the "biodb" vignette.
vignette('biodb', package='biodb')
Maintainer: Pierrick Roger [email protected] (ORCID)
Other contributors:
Alexis Delabrière [email protected] (ORCID) [contributor]
BiodbMain, BiodbConfig, BiodbFactory, BiodbPersistentCache, BiodbDbsInfo, BiodbEntryFields.
Forbids instantiation of an abstract class. This method must be called from within a constructor of an abstract class. It will throw an error if a direct call is made to this constructor.
abstractClass(cls, obj)
abstractClass(cls, obj)
cls |
The name of the abstract class to check. |
obj |
The object being instantiated. |
Nothing.
This method must be called from within the abstract method.
abstractMethod(obj)
abstractMethod(obj)
obj |
The object on which the abstract method is called. |
Nothing.
A persistent cache implementation that uses BiocCache package.
A persistent cache implementation that uses BiocCache package.
biodb::BiodbPersistentCache
-> BiodbBiocPersistentCache
biodb::BiodbPersistentCache$addFilesToCache()
biodb::BiodbPersistentCache$copyFilesIntoCache()
biodb::BiodbPersistentCache$deleteAllFiles()
biodb::BiodbPersistentCache$deleteFile()
biodb::BiodbPersistentCache$deleteFiles()
biodb::BiodbPersistentCache$disable()
biodb::BiodbPersistentCache$enable()
biodb::BiodbPersistentCache$enabled()
biodb::BiodbPersistentCache$erase()
biodb::BiodbPersistentCache$fileExist()
biodb::BiodbPersistentCache$fileExists()
biodb::BiodbPersistentCache$filesExist()
biodb::BiodbPersistentCache$folderExists()
biodb::BiodbPersistentCache$getDir()
biodb::BiodbPersistentCache$getFilePath()
biodb::BiodbPersistentCache$getFolderPath()
biodb::BiodbPersistentCache$getTmpFolderPath()
biodb::BiodbPersistentCache$getUsedCacheIds()
biodb::BiodbPersistentCache$isReadable()
biodb::BiodbPersistentCache$isWritable()
biodb::BiodbPersistentCache$listFiles()
biodb::BiodbPersistentCache$loadFileContent()
biodb::BiodbPersistentCache$markerExist()
biodb::BiodbPersistentCache$markerExists()
biodb::BiodbPersistentCache$moveFilesIntoCache()
biodb::BiodbPersistentCache$print()
biodb::BiodbPersistentCache$saveContentToFile()
biodb::BiodbPersistentCache$setMarker()
new()
New instance initializer. Cache objects must not be created directly. Instead, access the cache instance through the BiodbMain instance using the getPersistentCache() method.
BiodbBiocPersistentCache$new(...)
...
See the constructor of ExtGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbBiocPersistentCache$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbPersistentCache
,
BiodbBiocPersistentCache
.
A class for storing configuration values.
A class for storing configuration values.
This class is responsible for storing configuration. You must go through the
single instance of this class to create and set and get configuration values.
To get the single instance of this class, call the getConfig()
method
of class BiodbMain
.
new()
New instance initializer. No BiodbConfig object must not be created directly. Instead, access the config instance through the BiodbMain instance using the getConfig() method.
BiodbConfig$new(parent)
parent
The BiodbMain instance.
Nothing.
getKeys()
Get the list of available keys.
BiodbConfig$getKeys(deprecated = FALSE)
deprecated
If set to TRUE returns also the deprecated keys.
A character vector containing the config key names.
getTitle()
Get the title of a key.
BiodbConfig$getTitle(key)
key
The name of a configuration key.
The title of the key as a character value.
getDescription()
Get the description of a key.
BiodbConfig$getDescription(key)
key
The name of a configuration key.
The description of the key as a character value.
getDefaultValue()
Get the default value of a key.
BiodbConfig$getDefaultValue(key, as.chr = FALSE)
key
The name of a configuration key.
as.chr
If set to TRUE, returns the value as character.
The default value for that key.
hasKey()
Test if a key exists.
BiodbConfig$hasKey(key)
key
The name of a configuration key.
TRUE if a key with this name exists, FALSE otherwise.
isDefined()
Test if a key is defined (i.e.: if a value exists for this key).
BiodbConfig$isDefined(key, fail = TRUE)
key
The name of a configuration key.
fail
If set to TRUE and the configuration key does not exist, then an error will be raised.
TRUE if the key has a value, FALSE otherwise.
isEnabled()
Test if a boolean key is set to TRUE. This method will raise an error if the key is not a boolean key.
BiodbConfig$isEnabled(key)
key
The name of a configuration key.
TRUE if the boolean key has a value set to TRUE, FALSE otherwise.
get()
Get the value of a key.
BiodbConfig$get(key)
key
The name of a configuration key.
The value associated with the key.
set()
Set the value of a key.
BiodbConfig$set(key, value)
key
The name of a configuration key.
value
A value to associate with the key.
Nothing.
reset()
Reset the value of a key.
BiodbConfig$reset(key = NULL)
key
The name of a configuration key. If NULL, all keys will be reset.
Nothing.
enable()
Set a boolean key to TRUE.
BiodbConfig$enable(key)
key
The name of a configuration key.
Nothing.
disable()
Set a boolean key to FALSE.
BiodbConfig$disable(key)
key
The name of a configuration key.
Nothing.
print()
Print list of configuration keys and their values.
BiodbConfig$print()
Nothing.
listKeys()
Get the full list of keys as a data frame.
BiodbConfig$listKeys()
A data frame containing keys, titles, types, and default values.
getAssocEnvVar()
Returns the environment variable associated with this configuration key.
BiodbConfig$getAssocEnvVar(key)
key
The name of a configuration key.
The environment variable's value.
define()
Defines config properties from a structured object, normally loaded from a YAML file.
BiodbConfig$define(def)
def
The list of key definitions.
Nothing.
notifyNewObservers()
Called by BiodbMain when a new observer is registered.
BiodbConfig$notifyNewObservers(obs)
obs
The new observers registered by the BiodbMain instance.
Nothing.
terminate()
Terminates the instance. This method will be called automatically by the BiodbMain instance when you call
BiodbConfig$terminate()
BiodbMain
:terminate().
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbConfig$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get the config instance: config <- mybiodb$getConfig() # Print all available keys config$getKeys() # Get a configuration value: value <- config$get('cache.directory') # Set a configuration value: config$set('dwnld.timeout', 600) # For boolean values, you can use boolean methods: config$get('offline') config$enable('offline') # set to TRUE config$disable('offline') # set to FALSE config$isEnabled('offline') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get the config instance: config <- mybiodb$getConfig() # Print all available keys config$getKeys() # Get a configuration value: value <- config$get('cache.directory') # Set a configuration value: config$set('dwnld.timeout', 600) # For boolean values, you can use boolean methods: config$get('offline') config$enable('offline') # set to TRUE config$disable('offline') # set to FALSE config$isEnabled('offline') # Terminate instance. mybiodb$terminate()
The mother abstract class of all database connectors.
The mother abstract class of all database connectors.
This is the super class of all connector classes. All methods defined here are thus common to all connector classes. All connector classes inherit from this abstract class.
See section Fields for a list of the constructor's parameters. Concrete classes may have direct web services methods or other specific methods implemented, in which case they will be described inside the documentation of the concrete class. Please refer to the documentation of each concrete class for more information. The database direct web services methods will be named "ws.*".
The constructor has the following arguments:
id: The identifier of the connector.
cache.id: The identifier used in the disk cache.
biodb::BiodbConnBase
-> BiodbConn
biodb::BiodbConnBase$getBaseUrl()
biodb::BiodbConnBase$getConnClass()
biodb::BiodbConnBase$getConnClassName()
biodb::BiodbConnBase$getDbClass()
biodb::BiodbConnBase$getEntryClass()
biodb::BiodbConnBase$getEntryClassName()
biodb::BiodbConnBase$getEntryContentType()
biodb::BiodbConnBase$getEntryFileExt()
biodb::BiodbConnBase$getEntryIdField()
biodb::BiodbConnBase$getName()
biodb::BiodbConnBase$getPropSlots()
biodb::BiodbConnBase$getPropValSlot()
biodb::BiodbConnBase$getPropertyValue()
biodb::BiodbConnBase$getSchedulerNParam()
biodb::BiodbConnBase$getSchedulerTParam()
biodb::BiodbConnBase$getToken()
biodb::BiodbConnBase$getUrl()
biodb::BiodbConnBase$getUrls()
biodb::BiodbConnBase$getWsUrl()
biodb::BiodbConnBase$getXmlNs()
biodb::BiodbConnBase$hasProp()
biodb::BiodbConnBase$hasPropSlot()
biodb::BiodbConnBase$isSlotProp()
biodb::BiodbConnBase$propExists()
biodb::BiodbConnBase$setBaseUrl()
biodb::BiodbConnBase$setPropValSlot()
biodb::BiodbConnBase$setPropertyValue()
biodb::BiodbConnBase$setSchedulerNParam()
biodb::BiodbConnBase$setSchedulerTParam()
biodb::BiodbConnBase$setToken()
biodb::BiodbConnBase$setUrl()
biodb::BiodbConnBase$setWsUrl()
biodb::BiodbConnBase$updatePropertiesDefinition()
new()
New instance initializer. Connector objects must not be created directly. Instead, you create new connector instances through the BiodbFactory instance.
BiodbConn$new(id = NA_character_, cache.id = NA_character_, bdb, ...)
id
The ID of the connector instance.
cache.id
The Cache ID of the connector instance.
bdb
The BiodbMain instance.
...
Remaining arguments will be passed to the constructor of the super class.
Nothing.
getBiodb()
Returns the biodb main class instance to which this object is attached.
BiodbConn$getBiodb()
The main biodb instance.
getId()
Get the identifier of this connector.
BiodbConn$getId()
The identifier of this connector.
print()
Prints a description of this connector.
BiodbConn$print()
Nothing.
correctIds()
Correct a vector of IDs by formatting them to the database official format, if required and possible.
BiodbConn$correctIds(ids)
ids
A character vector of IDs.
The vector of IDs corrected.
getEntry()
Return the entry corresponding to this ID. You can pass a vector of IDs, and you will get a list of entries.
BiodbConn$getEntry(id, drop = TRUE, nulls = TRUE)
id
A character vector containing entry identifiers.
drop
If set to TRUE and only one entry is requrested, then the returned value will be a single BiodbEntry object, otherwise it will be a list of BiodbEntry objects.
nulls
If set to TRUE, NULL entries are preserved. This ensures
that the output list has the same length than the input vector id
.
Otherwise they are removed from the final list.
A list of BiodbEntry objects, the same size of the vector of IDs. The list will contain NULL values for invalid IDs. If drop is set to TRUE and only one etrny was requested then a single BiodbEntry is returned instead of a list.
getCacheFile()
Get the path to the persistent cache file.
BiodbConn$getCacheFile(entry.id)
entry.id
The identifiers (e.g.: accession numbers) as a character vector of the database entries.
A character vector, the same length as the vector of IDs, containing the paths to the cache files corresponding to the requested entry IDs.
getEntryContent()
Get the contents of database entries from IDs (accession numbers).
BiodbConn$getEntryContent(id)
id
A character vector of entry IDs.
A character vector containing the contents of the requested IDs. If no content is available for an entry ID, then NA will be used.
getEntryContentFromDb()
Get the contents of entries directly from the database. A direct request or an access to the database will be made in order to retrieve the contents. No access to the biodb cache system will be made.
BiodbConn$getEntryContentFromDb(entry.id)
entry.id
A character vector with the IDs of entries to retrieve.
A character vector, the same size of entry.id, with contents of the requested entries. An NA value will be set for the content of each entry for which the retrieval failed.
getEntryContentRequest()
Gets the URL to use in order to get the contents of the specified entries.
BiodbConn$getEntryContentRequest(entry.id, concatenate = TRUE, max.length = 0)
entry.id
A character vector with the IDs of entries to retrieve.
concatenate
If set to TRUE, then try to build as few URLs as possible, sending requests with several identifiers at once.
max.length
The maximum length of the URLs to return, in number of characters.
A vector of URL strings.
getEntryIds()
Get entry identifiers from the database. More arguments can be given, depending on implementation in specific databases. For mass databases the ms.level argument can also be set.
BiodbConn$getEntryIds(max.results = 0, ...)
max.results
The maximum of elements to return from the method.
...
Arguments specific to connectors.
A character vector containing entry IDs from the database. An empty vector for a remote database may mean that the database does not support requesting for entry accessions.
getNbEntries()
Get the number of entries contained in this database.
BiodbConn$getNbEntries(count = FALSE)
count
If set to TRUE and no straightforward way exists to get number of entries, count the output of getEntryIds().
The number of entries in the database, as an integer.
isEditable()
Tests if this connector is able to edit the database (i.e.: the connector class implements the interface BiodbEditable). If this connector is editable, then you can call allowEditing() to enable editing.
BiodbConn$isEditable()
Returns TRUE if the database is editable.
editingIsAllowed()
Tests if editing is allowed.
BiodbConn$editingIsAllowed()
TRUE if editing is allowed for this database, FALSE otherwise.
allowEditing()
Allows editing for this database.
BiodbConn$allowEditing()
Nothing.
disallowEditing()
Disallows editing for this database.
BiodbConn$disallowEditing()
Nothing.
setEditingAllowed()
Allow or disallow editing for this database.
BiodbConn$setEditingAllowed(allow)
allow
A logical value.
Nothing.
addNewEntry()
Adds a new entry to the database. The passed entry must have been previously created from scratch using BiodbFactory :createNewEntry() or cloned from an existing entry using BiodbEntry :clone().
BiodbConn$addNewEntry(entry)
entry
The new entry to add. It must be a valid BiodbEntry object.
Nothing.
isWritable()
Tests if this connector is able to write into the database. If this connector is writable, then you can call allowWriting() to enable writing.
BiodbConn$isWritable()
Returns TRUE if the database is writable.
allowWriting()
Allows the connector to write into this database.
BiodbConn$allowWriting()
Nothing.
disallowWriting()
Disallows the connector to write into this database.
BiodbConn$disallowWriting()
Nothing.
setWritingAllowed()
Allows or disallows writing for this database.
BiodbConn$setWritingAllowed(allow)
allow
If set to TRUE, allows writing.
Nothing.
writingIsAllowed()
Tests if the connector has access right to the database.
BiodbConn$writingIsAllowed()
TRUE if writing is allowed for this database, FALSE otherwise.
write()
Writes into the database. All modifications made to the database since the last time write() was called will be saved.
BiodbConn$write()
Nothing.
isSearchableByField()
Tests if a field can be used to search entries when using method searchForEntries().
BiodbConn$isSearchableByField(field = NULL, field.type = NULL)
field
The name of the field.
field.type
The field type.
Returns TRUE if the database is searchable using the specified field or searchable by any field of the specified type, FALSE otherwise.
getSearchableFields()
Get the list of all searchable fields.
BiodbConn$getSearchableFields()
A character vector containing all searchable fields for this connector.
searchForEntries()
Searches the database for entries whose name matches the specified name. Returns a character vector of entry IDs.
BiodbConn$searchForEntries(fields = NULL, max.results = 0)
fields
A list of fields on which to filter entries. To get a match,
all fields must be matched (i.e. logical AND). The keys of the list are the
entry field names on which to filter, and the values are the filtering
parameters. For character fields, the filter parameter is a character vector
in which all strings must be found inside the field's value. For numeric
fields, the filter parameter is either a list specifying a min-max range
(list(min=1.0, max=2.5)
) or a value with a tolerance in delta
(list(value=2.0, delta=0.1)
) or ppm (list(value=2.0, ppm=1.0)
).
max.results
If set, the number of returned IDs is limited to this number.
A character vector of entry IDs whose name matches the requested name.
searchByName()
DEPRECATED. Use searchForEntries() instead.
BiodbConn$searchByName(name, max.results = 0)
name
A character value to search inside name fields.
max.results
If set, the number of returned IDs is limited to this number.
A character vector of entry IDs whose name matches the requested name.
isDownloadable()
Tests if the connector can download the database.
BiodbConn$isDownloadable()
Returns TRUE if the database is downloadable.
isDownloaded()
Tests if the database has been downloaded.
BiodbConn$isDownloaded()
TRUE if the database content has already been downloaded.
requiresDownload()
Tests if the connector requires the download of the database.
BiodbConn$requiresDownload()
TRUE if the connector requires download of the database.
getDownloadPath()
Gets the path where the downloaded content is written.
BiodbConn$getDownloadPath()
The path where the downloaded database is written.
setDownloadedFile()
Set the downloaded file into the cache.
BiodbConn$setDownloadedFile(src, action = c("copy", "move"))
src
Path to the downloaded file.
action
Specifies if files have to be moved or copied into the cache.
Nothing.
isExtracted()
Tests if the downloaded database has been extracted (in case the database needs extraction).
BiodbConn$isExtracted()
TRUE if the downloaded database content has been extracted, FALSE otherwise.
download()
Downloads the database content locally.
BiodbConn$download()
Nothing.
isRemotedb()
Tests if the connector is connected to a remote database.
BiodbConn$isRemotedb()
Returns TRUE if the database is a remote database."
isCompounddb()
Tests if the connector's database is a compound database.
BiodbConn$isCompounddb()
Returns TRUE if the database is a compound database.
searchCompound()
This method is deprecated. Use searchForEntries() instead. Searches for compounds by name and/or by mass. At least one of name or mass must be set.
BiodbConn$searchCompound( name = NULL, mass = NULL, mass.field = NULL, mass.tol = 0.01, mass.tol.unit = "plain", max.results = 0 )
name
The name of a compound to search for.
mass
The searched mass.
mass.field
For searching by mass, you must indicate a mass field to use ('monoisotopic.mass', 'molecular.mass', 'average.mass' or 'nominal.mass').
mass.tol
The tolerance value on the molecular mass.
mass.tol.unit
The type of mass tolerance. Either 'plain' or 'ppm'.
max.results
The maximum number of matches to return.
description
A character vector of words or expressions to search for inside description field. The words will be searched in order. A match will be made only if all words are inside the description field.
A character vector of entry IDs."
annotateMzValues()
Annotates a mass spectrum with the database. For each matching entry the entry field values will be set inside columns appended to the data frame. Names of these columns will use a common prefix in order to distinguish them from other data from the input data frame.
BiodbConn$annotateMzValues( x, mz.tol, ms.mode, mz.tol.unit = c("plain", "ppm"), mass.field = "monoisotopic.mass", max.results = 3, mz.col = "mz", fields = NULL, prefix = NULL, insert.input.values = TRUE, fieldsLimit = 0 )
x
Either a data frame or a numeric vector containing the M/Z values.
mz.tol
The tolerance on the M/Z values.
ms.mode
The MS mode. Set it to either 'neg' or 'pos'.
mz.tol.unit
The type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
mass.field
The mass field to use for matching M/Z values. One of: 'monoisotopic.mass', 'molecular.mass', 'average.mass', 'nominal.mass'.
max.results
If set, it is used to limit the number of matches found for each M/Z value. To get all the matches, set this parameter to NA_integer_. Default value is 3.
mz.col
The name of the column where to find M/Z values in case x is a data frame.
fields
A character vector containing the additional entry fields you would like to get for each matched entry. Each field will be output in a different column.
prefix
A prefix that will be inserted before the name of each added column in the output. By default it will be set to the name of the database followed by a dot.
insert.input.values
Insert input values at the beginning of the result data frame.
fieldsLimit
The maximum of values to output for fields with multiple values. Set it to 0 to get all values.
A data frame containing the input values, and annotation columns
appended at the end. The first annotation column contains the IDs of the
matched entries. The following columns contain the fields you have requested
through the fields
parameter.
isMassdb()
Tests if the connector's database is a mass spectra database.
BiodbConn$isMassdb()
Returns TRUE if the database is a mass database.
checkDb()
Checks that the database is correct by trying to retrieve all its entries.
BiodbConn$checkDb()
Nothing.
getAllVolatileCacheEntries()
Get all entries stored in the memory cache (volatile cache).
BiodbConn$getAllVolatileCacheEntries()
A list of BiodbEntry instances.
getAllCacheEntries()
This method is deprecated. Use getAllVolatileCacheEntries() instead.
BiodbConn$getAllCacheEntries()
All entries cached in memory.
deleteAllEntriesFromVolatileCache()
Delete all entries from the volatile cache (memory cache).
BiodbConn$deleteAllEntriesFromVolatileCache()
Nothing.
deleteAllEntriesFromPersistentCache()
Delete all entries from the persistent cache (disk cache).
BiodbConn$deleteAllEntriesFromPersistentCache(deleteVolatile = TRUE)
deleteVolatile
If TRUE deletes also all entries from the volatile cache (memory cache).
Nothing.
deleteWholePersistentCache()
Delete all files associated with this connector from the persistent cache (disk cache).
BiodbConn$deleteWholePersistentCache(deleteVolatile = TRUE)
deleteVolatile
If TRUE deletes also all entries from the volatile cache (memory cache).
Nothing.
deleteAllCacheEntries()
Delete all entries from the memory cache. This method is deprecated, please use deleteAllEntriesFromVolatileCache() instead.
BiodbConn$deleteAllCacheEntries()
Nothing.
getCacheId()
Gets the ID used by this connector in the disk cache.
BiodbConn$getCacheId()
The cache ID of this connector.
makesRefToEntry()
Tests if some entry of this database makes reference to another entry of another database.
BiodbConn$makesRefToEntry(id, db, oid, any = FALSE, recurse = FALSE)
id
A character vector of entry IDs from the connector's database.
db
Another database connector.
oid
A entry ID from database db.
any
If set to TRUE, returns a single logical value: TRUE if any entry contains a reference to oid, FALSE otherwise.
recurse
If set to TRUE, the algorithm will follow all references to
entries from other databases, to see if it can establish an indirect link to
oid
.
A logical vector, the same size as id
, with TRUE for each entry
making reference to oid
, and FALSE otherwise.
makeRequest()
Makes a BiodbRequest instance using the passed parameters, and set ifself as the associated connector.
BiodbConn$makeRequest(...)
...
Those parameters are passed to the initializer of BiodbRequest.
The BiodbRequest instance.
getEntryImageUrl()
Gets the URL to a picture of the entry (e.g.: a picture of the molecule in case of a compound entry).
BiodbConn$getEntryImageUrl(entry.id)
entry.id
A character vector containing entry IDs.
A character vector, the same length as entry.id
,
containing for each entry ID either a URL or NA if no URL exists.
getEntryPageUrl()
Gets the URL to the page of the entry on the database web site.
BiodbConn$getEntryPageUrl(entry.id)
entry.id
A character vector with the IDs of entries to retrieve.
A list of BiodbUrl objects, the same length as entry.id
.
getChromCol()
Gets a list of chromatographic columns contained in this database.
BiodbConn$getChromCol(ids = NULL)
ids
A character vector of entry identifiers (i.e.: accession numbers). Used to restrict the set of entries on which to run the algorithm.
A data.frame with two columns, one for the ID 'id' and another one for the title 'title'.
getMatchingMzField()
Gets the field to use for M/Z matching.
BiodbConn$getMatchingMzField()
The name of the field (one of peak.mztheo or peak.mzexp).
setMatchingMzField()
Sets the field to use for M/Z matching.
BiodbConn$setMatchingMzField(field = c("peak.mztheo", "peak.mzexp"))
field
The field to use for matching.
Nothing.
getMzValues()
Gets a list of M/Z values contained inside the database.
BiodbConn$getMzValues( ms.mode = NULL, max.results = 0, precursor = FALSE, ms.level = 0 )
ms.mode
The MS mode. Set it to either 'neg' or 'pos' to limit the output to one mode.
max.results
If set, it is used to limit the size of the output.
precursor
If set to TRUE, then restrict the search to precursor peaks.
ms.level
The MS level to which you want to restrict your search. 0 means that you want to search in all levels.
A numeric vector containing M/Z values.
getNbPeaks()
Gets the number of peaks contained in the database.
BiodbConn$getNbPeaks(mode = NULL, ids = NULL)
mode
The MS mode. Set it to either 'neg' or 'pos' to limit the counting to one mode.
ids
A character vector of entry identifiers (i.e.: accession numbers). Used to restrict the set of entries on which to run the algorithm.
The number of peaks, as an integer.
filterEntriesOnRt()
Filters a list of entries on retention time values.
BiodbConn$filterEntriesOnRt( entry.ids, rt, rt.unit, rt.tol, rt.tol.exp, chrom.col.ids, match.rt )
entry.ids
A character vector of entry IDs.
rt
A vector of retention times to match. Used if input.df is not set. Unit is specified by rt.unit parameter.
rt.unit
The unit for submitted retention times. Either 's' or 'min'.
rt.tol
The plain tolerance (in seconds) for retention times: input.rt
rt.tol <= database.rt <= input.rt + rt.tol.
rt.tol.exp
A special exponent tolerance for retention times: input.rt
input.rt ** rt.tol.exp <= database.rt <= input.rt + input.rt ** rt.tol.exp. This exponent is applied on the RT value in seconds. If both rt.tol and rt.tol.exp are set, the inequality expression becomes input.rt - rt.tol - input.rt ** rt.tol.exp <= database.rt <= input.rt + rt.tol + input.rt ** rt.tol.exp.
chrom.col.ids
IDs of chromatographic columns on which to match the retention time.
match.rt
If set to TRUE, filters on RT values, otherwise does not do any filtering.
A character vector containing entry IDs after filtering.
searchForMassSpectra()
Searches for entries (i.e.: spectra) that contain a peak around the given M/Z value. Entries can also be filtered on RT values. You can input either a list of M/Z values through mz argument and set a tolerance with mz.tol argument, or two lists of minimum and maximum M/Z values through mz.min and mz.max arguments.
BiodbConn$searchForMassSpectra( mz.min = NULL, mz.max = NULL, mz = NULL, mz.tol = NULL, mz.tol.unit = c("plain", "ppm"), rt = NULL, rt.unit = c("s", "min"), rt.tol = NULL, rt.tol.exp = NULL, chrom.col.ids = NULL, precursor = FALSE, min.rel.int = 0, ms.mode = NULL, max.results = 0, ms.level = 0, include.ids = NULL )
mz.min
A vector of minimum M/Z values.
mz.max
A vector of maximum M/Z values. Its length must be the same as
mz.min
.
mz
A vector of M/Z values.
mz.tol
The M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unit
The type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
rt
A vector of retention times to match. Used if input.df is not set. Unit is specified by rt.unit parameter.
rt.unit
The unit for submitted retention times. Either 's' or 'min'.
rt.tol
The plain tolerance (in seconds) for retention times: input.rt
rt.tol <= database.rt <= input.rt + rt.tol.
rt.tol.exp
A special exponent tolerance for retention times: input.rt
input.rt ** rt.tol.exp <= database.rt <= input.rt + input.rt ** rt.tol.exp. This exponent is applied on the RT value in seconds. If both rt.tol and rt.tol.exp are set, the inequality expression becomes input.rt - rt.tol - input.rt ** rt.tol.exp <= database.rt <= input.rt + rt.tol + input.rt ** rt.tol.exp.
chrom.col.ids
IDs of chromatographic columns on which to match the retention time.
precursor
If set to TRUE, then restrict the search to precursor peaks.
min.rel.int
The minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.mode
The MS mode. Set it to either 'neg' or 'pos'.
max.results
If set, it is used to limit the number of matches found for each M/Z value.
ms.level
The MS level to which you want to restrict your search. 0 means that you want to search in all levels.
include.ids
A list of IDs to which to restrict the final results. All IDs that are not in this list will be excluded.
A character vector of spectra IDs.
searchMsEntries()
DEPRECATED. Use searchForMassSpectra() instead.
BiodbConn$searchMsEntries( mz.min = NULL, mz.max = NULL, mz = NULL, mz.tol = NULL, mz.tol.unit = c("plain", "ppm"), rt = NULL, rt.unit = c("s", "min"), rt.tol = NULL, rt.tol.exp = NULL, chrom.col.ids = NULL, precursor = FALSE, min.rel.int = 0, ms.mode = NULL, max.results = 0, ms.level = 0 )
mz.min
A vector of minimum M/Z values.
mz.max
A vector of maximum M/Z values. Its length must be the same as
mz.min
.
mz
A vector of M/Z values.
mz.tol
The M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unit
The type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
rt
A vector of retention times to match. Used if input.df is not set. Unit is specified by rt.unit parameter.
rt.unit
The unit for submitted retention times. Either 's' or 'min'.
rt.tol
The plain tolerance (in seconds) for retention times: input.rt
rt.tol <= database.rt <= input.rt + rt.tol.
rt.tol.exp
A special exponent tolerance for retention times: input.rt
input.rt ** rt.tol.exp <= database.rt <= input.rt + input.rt ** rt.tol.exp. This exponent is applied on the RT value in seconds. If both rt.tol and rt.tol.exp are set, the inequality expression becomes input.rt - rt.tol - input.rt ** rt.tol.exp <= database.rt <= input.rt + rt.tol + input.rt ** rt.tol.exp.
chrom.col.ids
IDs of chromatographic columns on which to match the retention time.
precursor
If set to TRUE, then restrict the search to precursor peaks.
min.rel.int
The minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.mode
The MS mode. Set it to either 'neg' or 'pos'.
max.results
If set, it is used to limit the number of matches found for each M/Z value.
ms.level
The MS level to which you want to restrict your search. 0 means that you want to search in all levels.
A character vector of spectra IDs.
searchMsPeaks()
For each M/Z value, searches for matching MS spectra and returns the matching peaks.
BiodbConn$searchMsPeaks( input.df = NULL, mz = NULL, mz.tol = NULL, mz.tol.unit = c("plain", "ppm"), min.rel.int = 0, ms.mode = NULL, ms.level = 0, max.results = 0, chrom.col.ids = NULL, rt = NULL, rt.unit = c("s", "min"), rt.tol = NULL, rt.tol.exp = NULL, precursor = FALSE, precursor.rt.tol = NULL, insert.input.values = TRUE, prefix = NULL, compute = TRUE, fields = NULL, fieldsLimit = 0, input.df.colnames = c(mz = "mz", rt = "rt"), match.rt = FALSE )
input.df
A data frame taken as input for searchMsPeaks(). It must contain a columns 'mz', and optionaly an 'rt' column.
mz
A vector of M/Z values to match. Used if input.df is not set.
mz.tol
The M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unit
The type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
min.rel.int
The minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.mode
The MS mode. Set it to either 'neg' or 'pos'.
ms.level
The MS level to which you want to restrict your search. 0 means that you want to search in all levels.
max.results
If set, it is used to limit the number of matches found for each M/Z value.
chrom.col.ids
IDs of chromatographic columns on which to match the retention time.
rt
A vector of retention times to match. Used if input.df is not set. Unit is specified by rt.unit parameter.
rt.unit
The unit for submitted retention times. Either 's' or 'min'.
rt.tol
The plain tolerance (in seconds) for retention times: input.rt
rt.tol <= database.rt <= input.rt + rt.tol.
rt.tol.exp
A special exponent tolerance for retention times: input.rt
input.rt ** rt.tol.exp <= database.rt <= input.rt + input.rt ** rt.tol.exp. This exponent is applied on the RT value in seconds. If both rt.tol and rt.tol.exp are set, the inequality expression becomes input.rt - rt.tol - input.rt ** rt.tol.exp <= database.rt <= input.rt + rt.tol + input.rt ** rt.tol.exp.
precursor
If set to TRUE, then restrict the search to precursor peaks.
precursor.rt.tol
The RT tolerance used when matching the precursor.
insert.input.values
Insert input values at the beginning of the result data frame.
prefix
Add prefix on column names of result data frame.
compute
If set to TRUE, use the computed values when converting found entries to data frame.
fields
A character vector of field names to output. The data frame output will be restricted to this list of fields.
fieldsLimit
The maximum of values to output for fields with multiple values. Set it to 0 to get all values.
input.df.colnames
Names of the columns in the input data frame.
match.rt
If set to TRUE, match also RT values.
A data frame with at least input MZ and RT columns, and annotation
columns prefixed with prefix
if set. For each matching found a row is
output. Thus if n matchings are found for M/Z value x, then there will be n
rows for x, each for a different match. The number of matching found for
each M/Z value is limited to max.results
.
msmsSearch()
Searches MSMS spectra matching a template spectrum. The mz.tol parameter is applied on the precursor search.
BiodbConn$msmsSearch( spectrum, precursor.mz, mz.tol, mz.tol.unit = c("plain", "ppm"), ms.mode, npmin = 2, dist.fun = c("wcosine", "cosine", "pkernel", "pbachtttarya"), msms.mz.tol = 3, msms.mz.tol.min = 0.005, max.results = 0 )
spectrum
A template spectrum to match inside the database.
precursor.mz
The M/Z value of the precursor peak of the mass spectrum.
mz.tol
The M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unit
The type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
ms.mode
The MS mode. Set it to either 'neg' or 'pos'.
npmin
The minimum number of peak to detect a match (2 is recommended).
dist.fun
The distance function used to compute the distance betweem two mass spectra.
msms.mz.tol
M/Z tolerance to apply while matching MSMS spectra. In PPM.
msms.mz.tol.min
Minimum of the M/Z tolerance (plain unit). If
the M/Z tolerance computed with msms.mz.tol
is lower than
msms.mz.tol.min
, then msms.mz.tol.min
will be used.
max.results
If set, it is used to limit the number of matches found for each M/Z value.
A data frame with columns id
, score
and peak.*
. Each
peak.*
column corresponds to a peak in the input spectrum, in the
same order and gives the number of the peak that was matched with it
inside the matched spectrum whose ID is inside the id
column.
collapseResultsDataFrame()
Collapse rows of a results data frame, by outputing a data frame with only one row for each MZ/RT value.
BiodbConn$collapseResultsDataFrame( results.df, mz.col = "mz", rt.col = "rt", sep = "|" )
results.df
Results data frame.
mz.col
The name of the M/Z column in the results data frame.
rt.col
The name of the RT column in the results data frame.
sep
The separator used to concatenate values, when collapsing results data frame.
A data frame with rows collapsed."
searchMzRange()
Find spectra in the given M/Z range. Returns a list of spectra IDs.
BiodbConn$searchMzRange( mz.min, mz.max, min.rel.int = 0, ms.mode = NULL, max.results = 0, precursor = FALSE, ms.level = 0 )
mz.min
A vector of minimum M/Z values.
mz.max
A vector of maximum M/Z values. Its length must be the
same as mz.min
.
min.rel.int
The minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.mode
The MS mode. Set it to either 'neg' or 'pos'.
max.results
If set, it is used to limit the number of matches found for each M/Z value.
precursor
If set to TRUE, then restrict the search to precursor peaks.
ms.level
The MS level to which you want to restrict your search. 0 means that you want to search in all levels.
A character vector of spectra IDs.
searchMzTol()
Find spectra containg a peak around the given M/Z value. Returns a character vector of spectra IDs.
BiodbConn$searchMzTol( mz, mz.tol, mz.tol.unit = "plain", min.rel.int = 0, ms.mode = NULL, max.results = 0, precursor = FALSE, ms.level = 0 )
mz
A vector of M/Z values.
mz.tol
The M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unit
The type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
min.rel.int
The minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.mode
The MS mode. Set it to either 'neg' or 'pos'.
max.results
If set, it is used to limit the number of matches found for each M/Z value.
precursor
If set to TRUE, then restrict the search to precursor peaks.
ms.level
The MS level to which you want to restrict your search. 0 means that you want to search in all levels.
A character vector of spectra IDs.
clone()
The objects of this class are cloneable with this method.
BiodbConn$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbConnBase
, and
BiodbFactory
class.
# Create an instance with default settings: mybiodb <- biodb::newInst() # 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 10 identifiers from the database: ids <- conn$getEntryIds(10) # Get number of entries contained in the database: n <- conn$getNbEntries() # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # 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 10 identifiers from the database: ids <- conn$getEntryIds(10) # Get number of entries contained in the database: n <- conn$getNbEntries() # Terminate instance. mybiodb$terminate()
BiodbConn
for encapsulating all needed information for
database access.Base class of BiodbConn
for encapsulating all needed information for
database access.
Base class of BiodbConn
for encapsulating all needed information for
database access.
This is the base class for BiodbConn
and BiodbDbInfo
.
When defining a new connector class, your class must not inherit from
BiodbBaseConn
but at least from BiodbConn
(or
BiodbRemoteConn
or any subclass of BiodbConn
).
Its main purpose is to store property values. Those values are initialized
from YAML files. The default definition file is located inside the package
in "inst/definitions.yml" and is loaded at Biodb startup. However you can
define your own files and load them using the
BiodbMain::loadDefinitions()
method.
Arguments to the contructor are:
other: Another object inheriting from BiodbBaseConn
, and
from which property values will be copied.
db.class: The class of the database ("mass.csv.file"
,
"comp.csv.file"
, ...).
properties: Some properties to set at initialization.
new()
New instance initializer. Connector objects must not be created directly. Instead, you create new connector instances through the BiodbFactory instance.
BiodbConnBase$new(other = NULL, db.class = NULL, properties = NULL, cfg = NULL)
other
Another BiodbConnBase instance as a model from which to copy property values.
db.class
The class of the connector (i.e.: "mass.csv.file").
properties
Some new values for the properties.
cfg
The BiodbConfig instance from which will be taken some property values.
Nothing.
print()
Prints a description of this connector.
BiodbConnBase$print()
Nothing.
hasProp()
Tests if this connector has a property.
BiodbConnBase$hasProp(name)
name
The name of the property to check.
Returns true if the property name
exists.
getPropSlots()
Gets the slot fields of a property.
BiodbConnBase$getPropSlots(name)
name
The name of a property.
Returns a character vector containing all slot names defined.
hasPropSlot()
Tests if a slot property has a specific slot.
BiodbConnBase$hasPropSlot(name, slot)
name
The name of a property.
slot
The slot name to check.
Returns TRUE if the property name
exists and has the
slot slot
defined, and FALSE otherwise."
propExists()
Checks if property exists.
BiodbConnBase$propExists(name)
name
The name of a property.
Returns TRUE if the property name
exists, and FALSE
otherwise.
isSlotProp()
Tests if a property is a slot property.
BiodbConnBase$isSlotProp(name)
name
The name of a property.
Returns TRUE if the property is a slot propert, FALSE otherwise.
getPropValSlot()
Retrieve the value of a slot of a property.
BiodbConnBase$getPropValSlot(name, slot, hook = TRUE)
name
The name of a property.
slot
The slot name inside the property.
hook
If set to TRUE, enables the calls to hook methods associated with the property. Otherwise, all calls to hook methods are disabled.
The value of the slot slot
of the property name
.
updatePropertiesDefinition()
Update the definition of properties.
BiodbConnBase$updatePropertiesDefinition(def)
def
A named list of property definitions. The names of the list must be the property names.
Nothing.
getEntryFileExt()
Returns the entry file extension used by this connector.
BiodbConnBase$getEntryFileExt()
A character value containing the file extension.
getDbClass()
Gets the Biodb name of the database associated with this connector.
BiodbConnBase$getDbClass()
A character value containing the Biodb database name.
getConnClassName()
Gets the name of the associated connector OOP class.
BiodbConnBase$getConnClassName()
Returns the connector OOP class name.
getConnClass()
Gets the associated connector OOP class.
BiodbConnBase$getConnClass()
Returns the connector OOP class.
getEntryClassName()
Gets the name of the associated entry class.
BiodbConnBase$getEntryClassName()
Returns the name of the associated entry class.
getEntryClass()
Gets the associated entry class.
BiodbConnBase$getEntryClass()
Returns the associated entry class.
getEntryIdField()
Gets the name of the corresponding database ID field in entries.
BiodbConnBase$getEntryIdField()
Returns the name of the database ID field.
getPropertyValue()
Gets a property value.
BiodbConnBase$getPropertyValue(name, hook = TRUE)
name
The name of the property.
hook
If set to TRUE, enables the calls to hook methods associated with the property. Otherwise, all calls to hook methods are disabled.
The value of the property.
setPropertyValue()
Sets the value of a property.
BiodbConnBase$setPropertyValue(name, value)
name
The name of the property.
value
The new value to set the property to.
Nothing.
setPropValSlot()
Set the value of the slot of a property.
BiodbConnBase$setPropValSlot(name, slot, value, hook = TRUE)
name
The name of the property.
slot
The name of the property's slot.
value
The new value to set the property's slot to.
hook
If set to TRUE, enables the calls to hook methods associated with the property. Otherwise, all calls to hook methods are disabled.
Nothing.
getBaseUrl()
Returns the base URL.
BiodbConnBase$getBaseUrl()
THe baae URL.
setBaseUrl()
Sets the base URL.
BiodbConnBase$setBaseUrl(url)
url
A URL as a character value.
Nothing.
getWsUrl()
Returns the web sevices URL.
BiodbConnBase$getWsUrl()
setWsUrl()
Sets the web sevices URL.
BiodbConnBase$setWsUrl(ws.url)
ws.url
A URL as a character value.
Nothing.
getToken()
Returns the access token.
BiodbConnBase$getToken()
setToken()
Sets the access token.
BiodbConnBase$setToken(token)
token
The token to use to access the database, as a character value.
Nothing.
getName()
Returns the full database name.
BiodbConnBase$getName()
getEntryContentType()
Returns the entry content type.
BiodbConnBase$getEntryContentType()
getSchedulerNParam()
Returns the N parameter for the scheduler.
BiodbConnBase$getSchedulerNParam()
setSchedulerNParam()
Sets the N parameter for the scheduler.
BiodbConnBase$setSchedulerNParam(n)
n
The N parameter as a whole number.
Nothing.
getSchedulerTParam()
Returns the T parameter for the scheduler.
BiodbConnBase$getSchedulerTParam()
setSchedulerTParam()
Sets the T parameter for the scheduler.
BiodbConnBase$setSchedulerTParam(t)
t
The T parameter as a whole number.
Nothing.
getUrls()
Returns the URLs.
BiodbConnBase$getUrls()
getUrl()
Returns a URL.
BiodbConnBase$getUrl(name)
name
The name of the URL to retrieve.
The URL as a character value.
setUrl()
Sets a URL.
BiodbConnBase$setUrl(name, url)
name
The name of the URL to set.
url
The URL value.
Nothing.
getXmlNs()
Returns the XML namespace.
BiodbConnBase$getXmlNs()
clone()
The objects of this class are cloneable with this method.
BiodbConnBase$clone(deep = FALSE)
deep
Whether to make a deep clone.
Sub-classes BiodbDbInfo
and BiodbConn
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Accessing BiodbConnBase methods when using a BiodbDbInfo object dbinf <- mybiodb$getDbsInfo()$get('comp.csv.file') # Test if a property exists dbinf$hasProp('name') # Get a property value dbinf$getPropertyValue('name') # Get a property value slot dbinf$getPropValSlot('urls', 'base.url') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Accessing BiodbConnBase methods when using a BiodbDbInfo object dbinf <- mybiodb$getDbsInfo()$get('comp.csv.file') # Test if a property exists dbinf$hasProp('name') # Get a property value dbinf$getPropertyValue('name') # Get a property value slot dbinf$getPropValSlot('urls', 'base.url') # Terminate instance. mybiodb$terminate()
Entry class for content in CSV format.
Entry class for content in CSV format.
This is an abstract class for handling database entries whose content is in CSV format.
biodb::BiodbEntry
-> BiodbCsvEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
new()
New instance initializer. Entry objects must not be created directly. Instead, they are retrieved through the connector instances.
BiodbCsvEntry$new(sep = ",", na.strings = "NA", quotes = "", ...)
sep
The separator to use in CSV files.
na.strings
The strings to recognize as NA values. This is a character vector.
quotes
The characters to recognize as quotes. This is a single character value.
...
The remaining arguments will be passed to the super class initializer.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbCsvEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbEntry
.
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbCsvEntry)
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbCsvEntry)
Inside the cache folder, one folder is created for each cache ID (each remote database has one single cache ID, always the same ,except if you change its URL). In each of theses folders are stored the cache files for this database.
biodb::BiodbPersistentCache
-> BiodbCustomPersistentCache
biodb::BiodbPersistentCache$addFilesToCache()
biodb::BiodbPersistentCache$copyFilesIntoCache()
biodb::BiodbPersistentCache$deleteAllFiles()
biodb::BiodbPersistentCache$deleteFile()
biodb::BiodbPersistentCache$deleteFiles()
biodb::BiodbPersistentCache$disable()
biodb::BiodbPersistentCache$enable()
biodb::BiodbPersistentCache$enabled()
biodb::BiodbPersistentCache$erase()
biodb::BiodbPersistentCache$fileExist()
biodb::BiodbPersistentCache$fileExists()
biodb::BiodbPersistentCache$filesExist()
biodb::BiodbPersistentCache$folderExists()
biodb::BiodbPersistentCache$getDir()
biodb::BiodbPersistentCache$getFilePath()
biodb::BiodbPersistentCache$getFolderPath()
biodb::BiodbPersistentCache$getTmpFolderPath()
biodb::BiodbPersistentCache$getUsedCacheIds()
biodb::BiodbPersistentCache$initialize()
biodb::BiodbPersistentCache$isReadable()
biodb::BiodbPersistentCache$isWritable()
biodb::BiodbPersistentCache$listFiles()
biodb::BiodbPersistentCache$loadFileContent()
biodb::BiodbPersistentCache$markerExist()
biodb::BiodbPersistentCache$markerExists()
biodb::BiodbPersistentCache$moveFilesIntoCache()
biodb::BiodbPersistentCache$print()
biodb::BiodbPersistentCache$saveContentToFile()
biodb::BiodbPersistentCache$setMarker()
clone()
The objects of this class are cloneable with this method.
BiodbCustomPersistentCache$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbPersistentCache
,
BiodbBiocPersistentCache
.
This class is used by BiodbDbsInfo
for storing database
characteristics, and returning them through the get()
method.
This class inherits from BiodbConnBase
.
biodb::BiodbConnBase
-> BiodbDbInfo
biodb::BiodbConnBase$getBaseUrl()
biodb::BiodbConnBase$getConnClass()
biodb::BiodbConnBase$getConnClassName()
biodb::BiodbConnBase$getDbClass()
biodb::BiodbConnBase$getEntryClass()
biodb::BiodbConnBase$getEntryClassName()
biodb::BiodbConnBase$getEntryContentType()
biodb::BiodbConnBase$getEntryFileExt()
biodb::BiodbConnBase$getEntryIdField()
biodb::BiodbConnBase$getName()
biodb::BiodbConnBase$getPropSlots()
biodb::BiodbConnBase$getPropValSlot()
biodb::BiodbConnBase$getPropertyValue()
biodb::BiodbConnBase$getSchedulerNParam()
biodb::BiodbConnBase$getSchedulerTParam()
biodb::BiodbConnBase$getToken()
biodb::BiodbConnBase$getUrl()
biodb::BiodbConnBase$getUrls()
biodb::BiodbConnBase$getWsUrl()
biodb::BiodbConnBase$getXmlNs()
biodb::BiodbConnBase$hasProp()
biodb::BiodbConnBase$hasPropSlot()
biodb::BiodbConnBase$initialize()
biodb::BiodbConnBase$isSlotProp()
biodb::BiodbConnBase$print()
biodb::BiodbConnBase$propExists()
biodb::BiodbConnBase$setBaseUrl()
biodb::BiodbConnBase$setPropValSlot()
biodb::BiodbConnBase$setPropertyValue()
biodb::BiodbConnBase$setSchedulerNParam()
biodb::BiodbConnBase$setSchedulerTParam()
biodb::BiodbConnBase$setToken()
biodb::BiodbConnBase$setUrl()
biodb::BiodbConnBase$setWsUrl()
biodb::BiodbConnBase$updatePropertiesDefinition()
clone()
The objects of this class are cloneable with this method.
BiodbDbInfo$clone(deep = FALSE)
deep
Whether to make a deep clone.
Parent class BiodbDbsInfo
and super class
BiodbConnBase
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a BiodbDbInfo object for a database: mybiodb$getDbsInfo()$get('comp.csv.file') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a BiodbDbInfo object for a database: mybiodb$getDbsInfo()$get('comp.csv.file') # Terminate instance. mybiodb$terminate()
A class for describing the available databases.
A class for describing the available databases.
The unique instance of this class is handle by the BiodbMain
class and accessed through the getDbsInfo()
method.
new()
New instance initializer. The class must not be instantiated directly. Instead, access the BiodbDbsInfo instance through the BiodbMain instance using the getDbsInfo() method.
BiodbDbsInfo$new(cfg)
cfg
The BiodbConfig instance.
Nothing.
define()
Define databases from a structured object, normally loaded from a YAML file.
BiodbDbsInfo$define(def, package = "biodb")
def
A named list of database definitions. The names of the list will be the IDs of the databases.
package
The package to which belong the new definitions.
Nothing.
getIds()
Gets the database IDs.
BiodbDbsInfo$getIds()
A character vector containing all the IDs of the defined databases.
isDefined()
Tests if a database is defined.
BiodbDbsInfo$isDefined(db.id)
db.id
A database ID, as a character string.
TRUE if the specified id corresponds to a defined database, FALSE otherwise.
checkIsDefined()
Checks if a database is defined. Throws an error if the specified id does not correspond to a defined database.
BiodbDbsInfo$checkIsDefined(db.id)
db.id
A character vector of database IDs.
Nothing.
get()
Gets information on a database.
BiodbDbsInfo$get(db.id = NULL, drop = TRUE)
db.id
Database IDs, as a character vector. If set to NULL, informations on all databases will be returned.
drop
If TRUE and only one database ID has been submitted, returns a single BiodbDbInfo instance instead of a list.
A list of BiodbDbInfo instances corresponding to the specified database IDs.
getAll()
Gets informations on all databases.
BiodbDbsInfo$getAll()
A list of all BiodbDbInfo instances."
print()
Prints informations about this instance, listing also all databases defined.
BiodbDbsInfo$print()
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbDbsInfo$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbMain
and child class BiodbDbInfo
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Getting the entry content type of a database: db.inf <- mybiodb$getDbsInfo()$get('comp.csv.file') cont.type <- db.inf$getPropertyValue('entry.content.type') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Getting the entry content type of a database: db.inf <- mybiodb$getDbsInfo()$get('comp.csv.file') cont.type <- db.inf$getPropertyValue('entry.content.type') # Terminate instance. mybiodb$terminate()
The mother abstract class of all database entry classes.
The mother abstract class of all database entry classes.
An entry is an element of a database, identifiable by its accession number.
Each contains a list of fields defined by a name and a value. The details of
all fields that can be set into an entry are defined inside the class
BiodbEntryFields
. From this class are derived other abstract classes
for different types of entry contents: BiodbTxtEntry
,
BiodbXmlEntry
, BiodbCsvEntry
, BiodbJsonEntry
and
BiodbHtmlEntry
. Then concrete classes are derived for each database:
CompCsvEntry
, MassCsvEntry
, etc. For biodb users, there is no
need to know this hierarchy; the knowledge of this class and its methods is
sufficient.
new()
New instance initializer. Entry objects must not be created directly. Instead, they are retrieved through the connector instances.
BiodbEntry$new(parent)
parent
A valid BiodbConn instance.
Nothing.
parentIsAConnector()
Tests if the parent of this entry is a connector instance.
BiodbEntry$parentIsAConnector()
TRUE if this entry belongs to a connector, FALSE otherwise.
getParent()
Returns the parent instance (A BiodbConn or BiodbFactory object) to which this object is attached.
BiodbEntry$getParent()
A BiodbConn instance or a BiodbFactory object.
getBiodb()
Returns the biodb main class instance to which this object is attached.
BiodbEntry$getBiodb()
The main biodb instance.
cloneInstance()
Clones this entry.
BiodbEntry$cloneInstance(db.class = NULL)
db.class
The database class (the Biodb database ID) of the clone. By setting this parameter, you can specify a different database for the clone, so you may clone an entry into another database if you wish. By default the class of the clone will be the same as the original entry.
The clone, as a new BiodbEntry instance.
getId()
Gets the entry ID.
BiodbEntry$getId()
the entry ID, which is the value if the accession
field.
isNew()
Tests if this entry is new.
BiodbEntry$isNew()
TRUE if this entry was newly created, FALSE otherwise.
getDbClass()
Gets the ID of the database associated with this entry.
BiodbEntry$getDbClass()
The name of the database class associated with this entry.
setFieldValue()
Sets the value of a field. If the field is not already set for this entry, then the field will be created. See BiodbEntryFields for a list of possible fields in biodb.
BiodbEntry$setFieldValue(field, value)
field
The name of a field.
value
The value to set.
Nothing.
appendFieldValue()
Appends a value to an existing field. If the field is not defined for this entry, then the field will be created and set to this value. Only fields with a cardinality greater than one can accept multiple values.
BiodbEntry$appendFieldValue(field, value)
field
The name of a field.
value
The value to append.
Nothing.
getFieldNames()
Gets a list of all fields defined for this entry.
BiodbEntry$getFieldNames()
A character vector containing all field names defined in this entry.
hasField()
Tests if a field is defined in this entry.
BiodbEntry$hasField(field)
field
The name of a field.
TRUE if the specified field is defined in this entry, FALSE otherwise.
removeField()
Removes the specified field from this entry.
BiodbEntry$removeField(field)
field
The name of a field.
Nothing.
getFieldValue()
Gets the value of the specified field.
BiodbEntry$getFieldValue( field, compute = TRUE, flatten = FALSE, last = FALSE, limit = 0, withNa = TRUE, duplicatedValues = TRUE )
field
The name of a field.
compute
If set to TRUE and a field is not defined, try to compute it using internal defined computing rules. If set to FALSE, let the field undefined.
flatten
If set to TRUE and a field's value is a vector of more than one element, then export the field's value as a single string composed of the field's value concatenated and separated by the character defined in the 'multival.field.sep' config key. If set to FALSE or the field contains only one value, changes nothing.
last
If set to TRUE and a field's value is a vector of more than one element, then export only the last value. If set to FALSE, changes nothing.
limit
The maximum number of values to get in case the field contains more than one value.
withNa
If set to TRUE, keep NA values. Otherwise filter out NAs values in vectors.
duplicatedValues
If set to TRUE, keeps duplicated values.
The value of the field.
getFieldsByType()
Gets the fields of this entry that have the specified type.
BiodbEntry$getFieldsByType(type)
type
The type of fields to retrieve.
A character vector containing the field names.
getFieldsAsDataframe()
Converts this entry into a data frame.
BiodbEntry$getFieldsAsDataframe( only.atomic = TRUE, compute = TRUE, fields = NULL, fields.type = NULL, flatten = TRUE, limit = 0, only.card.one = FALSE, own.id = TRUE, duplicate.rows = TRUE, sort = FALSE, virtualFields = FALSE )
only.atomic
If set to TRUE, only export field's values that are atomic
compute
If set to TRUE and a field is not defined, try to compute it using internal defined computing rules. If set to FALSE, let the field undefined.
fields
Set to character vector of field names in order to restrict execution to this set of fields.
fields.type
If set, output all the fields of the specified type.
flatten
If set to TRUE and a field's value is a vector of more than one element, then export the field's value as a single string composed of the field's value concatenated and separated by the character defined in the 'multival.field.sep' config key. If set to FALSE or the field contains only one value, changes nothing.
limit
The maximum number of field values to write into new columns. Used for fields that can contain more than one value.
only.card.one
If set to TRUE, only fields with a cardinality of one will be extracted.
own.id
If set to TRUE includes the database id field named
<database_name>.id
whose values are the same as the accession
field.
duplicate.rows
If set to TRUE and merging field values with cardinality greater than one, values will be duplicated.
sort
If set to TRUE sort the order of columns alphabetically, otherwise do not sort.
virtualFields
If set to TRUE includes also virtual fields, otherwise excludes them.
(i.e.
of type vector).
A data frame containg the values of the fields.
getFieldsAsJson()
Converts this entry into a JSON string.
BiodbEntry$getFieldsAsJson(compute = TRUE)
compute
If set to TRUE and a field is not defined, try to compute it using internal defined computing rules. If set to FALSE, let the field undefined.
A JSON object from jsonlite package.
parseContent()
Parses content string and set values accordingly for this entry's fields. This method is called automatically and should be run directly by users.
BiodbEntry$parseContent(content)
content
A character string containing definition for an entry and
obtained
from a database. The format can be CSV, HTML, JSON, XML, or just text.
Nothing.
computeFields()
Computes fields. Look at all missing fields, and try to compute them using references to other databases, if a rule exists.
BiodbEntry$computeFields(fields = NULL)
fields
A list of fields to review for computing. By default all fields will be reviewed.
TRUE if at least one field was computed successfully, FALSE otherwise.
print()
Displays short information about this instance.
BiodbEntry$print()
Nothing.
getName()
Gets a short text describing this entry instance.
BiodbEntry$getName()
A character value concatenating the connector name with the entry accession.
makesRefToEntry()
Tests if this entry makes reference to another entry.
BiodbEntry$makesRefToEntry(db, oid, recurse = FALSE)
db
Another database connector.
oid
A entry ID from database db.
recurse
If set to TRUE, the algorithm will follow all references to
entries from other databases, to see if it can establish an indirect link to
oid
.
TRUE if this entry makes reference to the entry oid from database db, FALSE otherwise.
getField()
DEPRECATED. Gets the value of a field.
BiodbEntry$getField(field)
field
The name of the field.
The value of the field.
setField()
DEPRECATED. Sets the value of a field.
BiodbEntry$setField(field, value)
field
The name of the field.
value
The new value of the field.
Nothing.
getFieldClass()
Gets the class of a field.
BiodbEntry$getFieldClass(field)
field
The name of the field.
The class of the field.
getFieldDef()
Gets the definition of an entry field.
BiodbEntry$getFieldDef(field)
field
The name of the field.
An object BiodbEntryField which defines the field.
getFieldCardinality()
Gets the cardinality of the field.
BiodbEntry$getFieldCardinality(field)
field
The name of the field.
The cardinality of the field.
fieldHasBasicClass()
DEPRECATED. Use BiodbEntryField::isVector() instead.
BiodbEntry$fieldHasBasicClass(field)
field
The name of the field.
TRUE if the field as a basic type (logical, numeric, character, ...).
clone()
The objects of this class are cloneable with this method.
BiodbEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbFactory
, BiodbConn
,
BiodbEntryFields
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a compound CSV file database chebi.tsv <- system.file("extdata", "chebi_extract.tsv", package='biodb') # Get the connector of a compound database conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi.tsv) # Get an entry: entry <- conn$getEntry(conn$getEntryIds(1)) # Get all defined fields: entry$getFieldNames() # Get a field value: accession <- entry$getFieldValue('accession') # Test if a field is defined: if (entry$hasField('name')) print(paste("The entry's name is ", entry$getFieldValue('name'), '.', sep='')) # Export an entry as a data frame: df <- entry$getFieldsAsDataframe() # You can set or reset a field's value: entry$setFieldValue('mass', 1893.1883) # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a compound CSV file database chebi.tsv <- system.file("extdata", "chebi_extract.tsv", package='biodb') # Get the connector of a compound database conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi.tsv) # Get an entry: entry <- conn$getEntry(conn$getEntryIds(1)) # Get all defined fields: entry$getFieldNames() # Get a field value: accession <- entry$getFieldValue('accession') # Test if a field is defined: if (entry$hasField('name')) print(paste("The entry's name is ", entry$getFieldValue('name'), '.', sep='')) # Export an entry as a data frame: df <- entry$getFieldsAsDataframe() # You can set or reset a field's value: entry$setFieldValue('mass', 1893.1883) # Terminate instance. mybiodb$terminate()
A class for describing an entry field.
A class for describing an entry field.
This class is used by BiodbEntryFields
for storing field
characteristics, and returning them through the get()
method. The
constructor is not meant to be used, but for development purposes the
constructor's parameters are nevertheless described in the Fields section.
The constructor accepts the following arguments:
name: The name of the field.
alias: A character vector containing zero or more aliases for the field.
type: A type describing the field. One of: "mass", "name" or "id". Optional.
class: The class of the field. One of: "character", "integer", "double", "logical", "object", "data.frame".
card: The cardinality of the field: either "1" or "*".
forbids.duplicates: If set to TRUE, the field forbids duplicated values.
description: A description of the field.
allowed.values: The values authorized for the field.
lower.case: Set to TRUE if you want all values set to the field to be forced to lower case.
case.insensitive: Set to TRUE of you want the field to ignore case when checking a value.
computable.from: The Biodb ID of a database, from which this field can be computed.
virtual: If set to TRUE
, the field is computed from other fields, and
thus cannot be modified.
virtual.group.by.type: For a virtual field of class data.frame, this indicates to gather all fields of the specified type to build a data frame.
new()
New instance initializer. This class must not be instantiated directly. Instead, you access the instances of this class through the BiodbEntryFields instance that you get from the BiodbMain instance.
BiodbEntryField$new( parent, name, alias = NA_character_, type = NA_character_, class = c("character", "integer", "double", "logical", "object", "data.frame"), card = c("one", "many"), forbids.duplicates = FALSE, description = NA_character_, allowed.values = NULL, lower.case = FALSE, case.insensitive = FALSE, computable.from = NULL, virtual = FALSE, virtual.group.by.type = NULL, dataFrameGroup = NA_character_ )
parent
The BiodbEntryFields parent instance.
name
The field name.
alias
The field aliases as a character vector.
type
The field type.
class
The field class.
card
The field cardinality.
forbids.duplicates
Set to TRUE to forbid duplicated values.
description
The field description.
allowed.values
Restrict possible values to a set of allowed values.
lower.case
All values will be converted to lower case.
case.insensitive
Comparison will be made case insensitive for this field.
computable.from
A list of databases from which to compute automatically the value of this field.
virtual
Set to TRUE if this field is virtual.
virtual.group.by.type
In case of a virtual field, set the type of fields to group together into a data frame.
dataFrameGroup
The data frame group.
Nothing.
getName()
Gets the name.
BiodbEntryField$getName()
The name of this field.
getType()
Gets field's type.
BiodbEntryField$getType()
The type of this field.
isOfType()
Tests if this field is of the specified type.
BiodbEntryField$isOfType(type)
type
The type.
TRUE if this field is of the specified type, FALSE otherwise.
getDescription()
Get field's description.
BiodbEntryField$getDescription()
The description of this field.
hasAliases()
Tests if this field has aliases.
BiodbEntryField$hasAliases()
TRUE if this entry field defines aliases, FALSE otherwise.
getAliases()
Get aliases.
BiodbEntryField$getAliases()
The list of aliases if some are defined, otherwise returns NULL."
addAlias()
Adds an alias to the list of aliases.
BiodbEntryField$addAlias(alias)
alias
The name of a valid alias.
Nothing.
removeAlias()
Removes an alias from the list of aliases.
BiodbEntryField$removeAlias(alias)
alias
The name of a valid alias.
Nothing.
getAllNames()
Gets all names.
BiodbEntryField$getAllNames()
The list of all names (main name and aliases).
isComputable()
Tests if this field is computable from another field or another database.
BiodbEntryField$isComputable()
TRUE if the field is computable, FALSE otherwise.
getComputableFrom()
Get the list of connectors that can be used to compute this field.
BiodbEntryField$getComputableFrom()
A list of list objects. Each list object contains the name of the database from which the field is computable.
getDataFrameGroup()
Gets the defined data frame group, if any.
BiodbEntryField$getDataFrameGroup()
The data frame group, as a character value.
isComputableFrom()
Gets the ID of the database from which this field can be computed.
BiodbEntryField$isComputableFrom()
The list of databases where to find this field's value.
addComputableFrom()
Adds a directive from the list of computableFrom.
BiodbEntryField$addComputableFrom(directive)
directive
A valid \"computable from\" directive.
Nothing.
removeComputableFrom()
Removes a directive from the list of computableFrom.
BiodbEntryField$removeComputableFrom(directive)
directive
A valid \"computable from\" directive.
Nothing.
correctValue()
Corrects a value so it is compatible with this field.
BiodbEntryField$correctValue(value)
value
A value.
The corrected value.
isEnumerate()
Tests if this field is an enumerate type (i.e.: it defines allowed values).
BiodbEntryField$isEnumerate()
TRUE if this field defines some allowed values, FALSE otherwise.
isVirtual()
Tests if this field is a virtual field.
BiodbEntryField$isVirtual()
TRUE if this field is virtual, FALSE otherwise.
getVirtualGroupByType()
Gets type for grouping field values when building a virtual data frame.
BiodbEntryField$getVirtualGroupByType()
The type, as a character value.
getAllowedValues()
Gets allowed values.
BiodbEntryField$getAllowedValues(value = NULL)
value
If this parameter is set to particular allowed values, then the method returns a list of synonyms for this value (if any).
A character vector containing all allowed values.
addAllowedValue()
Adds an allowed value, as a synonym to already an existing value. Note that not all enumerate fields accept synonyms.
BiodbEntryField$addAllowedValue(key, value)
key
The key associated with the value (i.e.: the key is the main name of an allowed value).
value
The new value to add.
Nothing.
checkValue()
Checks if a value is correct. Fails if value
is incorrect.
BiodbEntryField$checkValue(value)
value
The value to check.
Nothing.
hasCardOne()
Tests if this field has a cardinality of one.
BiodbEntryField$hasCardOne()
TRUE if the cardinality of this field is one, FALSE otherwise.
hasCardMany()
Tests if this field has a cardinality greater than one.
BiodbEntryField$hasCardMany()
TRUE if the cardinality of this field is many, FALSE otherwise.
forbidsDuplicates()
Tests if this field forbids duplicates.
BiodbEntryField$forbidsDuplicates()
TRUE if this field forbids duplicated values, FALSE otherwise.
isCaseInsensitive()
Tests if this field is case sensitive.
BiodbEntryField$isCaseInsensitive()
TRUE if this field is case insensitive, FALSE otherwise.
getClass()
Gets the class of this field's value.
BiodbEntryField$getClass()
class) of this field.
isObject()
Tests if this field's type is a class.
BiodbEntryField$isObject()
TRUE if field's type is a class, FALSE otherwise.
isDataFrame()
Tests if this field's type is data.frame
.
BiodbEntryField$isDataFrame()
TRUE if field's type is data frame, FALSE otherwise."
isAtomic()
Tests if this field's type is an atomic type.
BiodbEntryField$isAtomic()
character, integer, double or logical), FALSE otherwise.
isVector()
Tests if this field's type is a basic vector type.
BiodbEntryField$isVector()
character, integer, double or logical), FALSE otherwise.
equals()
Compares this instance with another, and tests if they are equal.
BiodbEntryField$equals(other, fail = FALSE)
other
Another BiodbEntryField instance.
fail
If set to TRUE, then throws error instead of returning FALSE.
TRUE if they are equal, FALSE otherwise.
updateWithValuesFrom()
Updates fields using values from other
instance. The updated fields
BiodbEntryField$updateWithValuesFrom(other)
other
Another BiodbEntryField instance.
are
'alias' and 'computable.from'. No values will be removed from those vectors. The new values will only be appended. This allows to extend an existing field inside a new connector definition.
Nothing.
print()
Print informations about this entry.
BiodbEntryField$print()
Nothing.
getCardinality()
Gets the field's cardinality.
BiodbEntryField$getCardinality()
The cardinality: "one" or "many".
check()
Checks if essential values are defined.
BiodbEntryField$check()
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbEntryField$clone(deep = FALSE)
deep
Whether to make a deep clone.
Parent class BiodbEntryFields
.
# Get the class of the InChI field. mybiodb <- biodb::newInst() inchi.field.class <- mybiodb$getEntryFields()$get('inchi')$getClass() # Test the cardinality of a field card.one <- mybiodb$getEntryFields()$get('name')$hasCardOne() card.many <- mybiodb$getEntryFields()$get('name')$hasCardMany() # Get the description of a field desc <- mybiodb$getEntryFields()$get('inchi')$getDescription() # Terminate instance. mybiodb$terminate()
# Get the class of the InChI field. mybiodb <- biodb::newInst() inchi.field.class <- mybiodb$getEntryFields()$get('inchi')$getClass() # Test the cardinality of a field card.one <- mybiodb$getEntryFields()$get('name')$hasCardOne() card.many <- mybiodb$getEntryFields()$get('name')$hasCardMany() # Get the description of a field desc <- mybiodb$getEntryFields()$get('inchi')$getDescription() # Terminate instance. mybiodb$terminate()
A class for handling description of all entry fields.
A class for handling description of all entry fields.
The unique instance of this class is handle by the BiodbMain
class and accessed through the getEntryFields()
method.
new()
New instance initializer. No BiodbEntryFields instance must be created directly. Instead, call the getEntryFields() method of BiodbMain.
BiodbEntryFields$new(parent)
parent
The BiodbMain instance.
Nothing.
notifyCfgUpdate()
Call back method called when a value is modified inside the configuration.
BiodbEntryFields$notifyCfgUpdate(k, v)
k
The config key name.
v
The value associated with the key.
Nothing.
isAlias()
Tests if names are aliases.
BiodbEntryFields$isAlias(name)
name
A character vector of names or aliases to test.
A logical vector, the same length as name
, with TRUE
for name values that are an alias of a field, and FALSE otherwise."
formatName()
Format field name(s) for biodb format: set to lower case and remove dot or underscore characters depending on configuration.
BiodbEntryFields$formatName(name)
name
A character vector of names or aliases to test.
A character vector of formatted names.
isDefined()
Tests if names are defined fields.
BiodbEntryFields$isDefined(name)
name
A character vector of names or aliases to test.
A logical vector, the same length as name
, with TRUE
for name values that corresponds to a defined field.
checkIsDefined()
Tests if names are valid defined fields. Throws an error if any name does not correspond to a defined field.
BiodbEntryFields$checkIsDefined(name)
name
A character vector of names or aliases to test.
Nothing.
getRealName()
Gets the real names (main names) of fields. If some name is not found neither in aliases nor in real names, an error is thrown.
BiodbEntryFields$getRealName(name, fail = TRUE)
name
A character vector of names or aliases.
fail
Fails if name is unknown.
A character vector, the same length as name
, with the real
field name for each name given (i.e. each alias is replaced with the
real name).
get()
Gets a BiodbEntryField instance.
BiodbEntryFields$get(name, drop = TRUE)
name
A character vector of names or aliases.
drop
If TRUE and only one name has been submitted, returns a single BiodbEntryField instance instead of a list.
A named list of BiodbEntryField instances. The names of the list are the real names of the entry fields, thus they may be different from the one provided inside the name argument.
getFieldNames()
Gets the main names of all fields.
BiodbEntryFields$getFieldNames(type = NULL, computable = NULL)
type
Set this parameter to a character vector in order to return only the names of the fields corresponding to the types specified.
computable
If set to TRUE, returns only the names of computable fields. If set to FALSE, returns only the names of fields that are not computable.
A character vector containing all selected field names.
getDatabaseIdField()
Gets a database ID field.
BiodbEntryFields$getDatabaseIdField(database)
database
The name (i.e.: Biodb ID) of a database.
accession numbers) for this database.
print()
Prints information about the instance.
BiodbEntryFields$print()
Nothing.
define()
Defines fields.
BiodbEntryFields$define(def)
def
A named list of field definitions. The names of the list are the main names of the fields.
Nothing.
terminate()
Terminates the instance. This method will be called automatically by the BiodbMain instance when you call
BiodbEntryFields$terminate()
BiodbMain
:terminate().
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbEntryFields$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbMain
and child class
BiodbEntryField
.
# Getting information about the accession field: mybiodb <- biodb::newInst() entry.field <- mybiodb$getEntryFields()$get('accession') # Test if a name is an alias of a field mybiodb$getEntryFields()$isAlias('genesymbols') # Test if a name is associated with a defined field mybiodb$getEntryFields()$isDefined('name') # Terminate instance. mybiodb$terminate()
# Getting information about the accession field: mybiodb <- biodb::newInst() entry.field <- mybiodb$getEntryFields()$get('accession') # Test if a name is an alias of a field mybiodb$getEntryFields()$isAlias('genesymbols') # Test if a name is associated with a defined field mybiodb$getEntryFields()$isDefined('name') # Terminate instance. mybiodb$terminate()
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)
bdb
The 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.class
The type of a database. The list of types can be obtained from the class BiodbDbsInfo.
url
An 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.
token
A 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.exists
If set to TRUE, the method will fail if a connector for
get.existing.conn
This 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.id
If 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.id
If 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.id
A connector ID.
TRUE if a connector with this ID exists, FALSE otherwise.
deleteConn()
Deletes an existing connector.
BiodbFactory$deleteConn(conn)
conn
A connector instance or a connector ID.
Nothing.
deleteConnByClass()
Deletes all existing connectors from a same class.
BiodbFactory$deleteConnByClass(db.class)
db.class
The 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.id
An existing connector ID.
class
If 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.
create
If 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.id
An existing connector ID.
id
A character vector containing database entry IDs (accession numbers).
drop
If 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.null
Set to TRUE to remove NULL entries.
limit
Set 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.class
A database ID.
A new BiodbEntry object.
createEntryFromContent()
Creates an entry instance from a content.
BiodbFactory$createEntryFromContent(conn.id, content, drop = TRUE)
conn.id
A valid BiodbConn identifier.
content
A list or character vector of contents to parse to create the entries.
drop
If 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.id
A 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.id
A connector ID.
Nothing.
deleteAllCacheEntries()
Deletes all entries stored in the cache of the given connector.
BiodbFactory$deleteAllCacheEntries(conn.id)
conn.id
A 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)
deep
Whether 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()
# 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()
Entry class for content in HTML format.
Entry class for content in HTML format.
This is an abstract class for handling database entries whose content is in HTML format.
biodb::BiodbEntry
-> biodb::BiodbXmlEntry
-> BiodbHtmlEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
new()
New instance initializer. Entry objects must not be created directly. Instead, they are retrieved through the connector instances.
BiodbHtmlEntry$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbHtmlEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbXmlEntry
.
# Create a concrete entry class inheriting from this class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbHtmlEntry)
# Create a concrete entry class inheriting from this class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbHtmlEntry)
This is an abstract class for handling database entries whose content is in JSON format.
biodb::BiodbEntry
-> BiodbJsonEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$initialize()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
clone()
The objects of this class are cloneable with this method.
BiodbJsonEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbEntry
.
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbJsonEntry)
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbJsonEntry)
This is an abstract class for handling database entries whose content is in list format.
biodb::BiodbEntry
-> BiodbListEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$initialize()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
clone()
The objects of this class are cloneable with this method.
BiodbListEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbEntry
.
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbListEntry)
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbListEntry)
The central class of the biodb package.
The central class of the biodb package.
The main class of the biodb
package.
In order to use the biodb package, you need first to create an instance of
this class.
The constructor takes a single argument, autoloadExtraPkgs
, to enable
(TRUE
or default) or disable (FALSE
) autoloading of extra
biodb packages.
Once the instance is created, some other important classes
(BiodbFactory
, BiodbPersistentCache
, BiodbConfig
, ...)
are instantiated (just once) and their instances are later accessible through
get*() methods.
new()
New instance initializer. The BiodbMain must not be instantiated directly. Instead use the newInst() global method.
BiodbMain$new(autoloadExtraPkgs = NULL)
autoloadExtraPkgs
Set to TRUE to allow automatic loading of extension packages. Set to FALSE to forbid it. If left to NULL, the default, autoload.extra.pkgs configuration value will be used.
Nothing.
terminate()
Closes \codeBiodbMain instance. Call this method when you are done with your \codeBiodbMain instance.
BiodbMain$terminate()
Nothing.
loadDefinitions()
Loads databases and entry fields definitions from YAML file.
BiodbMain$loadDefinitions(file, package = "biodb")
file
The path to a YAML file containing definitions for \codeBiodbMain (databases, fields or configuration keys).
package
The package to which belong the new definitions.
Nothing.
getConfig()
Returns the single instance of the \codeBiodbConfig class.
BiodbMain$getConfig()
The instance of the \codeBiodbConfig class attached to this BiodbMain instance.
getPersistentCache()
Returns the single instance of the BiodbPersistentCache class.
BiodbMain$getPersistentCache()
The instance of the BiodbPersistentCache class attached to this BiodbMain instance.
getDbsInfo()
Returns the single instance of the \codeBiodbDbsInfo class.
BiodbMain$getDbsInfo()
The instance of the \codeBiodbDbsInfo class attached to this BiodbMain instance.
getEntryFields()
Returns the single instance of the \codeBiodbEntryFields class.
BiodbMain$getEntryFields()
The instance of the \codeBiodbEntryFields class attached to this BiodbMain instance.
getFactory()
Returns the single instance of the \codeBiodbFactory class.
BiodbMain$getFactory()
The instance of the \codeBiodbFactory class attached to this BiodbMain instance.
getRequestScheduler()
Returns the single instance of the \codeBiodbRequestScheduler class.
BiodbMain$getRequestScheduler()
The instance of the \codeBiodbRequestScheduler class attached to this BiodbMain instance.
addObservers()
Adds new observers. Observers will be called each time an event occurs. This is the way used in biodb to get feedback about what is going inside biodb code.
BiodbMain$addObservers(observers)
observers
Either an object or a list of objects.
Nothing.
getObservers()
Gets the list of registered observers.
BiodbMain$getObservers()
The list or registered observers.
convertEntryIdFieldToDbClass()
Gets the database class name corresponding to an entry ID field.
BiodbMain$convertEntryIdFieldToDbClass(entry.id.field)
entry.id.field
The name of an ID field. It must end with \".id\".
entriesFieldToVctOrLst()
Extracts the value of a field from a list of entries. Returns either a vector or a list depending on the type of the field.
BiodbMain$entriesFieldToVctOrLst( entries, field, flatten = FALSE, compute = TRUE, limit = 0, withNa = TRUE )
entries
A list of \codeBiodbEntry instances.
field
The name of a field.
flatten
If set to \codeTRUE and the field has a cardinality greater than one, then values be converted into a vector of class character in which each entry values are collapsed.
compute
If set to \codeTRUE, computable fields will be output.
limit
The maximum number of values to retrieve for each entry. Set to 0 to get all values.
withNa
If set to TRUE, keep NA values. Otherwise filter out NAs values in vectors.
A vector if the field is atomic or flatten is set to \codeTRUE, otherwise a list.
entriesToDataframe()
Converts a list of entries or a list of list of entries (\codeBiodbEntry objects) into a data frame.
BiodbMain$entriesToDataframe( entries, only.atomic = TRUE, null.to.na = TRUE, compute = TRUE, fields = NULL, limit = 0, drop = FALSE, sort.cols = FALSE, flatten = TRUE, only.card.one = FALSE, own.id = TRUE, prefix = "" )
entries
A list of \codeBiodbEntry instances or a list of list of \codeBiodbEntry instances.
only.atomic
If set to \codeTRUE, output only atomic fields, i.e.: the fields whose value type is one of integer, numeric, logical or character.
null.to.na
If set to \codeTRUE, each \codeNULL entry in the list is converted into a row of NA values.
compute
If set to \codeTRUE, computable fields will be output.
fields
A character vector of field names to output. The data frame output will be restricted to this list of fields.
limit
The maximum number of field values to write into new columns. Used for fields that can contain more than one value. Set it to 0 to get all values.
drop
If set to \codeTRUE and the resulting data frame has only one column, a vector will be output instead of data frame.
sort.cols
Sort columns in alphabetical order.
flatten
If set to \codeTRUE, then each field with a cardinality greater than one, will be converted into a vector of class character whose values are collapsed.
only.card.one
Output only fields whose cardinality is one.
own.id
If set to TRUE includes the database id field named
<database_name>.id
whose values are the same as the accession
field.
prefix
Insert a prefix at the start of all field names.
A data frame containing the entries. Columns are named according to field names.
entryIdsToDataframe()
Construct a data frame using entry IDs and field values of the corresponding entries.
BiodbMain$entryIdsToDataframe( ids, db, fields = NULL, limit = 3, prefix = "", own.id = FALSE )
ids
A character vector of entry IDs or a list of character vectors of entry IDs.
db
The biodb database name for the entry IDs, or a connector ID, as a sinle character value.
fields
A character vector containing entry fields to add.
limit
The maximum number of field values to write into new columns. Used for fields that can contain more than one value. Set it to 0 to get all values.
prefix
Insert a prefix at the start of all field names.
own.id
If set to TRUE includes the database id field named
<database_name>.id
whose values are the same as the accession
field.
A
data frame containing in columns the requested field
values, with one entry per line, in the same order than in ids
vector.
addColsToDataframe()
Add values from a database to an existing data frame using a column containing entry identifiers.
BiodbMain$addColsToDataframe(x, id.col, db, fields, limit = 3, prefix = "")
x
A data frame containing at least one column with Biodb entry IDs
identified by the parameter id.col
.
id.col
The name of the column containing IDs inside the input data frame.
db
The biodb database name for the entry IDs, or a connector ID, as a single character value.
fields
A character vector containing entry fields to add.
limit
The maximum number of field values to write into new columns. Used for fields that can contain more than one value. Set it to 0 to get all values.
prefix
Insert a prefix at the start of all field names.
A data frame containing x
and new columns appended for the fields
requested.
entriesToJson()
Converts a list of \codeBiodbEntry objects into JSON. Returns a vector of characters.
BiodbMain$entriesToJson(entries, compute = TRUE)
entries
A list of \codeBiodbEntry instances. It may contain NULL elements.
compute
If set to \codeTRUE, computable fields will added to JSON too.
A list of JSON strings, the same length as entries list.
collapseRows()
Collapses rows of a data frame, by looking for duplicated values in the
reference columns (parameter cols
). The values contained in the reference
columns are supposed to be ordered inside the data frame, in the sens that
all duplicated values are supposed to directly follow the original values.
For all rows containing duplicated values, we look at values in all other
columns and concatenate values in each column containing different values.
BiodbMain$collapseRows(x, sep = "|", cols = 1L)
x
A data frame.
sep
The separator to use when concatenating values in collapsed rows.
cols
The indices or the names of the columns used as reference.
A data frame, with rows collapsed."
entriesToSingleFieldValues()
Extract all values of a field from a list of entries.
BiodbMain$entriesToSingleFieldValues( entries, field, sortOutput = FALSE, uniq = TRUE )
entries
A list of BiodbEntry objects.
field
The field for which to extract values.
sortOutput
Set to TRUE to sort the values.
uniq
Set to TRUE to remove duplicates.
The values of the field as a vector.
entryIdsToSingleFieldValues()
Extract all values of a field from a list of entries.
BiodbMain$entryIdsToSingleFieldValues( ids, db, field, sortOutput = FALSE, uniq = TRUE )
ids
A list of entry identifiers.
db
The database ID or connector ID where to find the entries.
field
The field for which to extract values.
sortOutput
Set to TRUE to sort the values.
uniq
Set to TRUE to remove duplicates.
The values of the field as a vector.
computeFields()
Computes missing fields in entries, for those fields that are comptable.
BiodbMain$computeFields(entries)
entries
A list of \codeBiodbEntry instances. It may contain NULL elements.
Nothing.
saveEntriesAsJson()
Saves a list of entries in JSON format. Each entry will be saved in a separate file.
BiodbMain$saveEntriesAsJson(entries, files, compute = TRUE)
entries
A list of \codeBiodbEntry instances. It may contain NULL elements.
files
A character vector of file paths, the same length as entries list.
compute
If set to \codeTRUE, computable fields will be saved too.
Nothing.
copyDb()
Copies all entries of a database into another database. The connector of the destination database must be editable.
BiodbMain$copyDb(conn.from, conn.to, limit = 0)
conn.from
The connector of the source datababase to copy.
conn.to
The connector of the destination database.
limit
The number of entries of the source database to copy. If set to \codeNULL, copy the whole database.
Nothing.
print()
Prints object information.
BiodbMain$print()
Nothing.
fieldIsAtomic()
DEPRECATED method to test if a field is an atomic field. The new method is \codeBiodbEntryField :isVector()."
BiodbMain$fieldIsAtomic(field)
field
The name of the field.
TRUE if the field's value is atomic.
getFieldClass()
DEPRECATED method to get the class of a field. The new method is
BiodbMain :getEntryFields()$get(field)$getClass()
.
BiodbMain$getFieldClass(field)
field
The name of the field.
The class of the field.
clone()
The objects of this class are cloneable with this method.
BiodbMain$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbFactory
, BiodbPersistentCache
,
BiodbConfig
, BiodbEntryFields
,
BiodbDbsInfo
.
# Create an instance: mybiodb <- biodb::newInst() # Get the factory instance fact <- mybiodb$getFactory() # Terminate instance. mybiodb$terminate() mybiodb <- NULL
# Create an instance: mybiodb <- biodb::newInst() # Get the factory instance fact <- mybiodb$getFactory() # Terminate instance. mybiodb$terminate() mybiodb <- NULL
The abstract class for handling file caching.
The abstract class for handling file caching.
This abstract class is the mother class of concrete classes that manage cache systems for saving downloaded files and request results.
It is designed for internal use, but you can still access some of the read-only methods if you wish.
new()
New instance initializer. Persistent cache objects must not be created directly. Instead, access the cache instance through the BiodbMain instance using the getPersistentCache() method.
BiodbPersistentCache$new(cfg, bdb = NULL)
cfg
An instance of the BiodbConfig class.
bdb
An instance of the BiodbMain class.
Nothing.
isReadable()
Checks if the cache system is readable.
BiodbPersistentCache$isReadable(conn = NULL)
conn
If not \codeNULL, checks if the cache system is readable for this particular connector.
\codeTRUE if the cache system is readable, \codeFALSE otherwise.
isWritable()
Checks if the cache system is writable.
BiodbPersistentCache$isWritable(conn = NULL)
conn
If not \codeNULL, checks if the cache system is writable for this particular connector.
\codeTRUE if the cache system is writable, \codeFALSE otherwise.
getDir()
Gets the path to the persistent cache folder.
BiodbPersistentCache$getDir()
The path to the cache folder as a character value.
getFolderPath()
Gets path to the cache system sub-folder dedicated to this cache ID.
BiodbPersistentCache$getFolderPath(cache.id, create = TRUE, fail = FALSE)
cache.id
The cache ID to use.
create
If set to TRUE and the folder does not exist, creates it.
fail
If set to TRUE, throws a warning if the folder does not exist.
A string containing the path to the folder.
folderExists()
Tests if a cache folder exists for this cache ID.
BiodbPersistentCache$folderExists(cache.id)
cache.id
The cache ID to use.
TRUE if a cache folder exists.
getFilePath()
Gets path of file in cache system.
BiodbPersistentCache$getFilePath(cache.id, name, ext)
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
A character vector, the same size as \codenames, containing the paths to the files.
filesExist()
Tests if at least one cache file exist for the specified cache ID.
BiodbPersistentCache$filesExist(cache.id)
cache.id
The cache ID to use.
A single boolean value.
fileExist()
DEPRECATED. Use fileExists().
BiodbPersistentCache$fileExist(cache.id, name, ext)
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc).
A logical vector, the same size as \codename, with \codeTRUE value if the file exists in the cache, or \codeFALSE otherwise.
fileExists()
Tests if a particular file exist in the cache.
BiodbPersistentCache$fileExists(cache.id, name, ext)
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc).
A logical vector, the same size as \codename, with \codeTRUE value if the file exists in the cache, or \codeFALSE otherwise.
markerExist()
DEPRECATED. Use markerExists().
BiodbPersistentCache$markerExist(cache.id, name)
cache.id
The cache ID to use.
name
A character vector containing marker names.
A logical vector, the same size as \codename, with \codeTRUE value if the marker file exists in the cache, or \codeFALSE otherwise.
markerExists()
Tests if markers exist in the cache. Markers are used, for instance, by biodb to remember that a downloaded zip file from a database has been extracted correctly.
BiodbPersistentCache$markerExists(cache.id, name)
cache.id
The cache ID to use.
name
A character vector containing marker names.
A logical vector, the same size as \codename, with \codeTRUE value if the marker file exists in the cache, or \codeFALSE otherwise.
setMarker()
Sets a marker.
BiodbPersistentCache$setMarker(cache.id, name)
cache.id
The cache ID to use.
name
A character vector containing marker names.
Nothing.
getTmpFolderPath()
Gets path to the cache system temporary folder.
BiodbPersistentCache$getTmpFolderPath()
A string containing the path to the folder.
getUsedCacheIds()
Returns a list of cache IDs actually used to store cache files.
BiodbPersistentCache$getUsedCacheIds()
A character vector containing all the cache IDs actually used inside the cache system.
loadFileContent()
Loads content of files from the cache.
BiodbPersistentCache$loadFileContent( cache.id, name, ext, output.vector = FALSE )
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
output.vector
If set to \codeTRUE, force output to be a \codevector instead of a \codelist. Where the list contains a \codeNULL, the \codevector will contain an \codeNA value.
A list (or a vector if \codeoutput.vector is set to \codeTRUE), the same size as \codename, containing the contents of the files. If some file does not exist, a \codeNULL value is inserted inside the list.
saveContentToFile()
Saves content to files into the cache.
BiodbPersistentCache$saveContentToFile(content, cache.id, name, ext)
content
A list or a character vector containing the contents of the files. It must have the same length as \codename.
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
Nothing.
addFilesToCache()
Adds exisiting files into the cache.
BiodbPersistentCache$addFilesToCache( src.file.paths, cache.id, name, ext, action = c("copy", "move") )
src.file.paths
The current paths of the source files, as a character vector.
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
action
Specifies if files have to be moved or copied into the cache.
Nothing.
copyFilesIntoCache()
Copies exisiting files into the cache.
BiodbPersistentCache$copyFilesIntoCache(src.file.paths, cache.id, name, ext)
src.file.paths
The current paths of the source files, as a character vector.
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
Nothing.
moveFilesIntoCache()
Moves exisiting files into the cache.
BiodbPersistentCache$moveFilesIntoCache(src.file.paths, cache.id, name, ext)
src.file.paths
The current paths of the source files, as a character vector.
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
Nothing.
erase()
Erases the whole cache.
BiodbPersistentCache$erase()
Nothing.
deleteFile()
Deletes a list of files inside the cache system.
BiodbPersistentCache$deleteFile(cache.id, name, ext)
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc).
Nothing.
deleteAllFiles()
Deletes, in the cache system, all files associated with this cache ID.
BiodbPersistentCache$deleteAllFiles(cache.id, fail = FALSE, prefix = FALSE)
cache.id
The cache ID to use.
fail
If set to TRUE, a warning will be emitted if no cache files exist for this cache ID.
prefix
DEPRECATED If set to TRUE, use cache.id as a prefix, deleting all files whose cache.id starts with this prefix.
Nothing.
deleteFiles()
Deletes all files with the specific extension of the cache ID in the cache system.
BiodbPersistentCache$deleteFiles(cache.id, ext)
cache.id
The cache ID to use.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc). Only files having this extension will be deleted.
Nothing.
listFiles()
Lists files present in the cache system.
BiodbPersistentCache$listFiles( cache.id, ext = NULL, extract.name = FALSE, full.path = FALSE )
cache.id
The cache ID to use.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc).
extract.name
If set to \codeTRUE, instead of returning the file paths, returns the list of names used to construct the file name: [cache_folder]/[cache.id]/[name].[ext].
full.path
If set to \codeTRUE, returns full path for files.
The files of found files, or the names of the files if \codeextract.name is set to \codeTRUE.
print()
Displays information about this object.
BiodbPersistentCache$print()
enabled()
DEPRECATED method. Use now \codeBiodbConfig :isEnabled('cache.system').
BiodbPersistentCache$enabled()
enable()
DEPRECATED method. Use now \codeBiodbConfig :enable('cache.system').
BiodbPersistentCache$enable()
disable()
DEPRECATED method. Use now \codeBiodbConfig :disable('cache.system').
BiodbPersistentCache$disable()
clone()
The objects of this class are cloneable with this method.
BiodbPersistentCache$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbMain
, BiodbBiocPersistentCache
,
BiodbBiocPersistentCache
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a compound CSV file database chebi.tsv <- system.file("extdata", "chebi_extract.tsv", package='biodb') # Get a connector instance: conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi.tsv) # Get all entries entries <- conn$getEntry(conn$getEntryIds()) # Get the cache instance: cache <- mybiodb$getPersistentCache() # Get list of files inside the cache: files <- cache$listFiles(conn$getCacheId()) # Delete files inside the cache: cache$deleteAllFiles(conn$getCacheId()) # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a compound CSV file database chebi.tsv <- system.file("extdata", "chebi_extract.tsv", package='biodb') # Get a connector instance: conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi.tsv) # Get all entries entries <- conn$getEntry(conn$getEntryIds()) # Get the cache instance: cache <- mybiodb$getPersistentCache() # Get list of files inside the cache: files <- cache$listFiles(conn$getCacheId()) # Delete files inside the cache: cache$deleteAllFiles(conn$getCacheId()) # Terminate instance. mybiodb$terminate()
Class Request.
Class Request.
This class represents a Request object that can be used with the Request Scheduler.
new()
Initializer.
BiodbRequest$new( url, method = c("get", "post"), header = character(), body = character(), encoding = integer(), conn = NULL )
url
A BiodbUrl
object.
method
HTTP method. Either "get" or "post".
header
The header.
body
The body.
encoding
The encoding to use.
conn
A valid BiodbConn instance for which this request is built.
Nothing.
setConn()
Sets the associated connector (usually the connector that created this request).
BiodbRequest$setConn(conn)
conn
A valid BiodbConn object.
Nothing.
getConn()
gets the associated connector (usually the connector that created this request).
BiodbRequest$getConn()
The associated connector as a BiodbConn object.
getUrl()
Gets the URL.
BiodbRequest$getUrl()
The URL as a BiodbUrl object.
getMethod()
Gets the method.
BiodbRequest$getMethod()
The method as a character value.
getEncoding()
Gets the encoding.
BiodbRequest$getEncoding()
The encoding.
getCurlOptions()
Gets the options object to pass to cURL library.
BiodbRequest$getCurlOptions(useragent)
useragent
The user agent as a character value.
An RCurl options object.
getUniqueKey()
Gets a unique key to identify this request. The key is an MD5 sum computed from the string representation of this request.
BiodbRequest$getUniqueKey()
A unique key as an MD5 sum.
getHeaderAsSingleString()
Gets the HTTP header as a string, concatenating all its information into a single string.
BiodbRequest$getHeaderAsSingleString()
The header as a single character value.
getBody()
Gets the body.
BiodbRequest$getBody()
The body as a character value.
print()
Displays information about this instance.
BiodbRequest$print()
self as invisible.
toString()
Gets a string representation of this instance.
BiodbRequest$toString()
A single string giving a representation of this instance.
clone()
The objects of this class are cloneable with this method.
BiodbRequest$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbRequestScheduler
, BiodbUrl
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Create a request object u <- 'https://www.ebi.ac.uk/webservices/chebi/2.0/test/getCompleteEntity' url <- BiodbUrl$new(url=u) url$setParam('chebiId', 15440) request <- BiodbRequest$new(method='get', url=url) # Send request mybiodb$getRequestScheduler()$sendRequest(request) # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Create a request object u <- 'https://www.ebi.ac.uk/webservices/chebi/2.0/test/getCompleteEntity' url <- BiodbUrl$new(url=u) url$setParam('chebiId', 15440) request <- BiodbRequest$new(method='get', url=url) # Send request mybiodb$getRequestScheduler()$sendRequest(request) # Terminate instance. mybiodb$terminate()
Class for handling requests.
Class for handling requests.
This class handles GET and POST requests, as well as file downloading. Each
remote database connection instance creates an instance of
BiodbRequestScheduler
for handling database connection. A timer is
used to schedule connections, and avoid sending too much requests to the
database. This class is not meant to be used directly by the library user.
See section Fields for a list of the constructor's parameters.
new()
New instance initializer. BiodbRequestScheduler class must not be instantiated direrctly. Instead, use the getRequestScheduler() method from BiodbMain.
BiodbRequestScheduler$new(bdb)
bdb
The BiodbMain instance.
Nothing.
sendSoapRequest()
Sends a SOAP request to a URL. Returns the string result.
BiodbRequestScheduler$sendSoapRequest( url, soap.request, soap.action = NA_character_, encoding = integer() )
url
The URL to access, as a character string.
soap.request
The XML SOAP request to send, as a character string.
soap.action
The SOAP action to contact, as a character string.
encoding
The encoding to use.
The results returned by the contacted server, as a single string value.
sendRequest()
Sends a request, and returns content result.
BiodbRequestScheduler$sendRequest(request, cache.read = TRUE)
request
A BiodbRequest instance.
cache.read
If set to TRUE, the cache system will be used. In case the same request has already been run and its results saved into the cache, then the request is not run again, the targeted server not contacted, and the results are directly loaded from the cache system.
The results returned by the contacted server, as a single string value.
downloadFile()
Downloads the content of a URL and save it into the specified destination file.
BiodbRequestScheduler$downloadFile(url, dest.file)
url
The URL to access, as a BiodbUrl object.
dest.file
A path to a destination file.
Nothing.
notifyConnUrlsUpdated()
Call back function called when connector URLs are changed.
BiodbRequestScheduler$notifyConnUrlsUpdated(conn)
conn
The connector instance for which the URLs were changed.
Nothing.
notifyConnSchedulerFrequencyUpdated()
Call back function called when connector T and N parameters (frequency) are changed.
BiodbRequestScheduler$notifyConnSchedulerFrequencyUpdated(conn)
conn
The connector instance for which the frequency were changed.
Nothing.
getUrlString()
Builds a URL object, using a base URL and parameters to be passed.
BiodbRequestScheduler$getUrlString(url, params = list())
url
A URL string.
params
A list of URL parameters.
A BiodUrl object.
getUrl()
Sends a request and get the result.
BiodbRequestScheduler$getUrl( url, params = list(), method = c("get", "post"), header = character(), body = character(), encoding = integer() )
url
A URL string.
params
A list of URL parameters.
method
The method to use. Either 'get' or 'post'.
header
The header to send.
body
The body to send.
encoding
The encoding to use.
The results of the request.
findRule()
Searches for a rule by host name.
BiodbRequestScheduler$findRule(url, create = TRUE)
url
The host URL.
create
Sets to TRUE to create a rule when none exists.
A BiodbRequestSchedulerRule object.
getConnectorRules()
Gets the rules associates with a connector.
BiodbRequestScheduler$getConnectorRules(conn)
conn
A valid connector object.
A list of rules.
registerConnector()
Registers a new connector with the scheduler.
BiodbRequestScheduler$registerConnector(conn)
conn
A valid connector object.
Nothing.
unregisterConnector()
Unregisters a connector from this scheduler.
BiodbRequestScheduler$unregisterConnector(conn)
conn
A valid connector object.
Nothing.
getAllRules()
Gets all defined rules.
BiodbRequestScheduler$getAllRules()
The list of all rules.
clone()
The objects of this class are cloneable with this method.
BiodbRequestScheduler$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get the scheduler sched <- mybiodb$getRequestScheduler() # Create a request object u <- 'https://www.ebi.ac.uk/webservices/chebi/2.0/test/getCompleteEntity' url <- BiodbUrl$new(url=u) url$setParam('chebiId', 15440) request <- BiodbRequest$new(method='get', url=url) # Send request sched$sendRequest(request) # Terminate instance. mybiodb$terminate() mybiodb <- NULL
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get the scheduler sched <- mybiodb$getRequestScheduler() # Create a request object u <- 'https://www.ebi.ac.uk/webservices/chebi/2.0/test/getCompleteEntity' url <- BiodbUrl$new(url=u) url$setParam('chebiId', 15440) request <- BiodbRequest$new(method='get', url=url) # Send request sched$sendRequest(request) # Terminate instance. mybiodb$terminate() mybiodb <- NULL
Scheduler rule class.
Scheduler rule class.
This class represents a rule for the request scheduler.
new()
Initializer.
BiodbRequestSchedulerRule$new(host, conn = NULL)
host
The web host for which this rules is applicable.
conn
The connector instance that is concerned by this rule.
Nothing.
getHost()
Gets host.
BiodbRequestSchedulerRule$getHost()
Returns the host.
getN()
Gets N value. The number of connections allowed during a period of T seconds.
BiodbRequestSchedulerRule$getN()
Returns N as an integer.
getT()
Gets T value. The number of seconds during which N connections are allowed.
BiodbRequestSchedulerRule$getT()
Returns T as a numeric.
setFrequency()
Sets both N and T.
BiodbRequestSchedulerRule$setFrequency(n, t)
n
The number of connections allowed during a period of t seconds, as an integer.
t
The number of seconds during which n connections are allowed, as a numeric value.
Nothing.
getConnectors()
Gets connectors associaated with this rule.
BiodbRequestSchedulerRule$getConnectors()
A list of BiodbConn objects.
addConnector()
Associate a connector with this rule.
BiodbRequestSchedulerRule$addConnector(conn)
conn
A BiodbConn object.
Nothing.
removeConnector()
Disassociate a connector from this rule.
BiodbRequestSchedulerRule$removeConnector(conn)
conn
A BiodbConn instance.
Nothing.
print()
Displays information about this instance.
BiodbRequestSchedulerRule$print()
Nothing.
waitAsNeeded()
Wait (sleep) until a new request is allowed.
BiodbRequestSchedulerRule$waitAsNeeded()
Nothing.
recomputeFrequency()
Recompute frequency from submitted N and T values.
BiodbRequestSchedulerRule$recomputeFrequency()
Nothing.
computeSleepTime()
Compute the needed sleep time to wait until a new request is allowed, starting from the submitted time.
BiodbRequestSchedulerRule$computeSleepTime(cur.time = Sys.time())
cur.time
Time from which to compute needed sleep time.
The needed sleep time in seconds.
storeCurrentTime()
Stores the current time.
BiodbRequestSchedulerRule$storeCurrentTime(cur.time = Sys.time())
cur.time
The current time.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbRequestSchedulerRule$clone(deep = FALSE)
deep
Whether to make a deep clone.
Entry class for content in SDF format.
Entry class for content in SDF format.
This is an abstract class for handling database entries whose content is in SDF format.
biodb::BiodbEntry
-> biodb::BiodbTxtEntry
-> BiodbSdfEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
new()
New instance initializer. Entry objects must not be created directly. Instead, they are retrieved through the connector instances.
BiodbSdfEntry$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbSdfEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbTxtEntry
.
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbSdfEntry)
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbSdfEntry)
This class represents an SQL binary operator.
This class represents an SQL binary operator.
biodb::BiodbSqlExpr
-> BiodbSqlBinaryOp
new()
Initializer.
BiodbSqlBinaryOp$new(lexpr, op, rexpr)
lexpr
A BiodbSqlExpr instance for the left part.
op
The binary operator, as a string.
rexpr
A BiodbSqlExpr instance for the right part.
Nothing.
toString()
Converts into a string.
BiodbSqlBinaryOp$toString()
A string containing the SQL expression.
clone()
The objects of this class are cloneable with this method.
BiodbSqlBinaryOp$clone(deep = FALSE)
deep
Whether to make a deep clone.
The SQL Expression abstact class.
The SQL Expression abstact class.
This abstract class represents an SQL expression.
toString()
Converts into a string.
BiodbSqlExpr$toString()
A string containing the SQL expression.
clone()
The objects of this class are cloneable with this method.
BiodbSqlExpr$clone(deep = FALSE)
deep
Whether to make a deep clone.
This class represents an SQL field.
This class represents an SQL field.
biodb::BiodbSqlExpr
-> BiodbSqlField
new()
Initializer.
BiodbSqlField$new(table = NA_character_, field)
table
The table name.
field
The field name.
Nothing.
toString()
Converts into a string.
BiodbSqlField$toString()
A string containing the SQL expression.
clone()
The objects of this class are cloneable with this method.
BiodbSqlField$clone(deep = FALSE)
deep
Whether to make a deep clone.
This class represents an SQL list.
This class represents an SQL list.
biodb::BiodbSqlExpr
-> BiodbSqlList
new()
Initializer.
BiodbSqlList$new(values)
values
The values of the list.
Nothing.
toString()
Converts into a string.
BiodbSqlList$toString()
A string containing the SQL expression.
clone()
The objects of this class are cloneable with this method.
BiodbSqlList$clone(deep = FALSE)
deep
Whether to make a deep clone.
This class represents an SQL logical operator.
This class represents an SQL logical operator.
biodb::BiodbSqlExpr
-> BiodbSqlLogicalOp
new()
Initializer.
BiodbSqlLogicalOp$new(op)
op
The logical operator, as a string.
Nothing.
addExpr()
Add an SQL expression to the logical operator.
BiodbSqlLogicalOp$addExpr(expr)
expr
A BiodbSqlExpr instance.
Nothing.
toString()
Converts into a string.
BiodbSqlLogicalOp$toString()
A string containing the SQL expression.
clone()
The objects of this class are cloneable with this method.
BiodbSqlLogicalOp$clone(deep = FALSE)
deep
Whether to make a deep clone.
This class handles an SQL Query.
This class handles an SQL Query.
This class represents an SQL query. It is used internally to generate an SQL query string.
new()
Initializer.
BiodbSqlQuery$new()
Nothing.
setTable()
Set the table.
BiodbSqlQuery$setTable(table)
table
The table name.
Nothing.
addField()
Set the fields.
BiodbSqlQuery$addField(table = NULL, field)
table
The table name.
field
A field name.
Nothing.
setDistinct()
Set or unset distinct modifier.
BiodbSqlQuery$setDistinct(distinct)
distinct
Either TRUE or FALSE for setting or unsetting the distinct flag.
Nothing.
setLimit()
Set results limit.
BiodbSqlQuery$setLimit(limit)
limit
The limit to set, as an integer value.
Nothing.
addJoin()
Add a join.
BiodbSqlQuery$addJoin(table1, field1, table2, field2)
table1
The first table.
field1
The field of the first table.
table2
The second table.
field2
The field of the second table.
Nothing.
setWhere()
Set the where clause.
BiodbSqlQuery$setWhere(expr)
expr
A BiodbSqlExpr representing the "where" clause.
Nothing.
getJoin()
Builds and returns the join expression.
BiodbSqlQuery$getJoin()
A character vector representing the join expression.
getWhere()
Gets the where expression.
BiodbSqlQuery$getWhere()
The BiodbSqlExpr instance representing the "where" clause.
getFields()
Gets the fields to retrieve.
BiodbSqlQuery$getFields()
A string containing the list of fields to retrieve.
toString()
Generates the string representation of this query.
BiodbSqlQuery$toString()
A string containing the full SQL query.
clone()
The objects of this class are cloneable with this method.
BiodbSqlQuery$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbRequestScheduler
, BiodbRequest
.
This class represents an SQL value.
This class represents an SQL value.
biodb::BiodbSqlExpr
-> BiodbSqlValue
new()
Initializer.
BiodbSqlValue$new(value)
value
The value.
Nothing.
toString()
Converts into a string.
BiodbSqlValue$toString()
A string containing the SQL expression.
clone()
The objects of this class are cloneable with this method.
BiodbSqlValue$clone(deep = FALSE)
deep
Whether to make a deep clone.
A class for acknowledging messages during tests.
A class for acknowledging messages during tests.
This observer is used to call a testthat::expect_*() method each time a message is received. This is used when running tests on Travis-CI, so Travis does not stop tests because no change is detected in output.
new()
New instance initializer.
BiodbTestMsgAck$new()
Nothing.
notifyProgress()
Call back method used to get progress advancement of a long process.
BiodbTestMsgAck$notifyProgress(what, index, total)
what
The reason as a character value.
index
The index number representing the progress.
total
The total number to reach for completing the process.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbTestMsgAck$clone(deep = FALSE)
deep
Whether to make a deep clone.
# To use the acknowledger, set ack=TRUE when creating the Biodb test # instance: biodb <- biodb::createBiodbTestInstance(ack=TRUE) # Terminate the BiodbMain instance biodb$terminate()
# To use the acknowledger, set ack=TRUE when creating the Biodb test # instance: biodb <- biodb::createBiodbTestInstance(ack=TRUE) # Terminate the BiodbMain instance biodb$terminate()
Entry class for content in text format.
Entry class for content in text format.
This is an abstract class for handling database entries whose content is in text format.
biodb::BiodbEntry
-> BiodbTxtEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
new()
New instance initializer. Entry objects must not be created directly. Instead, they are retrieved through the connector instances.
BiodbTxtEntry$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbTxtEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbEntry
.
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbTxtEntry)
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbTxtEntry)
Class URL.
Class URL.
This class represents a URL object that can be used in requests.
new()
Initializer.
BiodbUrl$new(url = character(), params = character(), chompExtraSlashes = TRUE)
url
The URL to access, as a character vector.
params
The list of parameters to append to this URL.
chompExtraSlashes
If set to TRUE, then slashes at the end and the beginning of each element of the url vector parameter will be removed before proper concatenation.
Nothing.
getDomain()
Gets the domain.
BiodbUrl$getDomain()
The domain.
setUrl()
Sets the base URL string.
BiodbUrl$setUrl(url)
url
The base URL string.
Nothing.
setParam()
Sets a parameter.
BiodbUrl$setParam(key, value)
key
The parameter name.
value
The value of the parameter.
Nothing.
print()
Displays information about this instance.
BiodbUrl$print()
self as invisible.
toString()
Gets the URL as a string representation.
BiodbUrl$toString(encode = TRUE)
encode
If set to TRUE, then encodes the URL.
The URL as a string, with all parameters and values set.
clone()
The objects of this class are cloneable with this method.
BiodbUrl$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbRequestScheduler
, BiodbRequest
.
# Create a URL object u <- c("https://www.uniprot.org", "uniprot") p <- c(query="reviewed:yes+AND+organism:9606", columns='id,entry name,protein names', format="tab") url <- BiodbUrl$new(url=u, params=p) url$toString()
# Create a URL object u <- c("https://www.uniprot.org", "uniprot") p <- c(query="reviewed:yes+AND+organism:9606", columns='id,entry name,protein names', format="tab") url <- BiodbUrl$new(url=u, params=p) url$toString()
Entry class for content in XML format.
Entry class for content in XML format.
This is an abstract class for handling database entries whose content is in XML format.
biodb::BiodbEntry
-> BiodbXmlEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
new()
New instance initializer. Entry objects must not be created directly. Instead, they are retrieved through the connector instances.
BiodbXmlEntry$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbXmlEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbEntry
.
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbXmlEntry)
# Create a concrete entry class inheriting from CSV class: MyEntry <- R6::R6Class("MyEntry", inherit=biodb::BiodbXmlEntry)
Searches for a deprecated location of the default cache folder, and moves files to the new location if possible. Otherwise raises a warning.
checkDeprecatedCacheFolders()
checkDeprecatedCacheFolders()
Nothing.
biodb::checkDeprecatedCacheFolders()
biodb::checkDeprecatedCacheFolders()
Matches peaks between two spectra.
closeMatchPpm(x, y, xidx, yidx, xolength, dppm, dmz)
closeMatchPpm(x, y, xidx, yidx, xolength, dppm, dmz)
x |
sorted M/Z values (ascending order) of input spectrum (no NA). |
y |
sorted M/Z values (ascending order) of reference spectrum (no NA). |
xidx |
indices of the M/Z peaks of x, taken from the original spectrum ordered in decreasing intensity values. |
yidx |
indices of the M/Z peaks of y, taken from the original spectrum ordered in decreasing intensity values. |
xolength |
The length of the output. |
dppm |
The M/Z tolerance in PPM. |
dmz |
Minimum M/Z tolerance. |
A list of results.
Compound CSV File connector class.
Compound CSV File connector class.
This is the connector class for a Compound CSV file database.
biodb::BiodbConnBase
-> biodb::BiodbConn
-> biodb::CsvFileConn
-> CompCsvFileConn
biodb::BiodbConnBase$getBaseUrl()
biodb::BiodbConnBase$getConnClass()
biodb::BiodbConnBase$getConnClassName()
biodb::BiodbConnBase$getDbClass()
biodb::BiodbConnBase$getEntryClass()
biodb::BiodbConnBase$getEntryClassName()
biodb::BiodbConnBase$getEntryContentType()
biodb::BiodbConnBase$getEntryFileExt()
biodb::BiodbConnBase$getEntryIdField()
biodb::BiodbConnBase$getName()
biodb::BiodbConnBase$getPropSlots()
biodb::BiodbConnBase$getPropValSlot()
biodb::BiodbConnBase$getPropertyValue()
biodb::BiodbConnBase$getSchedulerNParam()
biodb::BiodbConnBase$getSchedulerTParam()
biodb::BiodbConnBase$getToken()
biodb::BiodbConnBase$getUrl()
biodb::BiodbConnBase$getUrls()
biodb::BiodbConnBase$getWsUrl()
biodb::BiodbConnBase$getXmlNs()
biodb::BiodbConnBase$hasProp()
biodb::BiodbConnBase$hasPropSlot()
biodb::BiodbConnBase$isSlotProp()
biodb::BiodbConnBase$propExists()
biodb::BiodbConnBase$setBaseUrl()
biodb::BiodbConnBase$setPropValSlot()
biodb::BiodbConnBase$setPropertyValue()
biodb::BiodbConnBase$setSchedulerNParam()
biodb::BiodbConnBase$setSchedulerTParam()
biodb::BiodbConnBase$setToken()
biodb::BiodbConnBase$setUrl()
biodb::BiodbConnBase$setWsUrl()
biodb::BiodbConnBase$updatePropertiesDefinition()
biodb::BiodbConn$addNewEntry()
biodb::BiodbConn$allowEditing()
biodb::BiodbConn$allowWriting()
biodb::BiodbConn$annotateMzValues()
biodb::BiodbConn$checkDb()
biodb::BiodbConn$collapseResultsDataFrame()
biodb::BiodbConn$correctIds()
biodb::BiodbConn$deleteAllCacheEntries()
biodb::BiodbConn$deleteAllEntriesFromPersistentCache()
biodb::BiodbConn$deleteAllEntriesFromVolatileCache()
biodb::BiodbConn$deleteWholePersistentCache()
biodb::BiodbConn$disallowEditing()
biodb::BiodbConn$disallowWriting()
biodb::BiodbConn$download()
biodb::BiodbConn$editingIsAllowed()
biodb::BiodbConn$filterEntriesOnRt()
biodb::BiodbConn$getAllCacheEntries()
biodb::BiodbConn$getAllVolatileCacheEntries()
biodb::BiodbConn$getBiodb()
biodb::BiodbConn$getCacheFile()
biodb::BiodbConn$getCacheId()
biodb::BiodbConn$getChromCol()
biodb::BiodbConn$getDownloadPath()
biodb::BiodbConn$getEntry()
biodb::BiodbConn$getEntryContent()
biodb::BiodbConn$getEntryContentFromDb()
biodb::BiodbConn$getEntryContentRequest()
biodb::BiodbConn$getEntryIds()
biodb::BiodbConn$getEntryImageUrl()
biodb::BiodbConn$getEntryPageUrl()
biodb::BiodbConn$getId()
biodb::BiodbConn$getMatchingMzField()
biodb::BiodbConn$getMzValues()
biodb::BiodbConn$getNbEntries()
biodb::BiodbConn$getNbPeaks()
biodb::BiodbConn$getSearchableFields()
biodb::BiodbConn$isCompounddb()
biodb::BiodbConn$isDownloadable()
biodb::BiodbConn$isDownloaded()
biodb::BiodbConn$isEditable()
biodb::BiodbConn$isExtracted()
biodb::BiodbConn$isMassdb()
biodb::BiodbConn$isRemotedb()
biodb::BiodbConn$isSearchableByField()
biodb::BiodbConn$isWritable()
biodb::BiodbConn$makeRequest()
biodb::BiodbConn$makesRefToEntry()
biodb::BiodbConn$msmsSearch()
biodb::BiodbConn$requiresDownload()
biodb::BiodbConn$searchByName()
biodb::BiodbConn$searchCompound()
biodb::BiodbConn$searchForEntries()
biodb::BiodbConn$searchForMassSpectra()
biodb::BiodbConn$searchMsEntries()
biodb::BiodbConn$searchMsPeaks()
biodb::BiodbConn$searchMzRange()
biodb::BiodbConn$searchMzTol()
biodb::BiodbConn$setDownloadedFile()
biodb::BiodbConn$setEditingAllowed()
biodb::BiodbConn$setMatchingMzField()
biodb::BiodbConn$setWritingAllowed()
biodb::BiodbConn$write()
biodb::BiodbConn$writingIsAllowed()
biodb::CsvFileConn$addField()
biodb::CsvFileConn$getCsvQuote()
biodb::CsvFileConn$getCsvSep()
biodb::CsvFileConn$getFieldColName()
biodb::CsvFileConn$getFieldNames()
biodb::CsvFileConn$getFieldsAndColumnsAssociation()
biodb::CsvFileConn$getUnassociatedColumns()
biodb::CsvFileConn$hasField()
biodb::CsvFileConn$print()
biodb::CsvFileConn$setCsvQuote()
biodb::CsvFileConn$setCsvSep()
biodb::CsvFileConn$setDb()
biodb::CsvFileConn$setField()
biodb::CsvFileConn$setIgnoreUnassignedColumns()
new()
New instance initializer. Connector classes must not be instantiated directly. Instead, you must use the createConn() method of the factory class.
CompCsvFileConn$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
clone()
The objects of this class are cloneable with this method.
CompCsvFileConn$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class CsvFileConn
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector: chebi_file <- system.file("extdata", "chebi_extract.tsv", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi_file) # Get an entry e <- conn$getEntry('') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector: chebi_file <- system.file("extdata", "chebi_extract.tsv", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi_file) # Get an entry e <- conn$getEntry('') # Terminate instance. mybiodb$terminate()
Compound CSV File entry class.
Compound CSV File entry class.
This is the entry class for Compound CSV file databases.
biodb::BiodbEntry
-> biodb::BiodbCsvEntry
-> CompCsvFileEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
new()
New instance initializer. Entry objects must not be created directly. Instead, they are retrieved through the connector instances.
CompCsvFileEntry$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
clone()
The objects of this class are cloneable with this method.
CompCsvFileEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbCsvEntry
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector that inherits from CsvFileConn: chebi_file <- system.file("extdata", "chebi_extract.tsv", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi_file) # Get an entry e <- conn$getEntry('') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector that inherits from CsvFileConn: chebi_file <- system.file("extdata", "chebi_extract.tsv", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi_file) # Get an entry e <- conn$getEntry('') # Terminate instance. mybiodb$terminate()
This is the connector class for a Compound database.
biodb::BiodbConnBase
-> biodb::BiodbConn
-> biodb::SqliteConn
-> CompSqliteConn
biodb::BiodbConnBase$getBaseUrl()
biodb::BiodbConnBase$getConnClass()
biodb::BiodbConnBase$getConnClassName()
biodb::BiodbConnBase$getDbClass()
biodb::BiodbConnBase$getEntryClass()
biodb::BiodbConnBase$getEntryClassName()
biodb::BiodbConnBase$getEntryContentType()
biodb::BiodbConnBase$getEntryFileExt()
biodb::BiodbConnBase$getEntryIdField()
biodb::BiodbConnBase$getName()
biodb::BiodbConnBase$getPropSlots()
biodb::BiodbConnBase$getPropValSlot()
biodb::BiodbConnBase$getPropertyValue()
biodb::BiodbConnBase$getSchedulerNParam()
biodb::BiodbConnBase$getSchedulerTParam()
biodb::BiodbConnBase$getToken()
biodb::BiodbConnBase$getUrl()
biodb::BiodbConnBase$getUrls()
biodb::BiodbConnBase$getWsUrl()
biodb::BiodbConnBase$getXmlNs()
biodb::BiodbConnBase$hasProp()
biodb::BiodbConnBase$hasPropSlot()
biodb::BiodbConnBase$isSlotProp()
biodb::BiodbConnBase$propExists()
biodb::BiodbConnBase$setBaseUrl()
biodb::BiodbConnBase$setPropValSlot()
biodb::BiodbConnBase$setPropertyValue()
biodb::BiodbConnBase$setSchedulerNParam()
biodb::BiodbConnBase$setSchedulerTParam()
biodb::BiodbConnBase$setToken()
biodb::BiodbConnBase$setUrl()
biodb::BiodbConnBase$setWsUrl()
biodb::BiodbConnBase$updatePropertiesDefinition()
biodb::BiodbConn$addNewEntry()
biodb::BiodbConn$allowEditing()
biodb::BiodbConn$allowWriting()
biodb::BiodbConn$annotateMzValues()
biodb::BiodbConn$checkDb()
biodb::BiodbConn$collapseResultsDataFrame()
biodb::BiodbConn$correctIds()
biodb::BiodbConn$deleteAllCacheEntries()
biodb::BiodbConn$deleteAllEntriesFromPersistentCache()
biodb::BiodbConn$deleteAllEntriesFromVolatileCache()
biodb::BiodbConn$deleteWholePersistentCache()
biodb::BiodbConn$disallowEditing()
biodb::BiodbConn$disallowWriting()
biodb::BiodbConn$download()
biodb::BiodbConn$editingIsAllowed()
biodb::BiodbConn$filterEntriesOnRt()
biodb::BiodbConn$getAllCacheEntries()
biodb::BiodbConn$getAllVolatileCacheEntries()
biodb::BiodbConn$getBiodb()
biodb::BiodbConn$getCacheFile()
biodb::BiodbConn$getCacheId()
biodb::BiodbConn$getChromCol()
biodb::BiodbConn$getDownloadPath()
biodb::BiodbConn$getEntry()
biodb::BiodbConn$getEntryContent()
biodb::BiodbConn$getEntryContentFromDb()
biodb::BiodbConn$getEntryContentRequest()
biodb::BiodbConn$getEntryIds()
biodb::BiodbConn$getEntryImageUrl()
biodb::BiodbConn$getEntryPageUrl()
biodb::BiodbConn$getId()
biodb::BiodbConn$getMatchingMzField()
biodb::BiodbConn$getMzValues()
biodb::BiodbConn$getNbEntries()
biodb::BiodbConn$getNbPeaks()
biodb::BiodbConn$getSearchableFields()
biodb::BiodbConn$isCompounddb()
biodb::BiodbConn$isDownloadable()
biodb::BiodbConn$isDownloaded()
biodb::BiodbConn$isEditable()
biodb::BiodbConn$isExtracted()
biodb::BiodbConn$isMassdb()
biodb::BiodbConn$isRemotedb()
biodb::BiodbConn$isSearchableByField()
biodb::BiodbConn$isWritable()
biodb::BiodbConn$makeRequest()
biodb::BiodbConn$makesRefToEntry()
biodb::BiodbConn$msmsSearch()
biodb::BiodbConn$print()
biodb::BiodbConn$requiresDownload()
biodb::BiodbConn$searchByName()
biodb::BiodbConn$searchCompound()
biodb::BiodbConn$searchForEntries()
biodb::BiodbConn$searchForMassSpectra()
biodb::BiodbConn$searchMsEntries()
biodb::BiodbConn$searchMsPeaks()
biodb::BiodbConn$searchMzRange()
biodb::BiodbConn$searchMzTol()
biodb::BiodbConn$setDownloadedFile()
biodb::BiodbConn$setEditingAllowed()
biodb::BiodbConn$setMatchingMzField()
biodb::BiodbConn$setWritingAllowed()
biodb::BiodbConn$write()
biodb::BiodbConn$writingIsAllowed()
biodb::SqliteConn$getQuery()
biodb::SqliteConn$hasField()
biodb::SqliteConn$initialize()
clone()
The objects of this class are cloneable with this method.
CompSqliteConn$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class SqliteConn
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector: chebi_file <- system.file("extdata", "chebi_extract.sqlite", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.sqlite', url=chebi_file) # Get an entry e <- conn$getEntry('1018') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector: chebi_file <- system.file("extdata", "chebi_extract.sqlite", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.sqlite', url=chebi_file) # Get an entry e <- conn$getEntry('1018') # Terminate instance. mybiodb$terminate()
This is the entry class for a Compound SQLite database.
biodb::BiodbEntry
-> biodb::BiodbListEntry
-> CompSqliteEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$initialize()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
clone()
The objects of this class are cloneable with this method.
CompSqliteEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbListEntry
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "chebi_extract.sqlite", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('comp.sqlite', url=lcmsdb) # Get an entry e <- conn$getEntry('34.pos.col12.0.78') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "chebi_extract.sqlite", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('comp.sqlite', url=lcmsdb) # Get an entry e <- conn$getEntry('34.pos.col12.0.78') # Terminate instance. mybiodb$terminate()
Converts the connector name into the class prefix (e.g.: "mass.csv.file" –> "MassCsvFile").
connNameToClassPrefix(connName)
connNameToClassPrefix(connName)
connName |
A connector name (e.g.: "mass.csv.file"). |
The corresponding class prefix (e.g.: "MassCsvFile").
Creates a BiodbMain instance with options specially adapted for tests.
You can request the logging of all messages into a log file.
It is also possible to ask for the creation of a BiodbTestMsgAck observer,
which will receive all messages and emit a testthat test for each message.
This will allow the testthat output to not stall a long time while, for
example, downloading or extracting a database.
Do not forget to call terminate()
on your instance at the end of your
tests.
createBiodbTestInstance(ack = FALSE)
createBiodbTestInstance(ack = FALSE)
ack |
If set to TRUE, an instance of BiodbTestMsgAck will be attached to the BiodbMain instance. |
The created BiodbMain instance.
# Instantiate a BiodbMain instance for testing biodb <- biodb::createBiodbTestInstance() # Terminate the instance biodb$terminate()
# Instantiate a BiodbMain instance for testing biodb <- biodb::createBiodbTestInstance() # Terminate the instance biodb$terminate()
CSV File connector class.
CSV File connector class.
This is the abstract connector class for all CSV file databases.
biodb::BiodbConnBase
-> biodb::BiodbConn
-> CsvFileConn
biodb::BiodbConnBase$getBaseUrl()
biodb::BiodbConnBase$getConnClass()
biodb::BiodbConnBase$getConnClassName()
biodb::BiodbConnBase$getDbClass()
biodb::BiodbConnBase$getEntryClass()
biodb::BiodbConnBase$getEntryClassName()
biodb::BiodbConnBase$getEntryContentType()
biodb::BiodbConnBase$getEntryFileExt()
biodb::BiodbConnBase$getEntryIdField()
biodb::BiodbConnBase$getName()
biodb::BiodbConnBase$getPropSlots()
biodb::BiodbConnBase$getPropValSlot()
biodb::BiodbConnBase$getPropertyValue()
biodb::BiodbConnBase$getSchedulerNParam()
biodb::BiodbConnBase$getSchedulerTParam()
biodb::BiodbConnBase$getToken()
biodb::BiodbConnBase$getUrl()
biodb::BiodbConnBase$getUrls()
biodb::BiodbConnBase$getWsUrl()
biodb::BiodbConnBase$getXmlNs()
biodb::BiodbConnBase$hasProp()
biodb::BiodbConnBase$hasPropSlot()
biodb::BiodbConnBase$isSlotProp()
biodb::BiodbConnBase$propExists()
biodb::BiodbConnBase$setBaseUrl()
biodb::BiodbConnBase$setPropValSlot()
biodb::BiodbConnBase$setPropertyValue()
biodb::BiodbConnBase$setSchedulerNParam()
biodb::BiodbConnBase$setSchedulerTParam()
biodb::BiodbConnBase$setToken()
biodb::BiodbConnBase$setUrl()
biodb::BiodbConnBase$setWsUrl()
biodb::BiodbConnBase$updatePropertiesDefinition()
biodb::BiodbConn$addNewEntry()
biodb::BiodbConn$allowEditing()
biodb::BiodbConn$allowWriting()
biodb::BiodbConn$annotateMzValues()
biodb::BiodbConn$checkDb()
biodb::BiodbConn$collapseResultsDataFrame()
biodb::BiodbConn$correctIds()
biodb::BiodbConn$deleteAllCacheEntries()
biodb::BiodbConn$deleteAllEntriesFromPersistentCache()
biodb::BiodbConn$deleteAllEntriesFromVolatileCache()
biodb::BiodbConn$deleteWholePersistentCache()
biodb::BiodbConn$disallowEditing()
biodb::BiodbConn$disallowWriting()
biodb::BiodbConn$download()
biodb::BiodbConn$editingIsAllowed()
biodb::BiodbConn$filterEntriesOnRt()
biodb::BiodbConn$getAllCacheEntries()
biodb::BiodbConn$getAllVolatileCacheEntries()
biodb::BiodbConn$getBiodb()
biodb::BiodbConn$getCacheFile()
biodb::BiodbConn$getCacheId()
biodb::BiodbConn$getChromCol()
biodb::BiodbConn$getDownloadPath()
biodb::BiodbConn$getEntry()
biodb::BiodbConn$getEntryContent()
biodb::BiodbConn$getEntryContentFromDb()
biodb::BiodbConn$getEntryContentRequest()
biodb::BiodbConn$getEntryIds()
biodb::BiodbConn$getEntryImageUrl()
biodb::BiodbConn$getEntryPageUrl()
biodb::BiodbConn$getId()
biodb::BiodbConn$getMatchingMzField()
biodb::BiodbConn$getMzValues()
biodb::BiodbConn$getNbEntries()
biodb::BiodbConn$getNbPeaks()
biodb::BiodbConn$getSearchableFields()
biodb::BiodbConn$isCompounddb()
biodb::BiodbConn$isDownloadable()
biodb::BiodbConn$isDownloaded()
biodb::BiodbConn$isEditable()
biodb::BiodbConn$isExtracted()
biodb::BiodbConn$isMassdb()
biodb::BiodbConn$isRemotedb()
biodb::BiodbConn$isSearchableByField()
biodb::BiodbConn$isWritable()
biodb::BiodbConn$makeRequest()
biodb::BiodbConn$makesRefToEntry()
biodb::BiodbConn$msmsSearch()
biodb::BiodbConn$requiresDownload()
biodb::BiodbConn$searchByName()
biodb::BiodbConn$searchCompound()
biodb::BiodbConn$searchForEntries()
biodb::BiodbConn$searchForMassSpectra()
biodb::BiodbConn$searchMsEntries()
biodb::BiodbConn$searchMsPeaks()
biodb::BiodbConn$searchMzRange()
biodb::BiodbConn$searchMzTol()
biodb::BiodbConn$setDownloadedFile()
biodb::BiodbConn$setEditingAllowed()
biodb::BiodbConn$setMatchingMzField()
biodb::BiodbConn$setWritingAllowed()
biodb::BiodbConn$write()
biodb::BiodbConn$writingIsAllowed()
new()
New instance initializer. Connector classes must not be instantiated directly. Instead, you must use the createConn() method of the factory class.
CsvFileConn$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
getCsvQuote()
Gets the characters used to delimit quotes in the CSV database file.
CsvFileConn$getCsvQuote()
The characters used to delimit quotes as a single character value.
setCsvQuote()
Sets the characters used to delimit quotes in the CSV database file.
CsvFileConn$setCsvQuote(quote)
quote
The characters used to delimit quotes as a single character value.
You
may specify several characters. Example \"\\"'\".
Nothing.
getCsvSep()
Gets the current CSV separator used for the database file.
CsvFileConn$getCsvSep()
The CSV separator as a character value.
setCsvSep()
Sets the CSV separator to be used for the database file. If this method is called after the loading of the database, it will throw an error.
CsvFileConn$setCsvSep(sep)
sep
The CSV separator as a character value.
Nothing.
getFieldNames()
Get the list of all biodb fields handled by this database.
CsvFileConn$getFieldNames()
A character vector of the biodb field names.
hasField()
Tests if a field is defined for this database instance.
CsvFileConn$hasField(field)
field
A valid Biodb entry field name.
TRUE of the field is defined, FALSE otherwise.
addField()
Adds a new field to the database. The field must not already exist. The same single value will be set to all entries for this field. A new column will be written in the memory data frame, containing the value given.
CsvFileConn$addField(field, value)
field
A valid Biodb entry field name.
value
The value to set for this field.
Nothing.
getFieldColName()
Get the column name corresponding to a Biodb field.
CsvFileConn$getFieldColName(field)
field
A valid Biodb entry field name. This field must be defined for this database instance.
The column name from the CSV file.
setField()
Sets a field by making a correspondence between a Biodb field and one or more columns of the loaded data frame.
CsvFileConn$setField(field, colname, ignore.if.missing = FALSE)
field
A valid Biodb entry field name. This field must not be already defined for this database instance.
colname
A character vector containing one or more column names from the CSV file.
ignore.if.missing
Deprecated parameter.
Nothing.
getFieldsAndColumnsAssociation()
Gets the association between biodb field names and CSV file column names.
CsvFileConn$getFieldsAndColumnsAssociation()
A list with names being the biodb field names and values being a character vector of column names from the CSV file.
getUnassociatedColumns()
Gets the list of unassociated column names from the CSV file.
CsvFileConn$getUnassociatedColumns()
A character vector containing column names.
print()
Prints a description of this connector.
CsvFileConn$print()
Nothing.
setDb()
Sets the database directly from a data frame. You must not have set the database previously with the URL parameter.
CsvFileConn$setDb(db)
db
A data frame containing your database.
Nothing.
setIgnoreUnassignedColumns()
Tells the connector to ignore or not the columns found in the CSV file for which no assignment were found.
CsvFileConn$setIgnoreUnassignedColumns(ignore)
ignore
Set to TRUE to ignore the unassigned columns, and to FALSE otherwise.
Nothing.
clone()
The objects of this class are cloneable with this method.
CsvFileConn$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super classes BiodbConn
,
and sub-classes CompCsvFileConn
,
MassCsvFileConn
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector that inherits from CsvFileConn: chebi_file <- system.file("extdata", "chebi_extract.tsv", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi_file) # Get an entry e <- conn$getEntry('1018') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector that inherits from CsvFileConn: chebi_file <- system.file("extdata", "chebi_extract.tsv", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi_file) # Get an entry e <- conn$getEntry('1018') # Terminate instance. mybiodb$terminate()
Prints a data frame (partially if too big) into a string.
df2str(x, rowCut = 5, colCut = 5)
df2str(x, rowCut = 5, colCut = 5)
x |
The data frame object. |
rowCut |
The maximum of rows to print. |
colCut |
The maximum of columns to print. |
A string containing the data frame representation (or part of it).
# Converts the first 5 rows and first 6 columns of a data frame into a # string: x <- data.frame(matrix(1:160, nrow=10, byrow=TRUE)) s <- df2str(x, rowCut=5, colCut=6)
# Converts the first 5 rows and first 6 columns of a data frame into a # string: x <- data.frame(matrix(1:160, nrow=10, byrow=TRUE)) s <- df2str(x, rowCut=5, colCut=6)
Test if a URL is valid according to RCurl
doesRCurlRequestUrlExist(request, useragent = NULL)
doesRCurlRequestUrlExist(request, useragent = NULL)
request |
A BiodbRequest object, from which the URL will be gotten. |
useragent |
The user agent identification. |
Returns TRUE if the URL
Throws am error and logs it too with biodb logger.
error(...)
error(...)
... |
Values to be passed to sprintf(). |
Nothing.
# Throws an error: tryCatch(biodb::error('Index is %d.', 10), error=function(e){e$message})
# Throws an error: tryCatch(biodb::error('Index is %d.', 10), error=function(e){e$message})
Throws an error and logs it too with biodb logger, using paste0().
error0(...)
error0(...)
... |
Values to be passed to paste0(). |
Nothing.
# Throws an error: tryCatch(biodb::error0('Index is ', 10, '.'), error=function(e){e$message})
# Throws an error: tryCatch(biodb::error0('Index is ', 10, '.'), error=function(e){e$message})
A class for generating a new connector class.
This class generates a new connector class from given parameters.
The new class inherits from BiodbConn
.
It can be defined as a compound or mass database connector, and made
downloadable, editable and/or writable.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtConnClass
new()
Initializer.
ExtConnClass$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtConnClass$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new connector class inside R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtConnClass$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', connType='mass', remote=TRUE)$generate()
# Generate a new connector class inside R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtConnClass$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', connType='mass', remote=TRUE)$generate()
A class for generating C++ example files (code & test).
This class generates examples of an R function written in C++ using Rcpp, of a pure C++ function used to speed up computing, and of C++ code for testing the pure C++ function. As for the R function written with Rcpp, it is tested inside standard testthat R code.
biodb::ExtGenerator
-> ExtCpp
new()
Initializer.
ExtCpp$new(...)
...
See the constructor of ExtGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtCpp$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate C++ files pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtCpp$new(path=pkgFolder)$generate()
# Generate C++ files pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtCpp$new(path=pkgFolder)$generate()
A class for generating the definitions.yml file of a new extension package.
This class generates the definitions.yml of a new extension package, needed for definining the new connector.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtDefinitions
new()
Initializer.
ExtDefinitions$new(...)
...
See the constructor of ExtFileGenerator for the parameters. offers this possiblity.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtDefinitions$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate the biodb definitions.yml file inside "inst" folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtDefinitions$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database')$generate()
# Generate the biodb definitions.yml file inside "inst" folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtDefinitions$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database')$generate()
A class for generating a DESCRIPTION file for an extension package.
This class generates a DESCRIPTION for a biodb extension package.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtDescriptionFile
new()
Initializer.
ExtDescriptionFile$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtDescriptionFile$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate the DESCRIPTION file: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtDescriptionFile$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', email='[email protected]', firstname='John', lastname='Smith', rcpp=TRUE, entryType='xml')$generate()
# Generate the DESCRIPTION file: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtDescriptionFile$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', email='[email protected]', firstname='John', lastname='Smith', rcpp=TRUE, entryType='xml')$generate()
A class for generating a new entry class.
This class generates a new entry class from given parameters.
The new class can inherit directly from BiodbEntry
or
from one of its sub-classes: BiodbCsvEntry
, BiodbHtmlEntry
, ...
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtEntryClass
new()
Initializer.
ExtEntryClass$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtEntryClass$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new entry class inside R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtEntryClass$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', connType='mass', entryType='xml')$generate()
# Generate a new entry class inside R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtEntryClass$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', connType='mass', entryType='xml')$generate()
The mother class of all file generators for biodb extension packages.
All file generator classes for biodb extensions must inherit from this class.
biodb::ExtGenerator
-> ExtFileGenerator
new()
Initializer.
ExtFileGenerator$new( filename = NULL, overwrite = FALSE, folder = character(), template = NULL, upgrader = c("fullReplacer", "lineAdder"), ... )
filename
The name of the generated file.
overwrite
If set to TRUE, then overwrite existing destination file, even whatever the version of the template file. If set to FALSE, only overwrite if the version of the template file is strictly greater than the existing destination file.
folder
The destination subfolder inside the package directory, as a character vector of subfolders hierarchy.
template
The filename of the template to use.
upgrader
The type of upgrader to use. "fullReplacer" replaces the whole destination file by the template if it is newer (it compares version numbers). "lineAdder" only adds to the destination file the missing lines from the template file.
...
See the constructor of ExtGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtFileGenerator$clone(deep = FALSE)
deep
Whether to make a deep clone.
pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtConnClass$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', connType='mass', remote=TRUE)$generate()
pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtConnClass$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', connType='mass', remote=TRUE)$generate()
The mother class of all generators for biodb extension packages.
All generator classes for biodb extensions must inherit from this class.
new()
Initializer.
ExtGenerator$new( path, loadCfg = TRUE, saveCfg = TRUE, pkgName = getPkgName(path), email = "[email protected]", dbName = "foo.db", dbTitle = "Foo database", pkgLicense = getLicenses(), firstname = "Firstname of author", lastname = "Lastname of author", newPkg = FALSE, connType = getConnTypes(), entryType = getEntryTypes(), editable = FALSE, writable = FALSE, remote = FALSE, downloadable = FALSE, makefile = FALSE, travis = FALSE, rcpp = FALSE, vignetteName = getPkgName(path), githubRepos = getReposName(path, default = "myaccount/myrepos") )
path
The path to the package folder.
loadCfg
Set to FALSE to disable loading of tag values from config file "biodb_ext.yml".
saveCfg
Set to FALSE to disable saving of tag values into config file "biodb_ext.yml".
pkgName
The package name. If set to NULL, the folder name pointer by the "path" paramater will be used as the package name.
email
The email of the author.
dbName
The name of the database (in biodb format "my.db.name"), that will be used in "definitions.yml" file and for connector and entry classes.
dbTitle
The official name of the database (e.g.: HMDB, UniProtKB, KEGG).
pkgLicense
The license of the package.
firstname
The firstname of the author.
lastname
The lastname of the author.
newPkg
Set to TRUE if the package is not yet published on Bioconductor.
connType
The type of connector class to implement.
entryType
The type of entry class to implement.
editable
Set to TRUE to allow the generated connector to create new entries in memory.
writable
Set to TRUE to enable the generated connector to write into the database.
remote
Set to TRUE if the database to connect to is not local.
downloadable
Set to TRUE if the database needs to be downloaded or offers this possiblity.
makefile
Set to TRUE if you want a Makefile to be generated.
travis
Set to TRUE if you want a .travis.yml file to be generated.
rcpp
Set to TRUE to enable Rcpp C/C++ code inside the package.
vignetteName
Set to the name of the default/main vignette.
githubRepos
Set to the name of the associated GitHub repository. Example: myaccount/myrepos.
Nothing.
generate()
Generates the destination file(s).
ExtGenerator$generate(overwrite = FALSE, fail = TRUE)
overwrite
If set to TRUE and destination files exist, overwrite the destination files.
fail
If set to FALSE, do not fail if destination files exist, just do nothing and return.
# Generate a new extension package: pkgFolder <- file.path(tempfile(), 'biodbFoo') biodb::ExtPackage$new(pkgFolder)$generate()
upgrade()
Upgrade the destination file(s).
ExtGenerator$upgrade(generate = TRUE)
generate
If set to FALSE, and destination file(s) do not exist, then do not generate them.
clone()
The objects of this class are cloneable with this method.
ExtGenerator$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new connector class inside the R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtConnClass$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', connType='mass', remote=TRUE)$generate() ## ------------------------------------------------ ## Method `ExtGenerator$generate` ## ------------------------------------------------ # Generate a new extension package: pkgFolder <- file.path(tempfile(), 'biodbFoo') biodb::ExtPackage$new(pkgFolder)$generate()
# Generate a new connector class inside the R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtConnClass$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', connType='mass', remote=TRUE)$generate() ## ------------------------------------------------ ## Method `ExtGenerator$generate` ## ------------------------------------------------ # Generate a new extension package: pkgFolder <- file.path(tempfile(), 'biodbFoo') biodb::ExtPackage$new(pkgFolder)$generate()
A class for generating the .gitignore file of an extension package.
This class can be used to generate a new .gitignore file or to keep one up to date.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtGitignore
new()
Initializer.
ExtGitignore$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtGitignore$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtGitignore$new(path=pkgFolder)$generate()
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtGitignore$new(path=pkgFolder)$generate()
A class for generating or upgrading the license of a biodb extension package.
This class generates the license for a new extension package, or update the license of an existing one.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtLicense
new()
Initializer.
ExtLicense$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtLicense$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new connector class inside R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtLicense$new(path=pkgFolder)$generate()
# Generate a new connector class inside R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtLicense$new(path=pkgFolder)$generate()
A class for generating a Makefile for an extension package.
This class generates a Makefile, usable on UNIX-like platforms, for managing a biodb extension package. Targets are automatically generated for running CRAN check, Bioconductor check, testthat tests, compiling, generating documentation, cleaning, etc.
biodb::ExtGenerator
-> ExtMakefile
new()
Initializer.
ExtMakefile$new(...)
...
See the constructor of ExtGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtMakefile$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new connector class inside R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtMakefile$new(path=pkgFolder)$generate()
# Generate a new connector class inside R folder: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtMakefile$new(path=pkgFolder)$generate()
A class for generating the skeleton of a new extension package.
This class manages the files of an extension package.
It can generate all the files of a new extension package: DESCRIPTION,
NEWS, README.md, tests, definitons.yml, etc. Optionnaly it also generates
other files like: a .travis.yml
file for Travis-CI, a Makefile for easing
development on UNIX-like platforms outside of Rstudio.
It can also upgrade files of an existing package like: definitions.yml, Makefile, .travis.yml, LICENSE, etc.
biodb::ExtGenerator
-> ExtPackage
new()
Initializer.
ExtPackage$new(...)
...
See the constructor of ExtGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtPackage$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtPackage$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', rcpp=TRUE, connType='mass', entryType='txt', downloadable=TRUE, remote=TRUE)$generate()
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtPackage$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', rcpp=TRUE, connType='mass', entryType='txt', downloadable=TRUE, remote=TRUE)$generate()
A class for generating the package.R file for a biodb extension.
This class generates the package.R file, writing a reference to the generated skeleton vignette, and possibly including directives for C++ code.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtPackageFile
new()
Initializer.
ExtPackageFile$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtPackageFile$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtPackageFile$new(path=pkgFolder, dbName='foo.db')$generate()
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtPackageFile$new(path=pkgFolder, dbName='foo.db')$generate()
A class for generating the .Rbuildignore file of an extension package.
This class can be used to generate a new .Rbuildignore file or to keep one up to date.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtRbuildignore
new()
Initializer.
ExtRbuildignore$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtRbuildignore$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtRbuildignore$new(path=pkgFolder)$generate()
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtRbuildignore$new(path=pkgFolder)$generate()
A class for generating a README file for a new extension package.
Write a README file inside package directory, using a template file.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtReadme
new()
Initializer.
ExtReadme$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtReadme$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtReadme$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database')$generate()
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtReadme$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database')$generate()
A class for generating test files.
This class generates a test file for running biodb generic tests, and a test file containing an example of a custom test for this extension.
biodb::ExtGenerator
-> ExtTests
new()
Initializer.
ExtTests$new(...)
...
See the constructor of ExtGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtTests$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtTests$new(path=pkgFolder, dbName='foo.db', rcpp=TRUE, remote=TRUE)$generate()
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtTests$new(path=pkgFolder, dbName='foo.db', rcpp=TRUE, remote=TRUE)$generate()
A class for generating a .travis.yml file for a new extension package.
Write a .travis.yml file inside the package directory, using a template file.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtTravisFile
new()
Initializer.
ExtTravisFile$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtTravisFile$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtTravisFile$new(path=pkgFolder, email='[email protected]')$generate()
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtTravisFile$new(path=pkgFolder, email='[email protected]')$generate()
A class for generating a vignette example for an extension package.
This class generates a vignette file, serving as example to demonstrate the use of the extension package.
biodb::ExtGenerator
-> biodb::ExtFileGenerator
-> ExtVignette
new()
Initializer.
ExtVignette$new(...)
...
See the constructor of ExtFileGenerator for the parameters.
Nothing.
clone()
The objects of this class are cloneable with this method.
ExtVignette$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtVignette$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', vignetteName='main', firstname='John', lastname='Smith', remote=TRUE)$generate()
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::ExtVignette$new(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', vignetteName='main', firstname='John', lastname='Smith', remote=TRUE)$generate()
A class for reading a file template, replacing tags inside, and writing the results in an output file.
new()
Initializer.
FileTemplate$new(path)
path
The path to the template file.
Nothing.
replace()
Replace a tag by its value inside the template file.
FileTemplate$replace(tag, value)
tag
The tag to replace.
value
The value to replace the tag with.
invisible(self) for chaining method calls.
choose()
Choose one case among a set of cases.
FileTemplate$choose(set, case)
set
The name of the case set.
case
The name of case.
invisible(self) for chaining method calls.
select()
Select or remove sections that match a name.
FileTemplate$select(section, enable)
section
The name of the section.
enable
Set to TRUE to select the section (and keep it), and FALSE to remove it.
invisible(self) for chaining method calls.
write()
Write template with replaced values to disk.
FileTemplate$write(path, overwrite = FALSE, checkRemainingTags = TRUE)
path
Path to output file.
overwrite
If set to FALSE and the destination file already exists, a message is thrown. Otherwise writes into the destination.
checkRemainingTags
If set to TRUE, checks first, before writing, if there any remaining tags that have not been processed. A warning is thrown for each found tag.
Nothing.
getLines()
Get the lines of the templates.
FileTemplate$getLines()
A vector containing the lines of the templates.
clone()
The objects of this class are cloneable with this method.
FileTemplate$clone(deep = FALSE)
deep
Whether to make a deep clone.
Generates all the necessary files for a new extension package.
genNewExtPkg(...)
genNewExtPkg(...)
... |
Parameters passed to |
Nothing.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::genNewExtPkg(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', rcpp=TRUE, connType='mass', entryType='txt', downloadable=TRUE, remote=TRUE)
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::genNewExtPkg(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', rcpp=TRUE, connType='mass', entryType='txt', downloadable=TRUE, remote=TRUE)
Get URL content using base::url().
getBaseUrlContent(u, binary = FALSE)
getBaseUrlContent(u, binary = FALSE)
u |
The URL as a character value. |
binary |
Set to TRUE if the content to be retrieved is binary. |
The URL content as a character single value.
Get URL request result using base::url().
getBaseUrlRequestResult(request)
getBaseUrlRequestResult(request)
request |
A BiodbRequest object. |
A RequestResult object.
Gets the name of the connector class corresponding to a connector.
getConnClassName(connName)
getConnClassName(connName)
connName |
A connector name (e.g.: "mass.csv.file"). |
The name of the corresponding connector class (e.g.: "MassCsvFileConn").
biodb::getConnClassName('foo.db')
biodb::getConnClassName('foo.db')
Get the list of available connector types.
getConnTypes()
getConnTypes()
A character vector containing the connector types.
biodb::getConnTypes()
biodb::getConnTypes()
Returns the path to the default cache folder.
getDefaultCacheDir()
getDefaultCacheDir()
The path to the cache folder.
cacheFolderPath <- biodb::getDefaultCacheDir()
cacheFolderPath <- biodb::getDefaultCacheDir()
Gets the name of the entry class corresponding to a connector.
getEntryClassName(connName)
getEntryClassName(connName)
connName |
A connector name (e.g.: "mass.csv.file"). |
The name of the corresponding entry class (e.g.: "MassCsvFileEntry").
biodb::getEntryClassName('foo.db')
biodb::getEntryClassName('foo.db')
Get the list of available entry types.
getEntryTypes()
getEntryTypes()
A character vector containing the entry types.
biodb::getEntryTypes()
biodb::getEntryTypes()
Get the available licenses for extension packages.
getLicenses()
getLicenses()
A character vector containing license names.
biodb::getLicenses()
biodb::getLicenses()
Gets the main package logger, parent of all loggers of this package.
getLogger()
getLogger()
The main package logger (named "biodb") as a lgr::Logger object.
biodb::getLogger()
biodb::getLogger()
The package name is extracted from the path by taking the basename.
getPkgName(pkgRoot, check = TRUE)
getPkgName(pkgRoot, check = TRUE)
pkgRoot |
The path to the root folder of the package. |
check |
If set to TRUE the extracted package name is checked against regular expression "^biodb[A-Z][A-Za-z0-9]+$", to ensure the format is respected. |
The package name of the biodb extension.
biodb::getPkgName('/my/path/to/my/extension/biodbFoo')
biodb::getPkgName('/my/path/to/my/extension/biodbFoo')
Get URL content using RCurl::getURL().
getRCurlContent( u, opts = NULL, enc = integer(), header.fct = NULL, ssl.verifypeer = TRUE, method = c("get", "post"), binary = FALSE )
getRCurlContent( u, opts = NULL, enc = integer(), header.fct = NULL, ssl.verifypeer = TRUE, method = c("get", "post"), binary = FALSE )
u |
The URL as a character value. |
opts |
A valid RCurl options object. |
enc |
The encoding. |
header.fct |
An RCurl header gatherer function. |
ssl.verifypeer |
Set to TRUE to enable SSL verify peer. |
method |
The HTTP method to use, either 'get' or 'post'. |
binary |
Set to TRUE if the content to be retrieved is binary. |
The URL content as a character single value.
Get URL request result using RCurcl::getURL().
getRCurlRequestResult(request, useragent = NULL, ssl.verifypeer = TRUE)
getRCurlRequestResult(request, useragent = NULL, ssl.verifypeer = TRUE)
request |
A BiodbRequest object. |
useragent |
The user agent identification. |
ssl.verifypeer |
Set to TRUE to enable SSL verify peer. |
A RequestResult object.
Given the root path of a package, returns the GitHub repository name.
getReposName(pkgRoot, default = NULL)
getReposName(pkgRoot, default = NULL)
pkgRoot |
The path to the root folder of the package. |
default |
A default value to return in case git4r package is not available or the folder is not a Git repository. |
The repository name.
biodb::getReposName('/my/path/to/my/extension/biodbFoo')
biodb::getReposName('/my/path/to/my/extension/biodbFoo')
Returns the path to the test output directory. The function creates this also this directory if it does not exist.
getTestOutputDir()
getTestOutputDir()
The path to the test output directory, as a character value.
# Get the test output directory: biodb::getTestOutputDir()
# Get the test output directory: biodb::getTestOutputDir()
Get a URL content.
getUrlContent(u, binary = FALSE)
getUrlContent(u, binary = FALSE)
u |
The URL as a single character value. |
binary |
Set to TRUE if the content to be retrieved is binary. |
The content, as a single character value.
Send a request and get results.
getUrlRequestResult(request, useragent = NULL, ssl.verifypeer = TRUE)
getUrlRequestResult(request, useragent = NULL, ssl.verifypeer = TRUE)
request |
A BiodbRequest object. |
useragent |
The user agent identification. |
ssl.verifypeer |
Set to TRUE to enable SSL verify peer. |
A RequestResult object.
DEPRECATED. Use TestRefEntries class instead.
listTestRefEntries(conn.id, pkgName, limit = 0)
listTestRefEntries(conn.id, pkgName, limit = 0)
conn.id |
A valid Biodb connector ID. |
pkgName |
The name of the |
limit |
The maximum number of entries to retrieve. |
Lists the reference entries in the test folder for a specified connector.
The test reference files must be in <pkg>/inst/testref/
folder and
their names must match entry-<database_name>-<entry_accession>.json
(e.g.:
entry-comp.csv.file-1018.json
).
A list of entry IDs.
# List IDs of test reference entries: biodb::listTestRefEntries('comp.csv.file', pkgName='biodb')
# List IDs of test reference entries: biodb::listTestRefEntries('comp.csv.file', pkgName='biodb')
This function loads the contents of a list of files and returns the contents as a list, each element being the content of a single file, in the same order. If a file could not be opened, a NULL value is used as the content. NA values are interpreted by default, but this behaviour can be turned off.
loadFileContents(x, naValues = "NA", outVect = FALSE)
loadFileContents(x, naValues = "NA", outVect = FALSE)
x |
A character vector containing the paths of the files. |
naValues |
A character vector listing the content values to convert into NA value. Set to NULL to disable the interpretation of NA values. set to a different set of values to be interpreted. |
outVect |
If set to TRUE outputs a character vector (converting any NULL value into NA), otherwise outputs a list. |
A list with the contents of the files.
Logs a debug level message with biodb logger.
logDebug(...)
logDebug(...)
... |
Values to be passed to sprintf(). |
Nothing.
# Logs a debug message: biodb::logDebug('Index is %d.', 10)
# Logs a debug message: biodb::logDebug('Index is %d.', 10)
Logs a debug level message with biodb logger, using paste0().
logDebug0(...)
logDebug0(...)
... |
Values to be passed to paste0() |
Nothing.
# Logs a debug message: biodb::logDebug0('Index is ', 10, '.')
# Logs a debug message: biodb::logDebug0('Index is ', 10, '.')
Logs an information level message with biodb logger.
logInfo(...)
logInfo(...)
... |
Values to be passed to sprintf(). |
Nothing.
# Logs an info message: biodb::logInfo('Index is %d.', 10)
# Logs an info message: biodb::logInfo('Index is %d.', 10)
Logs an information level message with biodb logger, using paste0().
logInfo0(...)
logInfo0(...)
... |
Values to be passed to paste0(). |
Nothing.
# Logs an info message: biodb::logInfo0('Index is ', 10, '.')
# Logs an info message: biodb::logInfo0('Index is ', 10, '.')
Logs a trace level message with biodb logger.
logTrace(...)
logTrace(...)
... |
Values to be passed to sprintf(). |
Nothing.
# Logs a trace message: biodb::logTrace('Index is %d.', 10)
# Logs a trace message: biodb::logTrace('Index is %d.', 10)
Logs a trace level message with biodb logger, using paste0().
logTrace0(...)
logTrace0(...)
... |
Values to be passed to paste0() |
Nothing.
# Logs a trace message: biodb::logTrace0('Index is ', 10, '.')
# Logs a trace message: biodb::logTrace0('Index is ', 10, '.')
Prints a string (partially if too big) into a string.
lst2str(x, nCut = 10)
lst2str(x, nCut = 10)
x |
The list to convert into a string. |
nCut |
The maximum of elements to print. |
A string containing the list representation (or part of it).
# Converts the first 5 elements of a list into a string: s <- lst2str(1:10, nCut=5)
# Converts the first 5 elements of a list into a string: s <- lst2str(1:10, nCut=5)
Build an RCurl::CURLOptions object.
makeRCurlOptions( useragent = NULL, httpheader = NULL, postfields = NULL, timeout.ms = 60000, verbose = FALSE )
makeRCurlOptions( useragent = NULL, httpheader = NULL, postfields = NULL, timeout.ms = 60000, verbose = FALSE )
useragent |
The user agent identification. |
httpheader |
The HTTP header to send. |
postfields |
POST fields, in case of a POST method. |
timeout.ms |
The timeout in milliseconds. |
verbose |
Set to TRUE to get verbose output in RCurl. |
An RCurl::CURLOptions object.
Mass CSV File connector class.
Mass CSV File connector class.
This is the connector class for a MASS CSV file database.
biodb::BiodbConnBase
-> biodb::BiodbConn
-> biodb::CsvFileConn
-> MassCsvFileConn
biodb::BiodbConnBase$getBaseUrl()
biodb::BiodbConnBase$getConnClass()
biodb::BiodbConnBase$getConnClassName()
biodb::BiodbConnBase$getDbClass()
biodb::BiodbConnBase$getEntryClass()
biodb::BiodbConnBase$getEntryClassName()
biodb::BiodbConnBase$getEntryContentType()
biodb::BiodbConnBase$getEntryFileExt()
biodb::BiodbConnBase$getEntryIdField()
biodb::BiodbConnBase$getName()
biodb::BiodbConnBase$getPropSlots()
biodb::BiodbConnBase$getPropValSlot()
biodb::BiodbConnBase$getPropertyValue()
biodb::BiodbConnBase$getSchedulerNParam()
biodb::BiodbConnBase$getSchedulerTParam()
biodb::BiodbConnBase$getToken()
biodb::BiodbConnBase$getUrl()
biodb::BiodbConnBase$getUrls()
biodb::BiodbConnBase$getWsUrl()
biodb::BiodbConnBase$getXmlNs()
biodb::BiodbConnBase$hasProp()
biodb::BiodbConnBase$hasPropSlot()
biodb::BiodbConnBase$isSlotProp()
biodb::BiodbConnBase$propExists()
biodb::BiodbConnBase$setBaseUrl()
biodb::BiodbConnBase$setPropValSlot()
biodb::BiodbConnBase$setPropertyValue()
biodb::BiodbConnBase$setSchedulerNParam()
biodb::BiodbConnBase$setSchedulerTParam()
biodb::BiodbConnBase$setToken()
biodb::BiodbConnBase$setUrl()
biodb::BiodbConnBase$setWsUrl()
biodb::BiodbConnBase$updatePropertiesDefinition()
biodb::BiodbConn$addNewEntry()
biodb::BiodbConn$allowEditing()
biodb::BiodbConn$allowWriting()
biodb::BiodbConn$annotateMzValues()
biodb::BiodbConn$checkDb()
biodb::BiodbConn$collapseResultsDataFrame()
biodb::BiodbConn$correctIds()
biodb::BiodbConn$deleteAllCacheEntries()
biodb::BiodbConn$deleteAllEntriesFromPersistentCache()
biodb::BiodbConn$deleteAllEntriesFromVolatileCache()
biodb::BiodbConn$deleteWholePersistentCache()
biodb::BiodbConn$disallowEditing()
biodb::BiodbConn$disallowWriting()
biodb::BiodbConn$download()
biodb::BiodbConn$editingIsAllowed()
biodb::BiodbConn$filterEntriesOnRt()
biodb::BiodbConn$getAllCacheEntries()
biodb::BiodbConn$getAllVolatileCacheEntries()
biodb::BiodbConn$getBiodb()
biodb::BiodbConn$getCacheFile()
biodb::BiodbConn$getCacheId()
biodb::BiodbConn$getChromCol()
biodb::BiodbConn$getDownloadPath()
biodb::BiodbConn$getEntry()
biodb::BiodbConn$getEntryContent()
biodb::BiodbConn$getEntryContentFromDb()
biodb::BiodbConn$getEntryContentRequest()
biodb::BiodbConn$getEntryIds()
biodb::BiodbConn$getEntryImageUrl()
biodb::BiodbConn$getEntryPageUrl()
biodb::BiodbConn$getId()
biodb::BiodbConn$getMatchingMzField()
biodb::BiodbConn$getMzValues()
biodb::BiodbConn$getNbEntries()
biodb::BiodbConn$getNbPeaks()
biodb::BiodbConn$getSearchableFields()
biodb::BiodbConn$isCompounddb()
biodb::BiodbConn$isDownloadable()
biodb::BiodbConn$isDownloaded()
biodb::BiodbConn$isEditable()
biodb::BiodbConn$isExtracted()
biodb::BiodbConn$isMassdb()
biodb::BiodbConn$isRemotedb()
biodb::BiodbConn$isSearchableByField()
biodb::BiodbConn$isWritable()
biodb::BiodbConn$makeRequest()
biodb::BiodbConn$makesRefToEntry()
biodb::BiodbConn$msmsSearch()
biodb::BiodbConn$requiresDownload()
biodb::BiodbConn$searchByName()
biodb::BiodbConn$searchCompound()
biodb::BiodbConn$searchForEntries()
biodb::BiodbConn$searchForMassSpectra()
biodb::BiodbConn$searchMsEntries()
biodb::BiodbConn$searchMsPeaks()
biodb::BiodbConn$searchMzRange()
biodb::BiodbConn$searchMzTol()
biodb::BiodbConn$setDownloadedFile()
biodb::BiodbConn$setEditingAllowed()
biodb::BiodbConn$setMatchingMzField()
biodb::BiodbConn$setWritingAllowed()
biodb::BiodbConn$write()
biodb::BiodbConn$writingIsAllowed()
biodb::CsvFileConn$addField()
biodb::CsvFileConn$getCsvQuote()
biodb::CsvFileConn$getCsvSep()
biodb::CsvFileConn$getFieldColName()
biodb::CsvFileConn$getFieldNames()
biodb::CsvFileConn$getFieldsAndColumnsAssociation()
biodb::CsvFileConn$getUnassociatedColumns()
biodb::CsvFileConn$hasField()
biodb::CsvFileConn$print()
biodb::CsvFileConn$setCsvQuote()
biodb::CsvFileConn$setCsvSep()
biodb::CsvFileConn$setDb()
biodb::CsvFileConn$setField()
biodb::CsvFileConn$setIgnoreUnassignedColumns()
new()
New instance initializer. Connector classes must not be instantiated directly. Instead, you must use the createConn() method of the factory class.
MassCsvFileConn$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
getPrecursorFormulae()
Gets the list of formulae used to recognize precursors.
MassCsvFileConn$getPrecursorFormulae()
A character vector containing chemical formulae.
isAPrecursorFormula()
Tests if a formula is a precursor formula.
MassCsvFileConn$isAPrecursorFormula(formula)
formula
A chemical formula, as a character value.
TRUE if the submitted formula is considered a precursor.
setPrecursorFormulae()
Sets the list precursor formulae.
MassCsvFileConn$setPrecursorFormulae(formulae)
formulae
A character vector containing formulae.
Nothing.
addPrecursorFormulae()
Adds new formulae to the list of formulae used to recognize precursors.
MassCsvFileConn$addPrecursorFormulae(formulae)
formulae
A character vector containing formulae.
Nothing.
clone()
The objects of this class are cloneable with this method.
MassCsvFileConn$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class CsvFileConn
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "massbank_extract_lcms_2.tsv", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('mass.csv.file', url=lcmsdb) # Get an entry e <- conn$getEntry('PR010001') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "massbank_extract_lcms_2.tsv", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('mass.csv.file', url=lcmsdb) # Get an entry e <- conn$getEntry('PR010001') # Terminate instance. mybiodb$terminate()
Mass CSV File entry class.
Mass CSV File entry class.
This is the entry class for Mass CSV file databases.
biodb::BiodbEntry
-> biodb::BiodbCsvEntry
-> MassCsvFileEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
new()
New instance initializer. Entry objects must not be created directly. Instead, they are retrieved through the connector instances.
MassCsvFileEntry$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
clone()
The objects of this class are cloneable with this method.
MassCsvFileEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbCsvEntry
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "massbank_extract_lcms_2.tsv", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('mass.csv.file', url=lcmsdb) # Get an entry e <- conn$getEntry('PR010001') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "massbank_extract_lcms_2.tsv", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('mass.csv.file', url=lcmsdb) # Get an entry e <- conn$getEntry('PR010001') # Terminate instance. mybiodb$terminate()
This is the connector class for a MASS SQLite database.
biodb::BiodbConnBase
-> biodb::BiodbConn
-> biodb::SqliteConn
-> MassSqliteConn
biodb::BiodbConnBase$getBaseUrl()
biodb::BiodbConnBase$getConnClass()
biodb::BiodbConnBase$getConnClassName()
biodb::BiodbConnBase$getDbClass()
biodb::BiodbConnBase$getEntryClass()
biodb::BiodbConnBase$getEntryClassName()
biodb::BiodbConnBase$getEntryContentType()
biodb::BiodbConnBase$getEntryFileExt()
biodb::BiodbConnBase$getEntryIdField()
biodb::BiodbConnBase$getName()
biodb::BiodbConnBase$getPropSlots()
biodb::BiodbConnBase$getPropValSlot()
biodb::BiodbConnBase$getPropertyValue()
biodb::BiodbConnBase$getSchedulerNParam()
biodb::BiodbConnBase$getSchedulerTParam()
biodb::BiodbConnBase$getToken()
biodb::BiodbConnBase$getUrl()
biodb::BiodbConnBase$getUrls()
biodb::BiodbConnBase$getWsUrl()
biodb::BiodbConnBase$getXmlNs()
biodb::BiodbConnBase$hasProp()
biodb::BiodbConnBase$hasPropSlot()
biodb::BiodbConnBase$isSlotProp()
biodb::BiodbConnBase$propExists()
biodb::BiodbConnBase$setBaseUrl()
biodb::BiodbConnBase$setPropValSlot()
biodb::BiodbConnBase$setPropertyValue()
biodb::BiodbConnBase$setSchedulerNParam()
biodb::BiodbConnBase$setSchedulerTParam()
biodb::BiodbConnBase$setToken()
biodb::BiodbConnBase$setUrl()
biodb::BiodbConnBase$setWsUrl()
biodb::BiodbConnBase$updatePropertiesDefinition()
biodb::BiodbConn$addNewEntry()
biodb::BiodbConn$allowEditing()
biodb::BiodbConn$allowWriting()
biodb::BiodbConn$annotateMzValues()
biodb::BiodbConn$checkDb()
biodb::BiodbConn$collapseResultsDataFrame()
biodb::BiodbConn$correctIds()
biodb::BiodbConn$deleteAllCacheEntries()
biodb::BiodbConn$deleteAllEntriesFromPersistentCache()
biodb::BiodbConn$deleteAllEntriesFromVolatileCache()
biodb::BiodbConn$deleteWholePersistentCache()
biodb::BiodbConn$disallowEditing()
biodb::BiodbConn$disallowWriting()
biodb::BiodbConn$download()
biodb::BiodbConn$editingIsAllowed()
biodb::BiodbConn$filterEntriesOnRt()
biodb::BiodbConn$getAllCacheEntries()
biodb::BiodbConn$getAllVolatileCacheEntries()
biodb::BiodbConn$getBiodb()
biodb::BiodbConn$getCacheFile()
biodb::BiodbConn$getCacheId()
biodb::BiodbConn$getChromCol()
biodb::BiodbConn$getDownloadPath()
biodb::BiodbConn$getEntry()
biodb::BiodbConn$getEntryContent()
biodb::BiodbConn$getEntryContentFromDb()
biodb::BiodbConn$getEntryContentRequest()
biodb::BiodbConn$getEntryIds()
biodb::BiodbConn$getEntryImageUrl()
biodb::BiodbConn$getEntryPageUrl()
biodb::BiodbConn$getId()
biodb::BiodbConn$getMatchingMzField()
biodb::BiodbConn$getMzValues()
biodb::BiodbConn$getNbEntries()
biodb::BiodbConn$getNbPeaks()
biodb::BiodbConn$getSearchableFields()
biodb::BiodbConn$isCompounddb()
biodb::BiodbConn$isDownloadable()
biodb::BiodbConn$isDownloaded()
biodb::BiodbConn$isEditable()
biodb::BiodbConn$isExtracted()
biodb::BiodbConn$isMassdb()
biodb::BiodbConn$isRemotedb()
biodb::BiodbConn$isSearchableByField()
biodb::BiodbConn$isWritable()
biodb::BiodbConn$makeRequest()
biodb::BiodbConn$makesRefToEntry()
biodb::BiodbConn$msmsSearch()
biodb::BiodbConn$print()
biodb::BiodbConn$requiresDownload()
biodb::BiodbConn$searchByName()
biodb::BiodbConn$searchCompound()
biodb::BiodbConn$searchForEntries()
biodb::BiodbConn$searchForMassSpectra()
biodb::BiodbConn$searchMsEntries()
biodb::BiodbConn$searchMsPeaks()
biodb::BiodbConn$searchMzRange()
biodb::BiodbConn$searchMzTol()
biodb::BiodbConn$setDownloadedFile()
biodb::BiodbConn$setEditingAllowed()
biodb::BiodbConn$setMatchingMzField()
biodb::BiodbConn$setWritingAllowed()
biodb::BiodbConn$write()
biodb::BiodbConn$writingIsAllowed()
biodb::SqliteConn$getQuery()
biodb::SqliteConn$hasField()
biodb::SqliteConn$initialize()
clone()
The objects of this class are cloneable with this method.
MassSqliteConn$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class SqliteConn
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "massbank_extract.sqlite", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('mass.sqlite', url=lcmsdb) # Get an entry e <- conn$getEntry('34.pos.col12.0.78') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "massbank_extract.sqlite", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('mass.sqlite', url=lcmsdb) # Get an entry e <- conn$getEntry('34.pos.col12.0.78') # Terminate instance. mybiodb$terminate()
This is the entry class for a Mass spectra SQLite database.
biodb::BiodbEntry
-> biodb::BiodbListEntry
-> MassSqliteEntry
biodb::BiodbEntry$appendFieldValue()
biodb::BiodbEntry$cloneInstance()
biodb::BiodbEntry$computeFields()
biodb::BiodbEntry$fieldHasBasicClass()
biodb::BiodbEntry$getBiodb()
biodb::BiodbEntry$getDbClass()
biodb::BiodbEntry$getField()
biodb::BiodbEntry$getFieldCardinality()
biodb::BiodbEntry$getFieldClass()
biodb::BiodbEntry$getFieldDef()
biodb::BiodbEntry$getFieldNames()
biodb::BiodbEntry$getFieldValue()
biodb::BiodbEntry$getFieldsAsDataframe()
biodb::BiodbEntry$getFieldsAsJson()
biodb::BiodbEntry$getFieldsByType()
biodb::BiodbEntry$getId()
biodb::BiodbEntry$getName()
biodb::BiodbEntry$getParent()
biodb::BiodbEntry$hasField()
biodb::BiodbEntry$initialize()
biodb::BiodbEntry$isNew()
biodb::BiodbEntry$makesRefToEntry()
biodb::BiodbEntry$parentIsAConnector()
biodb::BiodbEntry$parseContent()
biodb::BiodbEntry$print()
biodb::BiodbEntry$removeField()
biodb::BiodbEntry$setField()
biodb::BiodbEntry$setFieldValue()
clone()
The objects of this class are cloneable with this method.
MassSqliteEntry$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbListEntry
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "massbank_extract.sqlite", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('mass.sqlite', url=lcmsdb) # Get an entry e <- conn$getEntry('34.pos.col12.0.78') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get path to LCMS database example file lcmsdb <- system.file("extdata", "massbank_extract.sqlite", package="biodb") # Create a connector conn <- mybiodb$getFactory()$createConn('mass.sqlite', url=lcmsdb) # Get an entry e <- conn$getEntry('34.pos.col12.0.78') # Terminate instance. mybiodb$terminate()
Instantiates a new BiodbMain object by calling the constructor.
newInst(...)
newInst(...)
... |
The parameters to pass to the BiodbMain constructor. See
|
A new BiodbMain instance.
# Create a new BiodbMain instance: mybiodb <- biodb::newInst() # Terminate the instance: mybiodb$terminate()
# Create a new BiodbMain instance: mybiodb <- biodb::newInst() # Terminate the instance: mybiodb$terminate()
Prepares file contents for saving.
prepareFileContents(contents)
prepareFileContents(contents)
contents |
File contents, as a list or a character vector. |
File contents.
A class for informing user about the progress of a process.
This class displays progress of a process to user, and sends notifications of this progress to observers too.
new()
Initializer.
Progress$new(biodb = NULL, msg, total = NA_integer_)
biodb
A BiodbMain instance that will be used to notify observers of progress.
msg
The message to display to the user.
total
The total number of elements to process or NA if unknown.
Nothing.
increment()
Increment progress.
Progress$increment()
Nothing.
clone()
The objects of this class are cloneable with this method.
Progress$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Create an instance prg <- biodb::Progress$new(msg='Processing data.', total=10L) # Processing for (i in seq_len(10)) { print("Doing something.") prg$increment() }
# Create an instance prg <- biodb::Progress$new(msg='Processing data.', total=10L) # Processing for (i in seq_len(10)) { print("Doing something.") prg$increment() }
Range class.
Range class.
A class for storing min/max range or value/tolerance.
new()
Initializer.
Range$new( min = NULL, max = NULL, value = NULL, delta = NULL, ppm = NULL, tol = NULL, tolType = c("delta", "plain", "ppm") )
min
The minimum value of the range.
max
The maximum value of the range.
value
The value.
delta
The delta tolerance.
ppm
The PPM tolerance.
tol
The tolerance value, whose type (ppm or delta) is specified by the "tolType" parameter.
tolType
The type of the tolerance value specified by the "tol" parameter.
Nothing.
# Create an instance from min and max: Range$new(min=1.2, max=1.5)
getValue()
Gets the middle value of the range.
Range$getValue()
The middle value.
getMin()
Gets the minimum value of the range.
Range$getMin()
The minimum value.
getMax()
Gets the maximum value of the range.
Range$getMax()
The maximum value.
getMinMax()
Get the min/max range.
Range$getMinMax()
A list containing two fields: "min" and "max.
getDelta()
Gets the delta tolerance of the range.
Range$getDelta()
The delta tolerance.
getPpm()
Gets the PPM tolerance of the range.
Range$getPpm()
The tolerance in PPM.
getTolExpr()
Gets the tolerance expression as a list.
Range$getTolExpr()
A list containing the tolerance range expression.
clone()
The objects of this class are cloneable with this method.
Range$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Convert a min/max range into a value/ppm tolerance: rng <- Range$new(min=0.4, max=0.401) value <- rng$getValue() ppm <- rng$getPpm() ## ------------------------------------------------ ## Method `Range$new` ## ------------------------------------------------ # Create an instance from min and max: Range$new(min=1.2, max=1.5)
# Convert a min/max range into a value/ppm tolerance: rng <- Range$new(min=0.4, max=0.401) value <- rng$getValue() ppm <- rng$getPpm() ## ------------------------------------------------ ## Method `Range$new` ## ------------------------------------------------ # Create an instance from min and max: Range$new(min=1.2, max=1.5)
Class RequestResult.
Class RequestResult.
Represents the result of a request.
new()
New instance initializer.
RequestResult$new( content = NULL, retry = FALSE, errMsg = NULL, status = 0, statusMessage = "", retryAfter = NULL, location = NULL )
content
The result content.
retry
If request should be resent.
errMsg
Error message.
status
HTTP status.
statusMessage
Status message.
retryAfter
Time after which to retry.
location
New location.
Nothing.
getContent()
Get content.
RequestResult$getContent()
The content as a character value or NULL.
getRetry()
Get the retry flag.
RequestResult$getRetry()
TRUE if the URL request should be sent again, FALSE otherwise.
getErrMsg()
Get the error message.
RequestResult$getErrMsg()
The error message as a character value or NULL.
getStatus()
Get the HTTP status of the response.
RequestResult$getStatus()
The status as an integer.
getRetryAfter()
Get the time to wait before retrying.
RequestResult$getRetryAfter()
The time.
getLocation()
Get the redirect location.
RequestResult$getLocation()
The redirect location as a character value or NULL.
processRequestErrors()
Process possible HTTP error.
RequestResult$processRequestErrors()
Nothing.
clone()
The objects of this class are cloneable with this method.
RequestResult$clone(deep = FALSE)
deep
Whether to make a deep clone.
This function must be used in tests on all connector classes, before any specific tests.
runGenericTests( conn, pkgName, testRefFolder = NULL, opt = NULL, short = TRUE, long = FALSE, maxShortTestRefEntries = 1 )
runGenericTests( conn, pkgName, testRefFolder = NULL, opt = NULL, short = TRUE, long = FALSE, maxShortTestRefEntries = 1 )
conn |
A valid biodb connector. |
pkgName |
The name of your package. |
testRefFolder |
The folder where to find test reference files. |
opt |
A set of options to pass to the test functions. |
short |
Run short tests. |
long |
Run long tests. |
maxShortTestRefEntries |
The maximum number of reference entries to use in short tests. |
Nothing.
# Instantiate a Biodb instance for testing biodb <- biodb::createBiodbTestInstance() # Create a connector instance lcmsdb <- system.file("extdata", "massbank_extract.tsv", package="biodb") conn <- biodb$getFactory()$createConn('mass.csv.file', lcmsdb) # Run generic tests biodb::runGenericTests(conn) # Terminate the instance biodb$terminate()
# Instantiate a Biodb instance for testing biodb <- biodb::createBiodbTestInstance() # Create a connector instance lcmsdb <- system.file("extdata", "massbank_extract.tsv", package="biodb") conn <- biodb$getFactory()$createConn('mass.csv.file', lcmsdb) # Run generic tests biodb::runGenericTests(conn) # Terminate the instance biodb$terminate()
Saves contents to files.
saveContentsToFiles(files, contents, prepareContents = FALSE)
saveContentsToFiles(files, contents, prepareContents = FALSE)
files |
The file paths to use for saving contents. |
contents |
The contents to save, as a list or a character vector. |
prepareContents |
If set to TRUE, then calls prepareFileContents() on the contents before saving them. |
Nothing.
SQLite connector class.
SQLite connector class.
This is the abstract connector class for all SQLite databases.
biodb::BiodbConnBase
-> biodb::BiodbConn
-> SqliteConn
biodb::BiodbConnBase$getBaseUrl()
biodb::BiodbConnBase$getConnClass()
biodb::BiodbConnBase$getConnClassName()
biodb::BiodbConnBase$getDbClass()
biodb::BiodbConnBase$getEntryClass()
biodb::BiodbConnBase$getEntryClassName()
biodb::BiodbConnBase$getEntryContentType()
biodb::BiodbConnBase$getEntryFileExt()
biodb::BiodbConnBase$getEntryIdField()
biodb::BiodbConnBase$getName()
biodb::BiodbConnBase$getPropSlots()
biodb::BiodbConnBase$getPropValSlot()
biodb::BiodbConnBase$getPropertyValue()
biodb::BiodbConnBase$getSchedulerNParam()
biodb::BiodbConnBase$getSchedulerTParam()
biodb::BiodbConnBase$getToken()
biodb::BiodbConnBase$getUrl()
biodb::BiodbConnBase$getUrls()
biodb::BiodbConnBase$getWsUrl()
biodb::BiodbConnBase$getXmlNs()
biodb::BiodbConnBase$hasProp()
biodb::BiodbConnBase$hasPropSlot()
biodb::BiodbConnBase$isSlotProp()
biodb::BiodbConnBase$propExists()
biodb::BiodbConnBase$setBaseUrl()
biodb::BiodbConnBase$setPropValSlot()
biodb::BiodbConnBase$setPropertyValue()
biodb::BiodbConnBase$setSchedulerNParam()
biodb::BiodbConnBase$setSchedulerTParam()
biodb::BiodbConnBase$setToken()
biodb::BiodbConnBase$setUrl()
biodb::BiodbConnBase$setWsUrl()
biodb::BiodbConnBase$updatePropertiesDefinition()
biodb::BiodbConn$addNewEntry()
biodb::BiodbConn$allowEditing()
biodb::BiodbConn$allowWriting()
biodb::BiodbConn$annotateMzValues()
biodb::BiodbConn$checkDb()
biodb::BiodbConn$collapseResultsDataFrame()
biodb::BiodbConn$correctIds()
biodb::BiodbConn$deleteAllCacheEntries()
biodb::BiodbConn$deleteAllEntriesFromPersistentCache()
biodb::BiodbConn$deleteAllEntriesFromVolatileCache()
biodb::BiodbConn$deleteWholePersistentCache()
biodb::BiodbConn$disallowEditing()
biodb::BiodbConn$disallowWriting()
biodb::BiodbConn$download()
biodb::BiodbConn$editingIsAllowed()
biodb::BiodbConn$filterEntriesOnRt()
biodb::BiodbConn$getAllCacheEntries()
biodb::BiodbConn$getAllVolatileCacheEntries()
biodb::BiodbConn$getBiodb()
biodb::BiodbConn$getCacheFile()
biodb::BiodbConn$getCacheId()
biodb::BiodbConn$getChromCol()
biodb::BiodbConn$getDownloadPath()
biodb::BiodbConn$getEntry()
biodb::BiodbConn$getEntryContent()
biodb::BiodbConn$getEntryContentFromDb()
biodb::BiodbConn$getEntryContentRequest()
biodb::BiodbConn$getEntryIds()
biodb::BiodbConn$getEntryImageUrl()
biodb::BiodbConn$getEntryPageUrl()
biodb::BiodbConn$getId()
biodb::BiodbConn$getMatchingMzField()
biodb::BiodbConn$getMzValues()
biodb::BiodbConn$getNbEntries()
biodb::BiodbConn$getNbPeaks()
biodb::BiodbConn$getSearchableFields()
biodb::BiodbConn$isCompounddb()
biodb::BiodbConn$isDownloadable()
biodb::BiodbConn$isDownloaded()
biodb::BiodbConn$isEditable()
biodb::BiodbConn$isExtracted()
biodb::BiodbConn$isMassdb()
biodb::BiodbConn$isRemotedb()
biodb::BiodbConn$isSearchableByField()
biodb::BiodbConn$isWritable()
biodb::BiodbConn$makeRequest()
biodb::BiodbConn$makesRefToEntry()
biodb::BiodbConn$msmsSearch()
biodb::BiodbConn$print()
biodb::BiodbConn$requiresDownload()
biodb::BiodbConn$searchByName()
biodb::BiodbConn$searchCompound()
biodb::BiodbConn$searchForEntries()
biodb::BiodbConn$searchForMassSpectra()
biodb::BiodbConn$searchMsEntries()
biodb::BiodbConn$searchMsPeaks()
biodb::BiodbConn$searchMzRange()
biodb::BiodbConn$searchMzTol()
biodb::BiodbConn$setDownloadedFile()
biodb::BiodbConn$setEditingAllowed()
biodb::BiodbConn$setMatchingMzField()
biodb::BiodbConn$setWritingAllowed()
biodb::BiodbConn$write()
biodb::BiodbConn$writingIsAllowed()
new()
New instance initializer. Connector classes must not be instantiated directly. Instead, you must use the createConn() method of the factory class.
SqliteConn$new(...)
...
All parameters are passed to the super class initializer.
Nothing.
hasField()
Tests if a field is defined for this database instance.
SqliteConn$hasField(field)
field
A valid Biodb entry field name.
TRUE of the field is defined, FALSE otherwise.
getQuery()
Run a query using a biodb SQL object.
SqliteConn$getQuery(query)
query
A valid BiodbSqlQuery object.
The result returned by DBI::dbGetQuery() call.
clone()
The objects of this class are cloneable with this method.
SqliteConn$clone(deep = FALSE)
deep
Whether to make a deep clone.
Super class BiodbConn
and sub-classes
CompSqliteConn
, and MassSqliteConn
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector that inherits from SqliteConn: chebi_file <- system.file("extdata", "chebi_extract.sqlite", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.sqlite', url=chebi_file) # Get an entry e <- conn$getEntry('1018') # Terminate instance. mybiodb$terminate()
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a connector that inherits from SqliteConn: chebi_file <- system.file("extdata", "chebi_extract.sqlite", package="biodb") conn <- mybiodb$getFactory()$createConn('comp.sqlite', url=chebi_file) # Get an entry e <- conn$getEntry('1018') # Terminate instance. mybiodb$terminate()
Define a context for tests using testthat framework.
In addition to calling testthat::context()
.
testContext(text)
testContext(text)
text |
The text to print as test context. |
No value returned.
# Define a context before running tests: biodb::testContext("Test my database connector.") # Instantiate a BiodbMain instance for testing biodb <- biodb::createBiodbTestInstance() # Terminate the instance biodb$terminate()
# Define a context before running tests: biodb::testContext("Test my database connector.") # Instantiate a BiodbMain instance for testing biodb <- biodb::createBiodbTestInstance() # Terminate the instance biodb$terminate()
A class for accessing the test reference entries.
A class for accessing the test reference entries.
The test reference entries are stored as JSON files inside
inst/testref
folder of each extension package.
new()
New instance initializer.
TestRefEntries$new(db.class, pkgName, folder = NULL, bdb = NULL)
db.class
Identifier of the database.
pkgName
Name of the package in which are stored the reference entry files.
folder
The folder where to find test reference files for the package. Usually it is "inst/testref".
bdb
A valid BiodbMain instance or NULL.
Nothing.
getAllIds()
Retrieve all identifiers.
TestRefEntries$getAllIds(limit = 0)
limit
The maximum number of identifiers to return.
A character vector containing the IDs.
getContents()
Get the reference contents for the specfied IDs.
TestRefEntries$getContents(ids)
ids
The reference IDs for which to get the contents.
A character vector.
getRealEntries()
Retrieve all real entries from database corresponding to the reference entris.
TestRefEntries$getRealEntries(ids = NULL)
ids
A character vector of entry identifiers.
A list containing BiodbEntry instances.
saveEntriesAsJson()
Saves a list of entries into separate JSON files, inside the test output folder.
TestRefEntries$saveEntriesAsJson(ids, entries)
ids
The IDs of the entries.
entries
A list of entries. It can contain NULL values.
Nothing.
getRealEntry()
Retrieves one real entry from database corresponding to one reference entry.
TestRefEntries$getRealEntry(id)
id
The identifier of the entry.
A BiodbEntry instance.
getRefEntry()
Retrieves the content of a single reference entry.
TestRefEntries$getRefEntry(id)
id
The identifier of the reference entry to retrieve.
The content of the reference entry as a list.
getAllRefEntriesDf()
Load all reference entries.
TestRefEntries$getAllRefEntriesDf()
A data frame containing all the reference entries with their values.
clone()
The objects of this class are cloneable with this method.
TestRefEntries$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Creates an instance refEntries <- TestRefEntries$new('comp.sqlite', pkgName='biodb') # Gets identifiers of all reference entries refEntries$getAllIds() # Gets a data frame with the content of the reference entries refEntries$getAllRefEntriesDf()
# Creates an instance refEntries <- TestRefEntries$new('comp.sqlite', pkgName='biodb') # Gets identifiers of all reference entries refEntries$getAllIds() # Gets a data frame with the content of the reference entries refEntries$getAllRefEntriesDf()
Run a test function, using testthat framework.
In addition to calling testthat::test_that()
.
testThat(msg, fct, biodb = NULL, conn = NULL, opt = NULL)
testThat(msg, fct, biodb = NULL, conn = NULL, opt = NULL)
msg |
The test message. |
fct |
The function to test. |
biodb |
A valid BiodbMain instance to be passed to the test function. |
conn |
A connector instance to be passed to the test function. |
opt |
A set of options to pass to the test function. |
No value returned.
# Define a context before running tests: biodb::testContext("Test my database connector.") # Instantiate a BiodbMain instance for testing biodb <- biodb::createBiodbTestInstance() # Define a test function my_test_function <- function(biodb) { # Do my tests... } # Run test biodb::testThat("My test works", my_test_function, biodb=biodb) # Terminate the instance biodb$terminate()
# Define a context before running tests: biodb::testContext("Test my database connector.") # Instantiate a BiodbMain instance for testing biodb <- biodb::createBiodbTestInstance() # Define a test function my_test_function <- function(biodb) { # Do my tests... } # Run test biodb::testThat("My test works", my_test_function, biodb=biodb) # Terminate the instance biodb$terminate()
Upgrades some of the files previously generated (.gitignore, .travis.yml, .Rbuildignore, Makefile, etc) to the latest versions.
upgradeExtPkg(...)
upgradeExtPkg(...)
... |
Parameters passed to |
Nothing.
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::genNewExtPkg(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', rcpp=TRUE, connType='mass', entryType='txt', downloadable=TRUE, remote=TRUE) # Upgrade it later biodb::upgradeExtPkg(path=pkgFolder)
# Generate a new package: pkgFolder <- file.path(tempfile(), 'biodbFoo') dir.create(pkgFolder, recursive=TRUE) biodb::genNewExtPkg(path=pkgFolder, dbName='foo.db', dbTitle='Foo database', rcpp=TRUE, connType='mass', entryType='txt', downloadable=TRUE, remote=TRUE) # Upgrade it later biodb::upgradeExtPkg(path=pkgFolder)
Throws a warning and logs it too with biodb logger.
warn(...)
warn(...)
... |
Values to be passed to sprintf(). |
Nothing.
# Throws a warning: tryCatch(biodb::warn('Index is %d.', 10), warning=function(w){w$message})
# Throws a warning: tryCatch(biodb::warn('Index is %d.', 10), warning=function(w){w$message})
Throws a warning and logs it too with biodb logger, using paste0().
warn0(...)
warn0(...)
... |
Values to be passed to paste0(). |
Nothing.
# Throws a warning: tryCatch(biodb::warn0('Index is ', 10, '.'), warning=function(w){w$message})
# Throws a warning: tryCatch(biodb::warn0('Index is ', 10, '.'), warning=function(w){w$message})