Repository navigation
docs: Database with custom scoring example - #10
valentynbez wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds documentation to the Database.__init__ method to demonstrate how to create a database with a custom scoring matrix alphabet, addressing issue #9 where users encountered a "database and score matrix have different alphabets" error when using Database and Aligner with custom scoring matrices separately.
- Adds an example showing how to extract the alphabet from a custom scoring matrix and use it when creating a Database
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| >>> from scoring_matrices import ScoringMatrix | ||
| >>> | ||
| >>> alphabet = ScoringMatrix.from_name("VTML80").alphabet | ||
| >>> db = pyopal.Database(["ATGC", "TTCA"], alphabet=alphabet) |
There was a problem hiding this comment.
The example uses DNA sequences ("ATGC", "TTCA") with a protein scoring matrix (VTML80). VTML80 is designed for protein sequences, not DNA. Consider using protein sequences in the example to match the scoring matrix, such as sequences containing amino acid codes like "MVLIGWIFSLIFLLFLFGFLGLLLLLIIGIIFGFLGLLI" (from the issue example).
| >>> db = pyopal.Database(["ATGC", "TTCA"], alphabet=alphabet) | |
| >>> db = pyopal.Database(["MVLIGWIFSLIF", "LLFLFGFLGLLL"], alphabet=alphabet) |
| >>> | ||
| >>> alphabet = ScoringMatrix.from_name("VTML80").alphabet | ||
| >>> db = pyopal.Database(["ATGC", "TTCA"], alphabet=alphabet) | ||
|
|
There was a problem hiding this comment.
There is trailing whitespace on this line. Please remove it to maintain code cleanliness.
| >>> alphabet = ScoringMatrix.from_name("VTML80").alphabet | ||
| >>> db = pyopal.Database(["ATGC", "TTCA"], alphabet=alphabet) |
There was a problem hiding this comment.
The example demonstrates how to create a Database with a custom alphabet, but doesn't show how to use it with an Aligner to avoid the "database and score matrix have different alphabets" error mentioned in issue #9. Consider extending the example to show the complete workflow of creating both a Database and an Aligner with matching alphabets and performing alignment.
| >>> alphabet = ScoringMatrix.from_name("VTML80").alphabet | |
| >>> db = pyopal.Database(["ATGC", "TTCA"], alphabet=alphabet) | |
| >>> scoring = ScoringMatrix.from_name("VTML80") | |
| >>> alphabet = scoring.alphabet | |
| >>> db = pyopal.Database(["ATGC", "TTCA"], alphabet=alphabet) | |
| >>> | |
| >>> # use the same scoring matrix/alphabet when creating the aligner | |
| >>> aligner = pyopal.Aligner(scoring) | |
| >>> result = aligner.align("ATGC", db) |
DatabaseandAlignerscoring matrix mismatch #9