-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_tumor.py
39 lines (32 loc) · 1.15 KB
/
find_tumor.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
import argparse
import os
import sys
from exitstatus import ExitStatus
from CancerDetector import CancerDetector
from TumorReader import TumorReader
ExitStatus.unix_failure = -1
def process_file(file):
try:
path = os.path.abspath(file)
reader = TumorReader(path)
matrix = reader.read_file()
detector = CancerDetector(matrix)
cancer_locations = detector.get_cancer_cells_positions()
errors = detector.has_errors
except Exception:
errors = True
if errors:
print(f"Error NA NA")
sys.exit(ExitStatus.unix_failure)
elif not len(cancer_locations):
print(f"False {reader.total_rows} {reader.total_columns}")
else:
print(f"True {reader.total_rows} {reader.total_columns}")
sys.exit(ExitStatus.success)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Pass in a file and it will find if a tumor is present.')
parser.add_argument('--inputfile', help='the input file location you want to parse')
args = parser.parse_args()
if not args.inputfile:
raise RuntimeError("You must pass in a file")
process_file(args.inputfile)