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):
# Run JET to compute TJET values
def launchJET(prot, retMet, bFile, fFile, pdbfile, chains, n, N, nl):
"""
"""
Call JET2 and produce prot+"_jet.res" file.
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):
Returns
-------
Nothing
"""
"""
chainID = chains[0]
chainID = chains[0]
#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 bFile!='':
if retMet=="input":
if bFile!='':
#TODO: I think these two lines must be here as well but I am not sure.
# print(N)
# editConfJETpython(N)
if(bFile == prot+"_"+chainID+".psiblast"):
shutil.copy2(bFile, bFile+".orig")
shutil.copy2(bFile+".orig ", prot+"_"+chainID+".psiblast")
else:
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(bFile == prot+"_"+chainID+".psiblast"):
shutil.copy2(bFile, bFile+".orig")
shutil.copy2(bFile+".orig ", prot+"_"+chainID+".psiblast")
else:
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 "+\
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 "+\
# 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"
#One can also add: -g 'trace,pc,cv,clusters,axs'
else:
print(N)
editConfJETpython(N)
if(fFile == prot+"_"+chainID+".fasta"):
shutil.copy2(fFile, fFile+".orig")
#I think this subprocess call causes overwriting of the fasta file.
#subprocess.call("cp "+fFile+" "+prot+"_"+chainID+".fasta",shell=True)
grpcmd="grep -m "+str(int(N)+1)+" -A "+str(nl)+" '^>' "+fFile+".orig > "+prot+"_"+chainID+".fasta"
else:
#subprocess.call("cp "+fFile+" "+prot+"_"+chainID+".fasta",shell=True)
grpcmd="grep -m "+str(int(N)+1)+" -A "+str(nl)+" '^>' "+fFile+" > "+prot+"_"+chainID+".fasta"
else:
print(N)
editConfJETpython(N)
if(fFile == prot+"_"+chainID+".fasta"):
shutil.copy2(fFile, fFile+".orig")
#I think this subprocess call causes overwriting of the fasta file.
#subprocess.call("cp "+fFile+" "+prot+"_"+chainID+".fasta",shell=True)
grpcmd="grep -m "+str(int(N)+1)+" -A "+str(nl)+" '^>' "+fFile+".orig > "+prot+"_"+chainID+".fasta"
else:
#subprocess.call("cp "+fFile+" "+prot+"_"+chainID+".fasta",shell=True)
grpcmd="grep -m "+str(int(N)+1)+" -A "+str(nl)+" '^>' "+fFile+" > "+prot+"_"+chainID+".fasta"
print("\nRunning:\n"+grpcmd)
subprocess.call(grpcmd,shell=True)
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 -f "+prot+"_"+chainID+".fasta -d chain -n "+n+" > "+prot+".out"
print("\nRunning command:\n"+jetcmd)
reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
else:
# Calculate SC1
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"
#One can also add: -g 'trace,pc,cv,clusters,axs'
print("\nRunning for SC1:\n"+jetcmd)
reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
dir_name = prot+"/"
if os.path.isdir(dir_name):
for f in os.listdir(dir_name):
f_path = os.path.join(dir_name, f)
if os.path.isfile(f_path):
os.remove(f_path)
os.rmdir(dir_name)
print("\nRunning:\n"+grpcmd)
subprocess.call(grpcmd,shell=True)
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 -f "+prot+"_"+chainID+".fasta -d chain -n "+n+" > "+prot+".out"
print("\nRunning command:\n"+jetcmd)
reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
else:
# Calculate SC1
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"
#One can also add: -g 'trace,pc,cv,clusters,axs'
print("\nRunning for SC1:\n"+jetcmd)
reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
dir_name = prot+"/"
if os.path.isdir(dir_name):
for f in os.listdir(dir_name):
f_path = os.path.join(dir_name, f)
if os.path.isfile(f_path):
os.remove(f_path)
os.rmdir(dir_name)
else:
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 "+retMet+" -d chain -n "+n+" > "+prot+".out"
else:
# 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"
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"
reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
dir_name = prot+"/"
if os.path.isdir(dir_name):
for f in os.listdir(dir_name):
f_path = os.path.join(dir_name, f)
if os.path.isfile(f_path):
os.remove(f_path)
os.rmdir(dir_name)
else:
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 "+retMet+" -d chain -n "+n+" > "+prot+".out"
else:
# 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"
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"
reCode=subprocess.call(jetcmd,shell=True)
if os.path.isfile(prot+"/"+prot+"_jet.res"):
os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
dir_name = prot+"/"
if os.path.isdir(dir_name):
for f in os.listdir(dir_name):
f_path = os.path.join(dir_name, f)
if os.path.isfile(f_path):
os.remove(f_path)
os.rmdir(dir_name)
# print("\nRunning:\n"+jetcmd)
# reCode=subprocess.call(jetcmd,shell=True)
# if os.path.isfile(prot+"/"+prot+"_jet.res"):
# os.rename(prot+"/"+prot+"_jet.res",prot+"_jet.res")
return(reCode)
return(reCode)
# Run Rscript to compute predictions
def launchPred(prot,inAli,mutFile, normWeightMode, alphabet):
......@@ -654,7 +659,7 @@ def check_argument_groups(parser, arg_dict, group, argument):
group_name = group.replace("-", "")
if arg_dict[group_name]=="input":
if c!=1:
parser.error("esgemme requires " + str(argument) + \
parser.error("esgemme requires " + str(argument) + \
" if " + group + " is set to input.")
else:
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