-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
90 lines (71 loc) · 3.01 KB
/
main.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import os
import argparse
import logging
import time
from graphk import pipeline
def banner():
"""
This function defines the banner text for your tool.
"""
return """
_____ _ _ __ _ ______
| __ \ | | | | / / | | | ___ \\
| | \/_ __ __ _ _ __ | |__ | |/ /______| | | |_/ /
| | __| '__/ _` | '_ \| '_ \| \______| | | /
| |_\ \ | | (_| | |_) | | | | |\ \ | |____| |\ \
\____/_| \__,_| .__/|_| |_\_| \_/ \_____/\_| \_|
| |
|_|
GraphK-LR - Long Read Binning Refiner Tool
"""
def main():
print(banner())
parser = argparse.ArgumentParser(description='Run the sequencing pipeline.')
parser.add_argument('-o', '--exp_dir', type=str, help='Path to the output directory')
parser.add_argument('-i', '--in_file', type=str, help='Path to the input file of inial binning results')
parser.add_argument('-r', '--fastq_file', type=str, help='Path to the original reads file (fastq)')
parser.add_argument('-e', '--epochs', type=int, default=100, help='Number of epochs (default: 100)')
parser.add_argument('--resume', action='store_true', help='Resume the program from previous checkpoints')
parser.add_argument('-g', '--groundtruth', type=str, help='Groundtruth file if available')
args = parser.parse_args()
exp_dir = args.exp_dir
in_file = args.in_file
# init logger
logger = logging.getLogger('GraphKLR')
logger.setLevel(logging.DEBUG)
# init logger console handler - To log messages to console
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
consoleHeader = logging.StreamHandler()
consoleHeader.setFormatter(formatter)
consoleHeader.setLevel(logging.INFO)
logger.addHandler(consoleHeader)
# Ensure the experiment directory exists
os.makedirs(exp_dir, exist_ok=True)
out_dir = os.path.join(exp_dir, "refined_output")
os.makedirs(out_dir, exist_ok=True)
# init logger file handler - To log messages to a file
fileHandler = logging.FileHandler(f"{exp_dir}/GraphKLR.log", mode='w')
fileHandler.setLevel(logging.DEBUG)
fileHandler.setFormatter(formatter)
logger.addHandler(fileHandler)
consoleHandler = logging.StreamHandler()
# starting the pipeline
start_time = time.time()
try:
pipeline.run_pipeline(args)
except Exception as e:
logger.error(f"An error occurred: {e}", exc_info=True)
finally:
# pipeline finished
end_time = time.time()
time_taken = end_time - start_time
logger.info(f"Program Finished! Please find the output.")
logger.info(f"Total time consumed = {time_taken:.2f} seconds")
logger.info(f"Thank you for using GraphKLR.")
# Remove handlers
logger.removeHandler(fileHandler)
logger.removeHandler(consoleHandler)
fileHandler.close()
consoleHandler.close()
if __name__ == "__main__":
main()