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

Reading in cadnano files into scripting interface results in various errors #1

Open
JDodd99 opened this issue Jan 10, 2023 · 0 comments

Comments

@JDodd99
Copy link

JDodd99 commented Jan 10, 2023

Description of issue

I am attempting to script a part of my origami design workflow in cadnano. I followed some of the guidance available from the docs to do this, but reading in and saving files is not working correctly. Would you be able to look into this? All details of my environment and some test files are provided below.

Bug_Report.zip

Reading a cadnano .json file into scripting interface, then saving it back results in a null or messed up output file without legacy enabled, and an error message with legacy enabled.

Environment

Windows 10.0.19044 Build 19044
cadnano 2.5.1.11 (installed via pip)
Python 3.6.13

Test design (json) files produced and tested in cadnano versions 2.3, 2.4, and 2.5

Steps to reproduce

Use scripting interface to read in file, save it back.

Remove "legacy=False" to run without error message.

import cadnano
from cadnano.document import Document
import os

def scripting_test(input_file):
    app = cadnano.app()  # cadnano structure initialization (need to define an app, document and part)
    doc = app.document = Document()
    doc.readFile(input_file)

    doc.writeToFile(os.path.join(os.path.dirname(input_file), 'adjusted_%s' % os.path.basename(input_file)),
                        legacy=False)

Input:
test_lattice.json
test_lattice_2.json
Rothemund-rect.json
(all available in attached zip file)

Output:
Without legacy=True:
adjusted_test_lattice.json
adjusted_test_lattice_2.json
adjusted_Rothemund-rect.json
(all available in attached zip file)

With legacy=True (error):

Found cadnano version 2 file
Traceback (most recent call last):
  File "read_test.py", line 25, in <module>
    break_maker()
  File "C:\Users\s2443849\Anaconda3\envs\cadnano\lib\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\s2443849\Anaconda3\envs\cadnano\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\s2443849\Anaconda3\envs\cadnano\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\s2443849\Anaconda3\envs\cadnano\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "read_test.py", line 22, in break_maker
    legacy=False)
TypeError: writeToFile() got an unexpected keyword argument 'legacy'

Testing on another machine (Mac)

Environment:
Mac OS 13.1 (Intel-based)
Cadnano 2.5.2.1
Python 3.6.15

Output:

Without legacy enabled:

Found cadnano version 2 file
Deletion added on helix 4, position 41 3
Deletion added on helix 8, position 44 7
Deletion added on helix 7, position 28 10
Deletion added on helix 3, position 23 14
Deletion added on helix 0, position 31 17
Traceback (most recent call last):
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/code.py", line 91, in runcode
   exec(code, self.locals)
 File "<input>", line 1, in <module>
 File "/Users/matt/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/223.8214.51/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
   pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
 File "/Users/matt/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/223.8214.51/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
   exec(compile(contents+"\n", file, 'exec'), glob, loc)
 File "/Users/matt/Documents/PhD/research_output/mini_coding_projects/cadnano_scripting/cadnano_break_point_maker.py", line 68, in <module>
   break_maker(sys.argv[1:])  # for use when debugging with pycharm
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/click/core.py", line 1128, in __call__
   return self.main(*args, **kwargs)
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/click/core.py", line 1053, in main
   rv = self.invoke(ctx)
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/click/core.py", line 1395, in invoke
   return ctx.invoke(self.callback, **ctx.params)
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/click/core.py", line 754, in invoke
   return __callback(*args, **kwargs)
 File "/Users/matt/Documents/PhD/research_output/mini_coding_projects/cadnano_scripting/cadnano_break_point_maker.py", line 62, in break_maker
   legacy=False)
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/cadnano/document.py", line 188, in writeToFile
   encodeToFile(filename, self, legacy)
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/cadnano/fileio/encode.py", line 17, in encodeToFile

   json_string = encode(document, legacy)
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/cadnano/fileio/encode.py", line 37, in encode
   obj = v3encode.encodeDocument(document)
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/cadnano/fileio/v3encode.py", line 21, in encodeDocument
   'slice_view_type': document.getSliceViewType(),
 File "/Users/matt/opt/anaconda3/envs/cadnano_scripting/lib/python3.6/site-packages/cadnano/document.py", line 950, in getSliceViewType
   return self.controller().getSliceViewType()
AttributeError: 'NoneType' object has no attribute 'getSliceViewType'

With legacy enabled:

test_lattice_legacy_true.json (also available in attached zip file)

Helices are moved around, sometimes breaking up the design, and some crossovers are also removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant