Code Monkey home page Code Monkey logo

Comments (4)

jorainer avatar jorainer commented on August 17, 2024 1

What I meant with CompDb is missing is the following:

idb <- IonDb(dbcon = icon, CompDb = cdb)

is supposed to create a new IonDb database from content taken from the CompDb cdb. We should however also allow a call like:

idb <- IonDb(dbcin = icon)

in which case icon is expected to be the database connection to an already existing IonDb (with all the required tables). This call should allow users to load a previously created database.

So, the IonDb function should be something like:

IonDb <- function(dbcon, CompDb) {
    if (!missing(CompDb)) {
        ## Call a function that copies the content from CompDb over to dbcon
        ## and create the other required tables for IonDb in dbcon
    }
    ## assign dbcon to @dbcon, check validity of the database and return it
}

from compounddb.

jorainer avatar jorainer commented on August 17, 2024

I try to explain the expected workflow: the user is supposed to have created (or downloaded) first a CompDb with compound annotations from e.g. HMDB. The goal would be to add also ion information to that database an hence convert the database to a IonDb.

One possible workflow would be, given that cdb is an existing CompDb and ions is a data.frame with ion information the user wants to add:

## create a new SQLite database that will contain the IonDb
idbcon <- dbConnect(SQLite(), "my_ion_db.sqlite")
## add ions to the database:
idb <- insertIons(cdb, ions, dbcon = idbcon)
## What this call needs to do:
## - copy all content from the original `cdb` to the new database
## - create the ms_ion table and add the ions to that
## - return an IonDb object

If the user wants to add additional ions it would be much easier, because he/she has already an IonDb:

## no need here to specify a different database or copy content, because `idb` does already have
## the required table and is expected to be read-write
idb <- insertIons(idb, ions)

I agree that this workflow is not that intuitive - because we're changing from a CompDb to a IonDb with the insertIons call. Maybe we should think of an alternative @andreavicini ?

from compounddb.

jorainer avatar jorainer commented on August 17, 2024

What about: insertIons is only defined for IonDb objects? The user would need to create first a IonDb database/object with the IonDb constructor function:

icon <- dbConnect(SQLite(), "my_ion_db.sqlite")
idb <- IonDb(dbcon = icon, CompDb = cdb)

A call like the one above is supposed to copy all tables from the CompDb over to dbcon and create in addition the ms_ion table and return the IonDb object with the connection to the new database (dbcon). If CompDb is missing the specified database connection is supposed to be for a database containing already the tables needed for an IonDb.

From here on insertIons could be called to insert ions in the new database.

Would that be a better workflow? @andreavicini what do you think?

from compounddb.

andreavicini avatar andreavicini commented on August 17, 2024

I like this second approach and maybe it's a bit clearer. I'm not sure if I understood what you mean in the case CompDb is missing. Should it have like empty tables for each of the required tables?

from compounddb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.