• Tips and Tricks
  • " />

    Multiple restez paths

    It is not advisable to download the entire GenBank database to your machine. Equally, it is best to limit the size of a database. Databases that are too large will be slow to query and are more likely to cause memory issues. For example, you may actually make a query that demands more memory than is available on your machine. One solution to instead set multiple restez paths on your machine.

    You can either set up a path for different domains. Or you could download for a single set of domains and then create a database from the same downloaded files using the alt_restez_path argument. Do also make use of restez_path_unset to disconnect and unset the restez path.

    # a larger database from the same download files in rodents_path
    db_create(alt_restez_path = rodents_path, max_length = 2000)

    Connecting and disconnecting

    Always ensure you disconnect after connecting to a restez path. Not doing so may lead to some strange database errors such as ‘seg faults’ or you may even be prevented from connecting to a database again until you restart R. In scripts you should always place restez_disconnect() as the end of the script or when you have stopped making queries. If you are making queries from your own custom function you should use on.exit. This allows you to run ‘clean up’ code whenever a function exits, even if it errors.

    suppressMessages(library(restez))
    random_definition <- function() {
      suppressMessages(restez_connect())
      on.exit(restez_disconnect())
      if (restez_ready()) {
        # deliberate mistake
        id <- sample(list_db_ids(n = NULL), 1)[[1]]
        return(gb_definition_get(id))
      }
    }
    restez_path_set(rodents_path)
    (definition <- random_definition())
    ##                                                                                     BC125447 
    ## "Mus musculus NIPA-like domain containing 1, mRNA (cDNA clone IMAGE:40129962), complete cds"
    # not connected outside of function!
    (restez_ready())
    ## [1] FALSE

    Which domain?

    The db_download function lists the various possible GenBank domains that can be downloaded. You can work out which GenBank domain a sequence belongs to by its three letter code towards the end of its locus. For example, the top of the record for this sequence indicates it is in the rodent domain.

    LOCUS       LT548182                 456 bp    DNA     linear   ROD 23-NOV-2016
    DEFINITION  TPA_inf: Cavia porcellus GLNH gene for globin H.
    ACCESSION   LT548182
    VERSION     LT548182.1

    Database performance and behaviour

    The restez package database is built with MonetDBlite. If you encounter any errors that include the phrase “Server says”, then an issue is likely to have occurred within the database. Please raise such issues with GitHub. But keep the following factors in mind:

    • Is your request from the database likely to return an object too large for your computer’s RAM? If the size of database is 5GB then it is likely that a request pulling all of the sequence data and information into an R session will be around 5GB as well.
    • Are you building and storing the database on a separate USB drive? It has been noted that database behaviour can be unusual on separate USB drives. When an issue, please provide information about your USB drive’s format, size and USB connections.