view ega_download_streamer.xml @ 9:6d0453b21b1c draft

planemo upload for repository https://github.com/ErasmusMC-Bioinformatics/ega_client_galaxy_wrapper commit f0c50d449bdbd88fc32d725e6c9503a03853da7f-dirty
author yhoogstrate
date Tue, 21 Jun 2016 09:46:28 -0400
parents 258bef815327
children
line wrap: on
line source

<tool id="ega_download_streamer" name="EGA Download streamer" version="2.1.6.g0">
    <description>data from the European Genome-phenome Archive in a secure manner</description>
    <requirements>
        <requirement type="package" version="2.1.6">EGA_download_streamer</requirement>
    </requirements>
    <stdio>
        <!-- Anything other than zero is an error -->
        <regex match="Login failed" source="both" level="fatal"/>
        <regex match="error:" source="both" level="fatal"/>
        <exit_code range="1:" />
        <exit_code range=":-1" />
    </stdio>
    <version_command>java -jar $JAVA_JAR_PATH"/EgaDemoClient.jar" -version | grep -i Version | grep -v -i new</version_command>
    <command><![CDATA[
        #import random
        #import string
        
        #set $encryption_key = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(2048))
        #set $random_request_uid = 'request_'+str($ega_file_identifier)+'_'+''.join(random.SystemRandom().choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(64))
        
        echo \$user > credentials.txt &&
        echo \$pass >> credentials.txt &&
        
        echo "Creating an encryption request at server:" && 
        
        if java -jar
            "\$JAVA_JAR_PATH/EgaDemoClient.jar"
            -pf "credentials.txt"
            -rf "$ega_file_identifier"
            -re "$encryption_key"
            -label "${random_request_uid}" | grep -v "Login failed" > request.log ; then
            
            cat request.log && 
            echo "" && 
            echo "" && 
            echo "" && 
            echo "Downloading request:" &&
            
            if java -jar
                "\$JAVA_JAR_PATH/EgaDemoClient.jar"
                -pf "credentials.txt"
                -dr "${random_request_uid}"
                -nt 7 > download.log ; then
                
                cat download.log &&
                
                ## Commands below may fail if authentication was not a success
                ENCRYPTED_FILES_NAME=\$(grep -oE "Completed Download Target:[ ]+(.*?)\.cip" download.log | sed -r "s/^Completed Download Target:[ ]+//" ) && 
                DECRYPTED_FILES_NAME=\${ENCRYPTED_FILES_NAME%.cip} && 
                
                echo "" && 
                echo "" && 
                echo "" && 
                echo "Decrpyting \$ENCRYPTED_FILES_NAME to \$DECRYPTED_FILES_NAME:" && 
                
                if java -jar
                        "\$JAVA_JAR_PATH/EgaDemoClient.jar"
                        -pf credentials.txt
                        -dc "\$ENCRYPTED_FILES_NAME"
                        -dck "$encryption_key" > decrypt.log ; then
                    
                    cat decrypt.log &&
                    
                    if file --mime-type "\$DECRYPTED_FILES_NAME" | grep -q /gzip\$; then
                    
                        echo "" && 
                        echo "" && 
                        echo "" && 
                        echo "Unpacking because it is an archive" &&
                        gunzip -cf "\$DECRYPTED_FILES_NAME" > "$output" ;
                        
                    else
                        mv "\$DECRYPTED_FILES_NAME" "$output" ;
                    fi ;
                    
                else
                    echo "Error: decrypting failed:" 1>&2 &&
                    cat decrypt.log &&
                    exit 1 ; 
                fi ;
            
            else
                echo "Error: downloading the request failed:" 1>&2 &&
                cat download.log &&
                exit 1 ; 
            fi ;
        
        else
            echo "Error: making the request failed" 1>&2 &&
            cat request.log && 
            exit 1 ;
        fi &&
        
        
        echo "Cleaning up credentials" && 
        echo "overwriten" > "credentials.txt" && 
        rm "credentials.txt"
    ]]></command>
    <inputs>
        <param name="ega_file_identifier" type="text" value="" label="Identifier of the file in EGA" />
    </inputs>
    <outputs>
        <data name="output" auto_format="true" label="${tool.name} on ${ega_file_identifier}" />
    </outputs>
    <tests>
        <test>
            <param name="ega_file_identifier" value="EGAF00001059069" />
            
            <output name="output" file="EGAF00001059069.fastq" />
        </test>
    </tests>
    
    <help>
**What it does**

Individual files or whole datasets may be downloaded from European Genome-phenome Archive (EGA) in a secure manner by first placing a download request and then downloading the file/s associated with the request. All files are automatically encrypted prior to streaming and shall be decrypted using the streamer after downloading has completed. 

**How to use**

When you load the tool in galaxy, the user should provide the corresponding EGA file identifier (e.g. EGAF00001059069).

**Configuration**

The admin has to configure a generic account, further described in the README: https://raw.githubusercontent.com/ErasmusMC-Bioinformatics/ega_client_galaxy_wrapper/master/README.rst

https://www.ebi.ac.uk/ega/about/your_EGA_account/download_streaming_client
    </help>
    
    <citations>
    </citations>
</tool>