|
1 | 1 | """ Test Module for VariantPeptidePool """
|
2 | 2 | import unittest
|
3 | 3 | from test.unit import create_aa_record
|
| 4 | +from Bio.Seq import Seq |
4 | 5 | from moPepGen.aa import VariantPeptidePool
|
5 | 6 |
|
6 | 7 |
|
@@ -122,3 +123,57 @@ def test_filter_keep_all_noncoding(self):
|
122 | 123 | keep_all_coding=False, keep_all_noncoding=True
|
123 | 124 | )
|
124 | 125 | self.assertEqual(len(filtered.peptides), 4)
|
| 126 | + |
| 127 | + def test_filter_denylist(self): |
| 128 | + """ Filter with denylist """ |
| 129 | + data = [ |
| 130 | + ['SSSSSSSSSR', 'ENST0001|SNV-100-A-T|1'], |
| 131 | + ['SSSSSSSSAR', 'ENST0002|SNV-100-A-T|1'], |
| 132 | + ['SSSSSSSSCR', 'ENST0003|SNV-100-A-T|1'], |
| 133 | + ['SSSSSSSSGR', 'ENST0004|SNV-100-A-T|1'], |
| 134 | + ] |
| 135 | + peptides = {create_aa_record(*x) for x in data} |
| 136 | + denylist_data = [ |
| 137 | + 'SSSSSSSSAR', 'SSSSSSSSGR' |
| 138 | + ] |
| 139 | + denylist = {Seq(x) for x in denylist_data} |
| 140 | + exprs = None |
| 141 | + coding_tx = ['ENST0001', 'ENST0003'] |
| 142 | + pool = VariantPeptidePool(peptides=peptides) |
| 143 | + filtered = pool.filter( |
| 144 | + exprs=exprs, cutoff=8, coding_transcripts=coding_tx, |
| 145 | + keep_all_coding=False, keep_all_noncoding=True, |
| 146 | + denylist=denylist, keep_canonical=False |
| 147 | + ) |
| 148 | + self.assertEqual(len(filtered.peptides), 2) |
| 149 | + self.assertEqual( |
| 150 | + {str(x.seq) for x in filtered.peptides}, |
| 151 | + {'SSSSSSSSSR', 'SSSSSSSSCR'} |
| 152 | + ) |
| 153 | + |
| 154 | + def test_filter_denylist_keep_canonical(self): |
| 155 | + """ Filter with denylist and keep_canonical = True """ |
| 156 | + data = [ |
| 157 | + ['SSSSSSSSSR', 'ENST0001|SNV-100-A-T|1'], |
| 158 | + ['SSSSSSSSAR', 'ENST0002|SNV-100-A-T|1'], |
| 159 | + ['SSSSSSSSCR', 'ENST0003|SNV-100-A-T|1'], |
| 160 | + ['SSSSSSSSGR', 'ENST0004|SNV-100-A-T|1'], |
| 161 | + ] |
| 162 | + peptides = {create_aa_record(*x) for x in data} |
| 163 | + denylist_data = [ |
| 164 | + 'SSSSSSSSAR', 'SSSSSSSSGR' |
| 165 | + ] |
| 166 | + denylist = {Seq(x) for x in denylist_data} |
| 167 | + exprs = None |
| 168 | + coding_tx = ['ENST0001', 'ENST0002', 'ENST0003'] |
| 169 | + pool = VariantPeptidePool(peptides=peptides) |
| 170 | + filtered = pool.filter( |
| 171 | + exprs=exprs, cutoff=8, coding_transcripts=coding_tx, |
| 172 | + keep_all_coding=False, keep_all_noncoding=True, |
| 173 | + denylist=denylist, keep_canonical=True |
| 174 | + ) |
| 175 | + self.assertEqual(len(filtered.peptides), 3) |
| 176 | + self.assertEqual( |
| 177 | + {str(x.seq) for x in filtered.peptides}, |
| 178 | + {'SSSSSSSSSR', 'SSSSSSSSAR', 'SSSSSSSSCR'} |
| 179 | + ) |
0 commit comments