| 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] (ORCID: <https://orcid.org/0000-0001-8177-4873>), Alexis Delabrière [ctb] (ORCID: <https://orcid.org/0000-0003-3308-4549>) |
| Maintainer: | Pierrick Roger <[email protected]> |
| License: | AGPL-3 |
| Version: | 1.21.0 |
| Built: | 2026-05-09 08:58:52 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, 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 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)
parentThe BiodbMain instance.
Nothing.
getKeys()
Get the list of available keys.
BiodbConfig$getKeys(deprecated = FALSE)
deprecatedIf 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)
keyThe name of a configuration key.
The title of the key as a character value.
getDescription()
Get the description of a key.
BiodbConfig$getDescription(key)
keyThe 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)
keyThe name of a configuration key.
as.chrIf set to TRUE, returns the value as character.
The default value for that key.
hasKey()
Test if a key exists.
BiodbConfig$hasKey(key)
keyThe 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)
keyThe name of a configuration key.
failIf 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)
keyThe 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)
keyThe name of a configuration key.
The value associated with the key.
set()
Set the value of a key.
BiodbConfig$set(key, value)
keyThe name of a configuration key.
valueA value to associate with the key.
Nothing.
reset()
Reset the value of a key.
BiodbConfig$reset(key = NULL)
keyThe name of a configuration key. If NULL, all keys will be reset.
Nothing.
enable()
Set a boolean key to TRUE.
BiodbConfig$enable(key)
keyThe name of a configuration key.
Nothing.
disable()
Set a boolean key to FALSE.
BiodbConfig$disable(key)
keyThe 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)
keyThe 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)
defThe list of key definitions.
Nothing.
notifyNewObservers()
Called by BiodbMain when a new observer is registered.
BiodbConfig$notifyNewObservers(obs)
obsThe 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)
deepWhether 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, ...)
idThe ID of the connector instance.
cache.idThe Cache ID of the connector instance.
bdbThe 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)
idsA 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)
idA character vector containing entry identifiers.
dropIf 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.
nullsIf 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.idThe 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)
idA 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.idA 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.idA character vector with the IDs of entries to retrieve.
concatenateIf set to TRUE, then try to build as few URLs as possible, sending requests with several identifiers at once.
max.lengthThe 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.resultsThe 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)
countIf 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)
allowA 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)
entryThe 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)
allowIf 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)
fieldThe name of the field.
field.typeThe 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)
fieldsA 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.resultsIf 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)
nameA character value to search inside name fields.
max.resultsIf 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"))srcPath to the downloaded file.
actionSpecifies 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 )
nameThe name of a compound to search for.
massThe searched mass.
mass.fieldFor searching by mass, you must indicate a mass field to use ('monoisotopic.mass', 'molecular.mass', 'average.mass' or 'nominal.mass').
mass.tolThe tolerance value on the molecular mass.
mass.tol.unitThe type of mass tolerance. Either 'plain' or 'ppm'.
max.resultsThe maximum number of matches to return.
descriptionA 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
)xEither a data frame or a numeric vector containing the M/Z values.
mz.tolThe tolerance on the M/Z values.
ms.modeThe MS mode. Set it to either 'neg' or 'pos'.
mz.tol.unitThe type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
mass.fieldThe mass field to use for matching M/Z values. One of: 'monoisotopic.mass', 'molecular.mass', 'average.mass', 'nominal.mass'.
max.resultsIf 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.colThe name of the column where to find M/Z values in case x is a data frame.
fieldsA 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.
prefixA 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.valuesInsert input values at the beginning of the result data frame.
fieldsLimitThe 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)
deleteVolatileIf 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)
deleteVolatileIf 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)
idA character vector of entry IDs from the connector's database.
dbAnother database connector.
oidA entry ID from database db.
anyIf set to TRUE, returns a single logical value: TRUE if any entry contains a reference to oid, FALSE otherwise.
recurseIf 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 sched::Request instance using the passed parameters.
BiodbConn$makeRequest(...)
...Those parameters are passed to the initializer of sched::Request.
The sched::Request 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.idA 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.idA character vector with the IDs of entries to retrieve.
A list of sched::URL objects, the same length as entry.id.
getChromCol()
Gets a list of chromatographic columns contained in this database.
BiodbConn$getChromCol(ids = NULL)
idsA 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"))fieldThe 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.modeThe MS mode. Set it to either 'neg' or 'pos' to limit the output to one mode.
max.resultsIf set, it is used to limit the size of the output.
precursorIf set to TRUE, then restrict the search to precursor peaks.
ms.levelThe 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)
modeThe MS mode. Set it to either 'neg' or 'pos' to limit the counting to one mode.
idsA 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.idsA character vector of entry IDs.
rtA vector of retention times to match. Used if input.df is not set. Unit is specified by rt.unit parameter.
rt.unitThe unit for submitted retention times. Either 's' or 'min'.
rt.tolThe plain tolerance (in seconds) for retention times: input.rt
rt.tol <= database.rt <= input.rt + rt.tol.
rt.tol.expA 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.idsIDs of chromatographic columns on which to match the retention time.
match.rtIf 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.minA vector of minimum M/Z values.
mz.maxA vector of maximum M/Z values. Its length must be the same as
mz.min.
mzA vector of M/Z values.
mz.tolThe M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unitThe type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
rtA vector of retention times to match. Used if input.df is not set. Unit is specified by rt.unit parameter.
rt.unitThe unit for submitted retention times. Either 's' or 'min'.
rt.tolThe plain tolerance (in seconds) for retention times: input.rt
rt.tol <= database.rt <= input.rt + rt.tol.
rt.tol.expA 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.idsIDs of chromatographic columns on which to match the retention time.
precursorIf set to TRUE, then restrict the search to precursor peaks.
min.rel.intThe minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.modeThe MS mode. Set it to either 'neg' or 'pos'.
max.resultsIf set, it is used to limit the number of matches found for each M/Z value.
ms.levelThe MS level to which you want to restrict your search. 0 means that you want to search in all levels.
include.idsA 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.minA vector of minimum M/Z values.
mz.maxA vector of maximum M/Z values. Its length must be the same as
mz.min.
mzA vector of M/Z values.
mz.tolThe M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unitThe type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
rtA vector of retention times to match. Used if input.df is not set. Unit is specified by rt.unit parameter.
rt.unitThe unit for submitted retention times. Either 's' or 'min'.
rt.tolThe plain tolerance (in seconds) for retention times: input.rt
rt.tol <= database.rt <= input.rt + rt.tol.
rt.tol.expA 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.idsIDs of chromatographic columns on which to match the retention time.
precursorIf set to TRUE, then restrict the search to precursor peaks.
min.rel.intThe minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.modeThe MS mode. Set it to either 'neg' or 'pos'.
max.resultsIf set, it is used to limit the number of matches found for each M/Z value.
ms.levelThe 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.dfA data frame taken as input for searchMsPeaks(). It must contain a columns 'mz', and optionaly an 'rt' column.
mzA vector of M/Z values to match. Used if input.df is not set.
mz.tolThe M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unitThe type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
min.rel.intThe minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.modeThe MS mode. Set it to either 'neg' or 'pos'.
ms.levelThe MS level to which you want to restrict your search. 0 means that you want to search in all levels.
max.resultsIf set, it is used to limit the number of matches found for each M/Z value.
chrom.col.idsIDs of chromatographic columns on which to match the retention time.
rtA vector of retention times to match. Used if input.df is not set. Unit is specified by rt.unit parameter.
rt.unitThe unit for submitted retention times. Either 's' or 'min'.
rt.tolThe plain tolerance (in seconds) for retention times: input.rt
rt.tol <= database.rt <= input.rt + rt.tol.
rt.tol.expA 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.
precursorIf set to TRUE, then restrict the search to precursor peaks.
precursor.rt.tolThe RT tolerance used when matching the precursor.
insert.input.valuesInsert input values at the beginning of the result data frame.
prefixAdd prefix on column names of result data frame.
computeIf set to TRUE, use the computed values when converting found entries to data frame.
fieldsA character vector of field names to output. The data frame output will be restricted to this list of fields.
fieldsLimitThe maximum of values to output for fields with multiple values. Set it to 0 to get all values.
input.df.colnamesNames of the columns in the input data frame.
match.rtIf 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
)spectrumA template spectrum to match inside the database.
precursor.mzThe M/Z value of the precursor peak of the mass spectrum.
mz.tolThe M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unitThe type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
ms.modeThe MS mode. Set it to either 'neg' or 'pos'.
npminThe minimum number of peak to detect a match (2 is recommended).
dist.funThe distance function used to compute the distance betweem two mass spectra.
msms.mz.tolM/Z tolerance to apply while matching MSMS spectra. In PPM.
msms.mz.tol.minMinimum 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.resultsIf 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.dfResults data frame.
mz.colThe name of the M/Z column in the results data frame.
rt.colThe name of the RT column in the results data frame.
sepThe 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.minA vector of minimum M/Z values.
mz.maxA vector of maximum M/Z values. Its length must be the
same as mz.min.
min.rel.intThe minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.modeThe MS mode. Set it to either 'neg' or 'pos'.
max.resultsIf set, it is used to limit the number of matches found for each M/Z value.
precursorIf set to TRUE, then restrict the search to precursor peaks.
ms.levelThe 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 )
mzA vector of M/Z values.
mz.tolThe M/Z tolerance, whose unit is defined by mz.tol.unit.
mz.tol.unitThe type of the M/Z tolerance. Set it to either to 'ppm' or 'plain'.
min.rel.intThe minimum relative intensity, in percentage (i.e.: float number between 0 and 100).
ms.modeThe MS mode. Set it to either 'neg' or 'pos'.
max.resultsIf set, it is used to limit the number of matches found for each M/Z value.
precursorIf set to TRUE, then restrict the search to precursor peaks.
ms.levelThe 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)
deepWhether 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)
otherAnother BiodbConnBase instance as a model from which to copy property values.
db.classThe class of the connector (i.e.: "mass.csv.file").
propertiesSome new values for the properties.
cfgThe 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)
nameThe name of the property to check.
Returns true if the property name exists.
getPropSlots()
Gets the slot fields of a property.
BiodbConnBase$getPropSlots(name)
nameThe 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)
nameThe name of a property.
slotThe 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)
nameThe 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)
nameThe 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)
nameThe name of a property.
slotThe slot name inside the property.
hookIf 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)
defA 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)
nameThe name of the property.
hookIf 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)
nameThe name of the property.
valueThe 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)
nameThe name of the property.
slotThe name of the property's slot.
valueThe new value to set the property's slot to.
hookIf 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)
urlA 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.urlA URL as a character value.
Nothing.
getToken()
Returns the access token.
BiodbConnBase$getToken()
setToken()
Sets the access token.
BiodbConnBase$setToken(token)
tokenThe 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)
nThe 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)
tThe T parameter as a whole number.
Nothing.
getUrls()
Returns the URLs.
BiodbConnBase$getUrls()
getUrl()
Returns a URL.
BiodbConnBase$getUrl(name)
nameThe name of the URL to retrieve.
The URL as a character value.
setUrl()
Sets a URL.
BiodbConnBase$setUrl(name, url)
nameThe name of the URL to set.
urlThe 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)
deepWhether 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 = "", ...)
sepThe separator to use in CSV files.
na.stringsThe strings to recognize as NA values. This is a character vector.
quotesThe 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)
deepWhether 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)
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)
deepWhether 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)
cfgThe BiodbConfig instance.
Nothing.
define()
Define databases from a structured object, normally loaded from a YAML file.
BiodbDbsInfo$define(def, package = "biodb")
defA named list of database definitions. The names of the list will be the IDs of the databases.
packageThe 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.idA 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.idA character vector of database IDs.
Nothing.
get()
Gets information on a database.
BiodbDbsInfo$get(db.id = NULL, drop = TRUE)
db.idDatabase IDs, as a character vector. If set to NULL, informations on all databases will be returned.
dropIf 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)
deepWhether 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)
parentA 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.classThe 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)
fieldThe name of a field.
valueThe 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)
fieldThe name of a field.
valueThe 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)
fieldThe 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)
fieldThe 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 )
fieldThe name of a field.
computeIf 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.
flattenIf 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.
lastIf 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.
limitThe maximum number of values to get in case the field contains more than one value.
withNaIf set to TRUE, keep NA values. Otherwise filter out NAs values in vectors.
duplicatedValuesIf 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)
typeThe 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.atomicIf set to TRUE, only export field's values that are atomic
computeIf 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.
fieldsSet to character vector of field names in order to restrict execution to this set of fields.
fields.typeIf set, output all the fields of the specified type.
flattenIf 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.
limitThe maximum number of field values to write into new columns. Used for fields that can contain more than one value.
only.card.oneIf set to TRUE, only fields with a cardinality of one will be extracted.
own.idIf set to TRUE includes the database id field named
<database_name>.id whose values are the same as the accession field.
duplicate.rowsIf set to TRUE and merging field values with cardinality greater than one, values will be duplicated.
sortIf set to TRUE sort the order of columns alphabetically, otherwise do not sort.
virtualFieldsIf 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)
computeIf 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)
contentA character string containing definition for an entry and
obtainedfrom 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)
fieldsA 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)
dbAnother database connector.
oidA entry ID from database db.
recurseIf 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)
fieldThe name of the field.
The value of the field.
setField()
DEPRECATED. Sets the value of a field.
BiodbEntry$setField(field, value)
fieldThe name of the field.
valueThe new value of the field.
Nothing.
getFieldClass()
Gets the class of a field.
BiodbEntry$getFieldClass(field)
fieldThe name of the field.
The class of the field.
getFieldDef()
Gets the definition of an entry field.
BiodbEntry$getFieldDef(field)
fieldThe name of the field.
An object BiodbEntryField which defines the field.
getFieldCardinality()
Gets the cardinality of the field.
BiodbEntry$getFieldCardinality(field)
fieldThe name of the field.
The cardinality of the field.
fieldHasBasicClass()
DEPRECATED. Use BiodbEntryField::isVector() instead.
BiodbEntry$fieldHasBasicClass(field)
fieldThe 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)
deepWhether 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_
)parentThe BiodbEntryFields parent instance.
nameThe field name.
aliasThe field aliases as a character vector.
typeThe field type.
classThe field class.
cardThe field cardinality.
forbids.duplicatesSet to TRUE to forbid duplicated values.
descriptionThe field description.
allowed.valuesRestrict possible values to a set of allowed values.
lower.caseAll values will be converted to lower case.
case.insensitiveComparison will be made case insensitive for this field.
computable.fromA list of databases from which to compute automatically the value of this field.
virtualSet to TRUE if this field is virtual.
virtual.group.by.typeIn case of a virtual field, set the type of fields to group together into a data frame.
dataFrameGroupThe 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)
typeThe 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)
aliasThe name of a valid alias.
Nothing.
removeAlias()
Removes an alias from the list of aliases.
BiodbEntryField$removeAlias(alias)
aliasThe 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)
directiveA valid \"computable from\" directive.
Nothing.
removeComputableFrom()
Removes a directive from the list of computableFrom.
BiodbEntryField$removeComputableFrom(directive)
directiveA valid \"computable from\" directive.
Nothing.
correctValue()
Corrects a value so it is compatible with this field.
BiodbEntryField$correctValue(value)
valueA 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)
valueIf 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)
keyThe key associated with the value (i.e.: the key is the main name of an allowed value).
valueThe new value to add.
Nothing.
checkValue()
Checks if a value is correct. Fails if value is incorrect.
BiodbEntryField$checkValue(value)
valueThe 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)
otherAnother BiodbEntryField instance.
failIf 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)
otherAnother 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)
deepWhether 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)
parentThe BiodbMain instance.
Nothing.
notifyCfgUpdate()
Call back method called when a value is modified inside the configuration.
BiodbEntryFields$notifyCfgUpdate(k, v)
kThe config key name.
vThe value associated with the key.
Nothing.
isAlias()
Tests if names are aliases.
BiodbEntryFields$isAlias(name)
nameA 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)
nameA character vector of names or aliases to test.
A character vector of formatted names.
isDefined()
Tests if names are defined fields.
BiodbEntryFields$isDefined(name)
nameA 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)
nameA 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)
nameA character vector of names or aliases.
failFails 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)
nameA character vector of names or aliases.
dropIf 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)
typeSet this parameter to a character vector in order to return only the names of the fields corresponding to the types specified.
computableIf 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)
databaseThe 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)
defA 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)
deepWhether 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)
bdbThe BiodbMain instance.
Nothing.
getBiodb()
Returns the biodb main class instance to which this object is attached.
BiodbFactory$getBiodb()
The main biodb instance.
createConn()
Creates a connector to a database.
BiodbFactory$createConn( db.class, url = NULL, token = NA_character_, fail.if.exists = TRUE, get.existing.conn = TRUE, conn.id = NULL, cache.id = NULL )
db.classThe type of a database. The list of types can be obtained from the class BiodbDbsInfo.
urlAn URL to the database for which to create a connection. Each database connector is configured with a default URL, but some allow you to change it.
tokenA security access token for the database. Some database require such a token for all or some of their webservices. Usually you obtain the token through your account on the database website.
fail.if.existsIf set to TRUE, the method will fail if a connector for
get.existing.connThis argument will be used only if fail.if.exists is set to FALSE and an identical connector already exists. If it set to TRUE, the existing connector instance will be returned, otherwise NULL will be returned.
conn.idIf set, this identifier will be used for the new connector. An error will be raised in case another connector already exists with this identifier.
cache.idIf set, this ID will be used as the cache ID for the new connector. An error will be raised in case another connector already exists with this cache identifier.
An instance of the requested connector class.
connExists()
Tests if a connector exists.
BiodbFactory$connExists(conn.id)
conn.idA connector ID.
TRUE if a connector with this ID exists, FALSE otherwise.
deleteConn()
Deletes an existing connector.
BiodbFactory$deleteConn(conn)
connA connector instance or a connector ID.
Nothing.
deleteConnByClass()
Deletes all existing connectors from a same class.
BiodbFactory$deleteConnByClass(db.class)
db.classThe type of a database. All connectors of this database type will be deleted.
Nothing.
getAllConnectors()
Gets all connectors.
BiodbFactory$getAllConnectors()
A list of all created connectors.
deleteAllConnectors()
Deletes all connectors.
BiodbFactory$deleteAllConnectors()
Nothing.
getConn()
Gets an instantiated connector instance, or create a new one.
BiodbFactory$getConn(conn.id, class = TRUE, create = TRUE)
conn.idAn existing connector ID.
classIf set to TRUE, and \"conn.id\" does not correspond to any instantiated connector, then interpret \"conn.id\" as a database class and looks for the first instantiated connector of that class.
createIf set to TRUE, and \"class\" is also set to TRUE, and no suitable instantiated connector was found, then creates a new connector instance of the class specified by \"conn.id\".
The connector instance corresponding to the connector ID or to the database ID submitted (if class \"parameter\" is set to TRUE).
getEntry()
Retrieves database entry objects from IDs (accession numbers), for the specified connector.
BiodbFactory$getEntry(conn.id, id, drop = TRUE, no.null = FALSE, limit = 0)
conn.idAn existing connector ID.
idA character vector containing database entry IDs (accession numbers).
dropIf set to TRUE and the list of entries contains only one element, then returns this element instead of the list. If set to FALSE, then returns always a list.
no.nullSet to TRUE to remove NULL entries.
limitSet to a positive value to limit the number of entries returned.
A list of BiodbEntry objects, the same length as id. A
NULL value is put into the list for each invalid ID of id.
createNewEntry()
Creates a new empty entry object from scratch. This entry is not stored in cache, and is directly attached to the factory instance instead of a particular connector.
BiodbFactory$createNewEntry(db.class)
db.classA database ID.
A new BiodbEntry object.
createEntryFromContent()
Creates an entry instance from a content.
BiodbFactory$createEntryFromContent(conn.id, content, drop = TRUE)
conn.idA valid BiodbConn identifier.
contentA list or character vector of contents to parse to create the entries.
dropIf set to TRUE
A list of new BiodbEntry objects.
getAllCacheEntries()
For a connector, gets all entries stored in the cache.
BiodbFactory$getAllCacheEntries(conn.id)
conn.idA connector ID.
A list of BiodbEntry objects.
deleteAllEntriesFromVolatileCache()
Deletes all entries stored in the cache of the given connector. This method is deprecated, please use deleteAllEntriesFromVolatileCache() instead.
BiodbFactory$deleteAllEntriesFromVolatileCache(conn.id)
conn.idA connector ID.
Nothing.
deleteAllCacheEntries()
Deletes all entries stored in the cache of the given connector.
BiodbFactory$deleteAllCacheEntries(conn.id)
conn.idA connector ID.
Nothing.
print()
Prints information about this instance.
BiodbFactory$print()
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbFactory$clone(deep = FALSE)
deepWhether to make a deep clone.
BiodbMain, BiodbConn and
BiodbEntry.
# Create a BiodbMain instance with default settings: mybiodb <- biodb::newInst() # Obtain the factory instance: factory <- mybiodb$getFactory() # Get a compound CSV file database chebi.tsv <- system.file("extdata", "chebi_extract.tsv", package='biodb') # Create a connector: conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi.tsv) # Get a database entry: entry <- conn$getEntry(conn$getEntryIds(1)) # Terminate instance. mybiodb$terminate()# 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)
deepWhether 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)
deepWhether 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)
deepWhether 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, 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)
autoloadExtraPkgsSet 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 BiodbMain instance. Call this method when you are done with
your BiodbMain instance.
BiodbMain$terminate()
Nothing.
loadDefinitions()
Loads databases and entry fields definitions from YAML file.
BiodbMain$loadDefinitions(file, package = "biodb")
fileThe path to a YAML file containing definitions for
BiodbMain (databases, fields or configuration keys).
packageThe package to which belong the new definitions.
Nothing.
getConfig()
Returns the single instance of the BiodbConfig class.
BiodbMain$getConfig()
The instance of the BiodbConfig 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 BiodbDbsInfo class.
BiodbMain$getDbsInfo()
The instance of the BiodbDbsInfo class attached to
this BiodbMain instance.
getEntryFields()
Returns the single instance of the BiodbEntryFields class.
BiodbMain$getEntryFields()
The instance of the BiodbEntryFields class
attached to this BiodbMain instance.
getFactory()
Returns the single instance of the BiodbFactory class.
BiodbMain$getFactory()
The instance of the BiodbFactory class attached to
this BiodbMain instance.
getRequestScheduler()
Returns the single instance of the Scheduler class.
BiodbMain$getRequestScheduler()
The instance of the Scheduler 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)
observersEither 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.fieldThe 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 )
entriesA list of BiodbEntry instances.
fieldThe name of a field.
flattenIf set to TRUE 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.
computeIf set to TRUE, computable fields will be
output.
limitThe maximum number of values to retrieve for each entry. Set to 0 to get all values.
withNaIf 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
TRUE, otherwise a list.
entriesToDataframe()
Converts a list of entries or a list of list of entries
(BiodbEntry 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 = "" )
entriesA list of BiodbEntry instances or a list of list of
BiodbEntry instances.
only.atomicIf set to TRUE, output only atomic fields, i.e.:
the fields whose value type is one of integer, numeric, logical or
character.
null.to.naIf set to TRUE, each NULL entry in the
list is converted into a row of NA values.
computeIf set to TRUE, computable fields will be output.
fieldsA character vector of field names to output. The data frame output will be restricted to this list of fields.
limitThe 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.
dropIf set to TRUE and the resulting data frame has only one
column, a vector will be output instead of data frame.
sort.colsSort columns in alphabetical order.
flattenIf set to TRUE, then each field with a cardinality
greater than one, will be converted into a vector of class character whose
values are collapsed.
only.card.oneOutput only fields whose cardinality is one.
own.idIf set to TRUE includes the database id field named
<database_name>.id whose values are the same as the accession field.
prefixInsert 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 )
idsA character vector of entry IDs or a list of character vectors of entry IDs.
dbThe biodb database name for the entry IDs, or a connector ID, as a sinle character value.
fieldsA character vector containing entry fields to add.
limitThe 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.
prefixInsert a prefix at the start of all field names.
own.idIf set to TRUE includes the database id field named
<database_name>.id whose values are the same as the accession field.
Adata 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 = "")
xA data frame containing at least one column with Biodb entry IDs
identified by the parameter id.col.
id.colThe name of the column containing IDs inside the input data frame.
dbThe biodb database name for the entry IDs, or a connector ID, as a single character value.
fieldsA character vector containing entry fields to add.
limitThe 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.
prefixInsert 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 BiodbEntry objects into JSON. Returns a vector of
characters.
BiodbMain$entriesToJson(entries, compute = TRUE)
entriesA list of BiodbEntry instances. It may contain NULL
elements.
computeIf set to TRUE, 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)
xA data frame.
sepThe separator to use when concatenating values in collapsed rows.
colsThe 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 )
entriesA list of BiodbEntry objects.
fieldThe field for which to extract values.
sortOutputSet to TRUE to sort the values.
uniqSet 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 )
idsA list of entry identifiers.
dbThe database ID or connector ID where to find the entries.
fieldThe field for which to extract values.
sortOutputSet to TRUE to sort the values.
uniqSet 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)
entriesA list of BiodbEntry 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)
entriesA list of BiodbEntry instances. It may contain NULL
elements.
filesA character vector of file paths, the same length as entries list.
computeIf set to TRUE, 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.fromThe connector of the source datababase to copy.
conn.toThe connector of the destination database.
limitThe number of entries of the source database to copy. If set to
NULL, 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 BiodbEntryField :isVector()."
BiodbMain$fieldIsAtomic(field)
fieldThe 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)
fieldThe name of the field.
The class of the field.
clone()
The objects of this class are cloneable with this method.
BiodbMain$clone(deep = FALSE)
deepWhether to make a deep clone.
BiodbFactory,
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
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)
deepWhether 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)
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)
whatThe reason as a character value.
indexThe index number representing the progress.
totalThe total number to reach for completing the process.
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbTestMsgAck$clone(deep = FALSE)
deepWhether 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)
deepWhether 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)
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)
deepWhether 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)
deepWhether 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)
deepWhether 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)
deepWhether 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)
deepWhether 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)
quoteThe characters used to delimit quotes as a single character value.
Youmay 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)
sepThe 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)
fieldA 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)
fieldA valid Biodb entry field name.
valueThe value to set for this field.
Nothing.
getFieldColName()
Get the column name corresponding to a Biodb field.
CsvFileConn$getFieldColName(field)
fieldA 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)
fieldA valid Biodb entry field name. This field must not be already defined for this database instance.
colnameA character vector containing one or more column names from the CSV file.
ignore.if.missingDeprecated 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)
dbA 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)
ignoreSet 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)
deepWhether 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)
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 reading a file template, replacing tags inside, and writing the results in an output file.
new()
Initializer.
FileTemplate$new(path)
pathThe path to the template file.
Nothing.
replace()
Replace a tag by its value inside the template file.
FileTemplate$replace(tag, value)
tagThe tag to replace.
valueThe 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)
setThe name of the case set.
caseThe name of case.
invisible(self) for chaining method calls.
select()
Select or remove sections that match a name.
FileTemplate$select(section, enable)
sectionThe name of the section.
enableSet 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)
pathPath to output file.
overwriteIf set to FALSE and the destination file already exists, a message is thrown. Otherwise writes into the destination.
checkRemainingTagsIf 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)
deepWhether to make a deep clone.
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()
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()
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)
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)
formulaA chemical formula, as a character value.
TRUE if the submitted formula is considered a precursor.
setPrecursorFormulae()
Sets the list precursor formulae.
MassCsvFileConn$setPrecursorFormulae(formulae)
formulaeA character vector containing formulae.
Nothing.
addPrecursorFormulae()
Adds new formulae to the list of formulae used to recognize precursors.
MassCsvFileConn$addPrecursorFormulae(formulae)
formulaeA character vector containing formulae.
Nothing.
clone()
The objects of this class are cloneable with this method.
MassCsvFileConn$clone(deep = FALSE)
deepWhether 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)
deepWhether 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)
deepWhether 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)
deepWhether 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()
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_)
biodbA BiodbMain instance that will be used to notify observers of progress.
msgThe message to display to the user.
totalThe 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)
deepWhether 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")
)minThe minimum value of the range.
maxThe maximum value of the range.
valueThe value.
deltaThe delta tolerance.
ppmThe PPM tolerance.
tolThe tolerance value, whose type (ppm or delta) is specified by the "tolType" parameter.
tolTypeThe 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)
deepWhether 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)
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 ## Not run: biodb::runGenericTests(conn, 'mypkg') ## End(Not run) # 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 ## Not run: biodb::runGenericTests(conn, 'mypkg') ## End(Not run) # Terminate the instance biodb$terminate()
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)
fieldA 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)
queryA 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)
deepWhether 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.classIdentifier of the database.
pkgNameName of the package in which are stored the reference entry files.
folderThe folder where to find test reference files for the package. Usually it is "inst/testref".
bdbA valid BiodbMain instance or NULL.
Nothing.
getAllIds()
Retrieve all identifiers.
TestRefEntries$getAllIds(limit = 0)
limitThe maximum number of identifiers to return.
A character vector containing the IDs.
getContents()
Get the reference contents for the specfied IDs.
TestRefEntries$getContents(ids)
idsThe 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)
idsA 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)
idsThe IDs of the entries.
entriesA list of entries. It can contain NULL values.
Nothing.
getRealEntry()
Retrieves one real entry from database corresponding to one reference entry.
TestRefEntries$getRealEntry(id)
idThe identifier of the entry.
A BiodbEntry instance.
getRefEntry()
Retrieves the content of a single reference entry.
TestRefEntries$getRefEntry(id)
idThe 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)
deepWhether 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()
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})