def simulateAlignment(model, treeFile, alignmentPrefix, randomSeed=False):
if randomSeed == False:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>random.seed(randomSeed)<EOL><DEDENT>tree = Bio.Phylo.read(treeFile, '<STR_LIT>')<EOL>for node in tree.get_terminals() + tree.get_nonterminals():<EOL><INDENT>if (node.branch_length == None) and (node == tree.root):<EOL><INDENT>node.branch_length = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>node.branch_length /= model.branchScale<EOL><DEDENT><DEDENT>fd, temp_path = mkstemp()<EOL>Bio.Phylo.write(tree, temp_path, '<STR_LIT>')<EOL>os.close(fd)<EOL>pyvolve_tree = pyvolve.read_tree(file=temp_path)<EOL>os.remove(temp_path)<EOL>partitions = pyvolvePartitions(model)<EOL>alignment = '<STR_LIT>'.format(alignmentPrefix)<EOL>info = '<STR_LIT>'.format(alignmentPrefix)<EOL>rates = '<STR_LIT>'.format(alignmentPrefix)<EOL>evolver = pyvolve.Evolver(partitions=partitions, tree=pyvolve_tree)<EOL>evolver(seqfile=alignment, infofile=info, ratefile=rates)<EOL>for f in [rates,info, "<STR_LIT>"]:<EOL><INDENT>if os.path.isfile(f):<EOL><INDENT>os.remove(f)<EOL><DEDENT><DEDENT>assert os.path.isfile(alignment)<EOL>
Simulate an alignment given a model and tree (units = subs/site).

Simulations done using `pyvolve`.

Args:
    `model` (`phydmslib.models.Models` object)
        The model used for the simulations. Only
        models that can be passed to `pyvolve.Partitions`
        are supported.
    `treeFile` (str)
        Name of newick file used to simulate the sequences.
        The branch lengths should be in substitutions per site,
        which is the default units for all `phydms` outputs.
    `alignmentPrefix`
        Prefix for the files created by `pyvolve`.

The result of this function is a simulated FASTA alignment
file with the name having the prefix giving by `alignmentPrefix`
and the suffix `'_simulatedalignment.fasta'`.