-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathDownload.jl
36 lines (33 loc) · 1.35 KB
/
Download.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Download Pfam
# =============
"""
It downloads a gzipped Stockholm alignment from InterPro for the Pfam family with the
given `pfamcode`.
By default, it downloads the `full` Pfam alignment. You can use the `alignment` keyword
argument to download the `seed` or the `uniprot` alignment instead. For example,
`downloadpfam("PF00069")` will download the **full alignment** for the
*PF00069 Pfam family*, while `downloadpfam("PF00069", alignment="seed")` will download the
**seed alignment** of the family.
The extension of the downloaded file is `.stockholm.gz` by default; you can change it
using the `filename` keyword argument, but the `.gz` at the end is mandatory.
"""
function downloadpfam(
pfamcode::String;
filename::String = "$pfamcode.stockholm.gz",
alignment::String = "full",
kargs...,
)
if alignment != "full" && alignment != "seed" && alignment != "uniprot"
throw(ErrorException("alignment must be \"full\", \"seed\" or \"uniprot\""))
end
endswith(filename, ".gz") || error("filename must end in .gz")
if occursin(r"^PF\d{5}$"i, pfamcode)
download_file(
"https://www.ebi.ac.uk/interpro/wwwapi/entry/pfam/$pfamcode/?annotation=alignment:$alignment&download",
filename;
kargs...,
)
else
throw(ErrorException("$pfamcode is not a correct Pfam code"))
end
end