-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_fullSequence.py
42 lines (34 loc) · 1.75 KB
/
main_fullSequence.py
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
# Runs prokkaMuscleFullSequence.py, neighbor joining algorithm in the whole sequence.
import subprocess
import sys
def run_script(script_path, *args):
# runs a given Python script using subprocess with additional arguments.
try:
# Include the script_path and any additional arguments in the command
command = ['python3', script_path] + list(args)
subprocess.run(command, check=True, text=True)
print(f"Successfully ran {script_path} with args {args}")
except subprocess.CalledProcessError as e:
print(f"Error running {script_path} with args {args}: {e}")
def main():
# checking number of required arguments.
if len(sys.argv) < 3:
print("Usage: python3 main_fullSequence.py <path_to_input_file> <reference_genome>")
sys.exit(1)
# The first argument after the script name is the path to the input file.
input_file = sys.argv[1]
# The second argument is the reference genome.
reference_genome = sys.argv[2]
# Defining the scripts and their corresponding arguments in a list of tuples
scripts_with_args = [
('fullSequenceAnalysis/prokkaMuscleFullSequence.py', input_file, reference_genome),
('fullSequenceAnalysis/neighborJoining/main_NJ.py',), # no additional args required. Input hardcoded within the file.
('fullSequenceAnalysis/neighborJoining/tree_maker.py',) # no additional args required. Input hardcoded within the file.
]
# Iterate through the scripts and their arguments, running them one by one.
for script_tuple in scripts_with_args:
script_path = script_tuple[0]
args = script_tuple[1:] # All the elements after the first one are the args ::
run_script(script_path, *args)
if __name__ == "__main__":
main()