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

Only warn about strands with duplicate names that can't be copies of each other. #243

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
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
31 changes: 28 additions & 3 deletions scadnano/scadnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -3283,6 +3283,31 @@ def __eq__(self, other: Any) -> bool: # remove quotes when Py3.6 support droppe
return False
return self.domains == other.domains

def equiv(self, other: Any) -> bool:
"""
Determines whether this strand could be a copy of `other`, up to the currently
defined sequences for each. This method does not require that the names, domain names,
labels, colors, etc. be the same.
"""
if not isinstance(other, Strand):
return False
elif self.modification_3p != other.modification_3p:
return False
elif self.modification_5p != other.modification_5p:
return False
elif self.modifications_int != other.modifications_int:
return False
elif self.circular != other.circular:
return False
if len(self.domains) != len(other.domains):
return False
for d1, d2 in zip(self.domains, other.domains):
if d1.dna_sequence != d2.dna_sequence:
return False
if d1.dna_length() != d2.dna_length():
return False
return True

def __hash__(self) -> int:
return hash(self.domains)

Expand Down Expand Up @@ -7686,9 +7711,9 @@ def _assign_default_helices_view_orders_to_groups(self) -> None:
def _warn_if_strand_names_not_unique(self) -> None:
names = [strand.name for strand in self.strands if strand.name is not None]
if len(names) > len(set(names)):
for name1, name2 in itertools.combinations(names, 2):
if name1 == name2:
print(f'WARNING: there are two strands with name {name1}')
for strand1, strand2 in itertools.combinations(self.strands, 2):
if (strand1.name == strand2.name) and not strand1.equiv(strand2):
print(f'WARNING: there are two non-equivalent strands with name {strand1.name}.')

def strand_with_name(self, name: str) -> Optional[Strand]:
"""
Expand Down