def test_calculate_percent_identity(self): """ Test the calculate percent identity function """ cigar_string="100S84M16S" md_field="MD:Z:27A5G2T6G4T1A6T2C0A7A1A0A0C0G1G1A5" expected_identity= 100.0 * ( 68 / 84.0 ) identity, alignment_length =nucleotide.calculate_percent_identity(cigar_string,md_field) self.assertEqual(identity, expected_identity)
def test_calculate_percent_identity_simple_md_field(self): """ Test the calculate percent identity function Test with a simple md field where all bases match """ cigar_string="100S84M16S" md_field="MD:Z:84" expected_identity= 100.0 * ( 84 / 84.0 ) identity, alignment_length=nucleotide.calculate_percent_identity(cigar_string,md_field) self.assertEqual(identity, expected_identity)
def test_calculate_percent_identity_two_match_mismatch_identifiers(self): """ Test the calculate percent identity function Test cigar string with the two match and mistmatch identifiers (X and =) """ cigar_string="100I84M1X2=2D" md_field="MD:Z:27A5G2T6G4T1A6T2C0A7A1A0A0C0G1G1A5" expected_identity= 100.0 * ( 68 / 189.0 ) identity, alignment_length =nucleotide.calculate_percent_identity(cigar_string,md_field) self.assertEqual(identity, expected_identity)
def test_calculate_percent_identity_insert_delete(self): """ Test the calculate percent identity function Test cigar string with insert and deletes """ cigar_string="100I84M2D" md_field="MD:Z:27A5G2T6G4T1A6T2C0A7A1A0A0C0G1G1A5" expected_identity= 100.0 * ( 68 / 186.0 ) identity, alignment_length =nucleotide.calculate_percent_identity(cigar_string,md_field) self.assertEqual(identity, expected_identity)
def test_calculate_percent_identity_missing_md_field(self): """ Test the calculate percent identity function Test with an empty md field """ cigar_string="100S84M16S" md_field="" expected_identity=0.0 identity, alignment_length=nucleotide.calculate_percent_identity(cigar_string,md_field) self.assertEqual(identity, expected_identity)
def test_calculate_percent_identity_missing_cigar_identifier(self): """ Test the calculate percent identity function Test with a cigar string that does not have the match/mismatch identifier """ cigar_string="*" md_field="MD:Z:84" expected_identity=0.0 identity, alignment_length=nucleotide.calculate_percent_identity(cigar_string,md_field) self.assertEqual(identity, expected_identity)