|
35 | 35 | group = parser.add_mutually_exclusive_group() |
36 | 36 | # group.add_argument("-v", "--verbose", action="store_true", help="increase output verbosity") |
37 | 37 | group.add_argument("-q", "--quiet", action="store_true", help="prevent output in command line") |
38 | | -# parser.add_argument("-l", "--log", action="store_true", help="store the output in a log file") |
39 | | -# parser.add_argument("-n", "--number", type=int, help="just a Test number") |
40 | 38 | parser.add_argument("-m", "--manual", action="store_true", help="display the manual for this program") |
41 | 39 | parser.add_argument("-i", "--input_file", help="comma separated table with SNP's") |
42 | 40 | parser.add_argument("-d", "--detail", action="store_true", help="write detailed output file") |
|
152 | 150 | l_count = 0 |
153 | 151 | snps = [] |
154 | 152 | for variant_line in variant_lines: |
155 | | - # remove /n form end of line |
156 | | - # variant_line = variant_line.strip() |
157 | | - # remove " from lines |
158 | | - # variant_line[0] = variant_line[0].translate(None, '"') |
159 | | - # variant_line[-1] = variant_line[-1].translate(None, '"') |
160 | 153 | if len(variant_line) >= 16: |
161 | 154 | success_count += 1 |
162 | 155 | context = variant_line[5].split(",") |
|
180 | 173 | print "created patient SNP objects with " + str(len(snps)) + " unique SNPs\n" |
181 | 174 | csvfile.close() |
182 | 175 |
|
| 176 | +# sanity check ### |
183 | 177 | if fail_count > success_count: |
184 | 178 | print "INPUT ERROR! wrong separator selected" |
185 | 179 | sys.exit(0) |
|
192 | 186 | # only clinically relevant quality |
193 | 187 | if snp.get_qual() <= 95: |
194 | 188 | del snps[i] |
195 | | - |
196 | 189 | # if mutation does not change the amino acid, it does not affect the cell (in most cases) |
197 | 190 | if "synonymous_variant" in snp.get_consequences(): |
198 | 191 | del snps[i] |
199 | 192 | i += 1 |
200 | 193 | print "past filter SNP count: " + str(len(snps)) |
201 | 194 |
|
202 | | -# write tab delimited file for annovar # |
| 195 | +# write tab delimited file for annovar ### |
203 | 196 | tab_mutations = open('amplicon_variants_tab.csv', 'w') |
204 | 197 | for snp in snps: |
205 | 198 | # check if type is deletion, correction of the data for annovar |
206 | 199 | if "Deletion" in snp.get_type(): |
207 | | - # print snp.get_ref() |
208 | | - # print mutation.get_alt() |
209 | 200 | newEnd = snp.get_pos() + (len(snp.get_ref()) - 2) |
210 | 201 | snp.set_alt("-") |
211 | 202 | if len(snp.get_ref()) > 2: |
|
216 | 207 | except IndexError: |
217 | 208 | snp.set_ref(snp.get_ref()[0]) |
218 | 209 | snp.set_new_end(newEnd) |
219 | | - # print mutation.get_pos() |
220 | | - # print newEnd |
221 | | - # print mutation.get_ref() |
222 | | - # print snp.get_alt() |
223 | 210 | tab_mutations.write(snp.export()) |
224 | 211 | tab_mutations.close() |
225 | 212 | if not args.quiet: |
226 | 213 | print "created tab delimited file for annovar" |
227 | 214 |
|
228 | 215 | # WORKS JUST UNDER UBUNTU OR THE UBUNTU BASH FOR WINDOWS # |
229 | | -# get annovar databases if needed ### |
230 | | - |
| 216 | +# download databases if needed ### |
231 | 217 | annotate_variation = "./perl/annotate_variation.pl " |
232 | 218 | databases = ["-buildver " + buildversion + " -downdb -webfrom annovar refGene " + buildversion, |
233 | 219 | "-buildver " + buildversion + " -downdb cytoBand " + buildversion, |
|
286 | 272 | print "annotating the SNPs" |
287 | 273 | annovar_pl = "./perl/table_annovar.pl " |
288 | 274 | dir_path = os.path.dirname(os.path.realpath(__file__)) |
289 | | -# print dir_path |
290 | 275 |
|
291 | 276 | if args.fast: |
292 | 277 | params = "amplicon_variants_tab.csv " + buildversion + " -buildver " + buildversion + " -out myanno -remove -protocol " \ |
|
364 | 349 | # if score != ".": |
365 | 350 | # rel_score = float(data._AnnovarParser__SIFT_score) / data._AnnovarParser__SIFT_max |
366 | 351 | # print rel_score |
367 | | -###### some work to do here #### |
| 352 | +###### some work to do here some day#### |
368 | 353 | # sys.exit(0) |
369 | 354 |
|
370 | 355 | # create Objects containing all human proteins ### |
|
390 | 375 | end = position[1] |
391 | 376 | geneDesc = variant_line[3].split(",") |
392 | 377 | chromosome = "chr" + str(variant_line[4]) |
393 | | - # print chromosome |
394 | 378 | allHumanProteins.append(AllProt(prot, geneSyn, ensembl, geneDesc, chromosome, int(start), |
395 | 379 | int(end), variant_line[6], variant_line[7:-1])) |
396 | 380 | allProtFile.close() |
|
432 | 416 | snp.get_refDepth(), snp.get_altDepth(), |
433 | 417 | snp.get_strandBias(), ".", ".", ".", ".", ".", ".", "." |
434 | 418 | )) |
435 | | - |
| 419 | +# this part is for getting the corresponding AA Seq. |
436 | 420 | # find DNA sequence for gene in each region and translate it ### |
437 | 421 | # mutation_with_sequence = {} |
438 | 422 | # for c_muta in coding_mutations: |
|
467 | 451 |
|
468 | 452 | # ensemble API for GRCh37 hg19 ### |
469 | 453 | # ensembl_rest.run(species="human", symbol="DOPEY2") |
| 454 | +# yes not jet finished |
470 | 455 |
|
471 | 456 |
|
472 | 457 | # write in export table ### |
|
559 | 544 | annotation._AnnovarParser__phastCons20way_mammalian[0], |
560 | 545 | annotation._AnnovarParser__SiPhy_29way_logOdds[0] |
561 | 546 | )) |
562 | | - # snp.get_geneChromosome(), |
563 | | - # snp.get_gene(), snp.get_geneSyn(), snp.get_geneDesc(), |
564 | | - # snp.get_proteinClass(), snp.get_geneStart(), snp.get_geneEnd() |
565 | | - # )) |
566 | 547 | else: |
567 | 548 | export_string = str("{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t" |
568 | 549 | "".format(snp.get_id(), snp.get_chr(), snp.get_pos(), |
|
643 | 624 | button("Invert colors".title(), id="invert_button") |
644 | 625 |
|
645 | 626 | with table(id="resultTable", border='1'): |
646 | | - # line = tr() |
647 | 627 | thead = thead() |
648 | 628 | tbody = tbody() |
649 | 629 | # write header first |
|
722 | 702 | annotation._AnnovarParser__phastCons20way_mammalian, |
723 | 703 | annotation._AnnovarParser__SiPhy_29way_logOdds |
724 | 704 | ]: |
| 705 | + # generate HTML table color gradient ### |
725 | 706 | if type(value) is tuple and not value[0] == ".": # (value, min, max, threshold) |
726 | 707 | if len(value) == 3: # has no threshold |
727 | 708 | range = float(value[2]) - float(value[1]) # max - min |
|
778 | 759 | blue = 20 |
779 | 760 | colorstring = str(int(red)) + ", " + str(int(green)) + ", " + str(blue) |
780 | 761 | row += td(value[0], style='background-color: rgb(' + colorstring + ")") |
781 | | - # if value == annotation._AnnovarParser__DANN_score: |
782 | | - # print str(value[2]) +", "+ str(value[3]) |
783 | | - # print value[0] |
784 | | - # print range |
785 | | - # print percentage |
786 | 762 |
|
787 | 763 | elif type(value) is tuple and value[0] == ".": |
788 | 764 | row += td(value[0]) |
|
817 | 793 | else: |
818 | 794 | row += td(value) |
819 | 795 |
|
820 | | - export_string = "" |
821 | 796 | # check for final prediction ### |
| 797 | + export_string = "" |
822 | 798 | if annotation._AnnovarParser__MetaLR_pred == "T": |
823 | 799 | export_string += "Tolerated" |
824 | 800 | elif annotation._AnnovarParser__MetaLR_pred == "D": |
|
864 | 840 | export_cnt += 1 |
865 | 841 |
|
866 | 842 | target_html.write(doc.render()) |
867 | | -# print(doc.render()) |
868 | 843 | target_html.close() |
869 | 844 |
|
870 | 845 | print "FINISHED" |
0 commit comments