Skip to content

Commit

Permalink
add rna_alignment/rna_align_fetch_cm.py rna_align_fetch_seed.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagnus committed Nov 21, 2024
1 parent 2eab220 commit ce789e9
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
49 changes: 49 additions & 0 deletions rna_tools/tools/rna_alignment/rna_align_fetch_cm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
"""
from __future__ import print_function
import argparse
from icecream import ic
import sys
ic.configureOutput(outputFunction=lambda *a: print(*a, file=sys.stderr))
ic.configureOutput(prefix='> ')
import requests


def get_parser():
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)

#parser.add_argument('-', "--", help="", default="")

parser.add_argument("-v", "--verbose",
action="store_true", help="be verbose")
parser.add_argument("family", help="", default="", nargs='+')
return parser


if __name__ == '__main__':
parser = get_parser()
args = parser.parse_args()

if list != type(args.family):
args.family = [args.family]

for family in args.family:

# URL of the Rfam seed alignment
url = f"https://rfam.org/family/{family}/cm"

# Output file name
output_file = f"{family}.cm"

# Download the file
response = requests.get(url)
if response.status_code == 200:
with open(output_file, "wb") as f:
f.write(response.content)
print(f"Downloaded model saved as {output_file}")
else:
print(f"Failed to download. Status code: {response.status_code}")
49 changes: 49 additions & 0 deletions rna_tools/tools/rna_alignment/rna_align_fetch_seed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
"""
from __future__ import print_function
import argparse
from icecream import ic
import sys
ic.configureOutput(outputFunction=lambda *a: print(*a, file=sys.stderr))
ic.configureOutput(prefix='> ')
import requests


def get_parser():
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)

#parser.add_argument('-', "--", help="", default="")

parser.add_argument("-v", "--verbose",
action="store_true", help="be verbose")
parser.add_argument("family", help="", default="", nargs='+')
return parser


if __name__ == '__main__':
parser = get_parser()
args = parser.parse_args()

if list != type(args.family):
args.family = [args.family]

for family in args.family:

# URL of the Rfam seed alignment
url = f"https://rfam.org/family/{family}/alignment/fastau"

# Output file name
output_file = f"{family}.seed.sto"

# Download the file
response = requests.get(url)
if response.status_code == 200:
with open(output_file, "wb") as f:
f.write(response.content)
print(f"Downloaded seed alignment saved as {output_file}")
else:
print(f"Failed to download. Status code: {response.status_code}")
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
'rna_tools/tools/rna_alignment/rna_align_find_core.py',
'rna_tools/tools/rna_alignment/rna_align_get_ss_from_stk.py',
'rna_tools/tools/rna_alignment/rna_align_seq_to_alignment.py',
'rna_tools/tools/rna_alignment/rna_align_fetch_seed.py',
'rna_tools/tools/rna_alignment/rna_align_fetch_cm.py',
'rna_tools/tools/rna_alignment/utils/rna_alignment_get_species.py',
'rna_tools/tools/rna_alignment/utils/rna_alignment_process_id.py',
'rna_tools/tools/rna_alignment/utils/rna_alignment_r2r.py',
Expand Down

0 comments on commit ce789e9

Please sign in to comment.