Skip to content
126 changes: 77 additions & 49 deletions tools/pyega3/pyega3.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
<tool id="pyega3" name="EGA Download Client" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="21.01" >
<tool id="pyega3" name="EGA Download Client" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="25.1" >
<macros>
<token name="@TOOL_VERSION@">5.0.2</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@VERSION_SUFFIX@">1</token>
</macros>
<requirements>
<requirement type="package" version="@TOOL_VERSION@">pyega3</requirement>
<credentials name="ega_credentials" version="1.0" label="EGA (European Genome Archive) credentials" description="Credentials for accessing EGA">
<secret name="ega_usename" inject_as_env="EGA_USERNAME" optional="false" label="EGA account username"/>
<secret name="ega_password" inject_as_env="EGA_PASSWORD" optional="false" label="EGA account password"/>
</credentials>
</requirements>
<version_command><![CDATA[
pyega3 -v |& grep version | cut -d" " -f 10
]]></version_command>
<command detect_errors="exit_code"><![CDATA[
#set $username = $__user__.extra_preferences.get('ega_account|username', "")
#if $username == "":
#set $username = "[email protected] (default user)"
#if $test_boolean
echo '{"username":"[email protected]","password":"egarocks"}' > credentials.json &&
#else
echo '{"username":"'\$EGA_USERNAME'","password":"'\$EGA_PASSWORD'"}' > credentials.json &&
#end if
echo "Running as user: $username. Set your credentials via: User -> Preferences -> Manage Information" &&

#if $action.action_type == "list_datasets"
pyega3 -cf '$credentials'
pyega3 -cf credentials.json
datasets
#elif $action.action_type == "list_dataset_files"
pyega3 -cf '$credentials'
pyega3 -cf credentials.json
files '$action.dataset_id'
&&

Expand All @@ -31,7 +35,7 @@
grep EGAF pyega3_output.log | sed -e 's/^\[.*\]\s\+//g' | sed 's/\s\+/\t/g' >> '$dataset_file_list'

#elif $action.action_type == "download_file"
pyega3 -c \${PYEGA_CONNECTIONS:-30} -cf '$credentials'
pyega3 -c \${PYEGA_CONNECTIONS:-30} -cf credentials.json
fetch '$action.file_id'
--max-retries 10
#if $action.range.reference_name
Expand All @@ -58,7 +62,7 @@
&&
echo 'Downloading $f'
&&
pyega3 -c \${PYEGA_CONNECTIONS:-30} -cf '$credentials'
pyega3 -c \${PYEGA_CONNECTIONS:-30} -cf credentials.json
fetch '$f'
--max-retries 10
#if $action.range.reference_name
Expand All @@ -72,26 +76,13 @@
#end if
--output-dir downloads
#end for
&& for vcf in \$(ls downloads/**/*vcf.gz); do mv "\${vcf}" "\${vcf:0:-6}vcf_bgzip"; done ## renaming vcf.gz files to vcf_bgzip to recognize format
&& if ls downloads/**/*vcf.gz >/dev/null 2>&1; then for vcf in downloads/**/*vcf.gz; do mv "\${vcf}" "\${vcf:0:-6}vcf_bgzip"; done; fi ## renaming vcf.gz files to vcf_bgzip to recognize format
&& rm -f downloads/**/*.md5 ## checksum validation already performed by pyEGA, clean up downloads folder

#end if
]]></command>
<configfiles>
<configfile name="credentials"><![CDATA[
#set $password = $__user__.extra_preferences.get('ega_account|password', "")
#set $username = $__user__.extra_preferences.get('ega_account|username', "")
#if $username == "" or $password == "":
#set $username = "[email protected]"
#set $password = "egarocks"
#end if
{
"username": "$username",
"password": "$password"
}
]]></configfile>
</configfiles>
<inputs>
<param name="test_boolean" type="boolean" checked="false" hidden="true"/>
<conditional name="action">
<param name="action_type" type="select" label="What would you like to do?">
<option value="list_datasets"> List my authorized datasets </option>
Expand Down Expand Up @@ -146,9 +137,21 @@
</collection>
</outputs>
<tests>
<!-- testing credentials feature -->
<test expect_num_outputs="0">
<conditional name="action">
<param name="action_type" value="list_datasets"/>
</conditional>
<assert_stderr>
<has_text text="Invalid username, password or secret key - please check and retry. If problem persists contact helpdesk on [email protected]"/>
</assert_stderr>
</test>
<!-- list datasets with default credentials -->
<test expect_num_outputs="1">
<param name="action_type" value="list_datasets"/>
<param name="test_boolean" value="true"/>
<conditional name="action">
<param name="action_type" value="list_datasets"/>
</conditional>
<output name="authorized_datasets" ftype="txt">
<assert_contents>
<has_text text="pyEGA3 - EGA python client version @TOOL_VERSION@"/>
Expand All @@ -158,8 +161,11 @@
</test>
<!-- list dataset files with default credentials, and request a log output file -->
<test expect_num_outputs="2">
<param name="action_type" value="list_dataset_files"/>
<param name="dataset_id" value="EGAD00001003338"/>
<param name="test_boolean" value="true"/>
<conditional name="action">
<param name="action_type" value="list_dataset_files"/>
<param name="dataset_id" value="EGAD00001003338"/>
</conditional>
<param name="output_log" value="true"/>
<output name="dataset_file_list" file="filelist_EGAD00001003338.tabular"/>
<output name="logfile" ftype="txt">
Expand All @@ -172,30 +178,44 @@
</test>
<!-- download a single file -->
<test expect_num_outputs="1">
<param name="action_type" value="download_file"/>
<param name="file_id" value="EGAF00001775036"/>
<param name="test_boolean" value="true"/>
<conditional name="action">
<param name="action_type" value="download_file"/>
<param name="file_id" value="EGAF00001775036"/>
</conditional>
<output name="downloaded_file" md5="3b89b96387db5199fef6ba613f70e27c"/>
</test>
<!-- download a single vcf.gz -->
<test expect_num_outputs="1">
<param name="action_type" value="download_file"/>
<param name="file_id" value="EGAF00007243775"/>
<param name="test_boolean" value="true"/>
<conditional name="action">
<param name="action_type" value="download_file"/>
<param name="file_id" value="EGAF00007243775"/>
</conditional>
<output name="downloaded_file" md5="51cfb69bf3b9416ff425381a58c18a2b" ftype="vcf_bgzip" />
</test>
<!-- download a single bam, with genomic range specified -->
<test expect_num_outputs="1">
<param name="action_type" value="download_file"/>
<param name="file_id" value="EGAF00001753756"/>
<param name="reference_name" value="1"/>
<param name="start" value="0"/>
<param name="end" value="10000"/>
<param name="test_boolean" value="true"/>
<conditional name="action">
<param name="action_type" value="download_file"/>
<param name="file_id" value="EGAF00001753756"/>
<section name="range">
<param name="reference_name" value="1"/>
<param name="start" value="0"/>
<param name="end" value="10000"/>
</section>
</conditional>
<output name="downloaded_file" md5="4b5344ad094c2bed7787430259205098"/>
</test>
<!-- download multiple files -->
<test expect_num_outputs="1">
<param name="action_type" value="download_files"/>
<param name="id_table" value="filelist.tabular"/>
<param name="id_column" value="1"/>
<param name="test_boolean" value="true"/>
<conditional name="action">
<param name="action_type" value="download_files"/>
<param name="id_table" value="filelist.tabular"/>
<param name="id_column" value="1"/>
</conditional>
<output_collection name="downloaded_file_collection" type="list" count="2">
<element name="ENCFF000VWO.bam" md5="b8ae14d5d1f717ab17d45e8fc36946a0" />
<element name="ENCFF284YOU.bam" md5="3b89b96387db5199fef6ba613f70e27c" />
Expand All @@ -206,12 +226,17 @@
</test>
<!-- download multiple files, in combination with a genomic range -->
<test expect_num_outputs="1">
<param name="action_type" value="download_files"/>
<param name="id_table" value="filelist2.tabular"/>
<param name="id_column" value="1"/>
<param name="reference_name" value="1"/>
<param name="start" value="0"/>
<param name="end" value="10000"/>
<param name="test_boolean" value="true"/>
<conditional name="action">
<param name="action_type" value="download_files"/>
<section name="range">
<param name="start" value="0"/>
<param name="end" value="10000"/>
<param name="reference_name" value="1"/>
</section>
<param name="id_table" value="filelist2.tabular"/>
<param name="id_column" value="1"/>
</conditional>
<output_collection name="downloaded_file_collection" count="2">
<element name="NA19239_genomic_range_1_0_10000" md5="497f443830a6a3ec2e5bb5a19c4db638" />
<element name="NA19240_genomic_range_1_0_10000" md5="4b5344ad094c2bed7787430259205098" />
Expand All @@ -222,9 +247,12 @@
</test>
<!-- download multiple vcf.gz files -->
<test expect_num_outputs="1">
<param name="action_type" value="download_files"/>
<param name="id_table" value="filelist3.tabular"/>
<param name="id_column" value="1"/>
<param name="test_boolean" value="true"/>
<conditional name="action">
<param name="action_type" value="download_files"/>
<param name="id_table" value="filelist3.tabular"/>
<param name="id_column" value="1"/>
</conditional>
<output_collection name="downloaded_file_collection" type="list" count="2">
<element name="HG00408.novoBreak__256r__4.100100-10100100__7.200100-9000100" md5="51cfb69bf3b9416ff425381a58c18a2b" ftype="vcf_bgzip" />
<element name="HG01890.HGSVC__145r__1.900100-10001000__18.2001000-90001000" md5="ebad4425191a89d3e970c02190a87175" ftype="vcf_bgzip" />
Expand Down
Loading
Loading