|
1
|
|
|
#!/usr/bin/env python |
|
2
|
|
|
# -*- coding: utf-8 -*- |
|
3
|
|
|
""" |
|
4
|
|
|
|
|
5
|
|
|
""" |
|
6
|
|
|
from __future__ import print_function |
|
7
|
|
|
import argparse |
|
8
|
|
|
from icecream import ic |
|
9
|
|
|
import sys |
|
10
|
|
|
ic.configureOutput(outputFunction=lambda *a: print(*a, file=sys.stderr)) |
|
11
|
|
|
ic.configureOutput(prefix='> ') |
|
12
|
|
|
import requests |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
def get_parser(): |
|
16
|
|
|
parser = argparse.ArgumentParser( |
|
17
|
|
|
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) |
|
18
|
|
|
|
|
19
|
|
|
#parser.add_argument('-', "--", help="", default="") |
|
20
|
|
|
|
|
21
|
|
|
parser.add_argument("-v", "--verbose", |
|
22
|
|
|
action="store_true", help="be verbose") |
|
23
|
|
|
parser.add_argument("family", help="", default="", nargs='+') |
|
24
|
|
|
return parser |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
View Code Duplication |
if __name__ == '__main__': |
|
|
|
|
|
|
28
|
|
|
parser = get_parser() |
|
29
|
|
|
args = parser.parse_args() |
|
30
|
|
|
|
|
31
|
|
|
if list != type(args.family): |
|
32
|
|
|
args.family = [args.family] |
|
33
|
|
|
|
|
34
|
|
|
for family in args.family: |
|
35
|
|
|
|
|
36
|
|
|
# URL of the Rfam seed alignment |
|
37
|
|
|
url = f"https://rfam.org/family/{family}/alignment/fastau" |
|
38
|
|
|
|
|
39
|
|
|
# Output file name |
|
40
|
|
|
output_file = f"{family}.seed.sto" |
|
41
|
|
|
|
|
42
|
|
|
# Download the file |
|
43
|
|
|
response = requests.get(url) |
|
44
|
|
|
if response.status_code == 200: |
|
45
|
|
|
with open(output_file, "wb") as f: |
|
46
|
|
|
f.write(response.content) |
|
47
|
|
|
print(f"Downloaded seed alignment saved as {output_file}") |
|
48
|
|
|
else: |
|
49
|
|
|
print(f"Failed to download. Status code: {response.status_code}") |
|
50
|
|
|
|