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

Add Composite Check Functionality to SBOL Utilities #238

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion sbol_utilities/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,21 @@ def is_circular(obj: Union[sbol3.Component, sbol3.LocalSubComponent, sbol3.Exter
:param obj: design to be checked
:return: true if circular
"""
return any(n==sbol3.SO_CIRCULAR for n in obj.types)
return any(n==sbol3.SO_CIRCULAR for n in obj.types)

def is_composite(obj):
Copy link
Contributor

Choose a reason for hiding this comment

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

Function needs docstring

def has_dna_type(o):
return any(tyto.SO.DNA == tyto.SO.get_uri_by_term(t) for t in o.types)

def has_assembly_plan(o):
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should be necessary, because every Component has a generated_by attribute, even if it is empty.

if not hasattr(o, "generated_by"):
return False
for activity_ref in o.generated_by:
activity = activity_ref.lookup()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change 'sbol:design' to the SBOL_DESIGN constant.

if activity and 'http://sbols.org/v3#assemblyPlan' in activity.types and 'sbol:design' in activity.types:
return True
return False

if isinstance(obj, sbol3.Component):
return has_dna_type(obj) and has_assembly_plan(obj)
return False
Loading