def setPartnerVirtualHelix(self, strand: StrandT): """ Args: strand: Description """ if strand.connection3p(): self._partner_virtual_helix_id_num = strand.connection3p().idNum() else: self._partner_virtual_helix_id_num = None
def update(self, strand5p: StrandT, idx: int = None): """Pass ``idx`` to this method in order to install a floating Xover for the forced xover tool Args: strand5p: Description idx: Default is ``None`` """ self._strand5p = strand5p strand3p = strand5p.connection3p() vhi5p = self._virtual_helix_item part_item = vhi5p.partItem() # This condition is for floating xovers idx_3_prime = idx if idx else strand5p.idx3Prime() if self._node5 is None: self._node5 = XoverNode5(vhi5p, self, strand5p, idx_3_prime) if strand3p is not None: if self._node3 is None: vhi3p = part_item.idToVirtualHelixItem(strand3p.idNum()) self._node3 = XoverNode3(vhi3p, self, strand3p, strand3p.idx5Prime()) else: self._node5.setIdx(idx_3_prime) self._node3.setIdx(strand3p.idx5Prime()) self._node5.setPartnerVirtualHelix(strand5p) self._updatePath(strand5p) else: if self._node3: self._node3.destroyItem() self._node3 = None
def strandResizedSlot(self, strand: StrandT, indices: SegmentT): """Slot for handling resizing of this StrandItem Args: strand: indices: low and high indices """ low_moved, group_low = self._low_cap.updatePosIfNecessary(self.idxs()[0]) high_moved, group_high = self._high_cap.updatePosIfNecessary(self.idxs()[1]) group = self.group() self.tempReparent() if low_moved: self.updateLine(self._low_cap) if high_moved: self.updateLine(self._high_cap) if strand.connection3p(): self.xover_3p_end.update(strand) self.refreshInsertionItems(strand) self._updateSequenceText() if group: group.addToGroup(self) if group_low is not None: group_low.addToGroup(self._low_cap) if group_high is not None: group_high.addToGroup(self._high_cap)
def strandResizedSlot(self, strand: StrandT, indices: SegmentT): """Slot for handling resizing of this StrandItem Args: strand: indices: low and high indices """ low_moved, group_low = self._low_cap.updatePosIfNecessary( self.idxs()[0]) high_moved, group_high = self._high_cap.updatePosIfNecessary( self.idxs()[1]) group = self.group() self.tempReparent() if low_moved: self.updateLine(self._low_cap) if high_moved: self.updateLine(self._high_cap) if strand.connection3p(): self.xover_3p_end.update(strand) self.refreshInsertionItems(strand) self._updateSequenceText() if group: group.addToGroup(self) if group_low is not None: group_low.addToGroup(self._low_cap) if group_high is not None: group_high.addToGroup(self._high_cap)
def strandHasNewOligoSlot(self, strand: StrandT): """Slot for changing the `Oligo` of the model `Strand` Args: strand: """ strand = self._model_strand self._controller.reconnectOligoSignals() self._updateColor(strand) if strand.connection3p(): self.xover_3p_end._updateColor(strand) for insertion in self.insertionItems().values(): insertion.updateItem()
def _updateAppearance(self, strand: StrandT): """Prepare Strand for drawing, positions are relative to the :class:`PathVirtualHelixItem`: 1. Show or hide caps depending on L and R connectivity. 2. Determine line coordinates. 3. Apply paint styles. """ # 0. Setup vhi = self._virtual_helix_item bw = _BASE_WIDTH half_base_width = bw / 2.0 low_idx, high_idx = strand.lowIdx(), strand.highIdx() l_upper_left_x, l_upper_left_y = vhi.upperLeftCornerOfBase(low_idx, strand) h_upper_left_x, h_upper_left_y = vhi.upperLeftCornerOfBase(high_idx, strand) low_cap = self._low_cap high_cap = self._high_cap dual_cap = self._dual_cap # 1. Cap visibilty lx = l_upper_left_x + bw # draw from right edge of base low_cap.safeSetPos(l_upper_left_x, l_upper_left_y) if strand.connectionLow() is not None: # has low xover # if we are hiding it, we might as well make sure it is reparented to the StrandItem low_cap.restoreParent() low_cap.hide() else: # has low cap if not low_cap.isVisible(): low_cap.show() hx = h_upper_left_x # draw to edge of base high_cap.safeSetPos(h_upper_left_x, h_upper_left_y) if strand.connectionHigh() is not None: # has high xover # if we are hiding it, we might as well make sure it is reparented to the StrandItem high_cap.restoreParent() high_cap.hide() else: # has high cap if not high_cap.isVisible(): high_cap.show() # special case: single-base strand with no L or H connections, # (unconnected caps were made visible in previous block of code) if strand.length() == 1 and (low_cap.isVisible() and high_cap.isVisible()): low_cap.hide() high_cap.hide() dual_cap.safeSetPos(l_upper_left_x, l_upper_left_y) dual_cap.show() else: dual_cap.hide() # 2. Xover drawing xo = self.xover_3p_end if strand.connection3p(): xo.update(strand) xo.showIt() else: xo.restoreParent() xo.hideIt() # 3. Refresh insertionItems if necessary drawing self.refreshInsertionItems(strand) # 4. Line drawing hy = ly = l_upper_left_y + half_base_width self.setLine(lx, ly, hx, hy) rectf = QRectF(l_upper_left_x + bw, l_upper_left_y, bw*(high_idx - low_idx - 1), bw) self._click_area.setRect(rectf) self._updateColor(strand)
def _updateAppearance(self, strand: StrandT): """Prepare Strand for drawing, positions are relative to the :class:`PathVirtualHelixItem`: 1. Show or hide caps depending on L and R connectivity. 2. Determine line coordinates. 3. Apply paint styles. """ # 0. Setup vhi = self._virtual_helix_item bw = _BASE_WIDTH half_base_width = bw / 2.0 low_idx, high_idx = strand.lowIdx(), strand.highIdx() l_upper_left_x, l_upper_left_y = vhi.upperLeftCornerOfBase( low_idx, strand) h_upper_left_x, h_upper_left_y = vhi.upperLeftCornerOfBase( high_idx, strand) low_cap = self._low_cap high_cap = self._high_cap dual_cap = self._dual_cap # 1. Cap visibilty lx = l_upper_left_x + bw # draw from right edge of base low_cap.safeSetPos(l_upper_left_x, l_upper_left_y) if strand.connectionLow() is not None: # has low xover # if we are hiding it, we might as well make sure it is reparented to the StrandItem low_cap.restoreParent() low_cap.hide() else: # has low cap if not low_cap.isVisible(): low_cap.show() hx = h_upper_left_x # draw to edge of base high_cap.safeSetPos(h_upper_left_x, h_upper_left_y) if strand.connectionHigh() is not None: # has high xover # if we are hiding it, we might as well make sure it is reparented to the StrandItem high_cap.restoreParent() high_cap.hide() else: # has high cap if not high_cap.isVisible(): high_cap.show() # special case: single-base strand with no L or H connections, # (unconnected caps were made visible in previous block of code) if strand.length() == 1 and (low_cap.isVisible() and high_cap.isVisible()): low_cap.hide() high_cap.hide() dual_cap.safeSetPos(l_upper_left_x, l_upper_left_y) dual_cap.show() else: dual_cap.hide() # 2. Xover drawing xo = self.xover_3p_end if strand.connection3p(): xo.update(strand) xo.showIt() else: xo.restoreParent() xo.hideIt() # 3. Refresh insertionItems if necessary drawing self.refreshInsertionItems(strand) # 4. Line drawing hy = ly = l_upper_left_y + half_base_width self.setLine(lx, ly, hx, hy) rectf = QRectF(l_upper_left_x + bw, l_upper_left_y, bw * (high_idx - low_idx - 1), bw) self._click_area.setRect(rectf) self._updateColor(strand)