Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • axa9070
    Member
    • Oct 2014
    • 11

    GeneTrail 2

    I've really started liking this tool called GeneTrail 2. There is a REST API for it and I'd like to take full advantage of it in R. There is already a client written in Python that I haven't tried using. So much of my pipelines are in R though I'd hate to have to switch.

    Using R6Class I've been able to get the bare bones of the client working:

    Code:
    ##
    # Gene Trail 2 Client class
    #
    GeneTrail2Client <- R6Class(
        'GeneTrail2Client',
        public = list(
            initialize = function(
                username, password, sessionId )
            {
                if ( !missing( username ) && !missing( password ) )
                    self$login( username, password )
                if ( !missing( sessionId ) )
                    private$sessionId <- sessionId
                else private$sessionId <-self$getSessionId()
                cat( private$sessionId, '\n' )
            },
            getAPIdoc = function()
            {
                return( self$doGet( '/api-docs' ) )
            },
            login = function( username, password )
            {
                return( self$doPost( '/user/login?username=%s&password=%s', username, password ) )
            },
            getSessionId = function()
            {
                if ( is.na( private$sessionId ) )
                    private$sessionId <- self$doGet( '/session' )[['session']]
                return( private$sessionId )
            },
            uploadGenes = function( genesFile, displayName )
            {
                cat( paste0( 'https://genetrail2.bioinf.uni-sb.de/results.html?session=', private$sessionId, '&show_all_results=true\n' ) )
                return( fromJSON( RCurl::postForm(
                    sprintf( paste0( private$GT_URL, '/upload?session=%s' ),
                        private$sessionId ),
                    file = fileUpload( genesFile ) ) ) )#, displayName = displayName ) ) )
            },
            getJobAlgorithms = function()
            {
                return( self$doGet( '/job/algorithms' ) )
            },
            getJobAlgorithmParameters = function( algorithm )
            {
                return( self$doGet( '/job/parameters/%s', algorithm ) )
            },
            startJob = function( contact )
            {
                if ( missing( contact ) )
                    return( self$doGet( '/job/start?session=%s', private$sessionId ) )
                else
                    return( self$doGet( '/job/start?session=%s&contact=%s', private$sessionId, contact ) )
            },
            setupJob = function( algorithm, ... )
            {
                return( self$doPostForm(
                    sprintf( paste0( private$GT_URL, '/job/setup/%s?session=%s' ),
                        algorithm, private$sessionId ), ... ) )
            },
            stopJob = function()
            {
                return( self$doGet( '/job/stop?session=%s', private$sessionId ) )
            },
            runGSEA = function( genes, jobName )
            {
                job <- self$uploadGenes( genes, jobName )
                return( job )
            },
            getGT_URL = function()
            {
                return( private$GT_URL )
            },
            doGet = function( endpoint, ... )
            {
                return( fromJSON( RCurl::httpGET(
                    sprintf( paste0( private$GT_URL, endpoint ), ... ),
                    httpheader = list(
                        Accept         = 'application/json',
                        `Content-type` = 'application/x-www-form-urlencoded' )
                    ) ) )
            },
            doPost = function( endpoint, ... )
            {
                return( fromJSON( RCurl::httpPOST(
                    sprintf( paste0( private$GT_URL, endpoint ), ... ),
                    httpheader = list(
                        Accept         = 'application/json',
                        `Content-type` = 'application/x-www-form-urlencoded' )
                    ) ) )
            },
            doPostForm = function( url, ... )
            {
                return( fromJSON( RCurl::postForm( url, style = 'POST', ... ) ) )
            },
            doPut = function( endpoint, content, ... )
            {
                return( fromJSON( RCurl::httpPUT(
                    sprintf( paste0( private$GT_URL, endpoint ), ... ),
                    content,
                    httpheader = list(
                        Accept         = 'application/json',
                        `Content-type` = 'application/x-www-form-urlencoded' )
                    ) ) )
            },
            api = list(
                API_DOC = '/api-docs',
                USER    = list(
                    login = '/user/login?username=%s&password=%s'
                ),
                SESSION = list(
                    get    = '/session',
                    PUTseal   = '/session/%s/seal',
                    DELETE = '/session/%s'
                ),
                UPLOAD = list(
                    uploadGenes = '/upload?session=%s&displayName=%s'
                ),
                JOB     = list(
                    getAlgorithms = '/job/algorithms',
                    getParameters = '/job/parameters/%s',
                    startJob      = '/job/start?session=%s',
                    setupJob      = '/job/setup/%s?session=%s',
                    stopJob       = '/job/stop?session=%s'
                ),
                RESOURCE = list(
                )
            )
        ),
        private = list(
            GT_URL = 'https://genetrail2.bioinf.uni-sb.de/api',
            sessionId = NA
        )
    )
    My hope is someone will eventually just create the R package. (I wish I had the ability to do so myself.) Until that happens though, is there anyone that could assist me in figuring out how to, through the API, retrieve recommended parameters. This is a feature you get through the web portal where the web applications reports: "Based on your uploaded data we recommend the following parameters." but this is something I'd like to simply be able to kick off with default parameters.

    If it helps, I've attached a POSTMAN json file with a bunch of calls to the API which is listed here with Swagger UI. (Sadly, the Swagger UI is BROKEN... the url in the api calls
    'https://genetrail2.bioinf-uni-sb.de/api/api-docs/' when it is supposed to be
    'https://genetrail2.bioinf.uni-sb.de/api/api-docs/'. smh)

    Thanks,
    Alex
    Attached Files
    Last edited by axa9070; 05-25-2016, 02:12 PM. Reason: Hard to read URLS

Latest Articles

Collapse

  • SEQadmin2
    Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
    by SEQadmin2



    Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
    ...
    Today, 11:10 AM
  • SEQadmin2
    Cancer Drug Resistance: The Lingering Barrier to Rising Survival
    by SEQadmin2



    Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

    There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
    Yesterday, 05:17 AM
  • GATTACAT
    Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
    by GATTACAT
    Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
    07-01-2026, 11:43 AM

ad_right_rmr

Collapse

News

Collapse

Topics Statistics Last Post
Started by SEQadmin2, Today, 10:04 AM
0 responses
7 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, Yesterday, 10:08 AM
0 responses
6 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 07-07-2026, 11:05 AM
0 responses
9 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 07-02-2026, 11:08 AM
0 responses
31 views
0 reactions
Last Post SEQadmin2  
Working...