@@ -205,13 +205,13 @@ def testGagFromAAStart(self):
205
205
class TestMakeCodonAln (unittest .TestCase ):
206
206
207
207
def testSimpleUse (self ):
208
- region = GenomeRegion ('p6' , [2134 , 2298 ], 'CTTCAGAGCAGACCAGAGCCAACAGCCCCACCAGAAGAGAGCTTCAGGTCTGGGGTAGAGACAACAAC'
208
+ region = GenomeRegion ('p6' , [2134 , 2292 ], 'CTTCAGAGCAGACCAGAGCCAACAGCCCCACCAGAAGAGAGCTTCAGGTCTGGGGTAGAGACAACAAC'
209
209
'TCCCCCTCAGAAGCAGGAGCCGATAGACAAGGAACTGTATCCTTTAACTTCCCTCAGGTCACTCTTTG'
210
210
'GCAACGACCCCTCGTCACAATAA' ,
211
- [449 , 500 ], 'LQSRPEPTAPPEESFRSGVETTTPPQKQEPIDKELYPLTSLRSLFGNDPSSQ' )
211
+ [449 , 500 ], 'LQSRPEPTAPPEESFRSGVETTTPPQKQEPIDKELYPLTSLRSLFGNDPSSQ* ' )
212
212
region .make_codon_aln ()
213
213
expected = '-L--Q--S--R--P--E--P--T--A--P--P--E--E--S--F--R--S--G--V--E--T--T--T--P--P--Q-' \
214
- '-K--Q--E--P--I--D--K--E--L--Y--P--L--T--S--L--R--S--L--F--G--N--D--P--S--S--Q-'
214
+ '-K--Q--E--P--I--D--K--E--L--Y--P--L--T--S--L--R--S--L--F--G--N--D--P--S--S--Q--*- '
215
215
result = region .codon_aln
216
216
self .assertEqual (expected , result )
217
217
@@ -1060,5 +1060,62 @@ def testInputAllSIV(self):
1060
1060
self .assertEqual (expected_ref_prot , result_ref_prot )
1061
1061
1062
1062
1063
+ class TestSetNucleotideEquivalent (InputTestCase ):
1064
+
1065
+ def testSimpleNuclEquiv (self ):
1066
+ configs = handle_args ('hiv' , 'prot' , self .hiv_nt_seq_path , self .hiv_ncoords_path ,
1067
+ self .hiv_aa_seq_path , self .hiv_pcoords_path )
1068
+
1069
+ ref_nt_seq = configs [0 ][0 ][1 ]
1070
+ ref_aa_seq = configs [1 ]
1071
+ nt_coords = configs [2 ]
1072
+ aa_coords = configs [3 ]
1073
+
1074
+ with open (nt_coords ) as ncoords , open (aa_coords ) as pcoords :
1075
+ ref_regions = set_regions ('prot' , ncoords , ref_nt_seq , pcoords , ref_aa_seq )
1076
+ for region in ref_regions :
1077
+ region .make_codon_aln ()
1078
+
1079
+ query_region = GenomeRegion ('Gag' , [2133 , 2292 ], 'GCTGAAGCAATGAGCCAAGTAACAAATTCAGCTACCATAATG' ,
1080
+ [364 , 377 ], 'AEAMSQVTNSATIM' )
1081
+
1082
+ expected = 'GCTGAAGCAATGAGCCAAGTAACAAATTCAGCTACCATAATG'
1083
+ result = set_nucleotide_equivalents (query_region , ref_regions )
1084
+ self .assertEqual (expected , result )
1085
+
1086
+ def testWithGaps (self ):
1087
+ ref_regions = [GenomeRegion ('test1' , [1 , 31 ], 'GGGGGCCCGGGTTTAAACCCGGGTTTAAATTTC' , [1 , 11 ], 'GGPGLNPGLNF' )]
1088
+ for region in ref_regions :
1089
+ region .make_codon_aln ()
1090
+ q_region = GenomeRegion ('test1' , [12 , 27 ], 'TTAAACCCGGGTTTA' , [1 , 5 ], 'LNPGL' )
1091
+ expected = 'TTAAACCCGGGTTTA'
1092
+ result = set_nucleotide_equivalents (q_region , ref_regions )
1093
+ self .assertEqual (expected , result )
1094
+
1095
+
1096
+ class TestSetProteinEquivalent (InputTestCase ):
1097
+
1098
+ def testHIV (self ):
1099
+ configs = handle_args ('hiv' , 'nucl' , self .hiv_nt_seq_path , self .hiv_ncoords_path ,
1100
+ self .hiv_aa_seq_path , self .hiv_pcoords_path )
1101
+
1102
+ ref_nt_seq = configs [0 ][0 ][1 ]
1103
+ ref_aa_seq = configs [1 ]
1104
+ nt_coords = configs [2 ]
1105
+ aa_coords = configs [3 ]
1106
+
1107
+ with open (nt_coords ) as ncoords , open (aa_coords ) as pcoords :
1108
+ ref_regions = set_regions ('nucl' , ncoords , ref_nt_seq , pcoords , ref_aa_seq )
1109
+
1110
+ for reg in ref_regions :
1111
+ reg .make_codon_aln ()
1112
+
1113
+ query_region = GenomeRegion ('Gag' , [2133 , 2292 ], 'GCTGAAGCAATGAGCCAAGTAACAAATTCAGCTACCATAATG' ,
1114
+ [364 , 377 ], 'AEAMSQVTNSATIM' )
1115
+ expected = 'AEAMSQVTNSATIM'
1116
+ result = set_protein_equivalents (query_region , ref_regions )
1117
+ self .assertEqual (expected , result )
1118
+
1119
+
1063
1120
if __name__ == '__main__' :
1064
1121
unittest .main ()
0 commit comments