Commit f469ecb8 by Mustafa Tekpinar

Changed default.conf file copy process from bash to more Pythonic way.

parent b20bee53
...@@ -127,7 +127,7 @@ def minMaxNormalization(data): ...@@ -127,7 +127,7 @@ def minMaxNormalization(data):
# Run JET to compute TJET values # Run JET to compute TJET values
def launchJET(prot, retMet, bFile, fFile, pdbfile, chains, n, N, nl): def launchJET(prot, retMet, bFile, fFile, pdbfile, chains, n, N, nl):
""" """
Call JET2 and produce prot+"_jet.res" file. Call JET2 and produce prot+"_jet.res" file.
prot+"_jet.res" will be used in the following steps (in launchPred) prot+"_jet.res" will be used in the following steps (in launchPred)
...@@ -168,102 +168,107 @@ def launchJET(prot, retMet, bFile, fFile, pdbfile, chains, n, N, nl): ...@@ -168,102 +168,107 @@ def launchJET(prot, retMet, bFile, fFile, pdbfile, chains, n, N, nl):
Returns Returns
------- -------
Nothing Nothing
""" """
chainID = chains[0] chainID = chains[0]
#TODO: Remove Bash dependency here. Make the copying process in Python #TODO: Remove Bash dependency here. Make the copying process in Python
subprocess.call("cp $ESGEMME_PATH/default.conf .",shell=True) #subprocess.call("cp $ESGEMME_PATH/default.conf .",shell=True)
esgemme_path = os.path.expandvars ('$ESGEMME_PATH')
shutil.copy2(os.path.join(esgemme_path, "default.conf"), os.getcwd())
if retMet=="input": if retMet=="input":
if bFile!='': if bFile!='':
#TODO: I think these two lines must be here as well but I am not sure. #TODO: I think these two lines must be here as well but I am not sure.
# print(N) # print(N)
# editConfJETpython(N) # editConfJETpython(N)
if(bFile == prot+"_"+chainID+".psiblast"): if(bFile == prot+"_"+chainID+".psiblast"):
shutil.copy2(bFile, bFile+".orig") shutil.copy2(bFile, bFile+".orig")
shutil.copy2(bFile+".orig ", prot+"_"+chainID+".psiblast") shutil.copy2(bFile+".orig ", prot+"_"+chainID+".psiblast")
else: else:
shutil.copy2(bFile+" ", prot+"_"+chainID+".psiblast") shutil.copy2(bFile+" ", prot+"_"+chainID+".psiblast")
if(pdbfile == None):
jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\ if(pdbfile == None):
jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\
prot+".pdb -o `pwd` -p J -r input -b "+prot+"_"+chainID+".psiblast -d chain -n "+n+" > "+prot+".out" prot+".pdb -o `pwd` -p J -r input -b "+prot+"_"+chainID+".psiblast -d chain -n "+n+" > "+prot+".out"
else: else:
# jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\ # jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\
# prot+".pdb -o `pwd` -p AVJ -r input -b "+prot+"_"+chainID+".psiblast -d chain -n "+n+" > "+prot+".out" # prot+".pdb -o `pwd` -p AVJ -r input -b "+prot+"_"+chainID+".psiblast -d chain -n "+n+" > "+prot+".out"
jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\ jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\
prot+".pdb -o `pwd` -p AVJCG -r input -f "+prot+"_"+chainID+".psiblast -d chain -n "+n+" -a 5"+" > "+prot+".out" prot+".pdb -o `pwd` -p AVJCG -r input -f "+prot+"_"+chainID+".psiblast -d chain -n "+n+" -a 5"+" > "+prot+".out"
#One can also add: -g 'trace,pc,cv,clusters,axs' #One can also add: -g 'trace,pc,cv,clusters,axs'
else: else:
print(N) print(N)
editConfJETpython(N) editConfJETpython(N)
if(fFile == prot+"_"+chainID+".fasta"): if(fFile == prot+"_"+chainID+".fasta"):
shutil.copy2(fFile, fFile+".orig") shutil.copy2(fFile, fFile+".orig")
#I think this subprocess call causes overwriting of the fasta file. #I think this subprocess call causes overwriting of the fasta file.
#subprocess.call("cp "+fFile+" "+prot+"_"+chainID+".fasta",shell=True) #subprocess.call("cp "+fFile+" "+prot+"_"+chainID+".fasta",shell=True)
grpcmd="grep -m "+str(int(N)+1)+" -A "+str(nl)+" '^>' "+fFile+".orig > "+prot+"_"+chainID+".fasta" grpcmd="grep -m "+str(int(N)+1)+" -A "+str(nl)+" '^>' "+fFile+".orig > "+prot+"_"+chainID+".fasta"
else: else:
#subprocess.call("cp "+fFile+" "+prot+"_"+chainID+".fasta",shell=True) #subprocess.call("cp "+fFile+" "+prot+"_"+chainID+".fasta",shell=True)
grpcmd="grep -m "+str(int(N)+1)+" -A "+str(nl)+" '^>' "+fFile+" > "+prot+"_"+chainID+".fasta" grpcmd="grep -m "+str(int(N)+1)+" -A "+str(nl)+" '^>' "+fFile+" > "+prot+"_"+chainID+".fasta"
print("\nRunning:\n"+grpcmd) print("\nRunning:\n"+grpcmd)
subprocess.call(grpcmd,shell=True) subprocess.call(grpcmd,shell=True)
if(pdbfile == None): if(pdbfile == None):
jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\ jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\
prot+".pdb -o `pwd` -p J -r input -f "+prot+"_"+chainID+".fasta -d chain -n "+n+" > "+prot+".out" prot+".pdb -o `pwd` -p J -r input -f "+prot+"_"+chainID+".fasta -d chain -n "+n+" > "+prot+".out"
print("\nRunning command:\n"+jetcmd) print("\nRunning command:\n"+jetcmd)
reCode=subprocess.call(jetcmd,shell=True) reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"): if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res") os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
else: else:
# Calculate SC1 # Calculate SC1
jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\ jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\
prot+".pdb -o `pwd` -p AVJCG -r input -f "+prot+"_"+chainID+".fasta -d chain -n "+n+" -a 3"+" > "+prot+".out" prot+".pdb -o `pwd` -p AVJCG -r input -f "+prot+"_"+chainID+".fasta -d chain -n "+n+" -a 3"+" > "+prot+".out"
#One can also add: -g 'trace,pc,cv,clusters,axs' #One can also add: -g 'trace,pc,cv,clusters,axs'
print("\nRunning for SC1:\n"+jetcmd) print("\nRunning for SC1:\n"+jetcmd)
reCode=subprocess.call(jetcmd,shell=True) reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"): if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res") os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
dir_name = prot+"/" dir_name = prot+"/"
if os.path.isdir(dir_name): if os.path.isdir(dir_name):
for f in os.listdir(dir_name): for f in os.listdir(dir_name):
f_path = os.path.join(dir_name, f) f_path = os.path.join(dir_name, f)
if os.path.isfile(f_path): if os.path.isfile(f_path):
os.remove(f_path) os.remove(f_path)
os.rmdir(dir_name) os.rmdir(dir_name)
else: else:
if(pdbfile == None): if(pdbfile == None):
jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\ jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\
prot+".pdb -o `pwd` -p J -r "+retMet+" -d chain -n "+n+" > "+prot+".out" prot+".pdb -o `pwd` -p J -r "+retMet+" -d chain -n "+n+" > "+prot+".out"
else: else:
# jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\ # jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\
# prot+".pdb -o `pwd` -p AVJ -r "+retMet+" -d chain -n "+n+" > "+prot+".out" # prot+".pdb -o `pwd` -p AVJ -r "+retMet+" -d chain -n "+n+" > "+prot+".out"
jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\ jetcmd = "java -Xmx4096m -cp $JET2_PATH:$JET2_PATH/jet/extLibs/vecmath.jar jet.JET -c default.conf -i "+\
prot+".pdb -o `pwd` -p AVJCG -r "+retMet+" -d chain -n "+n+" -a 5"+" > "+prot+".out" prot+".pdb -o `pwd` -p AVJCG -r "+retMet+" -d chain -n "+n+" -a 5"+" > "+prot+".out"
reCode=subprocess.call(jetcmd,shell=True) reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"): if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res") os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
dir_name = prot+"/" dir_name = prot+"/"
if os.path.isdir(dir_name): if os.path.isdir(dir_name):
for f in os.listdir(dir_name): for f in os.listdir(dir_name):
f_path = os.path.join(dir_name, f) f_path = os.path.join(dir_name, f)
if os.path.isfile(f_path): if os.path.isfile(f_path):
os.remove(f_path) os.remove(f_path)
os.rmdir(dir_name) os.rmdir(dir_name)
# print("\nRunning:\n"+jetcmd) # print("\nRunning:\n"+jetcmd)
# reCode=subprocess.call(jetcmd,shell=True) # reCode=subprocess.call(jetcmd,shell=True)
# if os.path.isfile(prot+"/"+prot+"_jet.res"): # if os.path.isfile(prot+"/"+prot+"_jet.res"):
# os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res") # os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
return(reCode) return(reCode)
# Run Rscript to compute predictions # Run Rscript to compute predictions
def launchPred(prot,inAli,mutFile, normWeightMode, alphabet): def launchPred(prot,inAli,mutFile, normWeightMode, alphabet):
...@@ -654,7 +659,7 @@ def check_argument_groups(parser, arg_dict, group, argument): ...@@ -654,7 +659,7 @@ def check_argument_groups(parser, arg_dict, group, argument):
group_name = group.replace("-", "") group_name = group.replace("-", "")
if arg_dict[group_name]=="input": if arg_dict[group_name]=="input":
if c!=1: if c!=1:
parser.error("esgemme requires " + str(argument) + \ parser.error("esgemme requires " + str(argument) + \
" if " + group + " is set to input.") " if " + group + " is set to input.")
else: else:
if c>0: if c>0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment