Skip to content

Commit

Permalink
memory load does not exceed 1GB for phy/nex output
Browse files Browse the repository at this point in the history
  • Loading branch information
dereneaton committed Sep 11, 2015
1 parent 6619406 commit 0303332
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
22 changes: 15 additions & 7 deletions pyrad/alignable.py
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import os
import shutil
import sys
import glob
import subprocess
Expand Down Expand Up @@ -798,12 +799,19 @@ def main(outgroup, minspecies, outname,
formats = outform.split(",")

" make phy, nex, SNP, uSNP, structure"
if any([i in formats for i in ['n','p']]):
if 'n' in formats:
print "\twriting nexus file"
if 'p' in formats:
print "\twriting phylip file"
loci2phynex.make(WORK,outname,names,longname, formats)
try:
os.mkdir(os.path.join(WORK, "tmp"))
if any([i in formats for i in ['n','p']]):
if 'p' in formats:
print "\tfiltering & writing to phylip file"
if 'n' in formats:
print "\twriting nexus file"
loci2phynex.make(WORK,outname,names,longname, formats)
finally:
print 'done'
if os.path.exists(os.path.join(WORK, "tmp")):
shutil.rmtree(os.path.join(WORK, "tmp"))


if 'f' in formats:
print "\tWriting gphocs file"
Expand All @@ -813,7 +821,7 @@ def main(outgroup, minspecies, outname,
if 's' in formats:
print "\t + writing full SNPs file"
if 'u' in formats:
print "\t + writing unlinked SNPs file"
print "\t + writing unlinked bi-allelic SNPs file"
if 'k' in formats:
print "\t + writing STRUCTURE file"
if 'g' in formats:
Expand Down
5 changes: 3 additions & 2 deletions pyrad/loci2SNP.py
Expand Up @@ -77,20 +77,21 @@ def make(WORK, outname, names, formats, seed, ploidy):
rando = bisnps[np.random.randint(len(bisnps))]
elif maxlist:
rando = maxlist[np.random.randint(len(maxlist))]
tbi = 0
for tax in S:
if tax in ns:
if pis:
" if none are bi-allelic "
if not bisnps:
bis += 1
tbi += 1
Si[tax].append(ss[ns.index(tax)][rando])
if pis:
" add spacer between loci "
S[tax].append(" ")
else:
" invariable locus "
S[tax].append("_ ")

bis += tbi
" names "
SF = list(S.keys())
SF.sort()
Expand Down

0 comments on commit 0303332

Please sign in to comment.