Mercurial > repos > melissacline > ucsc_cancer_utilities
comparison parseSnpEffVcf.py @ 48:a38cc72edd75
xena header
author | jingchunzhu |
---|---|
date | Fri, 14 Aug 2015 00:04:41 -0700 |
parents | 23d98125d20c |
children |
comparison
equal
deleted
inserted
replaced
47:23d98125d20c | 48:a38cc72edd75 |
---|---|
434 parser.add_argument("output", type=str, help="outputfile") | 434 parser.add_argument("output", type=str, help="outputfile") |
435 args = parser.parse_args() | 435 args = parser.parse_args() |
436 | 436 |
437 myVcf = vcf(sys.stdin) | 437 myVcf = vcf(sys.stdin) |
438 | 438 |
439 fout =open(args.ID,'w') | 439 tmpOutput = "file_"+args.ID |
440 fout =open(tmpOutput, 'w') | |
441 | |
442 if args.ID[-4:]==".vcf": | |
443 sampleID = args.ID[:-4] | |
444 else: | |
445 sampleID = args.ID | |
440 | 446 |
441 for row in myVcf.read(): | 447 for row in myVcf.read(): |
442 #total =total+1 | 448 #total =total+1 |
443 if row.alt =="NA": | 449 if row.alt =="NA": |
444 continue ######## bad calls in the VCF | 450 continue ######## bad calls in the VCF |
458 if len(row.effectPerGene)!=0: | 464 if len(row.effectPerGene)!=0: |
459 for gene in row.effectPerGene.keys(): | 465 for gene in row.effectPerGene.keys(): |
460 AA_Change = row.effectPerGene[gene]["Amino_Acid_Change"] | 466 AA_Change = row.effectPerGene[gene]["Amino_Acid_Change"] |
461 if AA_Change !="" and AA_Change[:2]!="p.": | 467 if AA_Change !="" and AA_Change[:2]!="p.": |
462 AA_Change="p."+AA_Change | 468 AA_Change="p."+AA_Change |
463 fout.write(string.join([args.ID, row.chr, str(row.start), | 469 fout.write(string.join([sampleID, row.chr, str(row.start), |
464 str(row.end), row.reference, row.alt, | 470 str(row.end), row.reference, row.alt, |
465 gene,row.effectPerGene[gene]["effect"], | 471 gene,row.effectPerGene[gene]["effect"], |
466 str(row.DNA_AF), str(row.RNA_AF),AA_Change | 472 str(row.DNA_AF), str(row.RNA_AF),AA_Change |
467 #, str(row.NORMAL_AF) | 473 #, str(row.NORMAL_AF) |
468 ],"\t")+"\n") | 474 ],"\t")+"\n") |
469 else: | 475 else: |
470 gene ="" | 476 gene ="" |
471 AA_Change="" | 477 AA_Change="" |
472 effect ="" | 478 effect ="" |
473 fout.write(string.join([args.ID, row.chr, str(row.start), | 479 fout.write(string.join([sampleID, row.chr, str(row.start), |
474 str(row.end), row.reference, row.alt, | 480 str(row.end), row.reference, row.alt, |
475 gene,effect, | 481 gene,effect, |
476 str(row.DNA_AF), str(row.RNA_AF),AA_Change | 482 str(row.DNA_AF), str(row.RNA_AF),AA_Change |
477 #, str(row.NORMAL_AF) | 483 #, str(row.NORMAL_AF) |
478 ],"\t")+"\n") | 484 ],"\t")+"\n") |
479 fout.close() | 485 fout.close() |
480 | 486 |
481 os.system("cat "+args.ID+" >> "+args.output) | 487 os.system("cat "+tmpOutput+" >> "+args.output) |
482 os.system("rm -f "+args.ID) | 488 os.system("rm -f "+tmpOutput) |
483 | 489 |
484 if __name__ == '__main__': | 490 if __name__ == '__main__': |
485 main() | 491 main() |
486 | 492 |
487 | 493 |