Passed
Push — master ( 24af79...dfabdb )
by Marcin
06:15 queued 22s
created

build.rna_tools.tools.rna_alignment.rna_align_fetch_seed   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 46 %

Importance

Changes 0
Metric Value
eloc 29
dl 23
loc 50
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_parser() 0 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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__':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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