Skip to content

Commit fb2ae2a

Browse files
committed
[FIX] Adjusts all unit test to new fasta defaults
1 parent f704d74 commit fb2ae2a

4 files changed

Lines changed: 80 additions & 8 deletions

File tree

test/unit/io/sequence_file/sequence_file_format_fasta_test.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct read : public sequence_file_data
9494

9595
TEST_F(read, newline_before_eof)
9696
{
97+
options.fasta_ignore_blank_before_id = true;
9798
std::string input
9899
{
99100
"> ID1\n"
@@ -120,8 +121,25 @@ TEST_F(read, noblank_before_id)
120121
do_read_test(input);
121122
}
122123

124+
TEST_F(read, ignore_blank_before_id)
125+
{
126+
options.fasta_ignore_blank_before_id = true;
127+
std::string input
128+
{
129+
"> ID1\n"
130+
"ACGTTTTTTTTTTTTTTT\n"
131+
"> ID2\n"
132+
"ACGTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n"
133+
"> ID3 lala\n"
134+
"ACGTTTA\n"
135+
};
136+
do_read_test(input);
137+
}
138+
139+
123140
TEST_F(read, whitespace_in_seq)
124141
{
142+
options.fasta_ignore_blank_before_id = true;
125143
std::string input
126144
{
127145
"> ID1\n"
@@ -137,6 +155,7 @@ TEST_F(read, whitespace_in_seq)
137155

138156
TEST_F(read, digits_in_seq)
139157
{
158+
options.fasta_ignore_blank_before_id = true;
140159
std::string input
141160
{
142161
"> ID1\n"
@@ -152,6 +171,7 @@ TEST_F(read, digits_in_seq)
152171

153172
TEST_F(read, old_id_style)
154173
{
174+
options.fasta_ignore_blank_before_id = true;
155175
std::string input
156176
{
157177
"; ID1\n"
@@ -167,6 +187,7 @@ TEST_F(read, old_id_style)
167187

168188
TEST_F(read, mixed_issues)
169189
{
190+
options.fasta_ignore_blank_before_id = true;
170191
std::string input
171192
{
172193
"> ID1\n"

test/unit/io/sequence_file/sequence_file_format_test_template.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ TYPED_TEST_P(sequence_file_read, standard)
7676
{
7777
std::stringstream istream{this->standard_input};
7878
seqan3::sequence_file_input fin{istream, TypeParam{}};
79+
fin.options.fasta_ignore_blank_before_id = true;
7980

8081
auto it = fin.begin();
8182
for (unsigned i = 0; i < 3; ++i, ++it)
@@ -103,6 +104,7 @@ TYPED_TEST_P(sequence_file_read, only_id)
103104
{
104105
std::stringstream istream{this->standard_input};
105106
seqan3::sequence_file_input fin{istream, TypeParam{}, seqan3::fields<seqan3::field::id>{}};
107+
fin.options.fasta_ignore_blank_before_id = true;
106108

107109
auto it = fin.begin();
108110
for (unsigned i = 0; i < 3; ++i, ++it)
@@ -114,6 +116,8 @@ TYPED_TEST_P(sequence_file_read, options_truncate_ids)
114116
std::stringstream istream{this->standard_input};
115117
seqan3::sequence_file_input fin{istream, TypeParam{}, seqan3::fields<seqan3::field::id>{}};
116118
fin.options.truncate_ids = true;
119+
fin.options.fasta_ignore_blank_before_id = true;
120+
117121
this->ids[2] = "ID3"; // "lala" is stripped
118122

119123
auto it = fin.begin();

test/unit/io/sequence_file/sequence_file_input_test.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ TEST_F(sequence_file_input_f, record_reading)
228228
{
229229
/* record based reading */
230230
seqan3::sequence_file_input fin{std::istringstream{input}, seqan3::format_fasta{}};
231+
fin.options.fasta_ignore_blank_before_id = true;
231232

232233
size_t counter = 0;
233234
for (auto & rec : fin)
@@ -246,6 +247,7 @@ TEST_F(sequence_file_input_f, record_reading_struct_bind)
246247
{
247248
/* record based reading */
248249
seqan3::sequence_file_input fin{std::istringstream{input}, seqan3::format_fasta{}};
250+
fin.options.fasta_ignore_blank_before_id = true;
249251

250252
size_t counter = 0;
251253
for (auto & [ seq, id, qual ] : fin)
@@ -275,6 +277,7 @@ TEST_F(sequence_file_input_f, record_reading_custom_options)
275277
/* record based reading */
276278
seqan3::sequence_file_input fin{istream, seqan3::format_fasta{}};
277279
fin.options.truncate_ids = true;
280+
fin.options.fasta_ignore_blank_before_id = true;
278281

279282
auto it = fin.begin();
280283
EXPECT_EQ((*it).id(), "ID1");
@@ -284,9 +287,34 @@ TEST_F(sequence_file_input_f, record_reading_custom_options)
284287
EXPECT_EQ((*it).id(), "ID3");
285288
}
286289

290+
TEST_F(sequence_file_input_f, record_reading_keep_blank_before_id)
291+
{
292+
std::istringstream istream{std::string
293+
{
294+
"> ID1 lala\n"
295+
"ACGTTTTTTTTTTTTTTT\n"
296+
"> ID2\n"
297+
"ACGTTTTTTT\n"
298+
"> ID3 lala\n"
299+
"ACGTTTA\n"
300+
}};
301+
302+
/* record based reading */
303+
seqan3::sequence_file_input fin{istream, seqan3::format_fasta{}};
304+
305+
auto it = fin.begin();
306+
EXPECT_EQ((*it).id(), " ID1 lala");
307+
++it;
308+
EXPECT_EQ((*it).id(), " ID2");
309+
++it;
310+
EXPECT_EQ((*it).id(), " ID3 lala");
311+
}
312+
313+
287314
TEST_F(sequence_file_input_f, file_view)
288315
{
289316
seqan3::sequence_file_input fin{std::istringstream{input}, seqan3::format_fasta{}};
317+
fin.options.fasta_ignore_blank_before_id = true;
290318

291319
auto minimum_length_filter = std::views::filter([] (auto const & rec)
292320
{
@@ -347,13 +375,15 @@ TEST_F(sequence_file_input_f, decompression_by_filename_gz)
347375
}
348376

349377
seqan3::sequence_file_input fin{filename.get_path()};
378+
fin.options.fasta_ignore_blank_before_id = true;
350379

351380
decompression_impl(*this, fin);
352381
}
353382

354383
TEST_F(sequence_file_input_f, decompression_by_stream_gz)
355384
{
356385
seqan3::sequence_file_input fin{std::istringstream{input_gz}, seqan3::format_fasta{}};
386+
fin.options.fasta_ignore_blank_before_id = true;
357387

358388
decompression_impl(*this, fin);
359389
}
@@ -367,6 +397,7 @@ TEST_F(sequence_file_input_f, read_empty_gz_file)
367397
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00'
368398
};
369399
seqan3::sequence_file_input fin{std::istringstream{empty_zipped_file}, seqan3::format_fasta{}};
400+
fin.options.fasta_ignore_blank_before_id = true;
370401

371402
EXPECT_TRUE(fin.begin() == fin.end());
372403
}
@@ -394,6 +425,7 @@ TEST_F(sequence_file_input_f, bgzf_decompression_by_filename_bgzf)
394425
}
395426

396427
seqan3::sequence_file_input fin{filename.get_path()};
428+
fin.options.fasta_ignore_blank_before_id = true;
397429

398430
decompression_impl(*this, fin);
399431
}
@@ -408,12 +440,15 @@ TEST_F(sequence_file_input_f, bgzf_decompression_by_filename_gz)
408440
}
409441

410442
seqan3::sequence_file_input fin{filename.get_path()};
443+
fin.options.fasta_ignore_blank_before_id = true;
444+
411445
decompression_impl(*this, fin);
412446
}
413447

414448
TEST_F(sequence_file_input_f, decompression_by_stream_bgzf)
415449
{
416450
seqan3::sequence_file_input fin{std::istringstream{input_bgzf}, seqan3::format_fasta{}};
451+
fin.options.fasta_ignore_blank_before_id = true;
417452

418453
decompression_impl(*this, fin);
419454
}
@@ -454,13 +489,15 @@ TEST_F(sequence_file_input_f, decompression_by_filename_bz2)
454489
}
455490

456491
seqan3::sequence_file_input fin{filename.get_path()};
492+
fin.options.fasta_ignore_blank_before_id = true;
457493

458494
decompression_impl(*this, fin);
459495
}
460496

461497
TEST_F(sequence_file_input_f, decompression_by_stream_bz2)
462498
{
463499
seqan3::sequence_file_input fin{std::istringstream{input_bz2}, seqan3::format_fasta{}};
500+
fin.options.fasta_ignore_blank_before_id = true;
464501

465502
decompression_impl(*this, fin);
466503
}
@@ -472,6 +509,7 @@ TEST_F(sequence_file_input_f, read_empty_bz2_file)
472509
'\x42', '\x5a', '\x68', '\x39', '\x17', '\x72', '\x45', '\x38', '\x50', '\x90', '\x00', '\x00', '\x00', '\x00'
473510
};
474511
seqan3::sequence_file_input fin{std::istringstream{empty_zipped_file}, seqan3::format_fasta{}};
512+
fin.options.fasta_ignore_blank_before_id = true;
475513

476514
EXPECT_TRUE(fin.begin() == fin.end());
477515
}

test/unit/io/sequence_file/sequence_file_integration_test.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ TEST(rows, assign_sequence_files)
2929

3030
std::string const output_comp
3131
{
32-
"> TEST 1\n"
32+
">TEST 1\n"
3333
"ACGT\n"
3434
"> Test2\n"
3535
"AGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGN\n"
@@ -39,6 +39,7 @@ TEST(rows, assign_sequence_files)
3939

4040
seqan3::sequence_file_input fin{std::istringstream{input}, seqan3::format_fasta{}};
4141
seqan3::sequence_file_output fout{std::ostringstream{}, seqan3::format_fasta{}};
42+
fout.options.fasta_blank_before_id = false;
4243
fout.options.fasta_letters_per_line = 0;
4344

4445
fout = fin;
@@ -51,21 +52,29 @@ TEST(integration, assign_sequence_file_pipes)
5152
{
5253
std::string const input
5354
{
54-
"> TEST1\n"
55+
">TEST1\n"
5556
"ACGT\n"
56-
"> Test2\n"
57+
">Test2\n"
5758
"AGGCTGNAGGCTGAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGN\n"
58-
"> Test3\n"
59+
">Test3\n"
5960
"GGAGTATAATATATATATATATAT\n"
6061
};
6162

6263
// valid without assignment?
6364
seqan3::sequence_file_input{std::istringstream{input}, seqan3::format_fasta{}} |
6465
seqan3::sequence_file_output{std::ostringstream{}, seqan3::format_fasta{}};
6566

67+
//!TODO this can be changed back to the following lines
68+
// when the default of output will change (no blanks before the id
69+
//auto fout = seqan3::sequence_file_input{std::istringstream{input}, seqan3::format_fasta{}} |
70+
// seqan3::sequence_file_output{std::ostringstream{}, seqan3::format_fasta{}};
71+
72+
6673
// valid with assignment and check contents
74+
auto fastaout = seqan3::sequence_file_output{std::ostringstream{}, seqan3::format_fasta{}};
75+
fastaout.options.fasta_blank_before_id = false;
6776
auto fout = seqan3::sequence_file_input{std::istringstream{input}, seqan3::format_fasta{}} |
68-
seqan3::sequence_file_output{std::ostringstream{}, seqan3::format_fasta{}};
77+
std::move(fastaout);
6978

7079
fout.get_stream().flush();
7180
EXPECT_EQ(reinterpret_cast<std::ostringstream&>(fout.get_stream()).str(), input);
@@ -75,11 +84,11 @@ TEST(integration, view)
7584
{
7685
std::string const input
7786
{
78-
"> TEST1\n"
87+
">TEST1\n"
7988
"ACGT\n"
80-
"> Test2\n"
89+
">Test2\n"
8190
"AGGCTGNAGGCTGAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGN\n"
82-
"> Test3\n"
91+
">Test3\n"
8392
"GGAGTATAATATATATATATATAT\n"
8493
};
8594

0 commit comments

Comments
 (0)