Updates file of alleles if the new allele passes length and identity checks
        :param sample: sample object
        :param gene: name of gene of interest
        :param targetallele: closest allele in database

def alleleupdater(self, sample, gene, targetallele):
        """
        Updates file of alleles if the new allele passes length and identity checks
        :param sample: sample object
        :param gene: name of gene of interest
        :param targetallele: closest allele in database
        """
        from Bio.Seq import Seq
        from Bio.Alphabet import IUPAC
        from Bio.SeqRecord import SeqRecord
        # As there is some discrepancy with the capitalisation of terms, make sure it is consistent
        analysistype = 'rMLST' if self.analysistype.lower() == 'rmlst' else 'MLST'

        # Set the directory containing the profile and alleles
        alleledir = self.referencefilepath + analysistype + '/local' if self.pipeline else self.referencefilepath
        allelefile = glob('{}/{}.fa'.format(alleledir, gene))[0]
        # Create a string to store the last local allele number
        nextallele = str()
        # Check the local allele file to see if this allele has already been recorded
        for record in SeqIO.parse(allelefile, 'fasta'):
            # String match of the sequence to the sequence of the alleles - if they match then set the name of the
            # matching allele to this local allele
            if sample[self.analysistype].queryseq[gene] == str(record.seq):

                allelenumber = record.id.split('_')[-1]
                # Return allelenumber, percent identity (100.0%), hsp.score - 100?
                return '', '', ''
            # Record the allele number + 1; following the last record, this number will represent the next allele number
            nextallele = int(record.id.split('_')[-1]) + 1
        # Translate the nucleotide sequence to determine if there are any internal stop codons
        dnaseq = Seq(sample[self.analysistype].queryseq[gene], IUPAC.unambiguous_dna)
        protseq = str(dnaseq.translate())
        # There should be only one stop codon per sequence. In sequences with more than one stop codon, this additional
        # stop codon must be internal
        internalstop = True if protseq.count('*') > 1 else False
        if not internalstop:

            # If the alignment length is less than the subject length, then the query sequence is truncated.
            # This may not be an issue, but it must still be flagged
            truncated = True if sample[self.analysistype].alignmentlength[gene] < sample[self.analysistype].subjectlength[gene] else False
            if not truncated:
                print('full length', sample.name, gene, nextallele, targetallele, alleledir, allelefile, protseq)
                # The header will be >BACT00001_1000000
                definitionline = '{}_{} {} NT from allele {}### no internal stop codons'\
                    .format(gene, nextallele, sample[self.analysistype].mismatches[gene], sample[self.analysistype].closealleles[gene])
                # Create a sequence record using BioPython
                fasta = SeqRecord(dnaseq,
                                  # Without this, the header will be improperly formatted
                                  description='',
                                  # Use >:definitionline as the header
                                  id=definitionline)
                print(definitionline)
                # with open(sample[self.analysistype].supplementalalleles) as supplemental:
                #     # Use the SeqIO module to properly format the new sequence record
                #     SeqIO.write(fasta, supplemental, 'fasta')
                # with open(allelefile) as localalleles:
                #     # Use the SeqIO module to properly format the new sequence record
                #     SeqIO.write(fasta, localalleles, 'fasta')
            else:
                print('truncated', sample.name, gene, nextallele, targetallele, alleledir, allelefile, protseq)

        else:
            print('internal stop', sample.name, gene, nextallele, targetallele, alleledir, allelefile, protseq)

        return '', '', ''