@@ -111,7 +111,7 @@ def test_vquest(self):
111
111
self .assertEqual (self .post .call_count , 1 )
112
112
self .assertEqual (
113
113
self .post .call_args .args ,
114
- ('http ://www.imgt.org/IMGT_vquest/analysis' , ))
114
+ ('https ://www.imgt.org/IMGT_vquest/analysis' , ))
115
115
config_used = self .config .copy ()
116
116
# Whatever input type was given the actual type submitted to the form
117
117
# will be "inline" to allow chunking of sequences if needed. The
@@ -236,6 +236,114 @@ def test_vquest_main_alignment(self):
236
236
self .check_missing_defaults_main (lambda : main (["--align" ]))
237
237
238
238
239
+ class TestVquestFasta (TestVquestBase ):
240
+ """File-based input with FASTA."""
241
+
242
+ def setUp (self ):
243
+ super ().setUp ()
244
+ self .input_path = self .path / "seqs.fasta"
245
+ del self .config ["sequences" ]
246
+ self .config ["fileSequences" ] = self .input_path
247
+
248
+ def test_vquest (self ):
249
+ """Test that a basic request gives the expected response."""
250
+ result = vquest (self .config )
251
+ # requests.post should have been called once, with this input.
252
+ self .assertEqual (self .post .call_count , 1 )
253
+ self .assertEqual (
254
+ self .post .call_args .args ,
255
+ ('https://www.imgt.org/IMGT_vquest/analysis' , ))
256
+ config_used = self .config .copy ()
257
+ # Whatever input type was given the actual type submitted to the form
258
+ # will be "inline" to allow chunking of sequences if needed. The
259
+ # sequences are also reformatted via Biopython when chunked.
260
+ config_used ["inputType" ] = "inline"
261
+ config_used ["sequences" ] = """>IGKV2-ACR*02
262
+ GACATTGTGATGACCCAGACTCCACTCTCCCTGCCCGTCACCCCTGGAGAGCCAGCCTCC
263
+ ATCTCCTGCAGGTCTAGTCAGAGCCTCTTGGATAGTGACGGGTACACCTGTTTGGACTGG
264
+ TACCTGCAGAAGCCAGGCCAGTCTCCACAGCTCCTGATCTATGAGGTTTCCAACCGGGTC
265
+ TCTGGAGTCCCTGACAGGTTCAGTGGCAGTGGGTCAGNCACTGATTTCACACTGAAAATC
266
+ AGCCGGGTGGAAGCTGAGGATGTTGGGGTGTATTACTGTATGCAAAGTATAGAGTTTCCT
267
+ CC
268
+ """
269
+ self .assertEqual (
270
+ self .post .call_args .kwargs ,
271
+ {"data" : config_used })
272
+ self .assertEqual (
273
+ list (result .keys ()),
274
+ ["Parameters.txt" , "vquest_airr.tsv" ])
275
+ with open (self .path / "expected/Parameters.txt" ) as f_in :
276
+ parameters = f_in .read ()
277
+ with open (self .path / "expected/vquest_airr.tsv" ) as f_in :
278
+ vquest_airr = f_in .read ()
279
+ self .assertEqual (parameters , result ["Parameters.txt" ])
280
+ self .assertEqual (vquest_airr , result ["vquest_airr.tsv" ])
281
+
282
+ def test_vquest_no_collapse (self ):
283
+ """test_vquest but with vquest(..., collapse=False)."""
284
+ # Also try with collapse=False, for raw output
285
+ result = vquest (self .config , collapse = False )
286
+ self .assertEqual (self .post .call_count , 1 )
287
+ self .assertEqual (len (result ), 1 )
288
+ self .assertEqual (
289
+ list (result [0 ].keys ()),
290
+ ["Parameters.txt" , "vquest_airr.tsv" ])
291
+
292
+ def test_vquest_main (self ):
293
+ """Test that the command-line interface gives the expected response."""
294
+ with tempfile .TemporaryDirectory () as tempdir :
295
+ os .chdir (tempdir )
296
+ with open (self .path / "config.yml" ) as f_in , open ("config.yml" , "wt" ) as f_out :
297
+ f_out .write (f_in .read ())
298
+ f_out .write (f"fileSequences: { self .input_path } \n " )
299
+ main (["config.yml" ])
300
+ self .assertTrue (Path ("vquest_airr.tsv" ).exists ())
301
+ self .assertTrue (Path ("Parameters.txt" ).exists ())
302
+
303
+ def test_vquest_main_no_collapse (self ):
304
+ """Test command-line interface with --no-collapse."""
305
+ with tempfile .TemporaryDirectory () as tempdir :
306
+ os .chdir (tempdir )
307
+ with open (self .path / "config.yml" ) as f_in , open ("config.yml" , "wt" ) as f_out :
308
+ f_out .write (f_in .read ())
309
+ f_out .write (f"fileSequences: { self .input_path } \n " )
310
+ main (["--no-collapse" , "config.yml" ])
311
+ self .assertTrue (Path ("001/vquest_airr.tsv" ).exists ())
312
+ self .assertTrue (Path ("001/Parameters.txt" ).exists ())
313
+
314
+ def test_vquest_main_alignment (self ):
315
+ """Try using the --align feature.
316
+
317
+ In this case the regular output files should not be created and instead
318
+ FASTA text should be written to stdout.
319
+ """
320
+ expected = """>IGKV2-ACR*02
321
+ gacattgtgatgacccagactccactctccctgcccgtcacccctggagagccagcctccatctcctgcaggtctagtcagagcctcttggatagt...gacgggtacacctgtttggactggtacctgcagaagccaggccagtctccacagctcctgatctatgaggtt.....................tccaaccgggtctctggagtccct...gacaggttcagtggcagtggg......tcagncactgatttcacactgaaaatcagccgggtggaagctgaggatgttggggtgtattactgtatgcaaagtatagagtttcctcc
322
+ """
323
+ out = StringIO ()
324
+ err = StringIO ()
325
+ with redirect_stdout (out ), redirect_stderr (err ):
326
+ with tempfile .TemporaryDirectory () as tempdir :
327
+ os .chdir (tempdir )
328
+ with open (self .path / "config.yml" ) as f_in , open ("config.yml" , "wt" ) as f_out :
329
+ f_out .write (f_in .read ())
330
+ f_out .write (f"fileSequences: { self .input_path } \n " )
331
+ main (["config.yml" , "--align" ])
332
+ self .assertFalse (Path ("vquest_airr.tsv" ).exists ())
333
+ self .assertFalse (Path ("Parameters.txt" ).exists ())
334
+ self .assertEqual (out .getvalue (), expected )
335
+ self .assertEqual (err .getvalue (), "" )
336
+
337
+
338
+ class TestVquestFastq (TestVquestFasta ):
339
+ """File-based input with FASTQ."""
340
+
341
+ def setUp (self ):
342
+ super ().setUp ()
343
+ self .input_path = self .path / "seqs.fastq"
344
+ self .config ["fileSequences" ] = self .input_path
345
+
346
+
239
347
class TestVquestCustom (TestVquestSimple ):
240
348
"""Try changing one of the configuration options.
241
349
@@ -274,7 +382,7 @@ def test_vquest(self):
274
382
self .assertEqual (self .post .call_count , 1 )
275
383
self .assertEqual (
276
384
self .post .call_args .args ,
277
- ('http ://www.imgt.org/IMGT_vquest/analysis' , ))
385
+ ('https ://www.imgt.org/IMGT_vquest/analysis' , ))
278
386
279
387
def test_vquest_main (self ):
280
388
"""Test that an html file with an error message is parsed correctly for cmd-line usage."""
0 commit comments