view ega_download_streamer.xml @ 4:887159f23385 draft

planemo upload for repository https://github.com/ErasmusMC-Bioinformatics/ega_client_galaxy_wrapper commit 63cc1d3eba84a01ae7e9da734ed91f5b531e4a91-dirty
author yhoogstrate
date Tue, 29 Mar 2016 06:02:22 -0400
parents 8613d02e64d3
children 8af9d199e410
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" && 
        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" && 
        
        echo "" && 
        echo "" && 
        echo "" && 
        echo "Downloading request" && 
        java -jar
            "\$JAVA_JAR_PATH/EgaDemoClient.jar"
            -pf "credentials.txt"
            -dr "${random_request_uid}"
            -nt 7 > download.log && 
        
        echo "" && 
        echo "" && 
        echo "" && 
        echo "------------------:" &&
        ls -alsh &&
        echo "---download.log---:" && 
        cat download.log &&
        echo "------------------:" &&
         
        ## 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" && 
        java -jar
            "\$JAVA_JAR_PATH/EgaDemoClient.jar"
            -pf credentials.txt
            -dc "\$ENCRYPTED_FILES_NAME"
            -dck "$encryption_key" &&
        
        if file --mime-type "\$DECRYPTED_FILES_NAME" | grep -q /gzip$; then
            echo "Unpacking as well" &&
            gunzip -cf "\$DECRYPTED_FILES_NAME" > "$output" ;
        else
            mv "\$DECRYPTED_FILES_NAME" "$output" ;
        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 must be decrypted using the streamer after download is complete. 

To download a given dataset, the user should provide the corresponding EGA file identifier (e.g. EGAF00001059069).

**Configuration**

The admin has to configure the server such that the environment variables $user and $pass are exported and reflect the credentials of the EGA account. The user and password shall not be visible to users. This can also be done in the config/jobs_conf.xml file.

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