feat: add ClustalW .aln format support for sequence alignments#880
Open
haoyu-haoyu wants to merge 2 commits intobiotite-dev:mainfrom
Open
feat: add ClustalW .aln format support for sequence alignments#880haoyu-haoyu wants to merge 2 commits intobiotite-dev:mainfrom
haoyu-haoyu wants to merge 2 commits intobiotite-dev:mainfrom
Conversation
- Validate sequence count >= 2 in get_alignment() with clear error - Validate line_length > 0 in set_alignment() - Clear existing entries before writing in set_alignment() to prevent stale data when reusing a ClustalFile object
Member
|
Thanks for adding the parser 👍. I'll have a look 👀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for reading and writing ClustalW
.alnalignment files, following the existing FASTA alignment I/O pattern.New files
src/biotite/sequence/io/clustal/__init__.pysrc/biotite/sequence/io/clustal/file.pyClustalFileclass (TextFile + MutableMapping)src/biotite/sequence/io/clustal/convert.pyget_alignment()/set_alignment()conversion functionstests/sequence/data/clustal.alntests/sequence/data/clustal_multi.alntests/sequence/test_clustal.pyImplementation details
ClustalFile
TextFileandMutableMapping(same pattern asFastaFile)clustal_file["seq1"]returns gapped sequence stringConversion functions
get_alignment(clustal_file, seq_type=None)— auto-detects nucleotide/proteinset_alignment(clustal_file, alignment, seq_names, line_length=60)— formats into blocksEdge cases handled
InvalidFileErrorInvalidFileErrorValueError(alignments need ≥ 2 sequences)line_length=0→ValueErrorClustalFileobject → entries cleared before writing*,:,.) correctly skipped during parsingTests
9 tests covering: file reading, multi-block parsing, dict interface, alignment conversion, round-trip consistency (object-level and file I/O-level), name count mismatch error, and explicit sequence type parameter.
Closes #774