Files
biopython/Tests
RachelStern20 ad9456f3bb Align: add substitution matrix support to Alignment.format() (#5049)
* Align: add optional substitution matrix/aligner argument to format()
- Extended Alignment.format() to accept an optional argument:
  * substitution matrix (e.g. from Bio.Align.substitution_matrices)
  * PairwiseAligner object (uses its substitution matrix)
- Preserves compatibility with existing writer-specific arguments
  (e.g. "vulgar" for exonerate, metadata for mauve).
- Internal logic now distinguishes between substitution matrices
  (used in pretty-printing) and writer arguments (passed to
  AlignmentWriter).
- All alignment format tests pass (58/58).

* Align: add substitution matrix argument to helper format functions

- Updated _format_pretty, _format_unicode, _format_generalized
  to accept optional substitution matrix argument.
- Passed matrix from Alignment.format() into these helpers.
- Updated docstrings accordingly.
- All alignment format tests pass (58/58).

* Align.format: support substitution matrices in helper functions; add tests

- Updated helper functions in Align.format (generalized, pretty, html, etc.)
  to correctly handle substitution_matrix arguments.
- Added new test file `Tests/test_format_matrix.py` to cover:
  * identity matches (|), positive mismatches (:), negative mismatches (.),
    and gaps (-) using substitution matrices.
  * verified behavior with both NUC.4.4 and a custom BLASTN-like matrix.
- Confirmed tests pass with pytest.

Resolves #5043

* Add Rachel Stern to contributors list and NEWS (first contribution)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix style issues in test_format_matrix and Align -__init__

* Rename test_format_matrix.py to test_format_matrix_unittest.py for AppVeyor test discovery

* Move format matrix test to unittest style

* Refactor scoring argument handling in counts() and format()

- Renamed the optional argument in counts() from `argument` to `scoring` for
  clarity and consistency.
- Updated format() to accept the `scoring` parameter via **kwargs instead of
  a dedicated argument.
- Removed the explicit writer argument from format(), since it is no longer
  needed with kwargs-based handling.
- Adjusted the docstring of format() accordingly to reflect the new usage.

* Update test_format_matrix_unittest.py:
- Use explicit assertEqual for pattern strings instead of only assertIn/NotIn, following reviewer feedback.
- Simplify alignment selection by indexing [0] instead of next(iter(...)).

* Remove _pattern_from_pretty, assert full alignment format instead

- Replaced usage of `_pattern_from_pretty` helper with direct comparison
  of `aln.format("", scoring=M)` output in all relevant tests.
- This makes the tests simpler and closer to the actual API usage.
- Removed unused `_pattern_from_pretty` function.

* docs: document new `scoring` argument in Alignment.format tutorial

- Added explanation of the optional `scoring` argument to
  `Alignment.format()` in Doc/Tutorial/chapter_align.rst.
- Included example using PairwiseAligner and a substitution matrix
  (NUC.4.4) to illustrate how the pattern line reflects scores.
- Clarifies how symbols (|, :, ., -) correspond to matches,
  positive/negative mismatches, and gaps.

* docs: add cont-doctest and update scoring example with '.' mismatch

* docs: fix scoring example with gap penalties to show ':' and '.' in doctest

* docs: add <BLANKLINE> to doctest output in scoring example

* doc: add 8 in the middle line of the format

* doc: Arranging the print format

* Rearrange the print format

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: mdehoon <mjldehoon@yahoo.com>
2025-09-04 14:14:55 +09:00
..
2021-08-31 10:41:38 +01:00
2016-12-09 11:58:05 +00:00
2023-11-02 09:14:55 +00:00
2024-11-21 17:29:30 +09:00
2024-03-18 11:55:25 +09:00
2013-04-11 11:59:16 +01:00
2023-11-02 09:14:55 +00:00
2002-12-03 18:11:41 +00:00
2023-10-28 17:36:54 +02:00
2023-06-07 22:10:42 +09:00
2008-07-16 05:40:57 +00:00
2024-06-26 10:44:57 +09:00
2016-06-03 11:15:51 +01:00
2020-01-13 20:32:17 +09:00
2000-09-07 02:28:23 +00:00
2002-05-14 07:06:44 +00:00
2015-10-07 10:36:30 +01:00
2010-01-25 20:13:26 +09:00
2024-01-22 09:11:55 +00:00
2023-01-24 13:23:15 +00:00
2000-11-15 18:34:43 +00:00
2021-08-31 10:41:38 +01:00
2024-09-02 13:58:03 +09:00
2025-03-02 09:19:37 +09:00
2022-09-29 10:21:04 +09:00
2024-03-14 11:05:43 +00:00
2025-03-02 09:19:37 +09:00
2020-11-27 12:49:13 +00:00
2025-05-29 10:00:50 +01:00
2024-09-03 12:30:49 +01:00
str
2020-11-27 23:16:07 +00:00
2025-02-19 21:49:09 +00:00
2023-10-05 08:47:54 +01:00
2023-10-05 08:47:54 +01:00
2025-03-22 06:59:36 +01:00
2024-03-14 11:05:43 +00:00
2024-03-14 11:05:43 +00:00
2025-07-24 18:13:30 +01:00
2025-03-02 09:19:37 +09:00