-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtmhmm_wrapper.py
More file actions
63 lines (46 loc) · 1.74 KB
/
tmhmm_wrapper.py
File metadata and controls
63 lines (46 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'''
Wrapper script for TMHMM, an ab-initio tool for identifying transmembrane alpha-helix proteins.
We will be using the protein fasta files generated by the Gene Prediction group.
For ease of post-processing the tool is being run to generate the output in the "short" format.
'''
#!/usr/bin/env python
import subprocess,os,sys
def tmhmm_runner(input_directory_path,protein_file,output_directory_path):
#Creating file path
input_file=input_directory_path + protein_file
#Creating a subdirectory in the output directory
output_subdir=output_directory_path+"tmhmm/"
#Creating output file
mod_protein_file_name=protein_file.split("_")
output_file=output_subdir+mod_protein_file_name[0]+"_tmhmm"
#Checking if the subdirectory exists
if not "tmhmm" in os.listdir(output_directory_path):
os.mkdir(output_subdir)
#Executing TMHMM
'''
The following commands produce the "short" output format for TMHMM.
To get the "long" output format, edit the script 'tmhmm' in the directory /home/projects/group-b/tools/tmhmm-2.0c/bin/
Make $opt_short = 0.
To get the probability plots for each file, edit the same script to make $opt_plot=1
'''
try:
print("Running TMHMM for "+protein_file)
command = "tmhmm "+input_file+" > "+output_file
os.system(command)
#print(tmhmm_output)
except subprocess.CalledProcessError as err:
print("Error running TMHMM. Check the input files")
print("Error thrown: "+err.output)
return False
print("Completed running TMHMM")
return True
def main():
inputpath=sys.argv[1]
outputpath=sys.argv[2]
files=os.listdir(inputpath)
if len(files) == 0:
print("No files present in the directory.")
for name in files:
tmhmm=tmhmm_runner(inputpath,name,outputpath)
if __name__ == "__main__":
main()