#!/usr/bin/env python import os import sys import argparse doc=''' Please provide a valid path for saving the TACOS\n "Usage:\n" ./download_lib.py -libdir libdir\n ==================================== Mandatory arguments:\n -libdir template_library_directory (full path for saving the library files, such as /home/liuzi/ITLIB) ''' def download_lib(libdir): """ """ lib=['BlastPDB', 'chains', 'CNT', 'cothLibrary', 'DEP', 'dotProfiles', 'hhsearchLibrary', 'MTX', 'PDB', 'PDBall', 'springLibrary', 'stride', 'summary', 'nr' ] #downloading for line in lib: cmd = ['cd ',libdir+';','wget -o log -c ',\ 'https://zhanglab.dcmb.med.umich.edu/TACOS/download/library/'+line+'.tar.bz2'] if os.system(' '.join(cmd))==0: if os.system('cd '+libdir+';'+'tar -xvf '+line+'.tar.bz2')==0: if os.system('cd '+libdir+';'+'rm -r '+line+'.tar.bz2')!=0: print('System call failed for removing: '+line+'.tar.bz2\n') else: print('System call failed for decompressing: '+line+'.tar.bz2\n') else: print('System call failed for downloading: '+line+'.tar.bz2\n') cmd=['cd ',libdir+';','wget -o log -c ',\ 'https://zhanglab.dcmb.med.umich.edu/TACOS/download/library/uniprot20_2016_02.tgz'] if os.system(' '.join(cmd))==0: if os.system('cd '+libdir+';'+'tar -zxvf uniprot20_2016_02.tgz')==0: if os.system('cd '+libdir+';'+'rm -r uniprot20_2016_02.tgz')!=0: print('System call failed for removing: uniprot20_2016_02.tgz\n') else: print('System call failed for decompressing: uniprot20_2016_02.tgz\n') else: print('System call failed for downloading: uniprot20_2016_02.tgz\n') def ParseCommandLine(): """ """ parser = argparse.ArgumentParser(description=doc,formatter_class=argparse.RawDescriptionHelpFormatter) arguments = parser.add_argument_group(title="Arguments") libDirHelp = "library directory" arguments.add_argument('-libdir',action="store",required=True,help=libDirHelp) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args if __name__=="__main__": args = ParseCommandLine() libraryDirectory = args.libdir download_lib(libraryDirectory)