annotate lrn_risk.py @ 2:8dc6d4aa17ec draft

Uploaded
author greg
date Fri, 28 Apr 2023 17:03:46 +0000
parents f98c92618a6c
children 5a27ac020c9e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
1 #!/usr/bin/env python
99e04eba4033 Uploaded
greg
parents:
diff changeset
2
99e04eba4033 Uploaded
greg
parents:
diff changeset
3 import argparse
99e04eba4033 Uploaded
greg
parents:
diff changeset
4
99e04eba4033 Uploaded
greg
parents:
diff changeset
5
99e04eba4033 Uploaded
greg
parents:
diff changeset
6 BLACKLIST_HEADER = ['Blacklisted Gene', 'Reason', 'Risk Category']
99e04eba4033 Uploaded
greg
parents:
diff changeset
7 VFDB_HEADER = ['Gene', 'Contig', '% Identity', '% Coverage', 'E-Value', 'Annotation', 'Comparison to Publicly Available Genomes']
99e04eba4033 Uploaded
greg
parents:
diff changeset
8
99e04eba4033 Uploaded
greg
parents:
diff changeset
9
99e04eba4033 Uploaded
greg
parents:
diff changeset
10 def get_species_from_gtdb(f):
99e04eba4033 Uploaded
greg
parents:
diff changeset
11 # get GTDB species
99e04eba4033 Uploaded
greg
parents:
diff changeset
12 # assumes there is one genome in the GTDB-Tk output file
99e04eba4033 Uploaded
greg
parents:
diff changeset
13 with open(f, 'r') as fh:
1
f98c92618a6c Uploaded
greg
parents: 0
diff changeset
14 for i, line in enumerate(fh):
f98c92618a6c Uploaded
greg
parents: 0
diff changeset
15 if i == 0:
f98c92618a6c Uploaded
greg
parents: 0
diff changeset
16 # Skip header.
f98c92618a6c Uploaded
greg
parents: 0
diff changeset
17 continue
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
18 try:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
19 items = line.split('\t')
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
20 tax = items[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
21 tax = tax.split(';')[-1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
22 # split on GTDB species tag
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
23 tax = tax.split('s__')[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
24 except Exception:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
25 return '(Unknown Species)'
1
f98c92618a6c Uploaded
greg
parents: 0
diff changeset
26 if len(tax) == 0:
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
27 return '(Unknown Species)'
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
28 return tax
99e04eba4033 Uploaded
greg
parents:
diff changeset
29
99e04eba4033 Uploaded
greg
parents:
diff changeset
30
99e04eba4033 Uploaded
greg
parents:
diff changeset
31 def get_blast_genes(f):
99e04eba4033 Uploaded
greg
parents:
diff changeset
32 # reads genes detected via BLAST
99e04eba4033 Uploaded
greg
parents:
diff changeset
33 # BLAST header is as follows:
99e04eba4033 Uploaded
greg
parents:
diff changeset
34 # qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore nident qlen
99e04eba4033 Uploaded
greg
parents:
diff changeset
35 d = {}
99e04eba4033 Uploaded
greg
parents:
diff changeset
36 with open(f, 'r') as fh:
99e04eba4033 Uploaded
greg
parents:
diff changeset
37 for line in fh:
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
38 try:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
39 items = line.split('\t')
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
40 gene = items[0]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
41 # contig = items[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
42 # pid = items[2]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
43 alen = items[3]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
44 # e = items[-4]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
45 qlen = items[-1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
46 # calculate query coverage by dividing alignment length by query length
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
47 qcov = round(float(alen) / float(qlen) * 100.0, 2)
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
48 if gene not in d.keys():
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
49 d[gene] = []
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
50 d[gene].append('%s\t%s' % (line, str(qcov)))
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
51 except Exception:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
52 return d
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
53 return d
99e04eba4033 Uploaded
greg
parents:
diff changeset
54
99e04eba4033 Uploaded
greg
parents:
diff changeset
55
99e04eba4033 Uploaded
greg
parents:
diff changeset
56 def get_blacklist(v, b):
99e04eba4033 Uploaded
greg
parents:
diff changeset
57 # identify high-risk isolates based on blacklisted genes
99e04eba4033 Uploaded
greg
parents:
diff changeset
58 # blacklisted genes file contains two columns:
99e04eba4033 Uploaded
greg
parents:
diff changeset
59 # column 0=the gene name as it appears in the gene database
99e04eba4033 Uploaded
greg
parents:
diff changeset
60 # column 1=the reason why the gene was blacklisted, which will be reported
99e04eba4033 Uploaded
greg
parents:
diff changeset
61 # e.g., 'ANTHRAX TOXIN'
99e04eba4033 Uploaded
greg
parents:
diff changeset
62 bdict = {}
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
63 blacklist_present = {}
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
64 with open(b, 'r') as fh:
99e04eba4033 Uploaded
greg
parents:
diff changeset
65 for line in fh:
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
66 try:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
67 items = line.split('\t')
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
68 gene = items[0]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
69 val = items[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
70 bdict[gene] = val
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
71 except Exception:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
72 return blacklist_present
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
73 for key in v.keys():
99e04eba4033 Uploaded
greg
parents:
diff changeset
74 if key in bdict.keys():
99e04eba4033 Uploaded
greg
parents:
diff changeset
75 val = bdict[key]
99e04eba4033 Uploaded
greg
parents:
diff changeset
76 blacklist_present[key] = val
99e04eba4033 Uploaded
greg
parents:
diff changeset
77 return blacklist_present
99e04eba4033 Uploaded
greg
parents:
diff changeset
78
99e04eba4033 Uploaded
greg
parents:
diff changeset
79
99e04eba4033 Uploaded
greg
parents:
diff changeset
80 def gene_dist(f, blast, gtdb):
99e04eba4033 Uploaded
greg
parents:
diff changeset
81 # get within-species prevalence of genes
99e04eba4033 Uploaded
greg
parents:
diff changeset
82 # for virulence factors (VFs): uses VFDB VFs detected via ABRicate's VFDB db
99e04eba4033 Uploaded
greg
parents:
diff changeset
83 # for AMR genes: uses AMR genes detected via ABRicate's ResFinder db
99e04eba4033 Uploaded
greg
parents:
diff changeset
84 # for VFs and AMR genes: genes were detected via ABRicate XXX
99e04eba4033 Uploaded
greg
parents:
diff changeset
85 # minimum nucleotide identity and coverage values >=80%
99e04eba4033 Uploaded
greg
parents:
diff changeset
86 # total of 61,161 genomes queried
99e04eba4033 Uploaded
greg
parents:
diff changeset
87 # takes VFDB or AMR gene distribution file as input (f)
99e04eba4033 Uploaded
greg
parents:
diff changeset
88 # BLAST file of VFDB or AMR genes (blast)
99e04eba4033 Uploaded
greg
parents:
diff changeset
89 # GTDB species (gtdb)
99e04eba4033 Uploaded
greg
parents:
diff changeset
90 # create dictionaries based on gene distribution
99e04eba4033 Uploaded
greg
parents:
diff changeset
91 d = {}
99e04eba4033 Uploaded
greg
parents:
diff changeset
92 annd = {}
99e04eba4033 Uploaded
greg
parents:
diff changeset
93 gtdbd = {}
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
94 finallines = []
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
95 with open(f, 'r') as fh:
99e04eba4033 Uploaded
greg
parents:
diff changeset
96 for line in fh:
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
97 try:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
98 items = line.split('\t')
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
99 tax = items[0]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
100 tax = tax.split('s__')[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
101 if len(tax) == 0:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
102 tax = '(Unknown Species)'
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
103 gene = items[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
104 ann = items[-1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
105 denom = items[3]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
106 d['%s___%s' % (tax, gene)] = line
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
107 annd[gene] = ann
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
108 gtdbd[tax] = denom
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
109 except Exception:
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
110 return finallines
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
111 # parse BLAST results
99e04eba4033 Uploaded
greg
parents:
diff changeset
112 for key in blast.keys():
99e04eba4033 Uploaded
greg
parents:
diff changeset
113 blastval = blast[key]
99e04eba4033 Uploaded
greg
parents:
diff changeset
114 for bv in blastval:
99e04eba4033 Uploaded
greg
parents:
diff changeset
115 testkey = '%s___%s' % (gtdb, key)
99e04eba4033 Uploaded
greg
parents:
diff changeset
116 if testkey in d.keys() and gtdb != '(Unknown Species)':
99e04eba4033 Uploaded
greg
parents:
diff changeset
117 taxval = d[testkey]
99e04eba4033 Uploaded
greg
parents:
diff changeset
118 items = taxval.split('\t')
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
119 tax = items[0]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
120 tax = tax.split('s__')[1]
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
121 if len(tax) == 0:
99e04eba4033 Uploaded
greg
parents:
diff changeset
122 tax = '(Unknown Species)'
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
123 gene = items[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
124 pres = items[2]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
125 denom = items[3]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
126 perc = items[4]
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
127 perc = str(round(float(perc), 2))
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
128 ann = items[-1]
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
129 freetext = 'Gene {0} has been detected in {1}% of {2} genomes ({3} of {4} genomes queried)'.format(gene, perc, tax, pres, denom)
99e04eba4033 Uploaded
greg
parents:
diff changeset
130 elif gtdb != '(Unknown Species)':
99e04eba4033 Uploaded
greg
parents:
diff changeset
131 ann = annd[key]
99e04eba4033 Uploaded
greg
parents:
diff changeset
132 denom = gtdbd[gtdb]
99e04eba4033 Uploaded
greg
parents:
diff changeset
133 freetext = 'WARNING: Gene {0} ({1}) has never been detected in species {2} (n={3} genomes queried)! Interpret with caution!'.format(key, ann, gtdb, denom)
99e04eba4033 Uploaded
greg
parents:
diff changeset
134 else:
99e04eba4033 Uploaded
greg
parents:
diff changeset
135 ann = annd[key]
99e04eba4033 Uploaded
greg
parents:
diff changeset
136 freetext = 'WARNING: Genome belongs to an undescribed species. Interpret with caution!'
99e04eba4033 Uploaded
greg
parents:
diff changeset
137 finalline = '%s\t%s\t%s' % (bv, ann, freetext)
99e04eba4033 Uploaded
greg
parents:
diff changeset
138 finallines.append(finalline)
99e04eba4033 Uploaded
greg
parents:
diff changeset
139 return finallines
99e04eba4033 Uploaded
greg
parents:
diff changeset
140
99e04eba4033 Uploaded
greg
parents:
diff changeset
141
99e04eba4033 Uploaded
greg
parents:
diff changeset
142 def output_blacklist(blacklist, blacklist_output_file):
99e04eba4033 Uploaded
greg
parents:
diff changeset
143 # takes detected blacklisted genes as input (blacklist)
99e04eba4033 Uploaded
greg
parents:
diff changeset
144 # blacklist results
99e04eba4033 Uploaded
greg
parents:
diff changeset
145 with open(blacklist_output_file, 'w') as fh:
99e04eba4033 Uploaded
greg
parents:
diff changeset
146 fh.write('%s\n' % '\t'.join(BLACKLIST_HEADER))
99e04eba4033 Uploaded
greg
parents:
diff changeset
147 if len(blacklist.keys()) == 0:
99e04eba4033 Uploaded
greg
parents:
diff changeset
148 # print this if no blacklisted genes are detected
99e04eba4033 Uploaded
greg
parents:
diff changeset
149 fh.write('(No blacklisted genes detected)\tNA\tNot high risk\n')
99e04eba4033 Uploaded
greg
parents:
diff changeset
150 else:
99e04eba4033 Uploaded
greg
parents:
diff changeset
151 # print this if blacklisted genes are detected
99e04eba4033 Uploaded
greg
parents:
diff changeset
152 # print a table with one row per detected blacklisted gene
99e04eba4033 Uploaded
greg
parents:
diff changeset
153 for key in blacklist.keys():
99e04eba4033 Uploaded
greg
parents:
diff changeset
154 val = blacklist[key]
99e04eba4033 Uploaded
greg
parents:
diff changeset
155 fh.write('%s\t%s\tHIGH RISK\n' % (key, val))
99e04eba4033 Uploaded
greg
parents:
diff changeset
156
99e04eba4033 Uploaded
greg
parents:
diff changeset
157
99e04eba4033 Uploaded
greg
parents:
diff changeset
158 def output_vfdb(vfdist, vfdb_output_file):
99e04eba4033 Uploaded
greg
parents:
diff changeset
159 # takes distribution of virulence factors as input (vfdist)
99e04eba4033 Uploaded
greg
parents:
diff changeset
160 # VFDB results
99e04eba4033 Uploaded
greg
parents:
diff changeset
161 with open(vfdb_output_file, 'w') as fh:
99e04eba4033 Uploaded
greg
parents:
diff changeset
162 fh.write('%s\n' % '\t'.join(VFDB_HEADER))
99e04eba4033 Uploaded
greg
parents:
diff changeset
163 if len(vfdist) == 0:
99e04eba4033 Uploaded
greg
parents:
diff changeset
164 # print this if no VFs detected
99e04eba4033 Uploaded
greg
parents:
diff changeset
165 fh.write('%s\n' % '\t'.join(['(No VFs Detected)'] * 7))
99e04eba4033 Uploaded
greg
parents:
diff changeset
166 else:
99e04eba4033 Uploaded
greg
parents:
diff changeset
167 # print table of VFs if VFs detected
99e04eba4033 Uploaded
greg
parents:
diff changeset
168 for vline in vfdist:
99e04eba4033 Uploaded
greg
parents:
diff changeset
169 # blast_header=['Gene', 'Contig', 'Percent (%) Nucleotide Identity', 'Alignment Length', 'Mismatches', 'Gaps', 'Query Start', 'Query End', 'Subject Start', 'Subject End', 'E-Value', 'Bit Score', 'Identical Matches', 'Query Length']
99e04eba4033 Uploaded
greg
parents:
diff changeset
170 # lc_header=['Query Coverage', 'Annotation', 'Comparison to Publicly Available Genomes']
99e04eba4033 Uploaded
greg
parents:
diff changeset
171 items = vline.split('\t')
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
172 vgene = items[0]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
173 vcontig = items[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
174 vid = items[2]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
175 vcov = items[-3]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
176 veval = items[-7]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
177 vann = items[-2]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
178 vnotes = items[-1]
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
179 vfinal = [vgene, vcontig, vid, vcov, veval, vann, vnotes]
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
180 vfinal = '\t'.join(vfinal)
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
181 fh.write('%s\n' % vfinal)
99e04eba4033 Uploaded
greg
parents:
diff changeset
182
99e04eba4033 Uploaded
greg
parents:
diff changeset
183
99e04eba4033 Uploaded
greg
parents:
diff changeset
184 def output_amr(amrdist, amr_output_file):
99e04eba4033 Uploaded
greg
parents:
diff changeset
185 # takes distribution of AMR genes as input (amrdist)
99e04eba4033 Uploaded
greg
parents:
diff changeset
186 # AMR results
99e04eba4033 Uploaded
greg
parents:
diff changeset
187 with open(amr_output_file, 'w') as fh:
99e04eba4033 Uploaded
greg
parents:
diff changeset
188 fh.write('%s\n' % '\t'.join(VFDB_HEADER))
99e04eba4033 Uploaded
greg
parents:
diff changeset
189 if len(amrdist) == 0:
99e04eba4033 Uploaded
greg
parents:
diff changeset
190 # print this if no AMR genes detected
99e04eba4033 Uploaded
greg
parents:
diff changeset
191 fh.write('%s\n' % '\t'.join(['(No AMR Genes Detected)'] * 7))
99e04eba4033 Uploaded
greg
parents:
diff changeset
192 else:
99e04eba4033 Uploaded
greg
parents:
diff changeset
193 # print this if AMR genes detected
99e04eba4033 Uploaded
greg
parents:
diff changeset
194 for aline in amrdist:
99e04eba4033 Uploaded
greg
parents:
diff changeset
195 # blast_header=['Gene', 'Contig', 'Percent (%) Nucleotide Identity', 'Alignment Length', 'Mismatches', 'Gaps', 'Query Start', 'Query End', 'Subject Start', 'Subject End', 'E-Value', 'Bit Score', 'Identical Matches', 'Query Length']
99e04eba4033 Uploaded
greg
parents:
diff changeset
196 # lc_header=['Query Coverage', 'Annotation', 'Comparison to Publicly Available Genomes']
99e04eba4033 Uploaded
greg
parents:
diff changeset
197 items = aline.split('\t')
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
198 agene = items[0]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
199 acontig = items[1]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
200 aid = items[2]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
201 acov = items[-3]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
202 aeval = items[-7]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
203 aann = items[-2]
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
204 anotes = items[-1]
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
205 afinal = [agene, acontig, aid, acov, aeval, aann, anotes]
2
8dc6d4aa17ec Uploaded
greg
parents: 1
diff changeset
206 afinal = '\t'.join(afinal)
0
99e04eba4033 Uploaded
greg
parents:
diff changeset
207 fh.write('%s\n' % afinal)
99e04eba4033 Uploaded
greg
parents:
diff changeset
208
99e04eba4033 Uploaded
greg
parents:
diff changeset
209
99e04eba4033 Uploaded
greg
parents:
diff changeset
210 # lrnrisk_prototype arguments
99e04eba4033 Uploaded
greg
parents:
diff changeset
211 parser = argparse.ArgumentParser()
99e04eba4033 Uploaded
greg
parents:
diff changeset
212
99e04eba4033 Uploaded
greg
parents:
diff changeset
213 parser.add_argument('--gtdb_file', action='store', dest='gtdb_file', help='Path to gtdbtk tsv file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
214 parser.add_argument('--virulence_factors_file', action='store', dest='virulence_factors_file', help='Path to tsv virulence factors file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
215 parser.add_argument('--amr_determinants_file', action='store', dest='amr_determinants_file', help='Path to AMR determinants tsv file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
216 parser.add_argument('--blacklist_file', action='store', dest='blacklist_file', help='Path to blacklisted high-risk virulence factors tsv file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
217 parser.add_argument('--vf_distribution_file', action='store', dest='vf_distribution_file', help='Path to virulence factor distribution tsv file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
218 parser.add_argument('--amr_distribution_file', action='store', dest='amr_distribution_file', help='Path to AMR determinant distribution tsv file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
219 parser.add_argument('--blacklist_output_file', action='store', dest='blacklist_output_file', help='Path to blacklist output file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
220 parser.add_argument('--vfdb_output_file', action='store', dest='vfdb_output_file', help='Path to vfdb output file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
221 parser.add_argument('--amr_output_file', action='store', dest='amr_output_file', help='Path to amr output file')
99e04eba4033 Uploaded
greg
parents:
diff changeset
222
99e04eba4033 Uploaded
greg
parents:
diff changeset
223 # parse arguments and run pipeline
99e04eba4033 Uploaded
greg
parents:
diff changeset
224 args = parser.parse_args()
99e04eba4033 Uploaded
greg
parents:
diff changeset
225
99e04eba4033 Uploaded
greg
parents:
diff changeset
226 # print_output(blacklist, vf_distribution, amr_distribution, args.output, species)
99e04eba4033 Uploaded
greg
parents:
diff changeset
227 virulence_genes = get_blast_genes(args.virulence_factors_file)
99e04eba4033 Uploaded
greg
parents:
diff changeset
228 species = get_species_from_gtdb(args.gtdb_file)
99e04eba4033 Uploaded
greg
parents:
diff changeset
229
99e04eba4033 Uploaded
greg
parents:
diff changeset
230 blacklist = get_blacklist(virulence_genes, args.blacklist_file)
99e04eba4033 Uploaded
greg
parents:
diff changeset
231 output_blacklist(blacklist, args.blacklist_output_file)
99e04eba4033 Uploaded
greg
parents:
diff changeset
232
99e04eba4033 Uploaded
greg
parents:
diff changeset
233 vf_distribution = gene_dist(args.vf_distribution_file, virulence_genes, species)
99e04eba4033 Uploaded
greg
parents:
diff changeset
234 output_vfdb(vf_distribution, args.vfdb_output_file)
99e04eba4033 Uploaded
greg
parents:
diff changeset
235
99e04eba4033 Uploaded
greg
parents:
diff changeset
236 amr_genes = get_blast_genes(args.amr_determinants_file)
99e04eba4033 Uploaded
greg
parents:
diff changeset
237 amr_distribution = gene_dist(args.amr_distribution_file, amr_genes, species)
99e04eba4033 Uploaded
greg
parents:
diff changeset
238 output_amr(amr_distribution, args.amr_output_file)