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

rp13_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")
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('*')
39
    for c in cases:
40
        # print('Case: ', c)
41
        # mode only for a specific case
42
        os.chdir(root)  # change to run and go to another case
43
        if args.case: # only if this is used
44
            if c != args.case:
45
                if args.verbose: print('!!! skip ' + c + '!!!')
46
                continue
47
48
        # if not break ed, use this
49
        if os.path.isdir(c):
50
            print ('Inside %s' % c)
51
            os.chdir(c) # go inside a folder
52
            if args.exe:
53
                exe(args.exe)
54
            #subcases = glob.glob('*.fa')
55
            #for sc in subcases:
56
            ## for i in [1000]: #
57
            ##     exe('rm *min.out.*.pdb', dryrun)
58
            ##     exe('mkdir %s_top%i' % (c, i), dryrun)
59
            ##     exe('extract_lowscore_decoys.py *min.out %i' % (i), dryrun)
60
            ##     exe('mv -v *min.out.*.pdb %s_top%i' % (c, i), dryrun)
61
            ## os.chdir(root)
62
            malibu_folder = c.replace('_cst', 'cst').replace('farna_', '')
63
            print(c, malibu_folder)
64
            # exe('trash top100')
65
            exe('mkdir top100')
66
            exe('pwd')
67
            os.chdir('top100')  # cd top100 didn't work ?!
68
            exe('rsync -v malibu:"~/rna-evo-malibu/_rp13_Stanford/_reg_vs_cst/%s/*.pdb" . ' %  malibu_folder)
69
            exe('rm c.*pdb')
70
            exe('rm *out.1[0-9][1-9]*.pdb')
71
            exe('rm *out.1[1-9]0*.pdb')
72
            exe('rm *out.200.pdb')
73
            exe('rm p[0-9].pdb')
74
            exe('rna_pdb_toolsx.py --rpr --renumber_residues --inplace  *')
75
            os.chdir('..')
76
            exe('evox.py -c rp13')
77