-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwater_for_all.py
More file actions
49 lines (38 loc) · 1.57 KB
/
water_for_all.py
File metadata and controls
49 lines (38 loc) · 1.57 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
import os
import sys
import time
from os.path import exists
# get starting time of program
program_start_time = time.time()
# checks if everything is as it should be
if not len(sys.argv) == 4:
print("Bad input. Command is: python get_het_vcf.py [GAP_OPEN_PENALTY] [GAP_EXTEND_PENALTY] [TXT WITH NAMES]")
exit()
base_path = "/vol/storage/pipeline/"
gap_open_penalty = sys.argv[1]
gap_extend_penalty = sys.argv[2]
names_txt = open(sys.argv[3])
lines = names_txt.readlines()
names_txt.close()
names = []
# get all the names
for i in range(len(lines)):
# name and remove newline character
if (i % 4 == 0):
names.append(lines[i][:-1])
print("Found " + str(len(names)) + " species names")
for i in range(len(names)):
if not os.path.exists(base_path + names[i] + "/mito/"):
print("No mito folder found for " + names[i])
continue
if os.path.exists(base_path + names[i] + "/mito/waterO" + gap_open_penalty + "E" + gap_extend_penalty + ".water"):
print("The file waterO" + gap_open_penalty + "E" + gap_extend_penalty + ".water already exists for " + names[i])
continue
current_path = base_path + names[i] + "/mito/"
asequence = current_path + "doubled.fasta "
bsequence = current_path + "sequence.fasta "
gap_open = "-gapopen " + gap_open_penalty + " "
gap_extend = "-gapextend " + gap_extend_penalty + " "
out_file = "-outfile " + current_path +"waterO" + gap_open_penalty + "E" + gap_extend_penalty + ".water"
os.system("water " + asequence + bsequence + gap_open + gap_extend + out_file)
print("Finished! It took " + str((time.time() - program_start_time) / 60) + " minutes to run.")