Extracts amplicon sequence from contig file
        :param sample: sample metadata object
        :param contig: name of the contig hit by primers
        :param amplicon_range: range of the amplicon within the contig
        :param forward_primer: name of the forward primer
        :param reverse_primer: name of the reverse primer

def ampliconfile(self, sample, contig, amplicon_range, forward_primer, reverse_primer):
        """
        Extracts amplicon sequence from contig file
        :param sample: sample metadata object
        :param contig: name of the contig hit by primers
        :param amplicon_range: range of the amplicon within the contig
        :param forward_primer: name of the forward primer
        :param reverse_primer: name of the reverse primer
        """
        # Open the file
        with open(sample[self.analysistype].ampliconfile, 'a') as ampliconfile:
            try:
                # Load the records from the assembly into the dictionary
                for record in SeqIO.parse(sample[self.analysistype].assemblyfile, 'fasta'):
                    if record.id == contig:
                        try:
                            # Extract the name of the gene from the primer name
                            genename = forward_primer[0].split('-')[0]
                            try:
                                # Sort the range calculated above
                                start = amplicon_range[0]
                                end = amplicon_range[1]
                                # Slice the gene sequence from the sequence record - remember to subtract one to
                                # allow for zero-based indexing
                                genesequence = str(record.seq)[int(start) - 1:int(end)]
                                # Set the record.id to be the sample name, the contig name,
                                # the range, and the primers
                                record.id = '{sn}_{contig}_{range}_{primers}' \
                                    .format(sn=sample.name,
                                            contig=contig,
                                            range='_'.join(str(x) for x in sorted(sample[self.analysistype]
                                                                                  .range[record.id][genename])),
                                            primers='_'.join(['_'.join(forward_primer), '_'.join(reverse_primer)]))
                                # Clear the record.description
                                record.description = ''
                                # Create a seq record from the sliced genome sequence
                                record.seq = Seq.Seq(genesequence)
                                # Write the amplicon to file
                                SeqIO.write(record, ampliconfile, 'fasta')
                            except IndexError:
                                pass
                        except AttributeError:
                            pass
            except FileNotFoundError:
                pass