def createDocument(self, base_doc: DocT = None): global CNMainWindow # print("CadnanoQt createDocument begin") default_file = self.argns.file or os.environ.get( 'CADNANO_DEFAULT_DOCUMENT', None) if default_file is not None and base_doc is not None: default_file = os.path.expanduser(default_file) default_file = os.path.expandvars(default_file) dw = CNMainWindow(base_doc) self.cnmain_windows.add(dw) # logger.info("Loading cadnano file %s to base document %s", default_file, base_doc) decodeFile(default_file, document=base_doc) dw.setFileName(default_file) print("Loaded default document: %s" % (default_file)) else: doc_window_count = len(self.cnmain_windows) # logger.info("Creating new empty document...") if doc_window_count == 0: # first dw # dw adds itself to app.cnmain_windows dw = CNMainWindow(base_doc) self.cnmain_windows.add(dw) elif doc_window_count == 1: # dw already exists dw = list(self.cnmain_windows)[0] dw.newDocument() # tell it to make a new doucment # print("CadnanoQt createDocument done") return dw.document()
def createDocument(self, base_doc: DocT = None): global CNMainWindow # print("CadnanoQt createDocument begin") default_file = self.argns.file or os.environ.get('CADNANO_DEFAULT_DOCUMENT', None) if default_file is not None and base_doc is not None: default_file = os.path.expanduser(default_file) default_file = os.path.expandvars(default_file) dw = CNMainWindow(base_doc) self.cnmain_windows.add(dw) # logger.info("Loading cadnano file %s to base document %s", default_file, base_doc) decodeFile(default_file, document=base_doc) dw.setFileName(default_file) print("Loaded default document: %s" % (default_file)) else: doc_window_count = len(self.cnmain_windows) # logger.info("Creating new empty document...") if doc_window_count == 0: # first dw # dw adds itself to app.cnmain_windows dw = CNMainWindow(base_doc) self.cnmain_windows.add(dw) elif doc_window_count == 1: # dw already exists dw = list(self.cnmain_windows)[0] dw.newDocument() # tell it to make a new doucment # print("CadnanoQt createDocument done") return dw.document()
def testDisplay(): designname = "Nature09_monolith.json" inputfile = pjoin(TEST_PATH, "data", designname) doc = cndecode.decodeFile(inputfile) part = doc.activePart() displayVHs(part, camera_z = 70)
def readFile(self, filename): """ Convenience wrapper for `decodeFile` to always emit_signals and set the `document` argument to `self` Args: filename (str): full path file name """ print("reading file", filename) return decodeFile(filename, document=self, emit_signals=True)
def readFile(self, filename: str) -> DocT: """Convenience wrapper for ``decodeFile`` to always emit_signals and set the ``document`` argument to ``self`` Args: filename: full path file name Returns: self ``Document`` object with data decoded from ``filename`` """ print("reading file", filename) return decodeFile(filename, document=self, emit_signals=True)
def createDocument(self, base_doc: DocT = None): global DocumentController # print("CadnanoQt createDocument begin") default_file = self.argns.file or os.environ.get('CADNANO_DEFAULT_DOCUMENT', None) if default_file is not None and base_doc is not None: default_file = os.path.expanduser(default_file) default_file = os.path.expandvars(default_file) dc = DocumentController(base_doc) # logger.info("Loading cadnano file %s to base document %s", default_file, base_doc) decodeFile(default_file, document=base_doc) dc.setFileName(default_file) print("Loaded default document: %s" % (default_file)) else: doc_ctrlr_count = len(self.document_controllers) # logger.info("Creating new empty document...") if doc_ctrlr_count == 0: # first dc # dc adds itself to app.document_controllers dc = DocumentController(base_doc) elif doc_ctrlr_count == 1: # dc already exists dc = list(self.document_controllers)[0] dc.newDocument() # tell it to make a new doucment # print("CadnanoQt createDocument done") return dc.document()
def loadFile(filename: str) -> DocT: inputfile = pjoin(TEST_PATH, "data", filename) doc = cndecode.decodeFile(inputfile) return doc
def testDisplay(): designname = "Nature09_monolith.json" inputfile = pjoin(TEST_PATH, "data", designname) doc = cndecode.decodeFile(inputfile) part = doc.activePart() displayVHs(part, camera_z=70)
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(root_path) BASE_LENGTH = 0.3 if __name__ == "__main__": test1 = 'super_barcode_hex.json' test2 = 'Nature09_squarenut.json' path_out = 'Nature09_squarenut.stl' root_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) test_path = os.path.join(root_path, 'tests', test2) doc = decode.decodeFile(test_path) solids = [] part = doc.children()[0] # print(part.radius()) radius = part.radius() + 0.1 for oligo in part.oligos(): if not oligo.isStaple(): strand5p = oligo.strand5p() for strand in strand5p.generator3pStrand(): length = BASE_LENGTH*strand.length() idx_low, idx_high = strand.idxs() z = BASE_LENGTH*((idx_high + idx_low) / 2.0)