|
3 | 3 | from pathlib import Path |
4 | 4 |
|
5 | 5 |
|
| 6 | +from flexidot.utils.alignments import load_alignments |
6 | 7 | from flexidot.utils.file_handling import read_gffs |
7 | 8 |
|
8 | 9 | # Test data paths |
@@ -66,3 +67,39 @@ def test_read_multiple_gffs_with_empty(self): |
66 | 67 | # Should still work and return data from the non-empty file |
67 | 68 | assert len(feat_dict) > 0 |
68 | 69 | assert 'Seq2' in feat_dict |
| 70 | + |
| 71 | + |
| 72 | +class TestEmptyAlignments: |
| 73 | + """Tests for empty alignment file handling.""" |
| 74 | + |
| 75 | + def test_empty_blast6_file(self, tmp_path): |
| 76 | + """Test reading an empty BLAST6 file.""" |
| 77 | + empty_file = tmp_path / 'empty.blast6' |
| 78 | + empty_file.write_text('') |
| 79 | + |
| 80 | + alignments = load_alignments(str(empty_file), file_format='blast6') |
| 81 | + assert alignments == [] |
| 82 | + |
| 83 | + def test_empty_paf_file(self, tmp_path): |
| 84 | + """Test reading an empty PAF file.""" |
| 85 | + empty_file = tmp_path / 'empty.paf' |
| 86 | + empty_file.write_text('') |
| 87 | + |
| 88 | + alignments = load_alignments(str(empty_file), file_format='paf') |
| 89 | + assert alignments == [] |
| 90 | + |
| 91 | + def test_blast6_file_with_only_comments(self, tmp_path): |
| 92 | + """Test reading a BLAST6 file with only comments.""" |
| 93 | + comment_file = tmp_path / 'comments.blast6' |
| 94 | + comment_file.write_text('# This is a comment\n# Another comment\n') |
| 95 | + |
| 96 | + alignments = load_alignments(str(comment_file), file_format='blast6') |
| 97 | + assert alignments == [] |
| 98 | + |
| 99 | + def test_paf_file_with_only_comments(self, tmp_path): |
| 100 | + """Test reading a PAF file with only comments.""" |
| 101 | + comment_file = tmp_path / 'comments.paf' |
| 102 | + comment_file.write_text('# This is a comment\n# Another comment\n') |
| 103 | + |
| 104 | + alignments = load_alignments(str(comment_file), file_format='paf') |
| 105 | + assert alignments == [] |
0 commit comments