Passed
Push — master ( a47e0a...19735b )
by Marcin
04:27
created

automatix.get_parser()   A

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nop 0
dl 13
loc 13
rs 9.85
c 0
b 0
f 0
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
"""
4
/home/magnus/rna-evo-malibu/ade # run here not up
5
"""
6
from __future__ import print_function
7
8
import argparse
9
import os
10
import glob
11
12
13 View Code Duplication
def get_parser():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14
    parser = argparse.ArgumentParser(
15
        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
16
17
    parser.add_argument('-d', "--dryrun",
18
                        action="store_true", help="dry run", default=False)
19
20
    parser.add_argument('-p', '--path', help="", default='')
21
    parser.add_argument('-c', '--case', help="only one case, for test", default="*")
22
    parser.add_argument('-e', '--exe', help="only one case, for test")
23
    parser.add_argument("-v", "--verbose",
24
                        action="store_true", help="be verbose")
25
    return parser
26
27
def exe(cmd, dryrun=False):
28
    print(cmd)
29
    if not dryrun: os.system(cmd)
30
31
if __name__ == '__main__':
32
    parser = get_parser()
33
    args = parser.parse_args()
34
35
    if args.path:
36
        os.chdir(args.path)
37
    root = os.getcwd()
38
    cases = glob.glob(args.case)# '*')
39
    for c in cases:
40
        print('Case: ', c)
41
        # mode only for a specific case
42
        #if args.case: # only if this is used
43
        #     if c != args.case:
44
        #        print('!!! skip ' + c + '!!!')
45
        #        continue
46
47
        # if not break ed, use this
48
        if os.path.isdir(c):
49
            print ('Inside %s' % c)
50
            os.chdir(c) # go inside a folder
51
            if args.exe:
52
                exe(args.exe)
53
            #subcases = glob.glob('*.fa')
54
            #for sc in subcases:
55
            ## for i in [1000]: #
56
            ##     exe('rm *min.out.*.pdb', dryrun)
57
            ##     exe('mkdir %s_top%i' % (c, i), dryrun)
58
            ##     exe('extract_lowscore_decoys.py *min.out %i' % (i), dryrun)
59
            ##     exe('mv -v *min.out.*.pdb %s_top%i' % (c, i), dryrun)
60
            ## os.chdir(root)
61