Ejemplo n.º 1
0
def main():
    scaffoldData, homHetRatios = readScaffoldData(sys.argv[1], delimiter=",")

    # print each row with data in scaffoldData
    print "\t".join(["Marker", "Chr", "Start", "End", "Pheno", "Color"])
    for chrBin, row in readMutationData(sys.argv[2], scaffoldData, delimiter=","):
        out = [row[0], chrBin[0], chrBin[1], chrBin[1], row[7], 2 if row[7] == "het" else 1]
        print "\t".join(map(str, out))
    pass
Ejemplo n.º 2
0
def main():
    scaffoldData, homHetRatios = readScaffoldData(sys.argv[1], delimiter=',')

    # print each row with data in scaffoldData
    print '\t'.join(['Marker', 'Chr', 'Start', 'End', 'Pheno', 'Color'])
    for chrBin, row in readMutationData(sys.argv[2],
                                        scaffoldData,
                                        delimiter=','):
        out = [
            row[0], chrBin[0], chrBin[1], chrBin[1], row[7],
            2 if row[7] == 'het' else 1
        ]
        print '\t'.join(map(str, out))
    pass
Ejemplo n.º 3
0
def processMutationData(fn, scaffoldData, homHetRatios, delimiter=" "):
    """
    Counts the number of hom/het mutations per bin, and
    calculates het/hom ratio. The hom/het counts are stored in another dictonary per bin
    such that we can directly count the number of occurrences of "het" and "hom".
    """
    for chrBin, row in readMutationData(fn, scaffoldData, delimiter=delimiter):
        homHetRatios[chrBin][row[7]] += 1

    # Finished reading data, now calculate ratios.
    for chrBin in homHetRatios:
        if homHetRatios[chrBin]["hom"] > 0:
            homHetRatios[chrBin]["ratio"] = homHetRatios[chrBin]["het"] / homHetRatios[chrBin]["hom"]
        else:
            # if hom-count is zero, no ratio can be calculated
            homHetRatios[chrBin]["ratio"] = "NA"
        # convert dictionaries to lists [hom, het, ratio]
        homHetRatios[chrBin] = [homHetRatios[chrBin]["hom"], homHetRatios[chrBin]["het"], homHetRatios[chrBin]["ratio"]]

    return homHetRatios
Ejemplo n.º 4
0
def processMutationData(fn, scaffoldData, homHetRatios, delimiter=' '):
    """
    Counts the number of hom/het mutations per bin, and
    calculates het/hom ratio. The hom/het counts are stored in another dictonary per bin
    such that we can directly count the number of occurrences of "het" and "hom".
    """
    for chrBin, row in readMutationData(fn, scaffoldData, delimiter=delimiter):
        homHetRatios[chrBin][row[7]] += 1

    # Finished reading data, now calculate ratios.
    for chrBin in homHetRatios:
        if homHetRatios[chrBin]['hom'] > 0:
            homHetRatios[chrBin]['ratio'] = homHetRatios[chrBin][
                'het'] / homHetRatios[chrBin]['hom']
        else:
            # if hom-count is zero, no ratio can be calculated
            homHetRatios[chrBin]['ratio'] = 'NA'
        # convert dictionaries to lists [hom, het, ratio]
        homHetRatios[chrBin] = [
            homHetRatios[chrBin]['hom'], homHetRatios[chrBin]['het'],
            homHetRatios[chrBin]['ratio']
        ]

    return homHetRatios