Skip to content

In restriction_and_ligation, add option to sort products based on presence of the first enzyme cut site#411

Merged
manulera merged 1 commit intomasterfrom
sort_by_recognition_sites
Mar 3, 2026
Merged

In restriction_and_ligation, add option to sort products based on presence of the first enzyme cut site#411
manulera merged 1 commit intomasterfrom
sort_by_recognition_sites

Conversation

@manulera
Copy link
Owner

@manulera manulera commented Mar 3, 2026

Backend part of manulera/OpenCloning_frontend#647


Note

Low Risk
Low risk: adds an optional query param that only affects the ordering of returned restriction_and_ligation products when enabled; core assembly generation is unchanged.

Overview
Adds an optional sort_by_recognition_sites query parameter to the /restriction_and_ligation endpoint to sort returned products by how many cut/recognition sites remain for the first restriction enzyme (useful for Golden Gate workflows).

Extends endpoint tests to validate that enabling sorting yields stable product ordering even when inputs are sequence-shifted, while disabling it preserves the previous (order-dependent) behavior.

Written by Cursor Bugbot for commit 5d9765a. This will update automatically on new commits. Configure here.

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.04%. Comparing base (ab6b331) to head (5d9765a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #411   +/-   ##
=======================================
  Coverage   97.03%   97.04%           
=======================================
  Files          31       31           
  Lines        1959     1962    +3     
=======================================
+ Hits         1901     1904    +3     
  Misses         58       58           
Flag Coverage Δ
unittests 97.04% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Free Tier Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


if len(enzymes) > 0 and sort_by_recognition_sites:
enzyme = parse_restriction_enzymes([source.restriction_enzymes[0]])
products.sort(key=lambda x: len(x.seq.get_cutsites(enzyme)))
Copy link

Choose a reason for hiding this comment

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

Inconsistent get_cutsites calling convention

Medium Severity

The new code calls x.seq.get_cutsites(enzyme) where enzyme is a RestrictionBatch, but the only other usage of get_cutsites in the codebase (no_assembly.py) always unpacks the batch with *enzymes. If get_cutsites expects individual enzyme objects as variadic arguments (as implied by the existing convention), passing the entire RestrictionBatch as a single argument would produce incorrect cut site counts, making the sort a no-op or incorrect — silently breaking the sorting feature without any error.

Fix in Cursor Fix in Web

@manulera manulera merged commit 2e130b8 into master Mar 3, 2026
12 checks passed
@manulera manulera deleted the sort_by_recognition_sites branch March 3, 2026 11:49
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.

1 participant