def loci2multinex(name, <EOL>locifile, <EOL>subsamples=None,<EOL>outdir=None,<EOL>maxloci=None,<EOL>minSNPs=<NUM_LIT:1>,<EOL>seed=<NUM_LIT>,<EOL>mcmc_burnin=int(<NUM_LIT>),<EOL>mcmc_ngen=int(<NUM_LIT>),<EOL>mcmc_sample_freq=<NUM_LIT:1000>,<EOL>):
<EOL>if outdir:<EOL><INDENT>if not os.path.exists(outdir):<EOL><INDENT>os.makedirs(outdir)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>outdir = os.path.curdir<EOL><DEDENT>outdir = os.path.realpath(outdir)<EOL>outdir = os.path.join(outdir, "<STR_LIT>".format(name))<EOL>if not os.path.exists(outdir):<EOL><INDENT>os.makedirs(outdir)<EOL><DEDENT>else:<EOL><INDENT>ofiles = glob.glob(os.path.join(outdir, "<STR_LIT>"))<EOL>for ofile in ofiles:<EOL><INDENT>os.remove(ofile)<EOL><DEDENT><DEDENT>with open(locifile) as infile:<EOL><INDENT>loci = (i for i in infile.read().strip().split("<STR_LIT>"))<EOL><DEDENT>if not subsamples:<EOL><INDENT>with open(locifile) as infile:<EOL><INDENT>subs = set((i.split()[<NUM_LIT:0>] for i in infile.readlines() if "<STR_LIT>" not in i))<EOL><DEDENT><DEDENT>else:   <EOL><INDENT>subs = set(subsamples)<EOL><DEDENT>lens = len(subs)<EOL>nlocus = <NUM_LIT:0><EOL>for loc in loci:<EOL><INDENT>dat = loc.split("<STR_LIT:\n>")[:-<NUM_LIT:1>]<EOL>names = [i.split()[<NUM_LIT:0>] for i in dat]<EOL>seqs = np.array([list(i.split()[<NUM_LIT:1>]) for i in dat])<EOL>if len(set(names).intersection(set(subs))) == lens:<EOL><INDENT>seqsamp = seqs[[names.index(tax) for tax in subs]]<EOL>seqsamp = _resolveambig(seqsamp)<EOL>pis = _count_PIS(seqsamp, minSNPs)<EOL>if pis:<EOL><INDENT>nlocus += <NUM_LIT:1><EOL>copied = seqsamp.copy()<EOL>copied[copied == "<STR_LIT:->"] = "<STR_LIT:N>"<EOL>rmcol = np.all(copied == "<STR_LIT:N>", axis=<NUM_LIT:0>)<EOL>seqsamp = seqsamp[:, ~rmcol]<EOL>mdict = dict(list(zip(subs, [i.tostring() for i in seqsamp])))<EOL>nexmake(mdict, nlocus, outdir, mcmc_burnin, mcmc_ngen, mcmc_sample_freq)<EOL><DEDENT><DEDENT><DEDENT>print("<STR_LIT>".format(nlocus, outdir))<EOL>
Converts loci file format to multiple nexus formatted files, one for 
each locus, and writes a mrbayes block in the nexus information. The 
mrbayes block will be set to run 2 replicate chains, for [mcmc_ngen]
generations, skipping [burnin] steps, and sampling every 
[mcmc_sample_freq] steps. 


Parameters:
-----------
name: (str)
    A prefix name for output files that will be produced
locifile: (str)
    A .loci file produced by ipyrad.
maxloci: (int)
    Limit the number of loci to the first N loci with sufficient sampling
    to be included in the analysis. 
minSNPs: (int)
    Only include loci that have at least N parsimony informative SNPs.
seed: (int)
    Random seed used for resolving ambiguities.
burnin: (int)
    mrbayes nexus block burnin parameter used for 'sump burnin' and 'sumt burnin'.
    The number of generations to skip before starting parameter and tree sampling. 
mcmc_ngen: (int)
    mrbayes nexus block 'mcmc ngen' and 'mcmc printfreq' parameters. We don't really
    to have any info printed to screen, so these values are set equal. This is the 
    length of the chains that will be run. 
mcmc_sample_freq: (int)
    mrbayes nexus block 'mcmc samplefreq' parameter. The frequency of sampling from
    the mcmc chain.