Skip to content

Instantly share code, notes, and snippets.

@rcallahan
Created February 25, 2014 21:22
Show Gist options
  • Save rcallahan/8fc3d3ba4d43155a0bc0 to your computer and use it in GitHub Desktop.
Save rcallahan/8fc3d3ba4d43155a0bc0 to your computer and use it in GitHub Desktop.
def setupV1bin(maxmm, binlist, ixlist, mapslice, alleles, qdlist):
"""Int -> [((Int,Int),String)] -> [(Int,String)] -> (Int, Int) -> [String] -> [String] ->
(Set Int, (Int -> String -> IO ()), IO ())"""
countmap = cnibls.emptyCountMap(ixlist,binlist)
memodict = {}
refdict = {}
def mapperClosure(cm, md, rd):
def innie(ix, query):
loc, allele = cnibls.FastMemoMapperQD(maxmm, md, mapslice, rd, alleles, qdlist, query)
if allele == 1:
cm[ix][loc].a += 1
elif allele == 2:
cm[ix][loc].b += 1
return innie
def finishClosure(cm):
def innie():
for ix,ixmap in cm.iteritems():
for loc, abcnt in ixmap.iteritems():
print "%d\t%d\t%d\t%d" % (ix, loc, abcnt.a, abcnt,b)
return (set(ix for ix, _ in ixlist), mapperClosure(countmap, memodict, refdict),
finishClosure(countmap))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment