bgruening / galaxy_ie_helpers

Helper scripts to work with Galaxy's Interactive Environments
MIT License
0 stars 6 forks source link

Get user history #5

Closed ValentinChCloud closed 6 years ago

ValentinChCloud commented 6 years ago

Hello Björn, I take this opportunity (#4) to propose a function Actually I use this to get the user history ( not a specific dataset). I think it could be useful in case where you want to get the list of all datasets and their names ( and choose only csv,txt etc..) , to display it to the user, and (this is the point) to display it on client side to have a dropdown button for example . image

There is the R function to get the dataset and parse for only csv file_type.

gx_get_user_history <- function( history_id="None"){
    library('rPython')
    python.load("/usr/local/bin/get_user_history.py")
    x <- python.call("user_history",history_id)
    v<-list()
    l=length(x)
    for (y in 1:l) {
        if(is.null(x[[y]])) { 
            print("nothing to see")
        }else{
            if(x[[y]]$'extension' == 'csv'){
                name<-paste(x[[y]]$'hid',x[[y]]$'name')
                id<-unname(x[[y]]$'hid')
                v[[name]]<-id
            }
        }
     }

 return v
}

It's an shiny use case example :

Once you get v as a named list, you can easely display it as show above. When the user click on the name of his dataset, in fact this is the hid wil be used to get the dataset.

ValentinChCloud commented 6 years ago

Yes, we can do this on the R side, but the function python.call of rPython library, will return :

On the R side it could look like

library('rPython')
python.load("/usr/local/bin/get_user_history.py")
x <- python.call("user_history",history_id)
v<-list()

# If the first element is not a list, it's mean only one dataset

if(is.list(x[[1]]) == FALSE) {
    if(x$'extension' == 'csv'){
                name<-paste(x$'hid',x$'name')
                id<-unname(x$'hid')
                v[[name]]<-id
    }
}else{
    l=length(x)
    for (y in 1:l){
        if(x[[y]]$'extension' == 'csv'){
                name<-paste(x[[y]]$'hid',x[[y]]$'name')
                id<-unname(x[[y]]$'hid')
                v[[name]]<-id
            }
     }
}

This is a bit heavy, but it's imposed by the fact R doesn't handle dictionnary objet as Python (mentioned there

I guess you right, I shouldn't have modified the python function to suit R problems, the function has to be the most flexible possible.

ValentinChCloud commented 6 years ago

Hello @bgruening, I have noticed this PR is still open , may be it can be merged if it's ok for you?

bgruening commented 6 years ago

Sorry, forgot about that :(

bgruening commented 6 years ago

Thanks! @erasche is working on a new awesome concept of mounting in entire histories during container start, so this will also make your life easier we hope!