Skip to content

Commit

Permalink
don't put Helix idx in base_pairs dict if Helix has no base pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-doty committed Dec 2, 2022
1 parent e55609d commit afc44b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scadnano/scadnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -5358,6 +5358,8 @@ def base_pairs(self, allow_mismatches: bool = False) -> Dict[int, List[int]]:
Base pairs in this design, represented as a dict mapping a :data:`Helix.idx` to a list of offsets
on that helix where two strands are.
If a :any:`Helix` has no base pairs, then its :data:`Helix.idx` is not a key in the returned dict.
:param allow_mismatches:
if True, then all offsets on a :any:`Helix` where there is both a forward and reverse
:any:`Domain` will be included. Otherwise, only offsets where the :any:`Domain`'s have
Expand All @@ -5367,7 +5369,7 @@ def base_pairs(self, allow_mismatches: bool = False) -> Dict[int, List[int]]:
"""
base_pairs = {}
for idx, helix in self.helices.items():
offsets = base_pairs[idx] = []
offsets = []
overlapping_domains = find_overlapping_domains_on_helix(helix)
for dom1, dom2 in overlapping_domains:
start, end = dom1.compute_overlap(dom2)
Expand All @@ -5376,6 +5378,8 @@ def base_pairs(self, allow_mismatches: bool = False) -> Dict[int, List[int]]:
base2 = dom2.dna_sequence_in(offset, offset)
if allow_mismatches or bases_complementary(base1, base2):
offsets.append(offset)
if len(offsets) > 0:
base_pairs[idx] = offsets

return base_pairs

Expand Down

0 comments on commit afc44b8

Please sign in to comment.