def muscle(sequences=None, alignment_file=None, fasta=None,
    fmt='fasta', as_file=False, maxiters=None, diags=False,
    gap_open=None, gap_extend=None, muscle_bin=None):
    '''
    Performs multiple sequence alignment with MUSCLE.

    Args:

        sequences (list): Sequences to be aligned. ``sequences`` can be one of four things:

            1. a FASTA-formatted string

            2. a list of BioPython ``SeqRecord`` objects

            3. a list of AbTools ``Sequence`` objects

            4. a list of lists/tuples, of the format ``[sequence_id, sequence]``

        alignment_file (str): Path for the output alignment file. If not supplied,
            a name will be generated using ``tempfile.NamedTemporaryFile()``.

        fasta (str): Path to a FASTA-formatted file of sequences. Used as an
            alternative to ``sequences`` when suppling a FASTA file.

        fmt (str): Format of the alignment. Options are 'fasta' and 'clustal'. Default
            is 'fasta'.

        threads (int): Number of threads (CPU cores) for MUSCLE to use. Default is ``-1``, which
            results in MUSCLE using all available cores.

        as_file (bool): If ``True``, returns a path to the alignment file. If ``False``,
            returns a BioPython ``MultipleSeqAlignment`` object (obtained by calling
            ``Bio.AlignIO.read()`` on the alignment file).

        maxiters (int): Passed directly to MUSCLE using the ``-maxiters`` flag.

        diags (int): Passed directly to MUSCLE using the ``-diags`` flag.

        gap_open (float): Passed directly to MUSCLE using the ``-gapopen`` flag. Ignored
            if ``gap_extend`` is not also provided.

        gap_extend (float): Passed directly to MUSCLE using the ``-gapextend`` flag. Ignored
            if ``gap_open`` is not also provided.

        muscle_bin (str): Path to MUSCLE executable. ``abutils`` includes built-in MUSCLE binaries
            for MacOS and Linux, however, if a different MUSCLE binary can be provided. Default is
            ``None``, which results in using the appropriate built-in MUSCLE binary.

    Returns:

        Returns a BioPython ``MultipleSeqAlignment`` object, unless ``as_file`` is ``True``,
            in which case the path to the alignment file is returned.
    '''
    if sequences:
        fasta_string = _get_fasta_string(sequences)
    elif fasta:
        fasta_string = open(fasta, 'r').read()
    if muscle_bin is None:
        # mod_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        muscle_bin = os.path.join(BINARY_DIR, 'muscle_{}'.format(platform.system().lower()))
    aln_format = ''
    if fmt == 'clustal':
        aln_format = ' -clwstrict'
    muscle_cline = '{}{} '.format(muscle_bin, aln_format)
    if maxiters is not None:
        muscle_cline += ' -maxiters {}'.format(maxiters)
    if diags:
        muscle_cline += ' -diags'
    if all([gap_open is not None, gap_extend is not None]):
        muscle_cline += ' -gapopen {} -gapextend {}'.format(gap_open, gap_extend)
    muscle = sp.Popen(str(muscle_cline),
                      stdin=sp.PIPE,
                      stdout=sp.PIPE,
                      stderr=sp.PIPE,
                      universal_newlines=True,
                      shell=True)
    if sys.version_info[0] > 2:
        alignment = muscle.communicate(input=fasta_string)[0]
    else:
        alignment = unicode(muscle.communicate(input=fasta_string)[0], 'utf-8')
    aln = AlignIO.read(StringIO(alignment), fmt)
    if as_file:
        if not alignment_file:
            alignment_file = tempfile.NamedTemporaryFile().name
        AlignIO.write(aln, alignment_file, fmt)
        return alignment_file
    return aln
Performs multiple sequence alignment with MUSCLE.

    Args:

        sequences (list): Sequences to be aligned. ``sequences`` can be one of four things:

            1. a FASTA-formatted string

            2. a list of BioPython ``SeqRecord`` objects

            3. a list of AbTools ``Sequence`` objects

            4. a list of lists/tuples, of the format ``[sequence_id, sequence]``

        alignment_file (str): Path for the output alignment file. If not supplied,
            a name will be generated using ``tempfile.NamedTemporaryFile()``.

        fasta (str): Path to a FASTA-formatted file of sequences. Used as an
            alternative to ``sequences`` when suppling a FASTA file.

        fmt (str): Format of the alignment. Options are 'fasta' and 'clustal'. Default
            is 'fasta'.

        threads (int): Number of threads (CPU cores) for MUSCLE to use. Default is ``-1``, which
            results in MUSCLE using all available cores.

        as_file (bool): If ``True``, returns a path to the alignment file. If ``False``,
            returns a BioPython ``MultipleSeqAlignment`` object (obtained by calling
            ``Bio.AlignIO.read()`` on the alignment file).

        maxiters (int): Passed directly to MUSCLE using the ``-maxiters`` flag.

        diags (int): Passed directly to MUSCLE using the ``-diags`` flag.

        gap_open (float): Passed directly to MUSCLE using the ``-gapopen`` flag. Ignored
            if ``gap_extend`` is not also provided.

        gap_extend (float): Passed directly to MUSCLE using the ``-gapextend`` flag. Ignored
            if ``gap_open`` is not also provided.

        muscle_bin (str): Path to MUSCLE executable. ``abutils`` includes built-in MUSCLE binaries
            for MacOS and Linux, however, if a different MUSCLE binary can be provided. Default is
            ``None``, which results in using the appropriate built-in MUSCLE binary.

    Returns:

        Returns a BioPython ``MultipleSeqAlignment`` object, unless ``as_file`` is ``True``,
            in which case the path to the alignment file is returned.