Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix CDS span calculations #196

Merged
merged 10 commits into from
Feb 27, 2025
Merged

Conversation

GavinHuttley
Copy link

@GavinHuttley GavinHuttley commented Feb 27, 2025

Summary by Sourcery

Fixes CDS span calculations and adds tests to validate the fix. The pull request also updates the CI configuration to include Python 3.13 and updates the test data URL.

Bug Fixes:

  • Fixes CDS span calculations to correctly determine the start and stop coordinates of CDS features, addressing issues with relative start and stop positions, especially in multi-exon scenarios.

Build:

  • Updates the requires-python field in pyproject.toml to allow Python 3.13.

CI:

  • Adds Python 3.13 to the testing matrix in the CI workflow.
  • Updates the cache key for test data to invalidate the cache and force a re-download of the test data.
  • Updates the test data URL to use a direct download link from Dropbox.

Tests:

  • Adds new tests to verify CDS sequence retrieval for single-exon and multi-exon genes, including cases with reverse strand and non-standard exon boundaries.
  • Adds a test case for retrieving CDS features for C. elegans.

[CHANGED] reference the optional install groups to simplify
        the listings of dependencies

[CHANGED] add support for python 3.13 and include in testing action
[NEW] used for conditional handling of adjusting translation boundaries
[CHANGED] relative start should not be adjusted for 0-based indexing

[CHANGED] updated tests to this
Copy link

sourcery-ai bot commented Feb 27, 2025

Reviewer's Guide by Sourcery

This pull request fixes CDS span calculations, adds tests for various CDS scenarios, and updates development dependencies and testing workflow to include Python 3.13 and resolve data download issues. The CDS span calculation fix ensures accurate sequence retrieval for both single and multi-exon transcripts.

Sequence diagram for CDS span calculation with single exon

sequenceDiagram
  participant get_transcript_attr_records
  participant LimitExons
  participant cds_spans

  get_transcript_attr_records->>LimitExons: lex.single_exon == True
  alt lex.single_exon == True
    get_transcript_attr_records->>cds_spans: ex_start = cds_spans[0][0] if lex.strand == 1 else cds_spans[0][1]
    get_transcript_attr_records->>cds_spans: start, stop = ex_start + lex.rel_start, ex_start + lex.rel_stop (if lex.strand == 1)
    get_transcript_attr_records->>cds_spans: start, stop = ex_start - lex.rel_stop, ex_start - lex.rel_start (if lex.strand != 1)
    get_transcript_attr_records->>cds_spans: cds_spans[0, :] = start, stop
    get_transcript_attr_records-->>get_transcript_attr_records: yield TranscriptAttrRecord
  end
Loading

File-Level Changes

Change Details Files
Corrected CDS span calculations for single and multi-exon transcripts, ensuring accurate sequence retrieval.
  • Fixed CDS span calculations for single-exon transcripts by correctly adjusting start and stop coordinates based on strand.
  • Corrected CDS span calculations for multi-exon transcripts, ensuring accurate sequence retrieval.
  • Added tests to verify CDS sequence retrieval for single-exon, multi-exon (plus strand), and two-exon (reverse strand) scenarios.
  • Modified get_transcript_attr_records to handle single exon CDS span calculations.
  • Adjusted relative start coordinate calculation in get_limit_exons.
  • Added a property to the LimitExons class to determine if the CDS is single exon.
tests/test_cli.py
src/ensembl_tui/_mysql_core_attr.py
tests/test_install.py
tests/test_genome.py
Updated development dependencies and testing workflow to include Python 3.13 and resolve data download issues.
  • Added Python 3.13 to the testing matrix in .github/workflows/testing_develop.yml.
  • Updated the test data download URL in tests/conftest.py and .github/workflows/testing_develop.yml to resolve download issues.
  • Added development dependencies to pyproject.toml.
pyproject.toml
.github/workflows/testing_develop.yml
tests/conftest.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @GavinHuttley - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The tests added in this PR are great, but could be improved by using smaller test fixtures rather than loading the entire genome.
  • The logic for single exon CDS spans seems overly complex; can it be simplified?
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coveralls
Copy link
Collaborator

coveralls commented Feb 27, 2025

Pull Request Test Coverage Report for Build 13556843807

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 87.673%

Totals Coverage Status
Change from base Build 13492055593: 0.08%
Covered Lines: 2660
Relevant Lines: 3034

💛 - Coveralls

@GavinHuttley GavinHuttley merged commit fc9b07c into cogent3:develop Feb 27, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants