-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_clans_cmd.py
executable file
·85 lines (76 loc) · 2.99 KB
/
run_clans_cmd.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
# The main script for running clans via the command-line (no graphics) #
########################################################################
import time
import os
import clans.config as cfg
import clans.clans.io.parser as parser
import clans.clans.io.file_handler as fh
import clans.clans.similarity_search.blast as blast
import clans.clans.layouts.layout_handler as lh
# Parse the command-line arguments
parser.parse_arguments()
cfg.run_params['working_dir'] = os.getcwd()
# Read the input file (fasta/clans/delimited) and fill the relevant main data-structures
try:
print("Reading the input file")
before = time.time()
fh.read_input_file(cfg.run_params['input_file'], cfg.run_params['input_format'])
after = time.time()
duration = (after - before)
if cfg.run_params['is_problem']:
print(cfg.run_params['error'])
exit()
else:
if cfg.run_params['is_debug_mode']:
print("Reading the input file took "+str(duration)+" seconds")
except Exception as err:
print("An error has occurred while reading the input file")
print(err)
exit()
# Perform BLAST search and fill the HSP's E-values in the similarity matrix
try:
if cfg.run_params['run_blast']:
print("Running blast")
before = time.time()
blast.find_HSPs()
after = time.time()
duration = (after - before)
if cfg.run_params['is_problem']:
print(cfg.run_params['error'])
exit()
else:
if cfg.run_params['is_debug_mode']:
print("Performing the BLAST search took " + str(duration) + " seconds")
except Exception as err:
print("An error has occurred while running the BLAST search")
print(err)
exit()
# Run the Fruchterman-Reingold layout calculation for the defined number of rounds
try:
if cfg.run_params['num_of_rounds'] > 0:
print("Running clustering of " + str(cfg.run_params['num_of_rounds']) + " rounds")
before = time.time()
lh.calculate_layout("FR")
after = time.time()
duration = (after - before)
if cfg.run_params['is_debug_mode'] and cfg.run_params['rounds_done'] % 100 != 0:
print("The calculation of " + str(cfg.run_params['rounds_done']) + " rounds took " + str(duration) +
" seconds")
except Exception as err:
print("An error has occurred while running the Fruchterman-Reingold layout calculation")
print(err)
exit()
## Write the output file
try:
if cfg.run_params['output_file'] is not None:
before = time.time()
fh.write_file(cfg.run_params['output_file'], cfg.run_params['output_format'], 0)
print("File " + cfg.run_params['output_file'] + " was successfully saved")
after = time.time()
duration = (after - before)
if cfg.run_params['is_debug_mode']:
print("Writing the output file took "+str(duration)+" seconds")
except Exception as err:
print("An error has occurred while saving the output file")
print(err)
exit()