@@ -125,103 +125,128 @@ public void testCompareReferencesMultipleReferencesStdOut() throws IOException{
125
125
}
126
126
127
127
// FIND_SNPS_ONLY tests:
128
- @ Test
129
- public void testFindSNPsMultipleSNPs () throws IOException {
130
- final File ref1 = new File (getToolTestDataDir () + "hg19mini.fasta" );
131
- final File ref2 = new File (getToolTestDataDir () + "hg19mini_chr2multiplesnps.fasta" );
132
- final File output = IOUtils .createTempDir ("tempFindSNPs" );
133
-
134
- final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , "FIND_SNPS_ONLY" , "-base-comparison-output" , output .getAbsolutePath ()};
135
- runCommandLine (args );
136
128
137
- final File actualOutput = new File (output , "hg19mini.fasta_hg19mini_chr2multiplesnps.fasta_snps.tsv" );
138
- final File expectedOutput = new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_chr2multiplesnps.fasta_snps.tsv" );
139
- IntegrationTestSpec .assertEqualTextFiles (actualOutput , expectedOutput );
129
+ @ DataProvider (name = "findSNPsData" )
130
+ public Object [][] findSNPsData () {
131
+ return new Object [][]{
132
+ // ref1, ref2, output name, expected output
133
+ new Object []{ new File (getToolTestDataDir () + "hg19mini.fasta" ),
134
+ new File (getToolTestDataDir () + "hg19mini_chr2multiplesnps.fasta" ),
135
+ "hg19mini.fasta_hg19mini_chr2multiplesnps.fasta_snps.tsv" ,
136
+ new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_chr2multiplesnps.fasta_snps.tsv" ),
137
+ },
138
+ new Object []{ new File (getToolTestDataDir () + "hg19mini.fasta" ),
139
+ new File (getToolTestDataDir () + "hg19mini_chr2iupacsnps.fasta" ),
140
+ "hg19mini.fasta_hg19mini_chr2iupacsnps.fasta_snps.tsv" ,
141
+ new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_chr2iupacsnps.fasta_snps.tsv" ),
142
+ },
143
+ // produces empty output file bc FIND_SNPS_ONLY doesn't work on indels
144
+ new Object []{ new File (getToolTestDataDir () + "hg19mini.fasta" ),
145
+ new File (getToolTestDataDir () + "hg19mini_chr1indel.fasta" ),
146
+ "hg19mini.fasta_hg19mini_chr1indel.fasta_snps.tsv" ,
147
+ new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_chr1indel.fasta_snps.tsv" ),
148
+ },
149
+ };
140
150
}
141
-
142
- @ Test
143
- public void testFindSNPsIUPACBases () throws IOException {
144
- final File ref1 = new File (getToolTestDataDir () + "hg19mini.fasta" );
145
- final File ref2 = new File (getToolTestDataDir () + "hg19mini_chr2iupacsnps.fasta" );
151
+ @ Test (dataProvider = "findSNPsData" )
152
+ public void testFindSNPs (File ref1 , File ref2 , String actualOutputFileName , File expectedOutput ) throws IOException {
146
153
final File output = IOUtils .createTempDir ("tempFindSNPs" );
147
154
148
- final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , "FIND_SNPS_ONLY" , "-base-comparison-output" , output .toPath (). toString ()};
155
+ final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , "FIND_SNPS_ONLY" , "-base-comparison-output" , output .getAbsolutePath ()};
149
156
runCommandLine (args );
150
157
151
- final File expectedOutput = new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_chr2iupacsnps.fasta_snps.tsv" );
152
- final File actualOutput = new File (output , "hg19mini.fasta_hg19mini_chr2iupacsnps.fasta_snps.tsv" );
153
-
158
+ final File actualOutput = new File (output , actualOutputFileName );
154
159
IntegrationTestSpec .assertEqualTextFiles (actualOutput , expectedOutput );
155
160
}
156
161
157
- // FULL_ALIGNMENT tests:
158
- @ Test
159
- public void testFullAlignmentModeMultipleSNPs () throws IOException {
160
- final File ref1 = new File (getToolTestDataDir () + "hg19mini.fasta" );
161
- final File ref2 = new File (getToolTestDataDir () + "hg19mini_chr2multiplesnps.fasta" );
162
- final File output = IOUtils .createTempDir ("tempFullAlignmentSNPs" );
163
-
164
- final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , "FULL_ALIGNMENT" , "-base-comparison-output" , output .getAbsolutePath ()};
165
- runCommandLine (args );
166
-
167
- final File expectedOutput = new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_chr2multiplesnps.fasta.vcf" );
168
- final File actualOutput = new File (output , "hg19mini.fasta_hg19mini_chr2multiplesnps.fasta.vcf" );
169
- IntegrationTestSpec .assertEqualTextFiles (actualOutput , expectedOutput );
162
+ @ DataProvider (name = "baseComparisonIllegalArgumentsData" )
163
+ public Object [][] baseComparisonIllegalArgumentsData () {
164
+ return new Object [][]{
165
+ // base comparison mode
166
+ new Object []{"FULL_ALIGNMENT" },
167
+ new Object []{"FIND_SNPS_ONLY" },
168
+ };
170
169
}
171
170
172
- @ Test
173
- public void testFullAlignmentModeDeletion () throws IOException {
171
+ // tool throws a UserException.CouldNotCreateOutputFile but gets wrapped in a NullPointerException
172
+ @ Test (dataProvider = "baseComparisonIllegalArgumentsData" , expectedExceptions = NullPointerException .class )
173
+ public void testFindSNPsNoOutputDir (String baseComparisonMode ) throws IOException {
174
174
final File ref1 = new File (getToolTestDataDir () + "hg19mini.fasta" );
175
- final File ref2 = new File (getToolTestDataDir () + "hg19mini_chr1indel.fasta" );
176
- final File output = IOUtils .createTempDir ("tempFullAlignmentIndel" );
175
+ final File ref2 = new File (getToolTestDataDir () + "hg19mini_chr2iupacsnps.fasta" );
177
176
178
- final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , "FULL_ALIGNMENT" , "-base-comparison-output" , output . getAbsolutePath () };
177
+ final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , baseComparisonMode };
179
178
runCommandLine (args );
180
-
181
- final File expectedOutput = new File (getToolTestDataDir (), "expected.testDeletion.hg19mini.fasta_hg19mini_chr1indel.fasta.vcf" );
182
- final File actualOutput = new File (output , "hg19mini.fasta_hg19mini_chr1indel.fasta.vcf" );
183
- IntegrationTestSpec .assertEqualTextFiles (actualOutput , expectedOutput );
184
179
}
185
180
186
- @ Test
187
- public void testFullAlignmentModeInsertion ( ) throws IOException {
188
- final File ref1 = new File (getToolTestDataDir () + "hg19mini_chr1indel .fasta" );
189
- final File ref2 = new File (getToolTestDataDir () + "hg19mini .fasta" );
190
- final File output = IOUtils . createTempDir ( "tempFullAlignmentIndel " );
181
+ @ Test ( dataProvider = "baseComparisonIllegalArgumentsData" , expectedExceptions = UserException . CouldNotCreateOutputFile . class )
182
+ public void testFindSNPsNonexistentOutputDir ( String baseComparisonMode ) throws IOException {
183
+ final File ref1 = new File (getToolTestDataDir () + "hg19mini .fasta" );
184
+ final File ref2 = new File (getToolTestDataDir () + "hg19mini_chr2iupacsnps .fasta" );
185
+ final File nonexistentOutputDir = new File ( "/tempreferences " );
191
186
192
- final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , "FULL_ALIGNMENT" , "-base-comparison-output" , output .getAbsolutePath ()};
187
+ final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , baseComparisonMode , "-base-comparison-output" , nonexistentOutputDir .getAbsolutePath ()};
193
188
runCommandLine (args );
194
-
195
- final File expectedOutput = new File (getToolTestDataDir (), "expected.testInsertion.hg19mini_chr1indel.fasta_hg19mini.fasta.vcf" );
196
- final File actualOutput = new File (output , "hg19mini_chr1indel.fasta_hg19mini.fasta.vcf" );
197
- IntegrationTestSpec .assertEqualTextFiles (actualOutput , expectedOutput );
198
189
}
199
190
200
- @ Test
201
- public void testFullAlignmentSNPsOnMultipleContigs ( ) throws IOException {
191
+ @ Test ( dataProvider = "baseComparisonIllegalArgumentsData" , expectedExceptions = UserException . BadInput . class )
192
+ public void testFindSNPsMoreThanTwoReferences ( String baseComparisonMode ) throws IOException {
202
193
final File ref1 = new File (getToolTestDataDir () + "hg19mini.fasta" );
203
- final File ref2 = new File (getToolTestDataDir () + "hg19mini_snpsmultiplecontigs.fasta" );
204
- final File output = IOUtils .createTempDir ("tempFullAlignmentSNPsMultipleContigs" );
194
+ final File ref2 = new File (getToolTestDataDir () + "hg19mini_chr2iupacsnps.fasta" );
195
+ final File ref3 = new File (getToolTestDataDir () + "hg19mini_chr2multiplesnps.fasta" );
196
+ final File output = IOUtils .createTempDir ("tempFindSNPs" );
205
197
206
- final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , "FULL_ALIGNMENT" , "-base-comparison-output" , output .getAbsolutePath ()};
198
+ final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-refcomp" , ref3 . getAbsolutePath (), "- base-comparison" , baseComparisonMode , "-base-comparison-output" , output .getAbsolutePath ()};
207
199
runCommandLine (args );
200
+ }
208
201
209
- final File expectedOutput = new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_snpsmultiplecontigs.fasta.vcf" );
210
- final File actualOutput = new File (output , "hg19mini.fasta_hg19mini_snpsmultiplecontigs.fasta.vcf" );
211
- IntegrationTestSpec .assertEqualTextFiles (actualOutput , expectedOutput );
202
+ // FULL_ALIGNMENT tests:
203
+ @ DataProvider (name = "fullAlignmentData" )
204
+ public Object [][] fullAlignmentData () {
205
+ return new Object [][]{
206
+ // ref1, ref2, output name, expected output
207
+ new Object []{ new File (getToolTestDataDir () + "hg19mini.fasta" ),
208
+ new File (getToolTestDataDir () + "hg19mini_chr2multiplesnps.fasta" ),
209
+ "hg19mini.fasta_hg19mini_chr2multiplesnps.fasta.vcf" ,
210
+ new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_chr2multiplesnps.fasta.vcf" ),
211
+ },
212
+ // order that these 2 references are specified determines whether it is an insertion or deletion
213
+ new Object []{ new File (getToolTestDataDir () + "hg19mini.fasta" ),
214
+ new File (getToolTestDataDir () + "hg19mini_chr1indel.fasta" ),
215
+ "hg19mini.fasta_hg19mini_chr1indel.fasta.vcf" ,
216
+ new File (getToolTestDataDir (), "expected.testDeletion.hg19mini.fasta_hg19mini_chr1indel.fasta.vcf" ),
217
+ },
218
+ // order that these 2 references are specified determines whether it is an insertion or deletion
219
+ new Object []{ new File (getToolTestDataDir () + "hg19mini_chr1indel.fasta" ),
220
+ new File (getToolTestDataDir () + "hg19mini.fasta" ),
221
+ "hg19mini_chr1indel.fasta_hg19mini.fasta.vcf" ,
222
+ new File (getToolTestDataDir (), "expected.testInsertion.hg19mini_chr1indel.fasta_hg19mini.fasta.vcf" ),
223
+ },
224
+ new Object []{ new File (getToolTestDataDir () + "hg19mini.fasta" ),
225
+ new File (getToolTestDataDir () + "hg19mini_snpsmultiplecontigs.fasta" ),
226
+ "hg19mini.fasta_hg19mini_snpsmultiplecontigs.fasta.vcf" ,
227
+ new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_snpsmultiplecontigs.fasta.vcf" ),
228
+ },
229
+ new Object []{ new File (getToolTestDataDir () + "hg19mini.fasta" ),
230
+ new File (getToolTestDataDir () + "hg19mini_snpandindel.fasta" ),
231
+ "hg19mini.fasta_hg19mini_snpandindel.fasta.vcf" ,
232
+ new File (getToolTestDataDir (), "expected.SNPandINDEL.hg19mini.fasta_hg19mini_snpandindel.fasta.vcf" ),
233
+ },
234
+ new Object []{ new File (getToolTestDataDir () + "hg19mini.fasta" ),
235
+ new File (getToolTestDataDir () + "hg19mini_manySNPsINDELs.fasta" ),
236
+ "hg19mini.fasta_hg19mini_manySNPsINDELs.fasta.vcf" ,
237
+ new File (getToolTestDataDir (), "expected.hg19mini.fasta_hg19mini_manySNPsINDELs.fasta.vcf" ),
238
+ },
239
+ };
212
240
}
213
241
214
- @ Test
215
- public void testFullAlignmentModeSNPAndINDEL () throws IOException {
216
- final File ref1 = new File (getToolTestDataDir () + "hg19mini.fasta" );
217
- final File ref2 = new File (getToolTestDataDir () + "hg19mini_snpandindel.fasta" );
218
- final File output = IOUtils .createTempDir ("tempFullAlignmentIndel" );
242
+ @ Test (dataProvider = "fullAlignmentData" )
243
+ public void testFullAlignmentMode (File ref1 , File ref2 , String actualOutputFileName , File expectedOutput ) throws IOException {
244
+ final File output = IOUtils .createTempDir ("tempDirFullAlignment" );
219
245
220
246
final String [] args = new String [] {"-R" , ref1 .getAbsolutePath () , "-refcomp" , ref2 .getAbsolutePath (), "-base-comparison" , "FULL_ALIGNMENT" , "-base-comparison-output" , output .getAbsolutePath ()};
221
247
runCommandLine (args );
222
248
223
- final File expectedOutput = new File (getToolTestDataDir (), "expected.SNPandINDEL.hg19mini.fasta_hg19mini_snpandindel.fasta.vcf" );
224
- final File actualOutput = new File (output , "hg19mini.fasta_hg19mini_snpandindel.fasta.vcf" );
249
+ final File actualOutput = new File (output , actualOutputFileName );
225
250
IntegrationTestSpec .assertEqualTextFiles (actualOutput , expectedOutput );
226
251
}
227
252
}
0 commit comments