Skip to content

Commit

Permalink
Raise StrandError in as_circular if strand contains Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
UnHumbleBen committed May 4, 2022
1 parent 5574331 commit 8b6c060
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scadnano/scadnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,10 @@ class Extension(_JSONSerializable, Generic[DomainLabel]):
def to_json_serializable(self, suppress_indent: bool = True, **kwargs: Any) -> Union[Dict[str, Any], NoIndent]:
raise NotImplementedError()

def dna_length(self) -> int:
"""Length of this :any:`Extension`; same as field :py:data:`Extension.length`."""
return self.length

@dataclass
class ExtensionBuilder(Generic[DomainLabel]):
length: Optional[int] = None
Expand Down Expand Up @@ -2964,6 +2968,8 @@ def set_circular(self, circular: bool = True) -> None:
raise StrandError(self, "cannot have a 5' modification on a circular strand")
if circular and self.modification_3p is not None:
raise StrandError(self, "cannot have a 3' modification on a circular strand")
if circular and self.contains_extensions():
raise StrandError(self, "Cannot have extension on a circular strand")
self.circular = circular

def set_linear(self) -> None:
Expand Down Expand Up @@ -3340,6 +3346,10 @@ def contains_loopouts(self) -> bool:
return True
return False

def contains_extensions(self) -> bool:
assert len(self.domains) > 0
return isinstance(self.domains[0], Extension) or isinstance(self.domains[-1], Extension)

def first_bound_domain(self) -> Domain:
"""First :any:`Domain` (i.e., not a :any:`Loopout`) on this :any:`Strand`.
Expand Down

0 comments on commit 8b6c060

Please sign in to comment.