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

fix oxView export exception with Loopouts #297

Closed
dave-doty opened this issue Mar 28, 2024 · 0 comments
Closed

fix oxView export exception with Loopouts #297

dave-doty opened this issue Mar 28, 2024 · 0 comments
Assignees
Labels
bug Something isn't working closed in dev

Comments

@dave-doty
Copy link
Member

dave-doty commented Mar 28, 2024

The following design

240210 zigzag growth.sc.txt

raises an exception when executing

import scadnano as sc
design = sc.Design.from_scadnano_file('240210 zigzag growth.sc')
design.write_oxview_file()

This is the error:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[3], line 4
      1 import scadnano as sc
      3 design = sc.Design.from_scadnano_file('240210 zigzag growth.sc')
----> 4 design.write_oxview_file()

File C:\Dropbox\git\scadnano-python-package\scadnano\scadnano.py:7877, in Design.write_oxview_file(self, directory, filename, warn_duplicate_strand_names, use_strand_colors)
   7862 def write_oxview_file(self, directory: str = '.', filename: Optional[str] = None,
   7863                       warn_duplicate_strand_names: bool = True, use_strand_colors: bool = True) -> None:
   7864     """Writes an oxView file rerpesenting this design.
   7865 
   7866     :param directory:
   (...)
   7875         of the strand.
   7876     """
-> 7877     oxvsystem = self.to_oxview_format(warn_duplicate_strand_names=warn_duplicate_strand_names,
   7878                                       use_strand_colors=use_strand_colors)
   7879     write_file_same_name_as_running_python_script(json.dumps(oxvsystem), 'oxview', directory, filename)

File C:\Dropbox\git\scadnano-python-package\scadnano\scadnano.py:7772, in Design.to_oxview_format(self, warn_duplicate_strand_names, use_strand_colors)
   7770 import datetime
   7771 self._check_legal_design(warn_duplicate_strand_names)
-> 7772 system = _convert_design_to_oxdna_system(self)
   7774 oxview_strands: List[Dict[str, Any]] = []
   7775 nuc_count = 0

File C:\Dropbox\git\scadnano-python-package\scadnano\scadnano.py:9145, in _convert_design_to_oxdna_system(design)
   9141 elif isinstance(domain, Loopout):
   9142     # we place the loopout nucleotides at temporary nonsense positions and orientations
   9143     # these will be updated later, for now we just need the base
   9144     for _ in range(domain.length):
-> 9145         base = seq[i]
   9146         center = _OxdnaVector()
   9147         normal = _OxdnaVector(0, -1, 0)

IndexError: string index out of range

One clue is that the loop variable _ is unused, and each iteration of the loop is accessing the same symbol seq[i] of the domain's sequence. So it might be that the fix is to replace lines 9144 and 9145 with

for j in range(domain.length):
    base = seq[j]
@dave-doty dave-doty added the bug Something isn't working label Mar 28, 2024
@dave-doty dave-doty changed the title fix oxView export exception fix oxView export exception with Loopouts Mar 28, 2024
dave-doty added a commit that referenced this issue Mar 28, 2024
…iew-export-exception

fixes #297: fix oxView export exception on Loopouts
@dave-doty dave-doty self-assigned this Mar 28, 2024
@dave-doty dave-doty mentioned this issue Mar 28, 2024
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working closed in dev
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant