align_seqs - Aligns sequences with clustalo

    :param found_seqs: List of the reference sequences
    :type found_seqs: ``List``
    :param sequence: The input consensus sequence.
    :type sequence: SeqRecord
    :param locus: The gene locus associated with the sequence.
    :type locus: ``str``
    :param annotated: dictonary of the annotated features
    :type annotated: ``dict``
    :param start_pos: Where the reference sequence starts
    :type start_pos: ``int``
    :param missing: List of the unmapped features
    :type missing: ``List``
    :param cutoff: The alignment cutoff
    :type cutoff: ``float``
    :param verbose: Flag for running in verbose mode.
    :type verbose: ``bool``
    :param verbosity: Numerical value to indicate how verbose the output will be in verbose mode.
    :type verbosity: ``int``
    :rtype: :ref:`ann`

def align_seqs(found_seqs, sequence, locus, start_pos, missing,
               annotated, cutoff=0.90, verbose=False, verbosity=0):
    """
    align_seqs - Aligns sequences with clustalo

    :param found_seqs: List of the reference sequences
    :type found_seqs: ``List``
    :param sequence: The input consensus sequence.
    :type sequence: SeqRecord
    :param locus: The gene locus associated with the sequence.
    :type locus: ``str``
    :param annotated: dictonary of the annotated features
    :type annotated: ``dict``
    :param start_pos: Where the reference sequence starts
    :type start_pos: ``int``
    :param missing: List of the unmapped features
    :type missing: ``List``
    :param cutoff: The alignment cutoff
    :type cutoff: ``float``
    :param verbose: Flag for running in verbose mode.
    :type verbose: ``bool``
    :param verbosity: Numerical value to indicate how verbose the output will be in verbose mode.
    :type verbosity: ``int``
    :rtype: :ref:`ann`
    """
    logger = logging.getLogger("Logger." + __name__)
    seqs = [found_seqs, sequence]

    if verbose and verbosity > 0:
        logger.info("found_seqs length = " + str(len(found_seqs)))
        logger.info("sequence length = " + str(len(sequence)))

    seqs = []
    seqs.append(found_seqs)
    seqs.append(sequence)

    align = []

    # piping to clustalo failed
    # when sequences were over ~7k bp
    if len(sequence) > 7000:

        # Writing sequences out to fasta files..
        if verbose:
            logger.info("Sequence too large to use pipe")
        randid = randomid()
        input_fasta = str(randid) + ".fasta"
        output_clu = str(randid) + ".clu"
        SeqIO.write(seqs, input_fasta, "fasta")
        clustalomega_cline = ClustalOmegaCommandline(infile=input_fasta,
                                                     outfile=output_clu,
                                                     outfmt='clu', wrap=20000,
                                                     verbose=True, auto=True)
        stdout, stderr = clustalomega_cline()
        aligns = AlignIO.read(output_clu, "clustal")
        for aln in aligns:
            align.append(str(aln.seq))

        # Delete files
        cleanup(randid)
    else:
        # Running clustalo by piping in sequences
        indata = flatten([[">" + str(s.id), str(s.seq)]
                          for s in seqs])
        child = Popen(['clustalo',
                       '--outfmt', 'clu',
                       '--wrap=50000',
                       '--auto', '-i', '-'],
                      stdout=PIPE,
                      stderr=STDOUT,
                      stdin=PIPE)

        stdout = child.communicate(input=str.encode("\n".join(indata)))
        child.wait()

        lines = bytes.decode(stdout[0]).split("\n")
        for line in lines:
            if re.search("\w", line) and not re.search("CLUSTAL", line):
                alignment = re.findall(r"[\S']+", line)
                if len(alignment) == 2:
                    align.append(list(alignment[1]))
        child.terminate()

    # Print out what blocks haven't been annotated
    if verbose and len(align) > 0:
        logger.info("* ClustalOmega alignment succeeded *")

    insers, dels = 0, 0
    all_features = []
    if len(align)-2 == 0:
        infeats = get_seqfeat(seqs[0])
        diffs = count_diffs(align, infeats, sequence, locus, cutoff, verbose, verbosity)
        if isinstance(diffs, Annotation):
            if verbose:
                logger.info("Run alignment with " + found_seqs.id)
                logger.info("***********************")
            return diffs, 0, 0
        else:
            insers, dels = diffs[0], diffs[1]
        f = find_features(infeats, align[0], annotated, start_pos, cutoff)
        all_features.append(f)
    else:
        for i in range(0, len(align)-2):
            infeats = get_seqfeat(seqs[i])
            f = find_features(infeats, align[i], annotated, start_pos, cutoff)
            all_features.append(f)

    if len(all_features) > 0:
        if verbose:
            logger.info("-- Resolving features -- ")
            for f in all_features[0]:
                logger.info("Resolving -> " + f)

        annotation = resolve_feats(all_features,
                                   align[len(align)-1],
                                   align[0],
                                   start_pos,
                                   locus,
                                   missing,
                                   verbose,
                                   verbosity)
        if verbose:
            logger.info("Run alignment with " + found_seqs.id)
            logger.info("Missing features = " + ",".join(list(missing.keys())))
            logger.info("Number of features found = " + str(len(all_features)))
            logger.info("Features found = " + ",".join(list(all_features[0].keys())))
            logger.info("Features annotated = " + ",".join(list(annotation.annotation.keys())))
            logger.info("***********************")

        return annotation, insers, dels
    else:
        if verbose:
            logger.info("***********************")
        return Annotation(complete_annotation=False), 0, 0