-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentropy-analysis
executable file
·93 lines (75 loc) · 3.09 KB
/
entropy-analysis
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
91
92
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2010 - 2012, A. Murat Eren
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
import sys
try:
import Oligotyping
except ImportError:
import inspect
print('''
Oligotyping package seems to be missing from your PYTHONPATH. Running this may help:
export PYTHONPATH="$PYTHONPATH:%s"
''' % (os.path.realpath(os.path.abspath(os.path.split(inspect.getfile(inspect.currentframe()))[0]))))
sys.exit()
from Oligotyping.utils.utils import import_error
try:
import matplotlib
except ImportError as e:
import_error(e)
sys.exit()
try:
import matplotlib.pyplot as plt
except RuntimeError:
print('''
matplotlib is failing to connect to any X server for its GTK display. Please
add the following directive into the 'matplotlibrc' file (which should be
under '~/.matplotlib/' directory, if there is no such file, you should
create one):
backend: Agg
''')
sys.exit()
try:
from Oligotyping.utils import parsers
from Oligotyping.lib.entropy import entropy_analysis
from Oligotyping.lib.entropy import EntropyError
from Oligotyping.utils.utils import process_command_line_args_for_quality_files
from Oligotyping.visualization.entropy_distribution_bar import entropy_distribution_bar
except ImportError as e:
import_error(e)
sys.exit()
if __name__ == '__main__':
if '--version' in sys.argv:
print(parsers.version)
sys.exit()
parser = parsers.entropy()
args = parser.parse_args()
# process qual scores if provided
qual_stats_dict = process_command_line_args_for_quality_files(args, _return = 'qual_stats_dict')
# the same file path is also used for the figure (e.g. output_file_path + '.png' or
# output_file_path + '.pdf')
output_file_path = args.alignment + '%s-ENTROPY' % ('-WEIGHTED' if args.weighted else '')
try:
entropy_values = entropy_analysis(args.alignment,
output_file = output_file_path,
uniqued = args.uniqued,
weighted = args.weighted,
qual_stats_dict = qual_stats_dict,
amino_acid_sequences = args.amino_acid_sequences)
except EntropyError as e:
print("Something went wrong. Here is what we know:\n\n\t%s\n\n" % e)
sys.exit(-1)
entropy_distribution_bar(args.alignment,
entropy_values,
output_file = output_file_path,
quick = args.quick,
no_display = args.no_display,
qual_stats_dict = qual_stats_dict,
weighted = args.weighted,
verbose = True)