def displayVHs(part: NucleicAcidPart, id_nums: List[int] = [], radius: float = 1.0, color: str = 'coral', width: int = WIDTH, height: int = HEIGHT, camera_z: float = CAM_Z, colors=['coral']): if len(id_nums) == 0: id_nums = part.getIdNums() len_colors = len(colors) items = [] mid_point_sum = (0, 0, 0) i = 0 for id_num in id_nums: color = colors[i] vh = part.getVirtualHelix(id_num) pos1 = vh.getAxisPoint(0) pos2 = vh.getAxisPoint(vh.getSize() - 1) vhm, mid_point = virtualHelixMesh(pos1, pos2, radius=radius, color=color) items.append(vhm) mid_point_sum += mid_point i += 1 i %= len_colors mid_point = mid_point_sum / len(id_nums) renderer, sc, cam = renderScene(items, width, height, camera_z, mid_point.tolist()) display(renderer) renderer.render(sc, cam)
def displayVHs( part: NucleicAcidPart, id_nums: List[int] = [], radius: float = 1.0, color: str = 'coral', width: int = WIDTH, height: int = HEIGHT, camera_z: float = CAM_Z, colors=['coral']): if len(id_nums) == 0: id_nums = part.getIdNums() len_colors = len(colors) items = [] mid_point_sum = (0, 0, 0) i = 0 for id_num in id_nums: color = colors[i] vh = part.getVirtualHelix(id_num) pos1 = vh.getAxisPoint(0) pos2 = vh.getAxisPoint(vh.getSize()-1) vhm, mid_point = virtualHelixMesh(pos1, pos2, radius=radius, color=color) items.append(vhm) mid_point_sum += mid_point i += 1 i %= len_colors mid_point = mid_point_sum / len(id_nums) renderer, sc, cam = renderScene(items, width, height, camera_z, mid_point.tolist()) display(renderer) renderer.render(sc, cam)
def deleteStrandSelection(self, use_undostack=True): """ Delete selected strands. First iterates through all selected strands and extracts refs to xovers and strands. Next, calls removeXover on xoverlist as part of its own macroed command for isoluation purposes. Finally, calls removeStrand on all strands that were fully selected (low and high), or had at least one non-xover endpoint selected. """ xoList = [] strand_dict = {} for strandset_dict in self._selection_dict.values(): for strand, selected in strandset_dict.items(): part = strand.part() idx_low, idx_high = strand.idxs() strand5p = strand.connection5p() strand3p = strand.connection3p() # both ends are selected strand_dict[strand] = selected[0] and selected[1] # only look at 3' ends to handle xover deletion sel3p = selected[0] if idx_low == strand.idx3Prime( ) else selected[1] if sel3p: # is idx3p selected? if strand3p: # is there an xover xoList.append((part, strand, strand3p, use_undostack)) else: # idx3p is a selected endpoint strand_dict[strand] = True else: if not strand5p: # idx5p is a selected endpoint strand_dict[strand] = True if use_undostack and xoList: self.undoStack().beginMacro("Delete xovers") for part, strand, strand3p, useUndo in xoList: NucleicAcidPart.removeXover(part, strand, strand3p, useUndo) self.removeStrandFromSelection(strand) self.removeStrandFromSelection(strand3p) self._selection_dict = {} self.documentClearSelectionsSignal.emit(self) if use_undostack: if xoList: # end xover macro if it was started self.undoStack().endMacro() if True in strand_dict.values(): self.undoStack().beginMacro("Delete selection") else: return # nothing left to do for strand, delete in strand_dict.items(): if delete: strand.strandSet().removeStrand(strand) if use_undostack: self.undoStack().endMacro()
def deleteStrandSelection(self, use_undostack=True): """ Delete selected strands. First iterates through all selected strands and extracts refs to xovers and strands. Next, calls removeXover on xoverlist as part of its own macroed command for isoluation purposes. Finally, calls removeStrand on all strands that were fully selected (low and high), or had at least one non-xover endpoint selected. """ xoList = [] strand_dict = {} for strandset_dict in self._selection_dict.values(): for strand, selected in strandset_dict.items(): part = strand.part() idx_low, idx_high = strand.idxs() strand5p = strand.connection5p() strand3p = strand.connection3p() # both ends are selected strand_dict[strand] = selected[0] and selected[1] # only look at 3' ends to handle xover deletion sel3p = selected[0] if idx_low == strand.idx3Prime() else selected[1] if sel3p: # is idx3p selected? if strand3p: # is there an xover xoList.append((part, strand, strand3p, use_undostack)) else: # idx3p is a selected endpoint strand_dict[strand] = True else: if not strand5p: # idx5p is a selected endpoint strand_dict[strand] = True if use_undostack and xoList: self.undoStack().beginMacro("Delete xovers") for part, strand, strand3p, useUndo in xoList: NucleicAcidPart.removeXover(part, strand, strand3p, useUndo) self.removeStrandFromSelection(strand) self.removeStrandFromSelection(strand3p) self._selection_dict = {} self.documentClearSelectionsSignal.emit(self) if use_undostack: if xoList: # end xover macro if it was started self.undoStack().endMacro() if True in strand_dict.values(): self.undoStack().beginMacro("Delete selection") else: return # nothing left to do for strand, delete in strand_dict.items(): if delete: strand.strandSet().removeStrand(strand) if use_undostack: self.undoStack().endMacro()
def createNucleicAcidPart(self, use_undostack=True, grid_type=GridType.HONEYCOMB): """ Create and store a new DnaPart and instance, and return the instance. Args: use_undostack (bool): optional, defaults to True """ dna_part = NucleicAcidPart(document=self, grid_type=grid_type) self._addPart(dna_part, use_undostack=use_undostack) return dna_part
def createNucleicAcidPart(self, use_undostack=True): """ Create and store a new DnaPart and instance, and return the instance. Args: use_undostack (bool): optional, defaults to True """ dnapart = NucleicAcidPart(document=self) self._addPart(dnapart, use_undostack=use_undostack) return dnapart
def createNucleicAcidPart( self, use_undostack: bool = True, grid_type: EnumType = GridEnum.NONE) -> NucleicAcidPart: """Create and store a new DnaPart and instance, and return the instance. Args: use_undostack: optional, defaults to True grid_type: optional default to HoneyComb Returns new :obj:`NucleicAcidPart` """ dna_part = NucleicAcidPart(document=self, grid_type=grid_type) self._addPart(dna_part, use_undostack=use_undostack) return dna_part