ARIA2
aria2 is a lightweight multi-protocol & multi-source, cross platform download utility operated in command-line. It supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink.
URL: https://github.com/aria2/aria2/
Example
This wrapper can be used in the following way:
rule test_aria2:
output:
"results/file.fas.gz",
log:
"logs/aria2.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
rule test_aria2_md5:
output:
"results/file.md5.fas.gz",
log:
"logs/aria2.md5.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
md5="42aa93c5bfdba6ac09a4822a4407b572",
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
rule test_aria2_md5fileH:
input:
storage.http(
"https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/md5checksums.txt"
),
output:
"results/file.md5fileH.fas.gz",
log:
"logs/aria2.md5fileH.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
md5=parse_input(
input[0],
parser=extract_checksum,
file="GCF_000869925.1_ViralProj17181_genomic.fna.gz",
),
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
rule test_aria2_md5file:
input:
checksum="GCF_000869925.1_ViralProj17181.md5",
output:
"results/file.md5file.fas.gz",
log:
"logs/aria2.md5file.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
md5=parse_input(
input[0],
parser=extract_checksum,
file="GCF_000869925.1_ViralProj17181_genomic.fna.gz",
),
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
rule test_aria2_sha1file:
input:
checksum="GCF_000869925.1_ViralProj17181.sha-1",
output:
"results/file.sha1file.fas.gz",
log:
"logs/aria2.sha1file.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
sha1=parse_input(
input[0],
parser=extract_checksum,
file="GCF_000869925.1_ViralProj17181_genomic.fna.gz",
),
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
rule test_aria2_sha224file:
input:
checksum="GCF_000869925.1_ViralProj17181.sha-224",
output:
"results/file.sha224file.fas.gz",
log:
"logs/aria2.sha224file.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
sha224=parse_input(
input[0],
parser=extract_checksum,
file="GCF_000869925.1_ViralProj17181_genomic.fna.gz",
),
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
rule test_aria2_sha256file:
input:
checksum="GCF_000869925.1_ViralProj17181.sha-256",
output:
"results/file.sha256file.fas.gz",
log:
"logs/aria2.sha256file.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
sha256=parse_input(
input[0],
parser=extract_checksum,
file="GCF_000869925.1_ViralProj17181_genomic.fna.gz",
),
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
rule test_aria2_sha384file:
input:
checksum="GCF_000869925.1_ViralProj17181.sha-384",
output:
"results/file.sha384file.fas.gz",
log:
"logs/aria2.sha384file.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
sha384=parse_input(
input[0],
parser=extract_checksum,
file="GCF_000869925.1_ViralProj17181_genomic.fna.gz",
),
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
rule test_aria2_sha512file:
input:
checksum="GCF_000869925.1_ViralProj17181.sha-512",
output:
"results/file.sha512file.fas.gz",
log:
"logs/aria2.sha512file.log",
params:
url="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/869/925/GCF_000869925.1_ViralProj17181/GCF_000869925.1_ViralProj17181_genomic.fna.gz",
extra="--file-allocation none --retry-wait 5 --console-log-level warn --log-level notice",
sha512=parse_input(
input[0],
parser=extract_checksum,
file="GCF_000869925.1_ViralProj17181_genomic.fna.gz",
),
threads: 2
resources:
mem_mb=1024,
runtime=30,
wrapper:
"v6.2.0/utils/aria2c"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Notes
Checksum input file only supported for single-file downloads
Requires snakemake >=9.3.1
Software dependencies
aria2=1.37.0
Params
url: URL to download fromextra: Optional arguments for aria2ctype: type of hash, where type in [“sha-1”, “sha-224”, “sha-256”, “sha-384”, “sha-512”, “md5”, “adler32”]
Code
__author__ = "Filipe G. Vieira"
__copyright__ = "Copyright 2023, Filipe G. Vieira"
__license__ = "MIT"
from snakemake.shell import shell
extra = snakemake.params.get("extra", "")
for hash_function, digest in snakemake.params.items():
if hash_function in [
"sha1",
"sha224",
"sha256",
"sha384",
"sha512",
"md5",
"adler32",
]:
if hash_function.startswith("sha"):
hash_function = hash_function.replace("sha", "sha-")
extra += f" --checksum {hash_function}={digest}"
break
shell(
"aria2c"
" --max-concurrent-downloads {snakemake.threads}"
" {extra}"
" --log {snakemake.log}"
" --out {snakemake.output[0]}"
" {snakemake.params.url}"
" > /dev/null"
)