-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkSNP_wrapper.py
More file actions
63 lines (47 loc) · 1.94 KB
/
kSNP_wrapper.py
File metadata and controls
63 lines (47 loc) · 1.94 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
#!/usr/bin/env python3
'''
*******************************************************************
**************-Run kSNP3.1 software on isolates-*******************
*******************************************************************
The usage for this script is: python3 make_phylogeny.py <path/to/input_file> </path/to/output/location>
Please import required packages prior to usage.
Input_file example: tab seperated file
/path/to/isolate1.fasta isolate1
/path/to/isolate2.fasta isolate2
/path/to/isolate3.fasta isolate3
. .
. .
. .
By: Courtney Astore
Last updated: 04/12/2020
'''
import subprocess,os,sys
#def create_InputFile(input_directory_path):
# list_of_file_paths = [f for f in os.listdir(input_directory_path) if os.path.isfile( os.path.join(input_directory_path, f) )]
# list_of_IDs = []
# for i in list_of_file_paths:
# tmp = i.split("/",1)
def kSNP_runner(input_directory_path,output_directory_path):
#Creating file path
input_file=input_directory_path + faa_file
output_dir = output_directory_path + "/OUT"
try:
print("kSNP3.1 "+ input_file)
os.system("kSNP3 -in " + input_file + " -k 25 -outdir " + output_dir + "-ML")
except subprocess.CalledProcessError as err:
print("Error running kSNP3.1. Check the input files")
print("Error thrown: "+err.output)
return False
print("Completed running kSNP3.1")
return True
def main():
inputpath=sys.argv[1] # input directory of files
outputpath=sys.argv[2] # input subdirectory path to create
#files=os.listdir(inputpath)
#if len(files) == 0:
# print("No files present in the directory.")
#for name in files:
# kSNP_run = kSNP_runner(inputpath,name,outputpath) # input_directory_path,faa_file,output_directory_path
kSNP_Run = kSNP_runner(inputpath,outputpath)
if __name__ == "__main__":
main()