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

Implement 'find_feature' Utility Function in SBOL Tutorial #237

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

vinayakjeet
Copy link

  • Implementation: Introduced find_feature function to enhance feature search within SBOL documents, addressing issue find_feature #185.
  • Objective: Simplifies the process of locating features that satisfy specific conditions, moving away from manual iteration to a more efficient, programmatic approach.
  • Advantages:
    • Enhances code efficiency by reducing the need for verbose loop constructs.
    • Improves code readability, making it easier to understand and maintain.
    • Provides a flexible search mechanism through a callable parameter, allowing for diverse search criteria.
  • Technical Details:
    • Function Signature: find_feature(doc: sbol3.Document, matching: Callable[[sbol3.Feature], bool]) -> Optional[sbol3.Feature]
    • Iterates through all sbol3.Component objects in the given sbol3.Document.
    • Applies the matching callable to each sbol3.Feature to determine if it meets the specified condition.
    • Returns the first matching sbol3.Feature, or None if no match is found.
  • Example Usage:
    found_feature = find_feature(doc, lambda feature: feature.instance_of == b0015.identity)
    if found_feature:
        # Demonstrates appending a new location to the found feature
        found_feature.locations.append(Range(i13504_seq, 746, 875))
    

closes #185

Signed-off-by: Vinayakjeet Singh Karki <[email protected]>
@jakebeal
Copy link
Contributor

jakebeal commented Apr 7, 2024

Tests are failing, but currently only the two caused by #231, so the testing is sufficient to proceed to a full review.

Copy link
Contributor

@jakebeal jakebeal left a comment

Choose a reason for hiding this comment

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

This function looks reasonable, but needs to have a test added to demonstrate that it is, in fact, behaving as expected.

return any(n==sbol3.SO_CIRCULAR for n in obj.types)
Copy link
Contributor

Choose a reason for hiding this comment

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

Per standard Python style, there should be two blank lines before the new function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

find_feature
2 participants