28
28
import org .testng .annotations .DataProvider ;
29
29
import org .testng .annotations .Test ;
30
30
31
- import java .io .File ;
32
31
import java .nio .file .Path ;
33
32
import java .nio .file .Paths ;
34
33
import java .util .*;
@@ -48,11 +47,10 @@ public class VcfFuncotationFactoryUnitTest extends GATKBaseTest {
48
47
private static final String FACTORY_VERSION = "TEST_VERSION" ;
49
48
private static final String EXAC_SNIPPET = toolsTestDir + "funcotator/test_exac.vcf" ;
50
49
50
+ private static final String DEFAULT_FILTER_STRING = "TODAY;A;Variant;Was;FILTERED" ;
51
+
51
52
//==================================================================================================================
52
53
// Private Members:
53
-
54
- private static final ReferenceDataSource CHR3_REF_DATA_SOURCE = ReferenceDataSource .of (new File (FuncotatorReferenceTestUtils .retrieveHg19Chr3Ref ()).toPath ());
55
-
56
54
private static final LinkedHashMap <String , Object > FIELD_DEFAULT_MAP = new LinkedHashMap <>();
57
55
58
56
static {
@@ -105,22 +103,25 @@ public class VcfFuncotationFactoryUnitTest extends GATKBaseTest {
105
103
FIELD_DEFAULT_MAP .put ("WTD" , "false" );
106
104
FIELD_DEFAULT_MAP .put ("dbSNPBuildID" , "" );
107
105
FIELD_DEFAULT_MAP .put ("ID" , "" );
106
+ FIELD_DEFAULT_MAP .put ("FILTER" , "" );
108
107
}
109
108
110
109
//==================================================================================================================
111
110
// Helper Methods:
112
111
113
112
114
113
115
- private Object [] helpProvideForTestCreateFuncotations (final String contig ,
114
+ private Object [] helpProvideForTestCreateFuncotations (final String variantFeatureFileName ,
115
+ final String contig ,
116
116
final int start ,
117
117
final int end ,
118
118
final String refAlleleString ,
119
119
final String altAlleleString ,
120
120
final List <Funcotation > expected ) {
121
121
return new Object []{
122
+ variantFeatureFileName ,
122
123
FuncotatorTestUtils .createSimpleVariantContext (FuncotatorReferenceTestUtils .retrieveHg19Chr3Ref (), contig , start , end , refAlleleString , altAlleleString ),
123
- new ReferenceContext (CHR3_REF_DATA_SOURCE , new SimpleInterval (contig , start , end )),
124
+ new ReferenceContext (ReferenceDataSource . of ( IOUtils . getPath ( b37Reference )) , new SimpleInterval (contig , start , end )),
124
125
expected
125
126
};
126
127
}
@@ -145,27 +146,39 @@ private Object[][] provideForTestCreateFuncotationsOnVariant() {
145
146
146
147
return new Object [][]{
147
148
// Trivial Case: No overlapping features:
148
- helpProvideForTestCreateFuncotations ("3" , 61650 , 61650 , "T" , "C" ,
149
+ helpProvideForTestCreateFuncotations (FuncotatorTestConstants .DBSNP_HG19_SNIPPET_FILE_PATH ,
150
+ "3" , 61650 , 61650 , "T" , "C" ,
149
151
Collections .singletonList (
150
152
TableFuncotation .create (FIELD_DEFAULT_MAP .keySet ().stream ().map (s -> FACTORY_NAME + "_" + s ).collect (Collectors .toList ()),
151
153
FIELD_DEFAULT_MAP .values ().stream ().map (Object ::toString ).collect (Collectors .toList ()),
152
154
Allele .create ("C" ), FACTORY_NAME , null )
153
155
)
154
156
),
155
157
// One overlapping VCF feature:
156
- helpProvideForTestCreateFuncotations ("3" , 61662 , 61662 , "T" , "C" ,
158
+ helpProvideForTestCreateFuncotations (FuncotatorTestConstants .DBSNP_HG19_SNIPPET_FILE_PATH ,
159
+ "3" , 61662 , 61662 , "T" , "C" ,
157
160
Collections .singletonList (
158
161
TableFuncotation .create (FIELD_DEFAULT_MAP .keySet ().stream ().map (s -> FACTORY_NAME + "_" + s ).collect (Collectors .toList ()),
159
- Arrays .asList ("true" , "false" , "0.9744,0.02556" , "false" , "false" , "1" , "false" , "true" , "false" , "" , "false" , "true" , "false" , "true" , "true" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "73009205" , "61662" , "false" , "false" , "0" , "true" , "0" , "false" , "0.954392,0.0456075" , "false" , "false" , "false" , "SNV" , "true" , "0x05010000000515043e000100" , "1" , "false" , "130" , "rs73009205" ),
162
+ Arrays .asList ("true" , "false" , "0.9744,0.02556" , "false" , "false" , "1" , "false" , "true" , "false" , "" , "false" , "true" , "false" , "true" , "true" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "73009205" , "61662" , "false" , "false" , "0" , "true" , "0" , "false" , "0.954392,0.0456075" , "false" , "false" , "false" , "SNV" , "true" , "0x05010000000515043e000100" , "1" , "false" , "130" , "rs73009205" , "" ),
160
163
Allele .create ("C" ), FACTORY_NAME , null )
161
164
)
162
165
),
163
166
// No matching VCF features (three overlap by position only), since there are no indels in dbSNP (the test datasource), so the ground truth should be a default entry, which was constructed here manually:
164
- helpProvideForTestCreateFuncotations ("3" , 64157 , 64166 , "AGAAAGGTCA" , "TCTTTCCAGT" ,
167
+ helpProvideForTestCreateFuncotations (FuncotatorTestConstants .DBSNP_HG19_SNIPPET_FILE_PATH ,
168
+ "3" , 64157 , 64166 , "AGAAAGGTCA" , "TCTTTCCAGT" ,
165
169
Collections .singletonList (TableFuncotation .create (FIELD_DEFAULT_MAP .keySet ().stream ().map (s -> FACTORY_NAME + "_" + s ).collect (Collectors .toList ()),
166
- Arrays .asList ("false" , "false" , "" , "false" , "false" , "" , "false" , "false" , "false" , "" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "" , "" , "false" , "false" , "" , "false" , "" , "false" , "" , "false" , "false" , "false" , "" , "false" , "" , "" , "false" , "" , "" ),
170
+ Arrays .asList ("false" , "false" , "" , "false" , "false" , "" , "false" , "false" , "false" , "" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "" , "" , "false" , "false" , "" , "false" , "" , "false" , "" , "false" , "false" , "false" , "" , "false" , "" , "" , "false" , "" , "" , "" ),
167
171
Allele .create ("TCTTTCCAGT" ), FACTORY_NAME , null ))
168
172
),
173
+ // One overlapping VCF feature, non-empty FILTER field:
174
+ helpProvideForTestCreateFuncotations (FuncotatorTestConstants .DBSNP_HG19_SNIPPET_WITH_FILTERS_FILE_PATH ,
175
+ "3" , 61662 , 61662 , "T" , "C" ,
176
+ Collections .singletonList (
177
+ TableFuncotation .create (FIELD_DEFAULT_MAP .keySet ().stream ().map (s -> FACTORY_NAME + "_" + s ).collect (Collectors .toList ()),
178
+ Arrays .asList ("true" , "false" , "0.9744,0.02556" , "false" , "false" , "1" , "false" , "true" , "false" , "" , "false" , "true" , "false" , "true" , "true" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "false" , "73009205" , "61662" , "false" , "false" , "0" , "true" , "0" , "false" , "0.954392,0.0456075" , "false" , "false" , "false" , "SNV" , "true" , "0x05010000000515043e000100" , "1" , "false" , "130" , "rs73009205" , "FILTER_73" ),
179
+ Allele .create ("C" ), FACTORY_NAME , null )
180
+ )
181
+ ),
169
182
};
170
183
}
171
184
@@ -205,17 +218,17 @@ public void testGetSupportedFuncotationFields() {
205
218
}
206
219
207
220
@ Test (dataProvider = "provideForTestCreateFuncotationsOnVariant" )
208
- public void testCreateFuncotationsOnVariant (final VariantContext variant ,
221
+ public void testCreateFuncotationsOnVariant (final String variantFeatureDataFileName ,
222
+ final VariantContext variant ,
209
223
final ReferenceContext referenceContext ,
210
224
final List <Funcotation > expected ) {
211
-
212
225
// Make our factory:
213
226
final VcfFuncotationFactory vcfFuncotationFactory =
214
- createVcfFuncotationFactory (FACTORY_NAME , FACTORY_VERSION , IOUtils .getPath (FuncotatorTestConstants . DBSNP_HG19_SNIPPET_FILE_PATH ));
227
+ createVcfFuncotationFactory (FACTORY_NAME , FACTORY_VERSION , IOUtils .getPath (variantFeatureDataFileName ));
215
228
216
229
// Create features from the file:
217
230
final List <Feature > vcfFeatures ;
218
- try (final VCFFileReader vcfReader = new VCFFileReader (IOUtils .getPath (FuncotatorTestConstants . DBSNP_HG19_SNIPPET_FILE_PATH ))) {
231
+ try (final VCFFileReader vcfReader = new VCFFileReader (IOUtils .getPath (variantFeatureDataFileName ))) {
219
232
vcfFeatures = vcfReader .query (variant .getContig (), variant .getStart (), variant .getEnd ()).stream ().collect (Collectors .toList ());
220
233
}
221
234
@@ -238,21 +251,21 @@ public void testCreateFuncotationsOnVariant(final VariantContext variant,
238
251
),
239
252
expected
240
253
);
241
-
242
254
}
243
255
244
256
@ Test (dataProvider = "provideForTestCreateFuncotationsOnVariant" )
245
- public void testCreateFuncotationMetadata (final VariantContext variant ,
257
+ public void testCreateFuncotationMetadata (final String variantFeatureDataFileName ,
258
+ final VariantContext variant ,
246
259
final ReferenceContext referenceContext ,
247
260
final List <Funcotation > expected ) {
248
261
// Don't need the expected gt for this test, but useful to reuse the data provider.
249
262
// Make our factory:
250
263
final VcfFuncotationFactory vcfFuncotationFactory =
251
- createVcfFuncotationFactory (FACTORY_NAME , FACTORY_VERSION , IOUtils .getPath (FuncotatorTestConstants . DBSNP_HG19_SNIPPET_FILE_PATH ));
264
+ createVcfFuncotationFactory (FACTORY_NAME , FACTORY_VERSION , IOUtils .getPath (variantFeatureDataFileName ));
252
265
253
266
// Create features from the file:
254
267
final List <Feature > vcfFeatures ;
255
- try (final VCFFileReader vcfReader = new VCFFileReader (IOUtils .getPath (FuncotatorTestConstants . DBSNP_HG19_SNIPPET_FILE_PATH ))) {
268
+ try (final VCFFileReader vcfReader = new VCFFileReader (IOUtils .getPath (variantFeatureDataFileName ))) {
256
269
vcfFeatures = vcfReader .query (variant .getContig (), variant .getStart (), variant .getEnd ()).stream ().collect (Collectors .toList ());
257
270
}
258
271
@@ -265,7 +278,7 @@ public void testCreateFuncotationMetadata(final VariantContext variant,
265
278
);
266
279
267
280
Assert .assertEquals (funcotations .stream ().map (f -> f .getMetadata ().retrieveAllHeaderInfo ()).collect (Collectors .toSet ()).size (), 1 );
268
- final Pair <VCFHeader , List <VariantContext >> vcfInfo = VariantContextTestUtils .readEntireVCFIntoMemory (FuncotatorTestConstants . DBSNP_HG19_SNIPPET_FILE_PATH );
281
+ final Pair <VCFHeader , List <VariantContext >> vcfInfo = VariantContextTestUtils .readEntireVCFIntoMemory (variantFeatureDataFileName );
269
282
final List <VCFInfoHeaderLine > gtOutputVcfInfoHeaderLines = vcfFuncotationFactory .createFuncotationVcfInfoHeaderLines (vcfInfo .getLeft ());
270
283
271
284
// Get the info headers that are in the VCF and make sure that these are also present in the metadata
0 commit comments