Mercurial > repos > dfornika > blast_report_basic
annotate blast_report.py @ 22:261235bbd475 draft
Uploaded
author | dfornika |
---|---|
date | Tue, 03 Mar 2020 09:29:50 +0000 |
parents | 9cf35f30bfb4 |
children | 8d92b3b58f5e |
rev | line source |
---|---|
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
1 #!/usr/bin/env python |
3 | 2 |
3 from __future__ import print_function | |
4 | |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
5 '''Report on BLAST results. |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
6 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
7 python blast_report.py input_tab cheetah_tmpl output_html output_tab [-f [filter_pident]:[filterkw1,...,filterkwN]] [-b bin1_label=bin1_path[,...binN_label=binN_path]] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
8 ''' |
3 | 9 |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
10 import argparse |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
11 import re |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
12 import sys |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
13 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
14 from Cheetah.Template import Template |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
15 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
16 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
17 def stop_err( msg ): |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
18 sys.stderr.write("%s\n" % msg) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
19 sys.exit(1) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
20 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
21 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
22 class BLASTBin: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
23 def __init__(self, label, file): |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
24 self.label = label |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
25 self.dict = {} |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
26 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
27 file_in = open(file) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
28 for line in file_in: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
29 self.dict[line.rstrip().split('.')[0]] = '' |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
30 file_in.close() |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
31 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
32 def __str__(self): |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
33 return "label: %s dict: %s" % (self.label, str(self.dict)) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
34 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
35 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
36 class BLASTQuery: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
37 def __init__(self, query_id): |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
38 self.query_id = query_id |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
39 self.matches = [] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
40 self.match_accessions = {} |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
41 self.bins = {} #{bin(label):[match indexes]} |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
42 self.pident_filtered = 0 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
43 self.kw_filtered = 0 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
44 self.kw_filtered_breakdown = {} #{kw:count} |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
45 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
46 def __str__(self): |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
47 return "query_id: %s len(matches): %s bins (labels only): %s pident_filtered: %s kw_filtered: %s kw_filtered_breakdown: %s" \ |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
48 % (self.query_id, |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
49 str(len(self.matches)), |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
50 str([bin.label for bin in bins]), |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
51 str(self.pident_filtered), |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
52 str(self.kw_filtered), |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
53 str(self.kw_filtered_breakdown)) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
54 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
55 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
56 class BLASTMatch: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
57 def __init__(self, subject_acc, subject_descr, score, p_cov, p_ident, subject_bins): |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
58 self.subject_acc = subject_acc |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
59 self.subject_descr = subject_descr |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
60 self.score = score |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
61 self.p_cov = p_cov |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
62 self.p_ident = p_ident |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
63 self.bins = subject_bins |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
64 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
65 def __str__(self): |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
66 return "subject_acc: %s subject_descr: %s score: %s p-cov: %s p-ident: %s" \ |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
67 % (self.subject_acc, |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
68 self.subject_descr, |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
69 str(self.score), |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
70 str(round(self.p_cov,2)), |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
71 str(round(self.p_ident, 2))) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
72 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
73 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
74 #PARSE OPTIONS AND ARGUMENTS |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
75 parser = argparse.ArgumentParser() |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
76 |
7 | 77 parser.add_argument('-f', '--filter-keywords', |
78 dest='filter_keywords', | |
79 ) | |
80 parser.add_argument('-i', '--min-identity', | |
81 dest='min_identity', | |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
82 ) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
83 parser.add_argument('-b', '--bins', |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
84 dest='bins' |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
85 ) |
3 | 86 parser.add_argument('-r', '--discard-redundant', |
87 dest='discard_redundant', | |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
88 default=False, |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
89 action='store_true' |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
90 ) |
7 | 91 parser.add_argument('input_tab') |
92 parser.add_argument('cheetah_tmpl') | |
93 parser.add_argument('output_html') | |
94 parser.add_argument('output_tab') | |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
95 args = parser.parse_args() |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
96 |
7 | 97 print('input_tab: %s cheetah_tmpl: %s output_html: %s output_tab: %s' % (args.input_tab, args.cheetah_tmpl, args.output_html, args.output_tab)) |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
98 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
99 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
100 #BINS |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
101 bins=[] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
102 if args.bins != None: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
103 bins = list([BLASTBin(label_file.split('=')[0],label_file.split('=')[-1]) for label_file in args.bins.split(',')]) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
104 print('database bins: %s' % str([bin.label for bin in bins])) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
105 |
7 | 106 #FILTERS |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
107 filter_pident = 0 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
108 filter_kws = [] |
9 | 109 if args.filter_keywords: |
110 filter_kws = args.filter_keywords.split(',') | |
7 | 111 print('minimum percent identity: %s filter_kws: %s' % (str(args.min_identity), str(filter_kws))) |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
112 |
3 | 113 if args.discard_redundant: |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
114 print('Throwing out redundant hits...') |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
115 |
7 | 116 |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
117 PIDENT_COL = 2 |
10 | 118 DESCR_COL = 24 |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
119 SUBJ_ID_COL = 12 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
120 SCORE_COL = 11 |
10 | 121 PCOV_COL = 25 |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
122 queries = [] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
123 current_query = '' |
7 | 124 output_tab = open(args.output_tab, 'w') |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
125 |
7 | 126 with open(args.input_tab) as input_tab: |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
127 for line in input_tab: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
128 cols = line.split('\t') |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
129 if cols[0] != current_query: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
130 current_query = cols[0] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
131 queries.append(BLASTQuery(current_query)) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
132 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
133 try: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
134 accs = cols[SUBJ_ID_COL].split('|')[1::2][1::2] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
135 except IndexError as e: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
136 stop_err("Problem with splitting:" + cols[SUBJ_ID_COL]) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
137 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
138 #hsp option: keep best (first) hit only for each query and accession id. |
3 | 139 if args.discard_redundant: |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
140 if accs[0] in queries[-1].match_accessions: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
141 continue #don't save the result and skip to the next |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
142 else: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
143 queries[-1].match_accessions[accs[0]] = '' |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
144 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
145 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
146 p_ident = float(cols[PIDENT_COL]) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
147 #FILTER BY PIDENT |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
148 if p_ident < filter_pident: #if we are not filtering, filter_pident == 0 and this will never evaluate to True |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
149 queries[-1].pident_filtered += 1 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
150 continue |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
151 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
152 descrs = cols[DESCR_COL] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
153 #FILTER BY KEY WORDS |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
154 filter_by_kw = False |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
155 for kw in filter_kws: |
7 | 156 kw = kw.strip() |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
157 if kw != '' and re.search(kw, descrs, re.IGNORECASE): |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
158 filter_by_kw = True |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
159 try: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
160 queries[-1].kw_filtered_breakdown[kw] += 1 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
161 except: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
162 queries[-1].kw_filtered_breakdown[kw] = 1 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
163 if filter_by_kw: #if we are not filtering, for loop will not be entered and this will never be True |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
164 queries[-1].kw_filtered += 1 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
165 continue |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
166 descr = descrs.split(';')[0] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
167 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
168 #ATTEMPT BIN |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
169 subj_bins = [] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
170 for bin in bins: #if we are not binning, bins = [] so for loop not entered |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
171 for acc in accs: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
172 if acc.split('.')[0] in bin.dict: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
173 try: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
174 queries[-1].bins[bin.label].append(len(queries[-1].matches)) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
175 except: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
176 queries[-1].bins[bin.label] = [len(queries[-1].matches)] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
177 subj_bins.append(bin.label) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
178 break #this result has been binned to this bin so break |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
179 acc = accs[0] |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
180 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
181 score = int(float(cols[SCORE_COL])) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
182 p_cov = float(cols[PCOV_COL]) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
183 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
184 #SAVE RESULT |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
185 queries[-1].matches.append( |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
186 BLASTMatch(acc, descr, score, p_cov, p_ident, subj_bins) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
187 ) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
188 output_tab.write(line) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
189 input_tab.close() |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
190 output_tab.close() |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
191 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
192 ''' |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
193 for query in queries: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
194 print(query) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
195 for match in query.matches: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
196 print(' %s' % str(match)) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
197 for bin in query.bins: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
198 print(' bin: %s' % bin) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
199 for x in query.bins[bin]: |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
200 print(' %s' % str(query.matches[x])) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
201 ''' |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
202 |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
203 namespace = {'queries': queries} |
7 | 204 html = Template(file=args.cheetah_tmpl, searchList=[namespace]) |
205 out_html = open(args.output_html, 'w') | |
0
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
206 out_html.write(str(html)) |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
207 out_html.close() |
5dfd84907521
planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/blast_report_basic commit bc359460bb66db7946cc68ccbd47cd479624c4a1-dirty
dfornika
parents:
diff
changeset
|
208 |