import os, sys import random import string import argparse def randomString(stringLength=10): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(stringLength)) """ Args include pdb_list - The file with pdb id's and chains graph type - calpha, cbeta, IS, centroid, APC weight - weighted , unweighted lower cutoff - lower threshold for networks upper cutoff - upper threshold for the network or Interaction strength cutoff for IS network res_sep - The minimum separation between residues output - edgelist, centrality, global """ # setting default value lower_cutoff = "0" #allowed_values graph_type_allowed = {"calpha" :"ca", "cbeta":"cb", "IS":"sidechain","APC":"any","centroid":"centroid"} weight_allowed= {"weighted":"weighted","unweighted":"unweighted"} analysis_allowed={"edgelist":"edgelist", "centrality":"centrality", "global":"basic"} #parsing args pdb_list = sys.argv[1] graph_type = sys.argv[2] weight = sys.argv[3] lower_cutoff = sys.argv[4] upper_cutoff = sys.argv[5] res_sep = sys.argv[6] random_name = randomString(10).upper() analysis = sys.argv[7] #check if params passed are correct if graph_type not in graph_type_allowed: print("Enter valid graph type - refer to help section") sys.exit() else: graph_type = graph_type_allowed[graph_type] if weight not in weight_allowed: print("Invalid weight parameter - refer to help section") sys.exit() else: weight = weight_allowed[weight] if analysis not in analysis_allowed: print("Enter valid analysis type - refer to help section") sys.exit() else: analysis = analysis_allowed[analysis] #Running the curl command s1 = 'curl -X POST -F "pdb_list=@' + pdb_list + '" -F "graph_type=' + graph_type + '" -F "weight=' + weight + '" -F "lower_cutoff=' + lower_cutoff + '" -F "upper_cutoff=' + upper_cutoff + '" -F "res_sep=' + res_sep + '" -F "random_name=' + random_name + '" -F "output=' + analysis + '" http://bioinf.iiit.ac.in/NAPS/bulkoutput.php' s2 = "curl -X GET 'http://bioinf.iiit.ac.in/NAPS/execute_bulk.php?jobid=" + random_name + "&output=" + analysis + "&graph_type=" + graph_type + "&weight=" + weight + "&lower_cutoff=" + lower_cutoff + "&upper_cutoff=" + upper_cutoff + "&res_sep=" + res_sep + "'" s3 = "curl -o ./" + random_name + ".zip" + " http://bioinf.iiit.ac.in/NAPS/files_generated/bulkupload/" + random_name + ".zip" os.system(s1) os.system(s2) os.system(s3) print ("Downloaded output: " + random_name + ".zip") #print("\n\n")