Mercurial > repos > melissacline > ucsc_cancer_utilities
diff parseSnpEffVcf.py @ 48:a38cc72edd75
xena header
author | jingchunzhu |
---|---|
date | Fri, 14 Aug 2015 00:04:41 -0700 |
parents | 23d98125d20c |
children |
line wrap: on
line diff
--- a/parseSnpEffVcf.py Thu Aug 13 23:26:33 2015 -0700 +++ b/parseSnpEffVcf.py Fri Aug 14 00:04:41 2015 -0700 @@ -436,7 +436,13 @@ myVcf = vcf(sys.stdin) - fout =open(args.ID,'w') + tmpOutput = "file_"+args.ID + fout =open(tmpOutput, 'w') + + if args.ID[-4:]==".vcf": + sampleID = args.ID[:-4] + else: + sampleID = args.ID for row in myVcf.read(): #total =total+1 @@ -460,7 +466,7 @@ AA_Change = row.effectPerGene[gene]["Amino_Acid_Change"] if AA_Change !="" and AA_Change[:2]!="p.": AA_Change="p."+AA_Change - fout.write(string.join([args.ID, row.chr, str(row.start), + fout.write(string.join([sampleID, row.chr, str(row.start), str(row.end), row.reference, row.alt, gene,row.effectPerGene[gene]["effect"], str(row.DNA_AF), str(row.RNA_AF),AA_Change @@ -470,7 +476,7 @@ gene ="" AA_Change="" effect ="" - fout.write(string.join([args.ID, row.chr, str(row.start), + fout.write(string.join([sampleID, row.chr, str(row.start), str(row.end), row.reference, row.alt, gene,effect, str(row.DNA_AF), str(row.RNA_AF),AA_Change @@ -478,10 +484,10 @@ ],"\t")+"\n") fout.close() - os.system("cat "+args.ID+" >> "+args.output) - os.system("rm -f "+args.ID) + os.system("cat "+tmpOutput+" >> "+args.output) + os.system("rm -f "+tmpOutput) if __name__ == '__main__': - main() + main()