Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pangolin: Add database usage options #3620

Merged
merged 8 commits into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tools/pangolin/fetch_latest_pangolearn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python

import json
import os
import tarfile

# rely on the fact that pangolin itself uses the requests module
import requests

response = requests.get(
"https://api.github.com/repos/cov-lineages/pangoLEARN/releases/latest"
)
if response.status_code == 200:
details = json.loads(response.text)
response = requests.get(details["tarball_url"])
if response.status_code == 200:
open("pangolearn.tgz", "wb").write(response.content)
tf = tarfile.open("pangolearn.tgz")
pl_path = tf.next().name
tf.extractall()
os.rename(pl_path + "/pangoLEARN", "datadir")
else:
response.raise_for_status()
else:
response.raise_for_status()
36 changes: 36 additions & 0 deletions tools/pangolin/pangolin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
<requirement type="package" version="0.22.0">csvtk</requirement>
</requirements>
<command detect_errors="exit_code"><![CDATA[
#if str($db.source) == "download"
python '$__tool_directory__/fetch_latest_pangolearn.py' &&
#else if str($db.source) == "builtin"
ln -s $db.db_release.path datadir
#end if
pangolin
--threads \${GALAXY_SLOTS:-1}
#if str($db.source) == "download" or str($db.source) == "builtin"
--datadir 'datadir'
#end if
$alignment
--outfile report.csv
--max-ambig $max_ambig
Expand All @@ -28,6 +36,26 @@
value="0.5" min="0" max="1" help="Maximum proportion of Ns allowed for pangolin to attempt assignment" />
<param argument="--min-length" type="integer" label="Minimum query length allowed"
value="10000" min="0" help="Minimum query length allowed for pangolin to attempt assignment"/>
<conditional name="db">
<param type="select" name="source" label="pangoLEARN source" help="Where to find the pangoLEARN database">
<option value="download">Download latest from web</option>
<option value="builtin">Use database from Galaxy server</option>
<option value="default">Use default database built in to pangolin (not recommended)</option>
</param>
<when value="download">
</when>
<when value="builtin">
<param name="db_release" label="pangoLEARN release" type="select">
<options from_data_table="pangolearn">
<column name="value" index="0"/>
<column name="description" index="1"/>
<filter type="sort_by" column="0"/>
</options>
</param>
</when>
<when value="default">
</when>
</conditional>
</inputs>
<outputs>
<data name="output1" format="tabular" label="pangolin on ${on_string}">
Expand All @@ -42,11 +70,19 @@
<tests>
<test expect_num_outputs="1">
<param name="input1" value="test1.fasta"/>
<conditional name="db">
<!-- use builtin pangoLEARN db "default" to ensure consistent test results -->
<param name="source" value="default" />
</conditional>
<output name="output1" file="result1.tsv" ftype="tabular" />
</test>
<test expect_num_outputs="2">
<param name="alignment" value="--alignment" />
<param name="input1" value="test1.fasta" />
<conditional name="db">
<!-- use builtin pangoLEARN db "default" to ensure consistent test results -->
<param name="source" value="default" />
</conditional>
<output name="output1" file="result1.tsv" ftype="tabular" />
<output name="align1" file="aln1.fasta" ftype="fasta" />
</test>
Expand Down
2 changes: 1 addition & 1 deletion tools/pangolin/test-data/result1.tsv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Consensus_EB232-crude-prep_S297.primertrimmed.consensus_threshold_0.75_quality_20 B.1.1 1.0 2021-04-01 passed_qc
Consensus_EB232-crude-prep_S297.primertrimmed.consensus_threshold_0.75_quality_20 B.1.1 1.0 2021-04-14 passed_qc