main.py 2.49 KB
Newer Older
Rudel Fankep's avatar
main  
Rudel Fankep committed
1
#!/home/theia/conda/bin/python
Rudel Fankep's avatar
Rudel Fankep committed
2
import argparse
Rudel Fankep's avatar
prepare    
Rudel Fankep committed
3
4
import subprocess

5

Rudel Fankep's avatar
prepare    
Rudel Fankep committed
6
data={'swissprot':{'download':'./download_swissprot.sh','blast':'./blast_swissprot.sh','ghostx':'./ghostx_swissprot.sh'},'pfam':{'download':'./download_pfam.sh'}}
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def myparser():
    parser=argparse.ArgumentParser(description='Download, convert and share the data to working computer',prog='PSOT_database_maker')
    
    subparsers=parser.add_subparsers(title='Subcommands',description='Authorized Subcommands',help='Additional help')

    prepare_parser=subparsers.add_parser('prepare',help='Databank download from the Website, extraction and transformation for another Programm')
    prepare_parser.add_argument('database',help='Database which have to be prepared',type=str)
    prepare_parser.add_argument('-t','--tool',help='Programm/Tool for the post analysis',type=str,)
    prepare_parser.add_argument('-o','--output',default='./output',help='target directory for the output.Default will be a created("output") folder in the working directory',type=str)
    prepare_parser.set_defaults(func=prepare)

    upload_parser=subparsers.add_parser('upload',help='Databank copy from the local directory to the web storage')
    upload_parser.add_argument('file',help='File to be transfered from the local directory',type=str)
    upload_parser.add_argument('-d','--directory',default='s3://db_storage',help='Target directory for the file transfer into "S3". Default will be "s3://db_storage"',type=str)
    upload_parser.set_defaults(func=upload)

    download_parser=subparsers.add_parser('download',help='Datenbank copy from the web storage to the working computer')
    download_parser.add_argument('file',help='File to be transfered from "S3"',type=str)
    download_parser.add_argument('-d','--directory',default='./output',help='Target directory for the file transfer. Default will be a created folder("output) in the current working directory',type=str)
    download_parser.set_defaults(func=download)
    return parser.parse_args()
def prepare(args):

    file_down=subprocess.run([data[args.database]['download'],args.output])
Rudel Fankep's avatar
prepare    
Rudel Fankep committed
31
    if args.tool:
32
        file_tool=subprocess.run([data[args.database][args.tool],args.output])
Rudel Fankep's avatar
prepare    
Rudel Fankep committed
33
    
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def upload(args):

    file_up=subprocess.run(['./upload_db.sh',args.file,args.directory])

        

def download(args):

    file_down=subprocess.run(['./download_db.sh',args.file,args.directory])
        

def main():
    
    subprocess.run(['./make_directory.sh'])
    args=myparser()
    args.func(args)

Rudel Fankep's avatar
Rudel Fankep committed
51

52
53
if __name__=='__main__':
    main()