def filter(myPileupFile, outFile):
    fout = open(outFile, 'w')
    #pileupInfoStIdx = 11
    header = 'gene\tchrom\tpos\tref\taltLs\tvariant'
    with open(myPileupFile) as f:
        print >> fout, header
        for line in f:
            if line[0] != '#':
                sp = line.strip().split('\t')
                chrom, pos, rs, ref, altLs = sp[0:5]
                gene = scoreClinvar.parseGene(sp, 7)

                callStatus = []
                pileupData = []

                idxLsLs = []
                newAltLs = []
                # GCGGCGGAGTGTTGTGCGAGTC
                # changed to ACGGCGGAGTGTTGTGCGAGTC,G 
                # Need A list of list of idx
                # and and a list of alternatives
                # output will be idx1,idx2;idx1 w/ alt1,alt2

                for alt in altLs.split(','):
                    newAltLs.append(alt)
                for newAlt in newAltLs:
                    print >> fout, '\t'.join( (gene, chrom,
                                               str(int(pos)),
                                               ref, newAlt,
                                               chrom + ':' + str(int(pos)) +
                                               ref + '>' + altLs,
                                               ) )
    fout.close()
Example #2
0
def convert(myPileupFile, outFile):
    fout = open(outFile, 'w')
    #pileupInfoStIdx = 11
    header = 'gene\tchrom\tpos\tref\taltLs\tvariant'
    with open(myPileupFile) as f:
        print >> fout, header
        for line in f:
            sp = line.strip().split('\t')
            chrom, pos, rs, ref, altLs = sp[0:5]
            gene = scoreClinvar.parseGene(sp, 7)
            newAltLs = []
            for alt in altLs.split(','):
                newAltLs.append(alt)
            for newAlt in newAltLs:
                print >> fout, '\t'.join( (gene, chrom,
                                           str(int(pos)),
                                           ref, newAlt,
                                           chrom + ':' + str(int(pos)) +
                                           ref + '>' + altLs,
                                           ) )
    fout.close()