def testMutationPositionStartCodon2(self): mutation_position = 3 # @formatter:off database_amr_gene_string = "ATCGATCGA" input_genome_string = "ATCAATCGA" #@formatter:on amr_gene_start = 1 mutation = CodonMutationPosition(mutation_position, database_amr_gene_string, input_genome_string, amr_gene_start) self.assertEqual(mutation.get_nucleotide_position(), 4, 'Incorrect nucleotide position') self.assertEqual(mutation.get_codon_start(), 2, 'Incorrect codon start') self.assertEqual(mutation.get_mutation_position(), 2, 'Incorrect mutation start') self.assertEqual(mutation.get_database_amr_gene_codon(), 'GAT', 'Incorrect database codon') self.assertEqual(mutation.get_input_genome_codon(), 'AAT', 'Incorrect query codon') self.assertEqual(mutation.get_database_amr_gene_mutation(), 'D', 'Incorrect database amino acid') self.assertEqual(mutation.get_input_genome_mutation(), 'N', 'Incorrect query amino acid') self.assertEqual(mutation.get_mutation_string_short(), 'D2N', 'Incorrect string')
def testMutationPositionGapReferenceMiddle(self): mutation_position = 1 # @formatter:off database_amr_gene_string = "A-CG" input_genome_string = "ATCG" #@formatter:on amr_gene_start = 1 mutation = CodonMutationPosition(mutation_position, database_amr_gene_string, input_genome_string, amr_gene_start) self.assertEqual(mutation.get_nucleotide_position(), 2, 'Incorrect nucleotide position') self.assertEqual(mutation.get_codon_start(), 1, 'Incorrect codon start') self.assertEqual(mutation.get_mutation_position(), 1, 'Incorrect mutation start') self.assertEqual(mutation.get_database_amr_gene_codon(), 'A-C', 'Incorrect database codon') self.assertEqual(mutation.get_input_genome_codon(), 'ATC', 'Incorrect query codon') self.assertEqual(mutation.get_database_amr_gene_mutation(), 'X', 'Incorrect database amino acid') self.assertEqual(mutation.get_input_genome_mutation(), 'I', 'Incorrect query amino acid') self.assertEqual(mutation.get_mutation_string_short(), 'X1I', 'Incorrect string')
def testMutationPositionEndCodon1(self): mutation_position = 2 # @formatter:off database_amr_gene_string = "ATCGATCGA" input_genome_string = "ATGGATCGA" #@formatter:on amr_gene_start = 1 mutation = CodonMutationPosition(mutation_position, database_amr_gene_string, input_genome_string, amr_gene_start) self.assertEqual(mutation.get_nucleotide_position(), 3, 'Incorrect nucleotide position') self.assertEqual(mutation.get_codon_start(), 1, 'Incorrect codon start') self.assertEqual(mutation.get_mutation_position(), 1, 'Incorrect mutation start') self.assertEqual(mutation.get_database_amr_gene_codon(), 'ATC', 'Incorrect database codon') self.assertEqual(mutation.get_input_genome_codon(), 'ATG', 'Incorrect query codon') self.assertEqual(mutation.get_database_amr_gene_mutation(), 'I', 'Incorrect database amino acid') self.assertEqual(mutation.get_input_genome_mutation(), 'M', 'Incorrect query amino acid') self.assertEqual(mutation.get_mutation_string_short(), 'I1M', 'Incorrect string')
def testMutationPositionGapReferenceLargerPreviousCodon(self): mutation_position = 3 # @formatter:off database_amr_gene_string = "C-----GACTT" input_genome_string = "CCCATCGACTT" # @formatter:on amr_gene_start = 1 mutation = CodonMutationPosition(mutation_position, database_amr_gene_string, input_genome_string, amr_gene_start) self.assertEqual(mutation.get_nucleotide_position(), 4, 'Incorrect nucleotide position') self.assertEqual(mutation.get_codon_start(), 2, 'Incorrect codon start') self.assertEqual(mutation.get_mutation_position(), 2, 'Incorrect mutation start') self.assertEqual(mutation.get_database_amr_gene_codon(), '---', 'Incorrect database codon') self.assertEqual(mutation.get_input_genome_codon(), 'ATC', 'Incorrect query codon') self.assertEqual(mutation.get_database_amr_gene_mutation(), 'ins', 'Incorrect database amino acid') self.assertEqual(mutation.get_input_genome_mutation(), 'I', 'Incorrect query amino acid') self.assertEqual(mutation.get_mutation_string_short(), 'ins2I', 'Incorrect string')
def testMutationPositionGapBeforeAfter(self): mutation_position = 3 # @formatter:off database_amr_gene_string = "CCCATCGACT" input_genome_string = "-CCA--GA-T" #@formatter:on amr_gene_start = 1 mutation = CodonMutationPosition(mutation_position, database_amr_gene_string, input_genome_string, amr_gene_start) self.assertEqual(mutation.get_nucleotide_position(), 4, 'Incorrect nucleotide position') self.assertEqual(mutation.get_codon_start(), 2, 'Incorrect codon start') self.assertEqual(mutation.get_mutation_position(), 2, 'Incorrect mutation start') self.assertEqual(mutation.get_database_amr_gene_codon(), 'ATC', 'Incorrect database codon') self.assertEqual(mutation.get_input_genome_codon(), 'A--', 'Incorrect query codon') self.assertEqual(mutation.get_database_amr_gene_mutation(), 'I', 'Incorrect database amino acid') self.assertEqual(mutation.get_input_genome_mutation(), 'X', 'Incorrect query amino acid') self.assertEqual(mutation.get_mutation_string_short(), 'I2X', 'Incorrect string')
def _get_mutation_positions(self, start): amr_seq = self.get_amr_gene_seq() genome_seq = self.get_genome_contig_hsp_seq() # @formatter:off return [ CodonMutationPosition(i, amr_seq, genome_seq, start) for i in self._get_match_positions() ]
def testGetResistanceCodons1MutationStartCodon(self): mutation_position = 0 amr_gene_string = "ATCGATCGA" genome_string = "ATGGATCGA" amr_gene_start = 1 mutation_start_methionine = CodonMutationPosition( mutation_position, amr_gene_string, genome_string, amr_gene_start) resistance_mutations = self.database.get_resistance_codons( 'gyrA', [mutation_start_methionine]) self.assertEqual(resistance_mutations, [], "Did not pick up correct mutations")
def setUp(self): pandas_pointfinder_table = pd.DataFrame([ ['gyrA', 'gyrA', 1, 1, 'ATC', 'I', 'F', 'Quinolones', 15848289], ['gyrA', 'gyrA', 1, 2, 'GAT', 'D', 'N,H', 'Quinolones', 15848289], ], columns=( '#Gene_ID', 'Gene_name', 'No of mutations needed', 'Codon_pos', 'Ref_nuc', 'Ref_codon', 'Res_codon', 'Resistance', 'PMID')) self.database = PointfinderDatabaseInfo.from_pandas_table( pandas_pointfinder_table) mutation_position = 0 amr_gene_string = "ATCGATCGA" genome_string = "TTCGATCGA" amr_gene_start = 1 self.mutation1 = CodonMutationPosition(mutation_position, amr_gene_string, genome_string, amr_gene_start) mutation_position = 3 amr_gene_string = "ATCGATCGA" genome_string = "ATCAATCGA" amr_gene_start = 1 self.mutation2 = CodonMutationPosition(mutation_position, amr_gene_string, genome_string, amr_gene_start) mutation_position = 8 amr_gene_string = "ATCGATCGA" genome_string = "ATCGATCGT" amr_gene_start = 1 self.mutation_missing = CodonMutationPosition(mutation_position, amr_gene_string, genome_string, amr_gene_start)
def testGetResistanceCodons1MutationAANotMatch(self): mutation_position = 3 amr_gene_string = "ATCGATCGA" genome_string = "ATCGAACGA" amr_gene_start = 1 mutation_aa_not_match = CodonMutationPosition(mutation_position, amr_gene_string, genome_string, amr_gene_start) resistance_mutations = self.database.get_resistance_codons( 'gyrA', [mutation_aa_not_match]) self.assertEqual(resistance_mutations, [], "Did not pick up correct mutations")
def _get_mutation_positions(self, start): mutation_positions_filtered = [] codon_starts = [] amr_seq = self.get_amr_gene_seq() genome_seq = self.get_genome_contig_hsp_seq() # Only return mutation position objects with unique codon start positions mutation_positions = [ CodonMutationPosition(i, amr_seq, genome_seq, start) for i in self._get_match_positions() ] for m in mutation_positions: if m._codon_start not in codon_starts: codon_starts.append(m._codon_start) mutation_positions_filtered.append(m) # @formatter:off return mutation_positions_filtered