Exemple #1
0
            posE = pos

        # select samples
        sample_charaters = calls.selectSamples(sampCol, words)

        # check if one- or two-character code
        if any(["/" in gt for gt in sample_charaters]):
            sample_charaters = calls.twoToOne(sample_charaters)

        # if window size is reached output the results
        if Chr > ChrPrevious:  # if end of a chromosome
            try:
                HeterWindow = round(meanWindow(Hwindow, Twindow), 4)
            except Exception:
                HeterWindow = "NA"
            calls.processWindow(ChrPrevious, posS, posE, HeterWindow,
                                outputFile)
            windPosEnd = windSize
            Hwindow = []
            Twindow = []
            posS = pos
        elif pos > windPosEnd:  # if end of a window
            try:
                HeterWindow = round(meanWindow(Hwindow, Twindow), 4)
            except Exception:
                HeterWindow = "NA"
            calls.processWindow(Chr, posS, posE, HeterWindow, outputFile)
            windPosEnd = windPosEnd + windSize
            Hwindow = []
            Twindow = []
            posS = pos
            while pos > windPosEnd:  # if the gap in positions is larger than window size
        pos = int(words[1])
        indVal = float(words[2])

        # to store the values of a previous line
        if not ChrPrevious:
            ChrPrevious = Chr
        if not posS:
            posS = pos
        if not posE:
            posE = pos

        # if window size is reached output the results
        if Chr != ChrPrevious:  # if end of a chromosome
            meanValWindow = proportionWindow(Vwindow, args.threshold)
            meanValWindowP = '\t'.join(str(s) for s in meanValWindow)
            calls.processWindow(ChrPrevious, posS, posE, meanValWindowP,
                                outputFile)
            windPosEnd = windSize
            Vwindow = []
            posS = pos
        elif pos > windPosEnd:  # if end of a window
            if Vwindow:
                meanValWindow = proportionWindow(Vwindow, args.threshold)
                meanValWindowP = '\t'.join(str(s) for s in meanValWindow)
                calls.processWindow(Chr, posS, posE, meanValWindowP,
                                    outputFile)
            windPosEnd = windPosEnd + windSize
            Vwindow = []
            posS = pos
            while pos > windPosEnd:  # gap is larger than window size
                windPosEnd = windPosEnd + windSize
Exemple #3
0
        # to store the values of a previous line
        if not ChrPrevious:
            ChrPrevious = Chr
        if not posS:
            posS = pos
        if not posE:
            posE = pos

        # select samples
        sample_charaters = calls.selectSamples(sampCol, words)

        # if window size is reached output the results
        if Chr > ChrPrevious:
            NsInWindow = meanInWindow(Nwindow, nSample)
            calls.processWindow(ChrPrevious, posS, posE, NsInWindow,
                                NsFr_output)
            windPosEnd = windSize
            Nwindow = []
            posS = pos
        elif pos > windPosEnd:
            NsInWindow = meanInWindow(Nwindow, nSample)
            calls.processWindow(Chr, posS, posE, NsInWindow, NsFr_output)
            windPosEnd = windPosEnd + windSize
            Nwindow = []
            posS = pos
            while pos > windPosEnd:  # if the gap in positions is larger than window size
                windPosEnd = windPosEnd + windSize

        ChrPrevious = Chr
        posE = pos