def test_ssm_sequence_wrong_multiple_goi(self): """ Scenario desc: Gene of interest is found multiple times in the plasmid. We expect error. """ sequences = SSMSequences( forward_primer=fw_primer_short, reverse_primer=rv_primer_short, gene_of_interest=goi_short, plasmid=Plasmid(plasmid_sequence=plasmid_seq_short + goi_short)) with self.assertRaises(ValueError) as context: sequences.get_full_sequence_with_offset() self.assertTrue( 'Gene of interest position is ambiguous' in str(context.exception))
def test_ssm_sequence_complex_valid(self): """ Scenario desc: Checking creation of full sequence and finding the offset for long sequence (length=1747) """ sequences = SSMSequences(forward_primer=fw_primer, reverse_primer=rv_primer, gene_of_interest=gene_of_interest, plasmid=Plasmid(plasmid_sequence=plasmid_seq)) result_full_seq, offsets = sequences.get_full_sequence_with_offset() self.assertEqual(result_full_seq, full_seq) self.assertEqual(offsets, (316, 1747))
def test_ssm_sequence_wrong_rv_primer(self): """ Scenario desc: Complement to reverse primer is not found in sequence. We expect error. """ sequences = SSMSequences( forward_primer=fw_primer_short, reverse_primer="CCC", gene_of_interest=goi_short, plasmid=Plasmid(plasmid_sequence=plasmid_seq_short)) with self.assertRaises(ValueError) as context: sequences.get_full_sequence_with_offset() self.assertTrue('Reverse primer was not found in plasmid' in str( context.exception))
def test_ssm_sequence_missing_goi(self): """ Scenario desc: Gene of interest is not found in sequence. We expect error. """ sequences = SSMSequences( forward_primer=fw_primer_short, reverse_primer=rv_primer_short, gene_of_interest="GGG", plasmid=Plasmid(plasmid_sequence=plasmid_seq_short)) with self.assertRaises(ValueError) as context: sequences.get_full_sequence_with_offset() self.assertTrue('Gene of interest was not found in plasmid' in str( context.exception))
def test_ssm_sequence_valid_cyclic_seq(self): """ Scenario desc: check offset computation and g.o.i. look-up in cyclic sequence. Sequence has same start/end so here we look more at creating the full sequence. """ sequences = SSMSequences(forward_primer="AAT", reverse_primer="GGC", gene_of_interest="CCC", plasmid=Plasmid(plasmid_sequence="AAA" + plasmid_seq_short + "AAA")) result_full_seq, offsets = sequences.get_full_sequence_with_offset() self.assertEqual(result_full_seq, "AATGTCAAACCCTTTGCC") self.assertEqual(offsets, (9, 12))
def test_ssm_sequence_simple_valid(self): """ Scenario desc: check offset computation and g.o.i. look-up in simple sequence. :return: """ sequences = SSMSequences( forward_primer=fw_primer_short, reverse_primer=rv_primer_short, gene_of_interest="AAA", plasmid=Plasmid(plasmid_sequence=plasmid_seq_short)) result_full_seq, offsets = sequences.get_full_sequence_with_offset() self.assertEqual(result_full_seq, "AATGTCAAACCCTTTGCC") self.assertEqual(offsets, (6, 9))
def test_ssm_sequence_simple_valid_rev(self): """ Scenario desc: check offset computation and g.o.i. look-up in simple sequence. This time the forward primer is after reverse primer in sequence. :return: """ sequences = SSMSequences( forward_primer="GCC", reverse_primer="TTT", gene_of_interest="GTC", plasmid=Plasmid(plasmid_sequence="AATGTCAAACCCTTTGCC")) result_full_seq, offsets = sequences.get_full_sequence_with_offset() self.assertEqual(result_full_seq, "GCCAATGTCAAA") self.assertEqual(offsets, (6, 9))
def __init__(self, ssm_sequences: SSMSequences, ssm_config: SSMConfig, main_primer_generator: PrimerGenerator, secondary_primer_generator: PrimerGenerator) -> None: self.main_primer_generator = main_primer_generator self.secondary_primer_generator = secondary_primer_generator self.config = ssm_config self.temp_calculator = ssm_config.temperature_config.create_calculator( ) if self.temp_calculator.precision > 1: raise ValueError( """Temperature calculation for SSM with precision of more than one decimal place \ is not needed and have severe negative impact on performance""") self.gc_settings = MinOptMax(self.config.min_gc_content, self.config.opt_gc_content, self.config.max_gc_content) self.forward_primer = ssm_sequences.forward_primer self.reverse_primer = ssm_sequences.reverse_primer self.forward_primer_temp = self.temp_calculator(self.forward_primer) self.reverse_primer_temp = self.temp_calculator(self.reverse_primer) self.three_end_pivot_temps = [ self.forward_primer_temp, self.reverse_primer_temp ] self.sequence, self.goi_range = ssm_sequences.get_full_sequence_with_offset( ) self.flanks = SSMFlankingSequences(ssm_sequences.forward_primer, ssm_sequences.reverse_primer)
def sample_ssm_sequence(): return SSMSequences( forward_primer="PLACE_YOUR_OWN_SEQUENCE_FOR_TESTING", reverse_primer="PLACE_YOUR_OWN_SEQUENCE_FOR_TESTING", gene_of_interest="PLACE_YOUR_OWN_SEQUENCE_FOR_TESTING", plasmid=Plasmid( plasmid_sequence="PLACE_YOUR_OWN_SEQUENCE_FOR_TESTING"))
def test_ssm_sequence_goi_outside_primers(self): """ Scenario desc: Gene of interest is not found between forward and revers primer. We expect error. Plasmid sequence: AAT GTC AAA CCC TTT GCC Forward primer: AAT Reverse primer: AAA (reverse is TTT) Gene of interest: GCC (which is after TTT) Sequence specified by primers should be: AAT GTC AAA CCC TTT """ sequences = SSMSequences( forward_primer=fw_primer_short, reverse_primer="AAA", gene_of_interest="GCC", plasmid=Plasmid(plasmid_sequence=plasmid_seq_short)) with self.assertRaises(ValueError) as context: sequences.get_full_sequence_with_offset() self.assertTrue('Gene of interest was not found in plasmid' in str( context.exception))
def create_test_config(goi, plasmid, mutations, use_fast_approximation_algorithm): ssm_data = SSMInput( sequences=SSMSequences( forward_primer="PLACE_YOUR_OWN_SEQUENCE_FOR_TESTING", reverse_primer="PLACE_YOUR_OWN_SEQUENCE_FOR_TESTING", gene_of_interest=goi, plasmid=Plasmid(plasmid_sequence=plasmid, )), config=SSMConfig( calculation_method="MaxMutationsCovered", max_three_end_ranges=1, temperature_config=TemperatureConfig(precision=0), use_fast_approximation_algorithm=use_fast_approximation_algorithm), mutations=mutations) return ssm_data