Skip to content

Commit

Permalink
works now even if all samples in data file are not assigned to popula…
Browse files Browse the repository at this point in the history
…tions.
  • Loading branch information
dereneaton committed Apr 2, 2015
1 parent 2d0426e commit 65077a9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions loci2treemix.py
Expand Up @@ -68,6 +68,14 @@ def make(WORK, outname, taxadict, minhits):
a,b = line.split()
SNPS[a] = b

## reduce Taxa dict to only samples that are in the unlinkedsnps alignment
for key in taxa:
replacement = []
for val in taxa[key]:
if val in SNPS.keys():
replacement.append(val)
taxa[key] = replacement

## create a dictionary with empty lists for each taxon
FREQ = OrderedDict()
for tax in taxa:
Expand All @@ -84,6 +92,7 @@ def make(WORK, outname, taxadict, minhits):
if all(GG):
keeps.append(snp)


for keep in keeps:
for tax in FREQ:
bunch = []
Expand All @@ -93,11 +102,6 @@ def make(WORK, outname, taxadict, minhits):
#print tax, i, SNPS[i][keep], bunch
FREQ[tax].append("".join(bunch))

## check that no included taxa have no data
# for i,j in zip(taxa,minhits):
# if not FREQ[i]:
# print "taxon/group ",i,"has no data shared across at least",j,"samples, it must be excluded to build treemix output"

## header
print >>outfile, " ".join(FREQ.keys())

Expand Down

0 comments on commit 65077a9

Please sign in to comment.