From 5b9cf32b6614e2bd3ccd89b9d3bd9bd1f595268f Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Wed, 27 May 2015 14:07:07 +0100 Subject: [PATCH] Fixed bug in dxy calculation --- egglib_sliding_windows.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/egglib_sliding_windows.py b/egglib_sliding_windows.py index 9d10efa..5a42c33 100644 --- a/egglib_sliding_windows.py +++ b/egglib_sliding_windows.py @@ -157,9 +157,11 @@ def dxy(align): # "align" if the egglib alignment object, this consistes of sequ diffs = sum(sA != sB for sA, sB in zippedSeqs if sA != "N" and sB != "N") #sites = sum(sA != "N" and sB != "N" for sA, sB in zippedSeqs) sites = len([site for site in zippedSeqs if site[0] != "N" and site[1] != "N"]) - + #now add this pairwise dxy to the total and add 1 to the number of pairs considered + pairwiseSum += 1.0*diffs/sites + totalPairs += 1 #after considering all positions for each pair of haplotypes, return the average pairwise pi - return 1.0 * diffs/sites + return pairwiseSum/totalPairs def px(align):