BiodbConn-class {biodb} | R Documentation

## The mother abstract class of all database connectors.

### Description

This is the super class of all connector classes. All methods defined here are thus common to all connector classes. Some connector classes inherit directly from this abstract class. Some others inherit from intermediate classes `BiodbRemotedbConn` and `BiodbMassdbConn`. As for all connector concrete classes, you won't have to create an instance of this class directly, but you will instead go through the factory class. However, if you plan to develop a new connector, you will have to call the constructor of this 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.*".

### Details

The constructor has the following arguments:

id: The identifier of the connector.

cache.id: The identifier used in the disk cache.

### Methods

`checkDb()`

  :

  Checks that the database is correct by trying to retrieve all its entries.

  Returned values: None.

`correctIds(ids)`

  :

  Correct a vector of IDs by formatting them to the database official format, if required and possible.

  ids: A character vector of IDs.

  Returned values: The vector of IDs corrected.

`deleteAllCacheEntries()`

  :

  Delete all entries from the memory cache. This method is deprecated, please use deleteAllEntriesFromVolatileCache() instead.

  Returned value: None.

`deleteAllEntriesFromPersistentCache(deleteVolatile = TRUE)`

  :

  Delete all entries from the persistent cache (disk cache).

  deleteVolatile: If TRUE deletes also all entries from the volatile cache (memory cache).

  Returned value: None.

`deleteAllEntriesFromVolatileCache()`

  :

  Delete all entries from the volatile cache (memory cache).

  Returned value: None.

`deleteWholePersistentCache(deleteVolatile = TRUE)`

  :

  Delete all files associated with this connector from the persistent cache (disk cache). deleteVolatile: If TRUE deletes also all entries from the volatile cache (memory cache).

  Returned value: None.

`getAllCacheEntries()`

  :

  This method is deprecated.

  Use getAllVolatileCacheEntries() instead.

`getAllVolatileCacheEntries()`

  :

  Get all entries stored in the memory cache (volatile cache).

  Returned value: A list of BiodbEntry instances.

`getCacheFile(entry.id)`

  :

  Get the path to the persistent cache file.

  entry.id: The identifiers (e.g.: accession numbers) as a character vector of the database entries.

  Returned value: A character vector, the same length as the vector of IDs, containing the paths to the cache files corresponding to the requested entry IDs.

`getCacheId()`

  :

  Gets the ID used by this connector in the disk cache.

  Returned value: The cache ID of this connector.

`getEntry(id, drop = TRUE, nulls = TRUE)`

  :

  Return the entry corresponding to this ID. You can pass a vector of IDs, and you will get a list of entries.

  id: A character vector containing entry identifiers.

  drop: If set to TRUE and only one entry is requrested, then the returned value will be a single BiodbEntry object, otherwise it will be a list of BiodbEntry objects.

  nulls: If set to TRUE, NULL entries are preserved. This ensures that the output list has the same length than the input vector 'id'. Otherwise they are removed from the final list.

  Returned value: 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.

`getEntryContent(id)`

  :

  Get the contents of database entries from IDs (accession numbers).

  id: A character vector of entry IDs.

  Returned values: 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(entry.id)`

  :

  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.

  entry.id: A character vector with the IDs of entries to retrieve.

  Returned value: 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.

`getEntryIds(max.results = 0, ...)`

  :

  Get entry identifiers from the database. More arguments can be given, depending on implementation in specific databases. For mass databases, the ones derived from BiodbBiodbMassdbConn class, the ms.level argument can be set.

  max.results: The maximum of elements to return from the method.

  ...: First arguments to be passed to private .doGetEntryIds() method.

  Returned value: 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.

`getId()`

  :

  Get the identifier of this connector.

  Returned value: The identifier of this connector.

`getNbEntries(count = FALSE)`

  :

  Get the number of entries contained in this database.

  count: If set to TRUE and no straightforward way exists to get number of entries, count the output of getEntryIds().

  Returned value: The number of entries in the database, as an integer.

`getSearchableFields()`

  :

  Get the list of all searchable fields.

  Returned value: A character vector containing all searchable fields for this connector.

`isCompounddb()`

  :

  Tests if the connector's database is a compound database (i.e.: the connector class inherits from BiodbCompounddbConn class).

  Returned value: Returns TRUE if the database is a compound database.

`isDownloadable()`

  :

  Tests if the connector can download the database (i.e.: the connector class implements the interface BiodbDownloadable).

  Returned value: Returns TRUE if the database is downloadable.

`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.

  Returned value: Returns TRUE if the database is editable.

`isMassdb()`

  :

  Tests if the connector's database is a mass spectra database (i.e.: the connector class inherits from BiodbMassdbConn class).

  Returned value: Returns TRUE if the database is a mass database.

`isRemotedb()`

  :

  Tests of the connector is connected to a remote database (i.e.: the connector class inherits from BiodbRemotedbConn class).

  Returned value: Returns TRUE if the database is a remote database.

`isSearchableByField(field)`

  :

  Tests if a field can be used to search entries when using methods searchByName() and searchCompound().

  field: The name of the field.

  Returned value: Returns TRUE if the database is searchable using the specified field, FALSE otherwise.

`isWritable()`

  :

  Tests if this connector is able to write into the database (i.e.: the connector class implements the interface BiodbWritable). If this connector is writable, then you can call allowWriting() to enable writing.

  Returned value: Returns TRUE if the database is writable.

`makeRequest(...)`

  :

  Makes a BiodbRequest instance using the passed parameters, and set ifself as the associated connector.

  ...: Those parameters are passed to the initializer of BiodbRequest.

  Returned value: The BiodbRequest instance.

`makesRefToEntry(id, db, oid, any = FALSE, recurse = FALSE)`

  :

  Tests if some entry of this database makes reference to another entry of another database.

  id: A character vector of entry IDs from the connector's database.

  db: Another database connector.

  oid: A entry ID from database db.

  any: If set to TRUE, returns a single logical value: TRUE if any entry contains a reference to oid, FALSE otherwise.

  recurse: If set to TRUE, the algorithm will follow all references to entries from other databases, to see if it can establish an indirect link to 'oid'.

  Returned value: A logical vector, the same size as 'id', with TRUE for each entry making reference to 'oid', and FALSE otherwise.

`searchByName(name, max.results = 0)`

  :

  This method is deprecated.

  Use searchForEntries() instead.

`searchForEntries(fields = NULL, max.results = 0)`

  :

  Searches the database for entries whose name matches the specified name. Returns a character vector of entry IDs.

  fields: A list of fields on which to filter entries. To get a match, all fields must be matched (i.e.: logical AND). The keys of the list are the entry field names on which to filter, and the values are the filtering parameters. For character fields, the filter parameter is a character vector in which all strings must be found inside the field's value. For numeric fields, the filter parameter is either a list specifying a min-max range ('list(min=1.0, max=2.5)') or a value with a tolerance in delta ('list(value=2.0, delta=0.1)') or ppm ('list(value=2.0, ppm=1.0)').

  max.results: If set, the number of returned IDs is limited to this number.

  Returned value: A character vector of entry IDs whose name matches the requested name.

`show()`

  :

  Prints a description of this connector.

  Returned value: None.

### See Also

Super class `BiodbConnBase`, `BiodbFactory`, `BiodbRemotedbConn` and `BiodbMassdbConn`.

### Examples

    # 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()

[Package biodb version 1.0.4 Index]