def __init__(self,
                 part: NucleicAcidPartT,
                 x: float,
                 y: float,
                 z: float,
                 length: int,
                 direction: Vec3T = (0, 0, 1.),
                 id_num: int = None,
                 properties: Union[tuple, dict] = None,
                 safe: bool = True,
                 parity: int = None):
        '''``UndoCommand`` to create a virtual helix in a ``NucleicAcidPart``

        Args:
            part: The parent ``NucleicAcidPart``
            x: ``x`` coordinate of the 0 - index base
            y: ``y`` coordinate of the 0 - index base
            z: ``z`` coordinate of the 0 - index base
            length: Length of the virtual helix in bases
            direction: the direction of the virtual helix
            id_num: the ID number of the helix in the ``part``
            properties: the initial or inherited properties of the ``part``
            safe: Default is ``True``. safe must be ``True`` to update neighbors.
                otherwise, neighbors need to be explicitly updated.  Set to
                ``False`` to speed up creation of many virtual helices
            parity: even == 0, odd == 1, None == doesn't matter.  Legacy from
                scaffold based design
        '''
        super(CreateVirtualHelixCommand, self).__init__("create virtual helix")
        self.part: NucleicAcidPartT = part
        if id_num is None:
            id_num = part._getNewIdNum(parity=parity)
        else:
            part._reserveIdNum(id_num)
        self.id_num: int = id_num
        self.origin_pt: Vec3T = (x, y, z)
        self.direction: Vec3T = direction
        self.length: int = length
        self.color: str = part.getColor()
        self.keys: List[str] = None
        if properties is not None:
            if isinstance(properties, tuple):  # usually for unsafe
                self.keys, self.values = properties
            else:
                self.keys = list(properties.keys())
                self.values = list(properties.values())

        self.neighbors: List[int] = []
        if not safe:
            self.neighbors = literal_eval(
                self.values[self.keys.index('neighbors')])

        self.threshold: float = 2.1 * part.radius()
        self.safe: bool = safe
        self.old_limits: RectT = None
示例#2
0
    def __init__(self,
                part: NucleicAcidPartT,
                x: float,
                y: float,
                z: float,
                length: int,
                direction: Vec3T = (0, 0, 1.),
                id_num: int = None,
                properties: Union[tuple, dict] = None,
                safe: bool = True,
                parity: int = None):
        '''``UndoCommand`` to create a virtual helix in a ``NucleicAcidPart``

        Args:
            part: The parent ``NucleicAcidPart``
            x: ``x`` coordinate of the 0 - index base
            y: ``y`` coordinate of the 0 - index base
            z: ``z`` coordinate of the 0 - index base
            length: Length of the virtual helix in bases
            direction: the direction of the virtual helix
            id_num: the ID number of the helix in the ``part``
            properties: the initial or inherited properties of the ``part``
            safe: Default is ``True``. safe must be ``True`` to update neighbors.
                otherwise, neighbors need to be explicitly updated.  Set to
                ``False`` to speed up creation of many virtual helices
            parity: even == 0, odd == 1, None == doesn't matter.  Legacy from
                scaffold based design
        '''
        super(CreateVirtualHelixCommand, self).__init__("create virtual helix")
        self.part: NucleicAcidPartT = part
        if id_num is None:
            id_num = part._getNewIdNum(parity=parity)
        else:
            part._reserveIdNum(id_num)
        self.id_num: int = id_num
        self.origin_pt: Vec3T = (x, y, z)
        self.direction: Vec3T = direction
        self.length: int = length
        self.color: str = part.getColor()
        self.keys: List[str] = None
        if properties is not None:
            if isinstance(properties, tuple):  # usually for unsafe
                self.keys, self.values = properties
            else:
                self.keys = list(properties.keys())
                self.values = list(properties.values())

        self.neighbors: List[int] = []
        if not safe:
            self.neighbors = literal_eval(self.values[self.keys.index('neighbors')])

        self.threshold: float = 2.1*part.radius()
        self.safe: bool = safe
        self.old_limits: RectT = None
示例#3
0
    def __init__(self, is_fwd: bool, id_num: int, part: NucleicAcidPartT,
                 initial_size: int):
        self._document = part.document()
        super(StrandSet, self).__init__(part)
        self._is_fwd = is_fwd
        self._is_scaffold = is_fwd if (id_num % 2 == 0) else not is_fwd
        self._strand_type = StrandEnum.FWD if self._is_fwd else StrandEnum.REV
        self._id_num = id_num
        self._part = part

        self._reset(int(initial_size))

        self._undo_stack = None
示例#4
0
    def __init__(self,  is_fwd: bool,
                        id_num: int,
                        part: NucleicAcidPartT,
                        initial_size: int):
        self._document = part.document()
        super(StrandSet, self).__init__(part)
        self._is_fwd = is_fwd
        self._is_scaffold = is_fwd if (id_num % 2 == 0) else not is_fwd
        self._strand_type = StrandEnum.FWD if self._is_fwd else StrandEnum.REV
        self._id_num = id_num
        self._part = part

        self._reset(int(initial_size))

        self._undo_stack = None
 def __init__(self, part: NucleicAcidPartT, id_num: int):
     super(RemoveVirtualHelixCommand, self).__init__("remove virtual helix")
     self.part = part
     self.id_num = id_num
     _, self.length = part.getOffsetAndSize(id_num)
     x, y, _ = part.getVirtualHelixOrigin(id_num)
     self.origin_pt = (x, y, 0.)
     self.direction = tuple(part.directions[id_num]) # (0, 0, 1.)
     neighbors = part.getVirtualHelixProperties(id_num, 'neighbors')
     self.neighbors = literal_eval(neighbors)
     self.color = part.getVirtualHelixProperties(id_num, 'color')
     self.props = part.getAllVirtualHelixProperties(id_num, inject_extras=False)
     self.old_active_base_info = part.active_base_info
     self._vh_order = part.getVirtualHelixOrder().copy()  # just copy the whole list
示例#6
0
    def __init__(self, model_part: NucleicAcidPartT,
                 part_item: PathNucleicAcidPartItemT):
        """
        Args:
            model_part:
            part_item:
        """
        super(QGraphicsRectItem, self).__init__(BASE_RECT, part_item.proxy())
        self.setAcceptHoverEvents(True)
        self.setBrush(getBrushObj(styles.BLUE_FILL, alpha=12))
        self.setPen(getNoPen())
        self.setZValue(styles.ZWORKPLANE)

        self._model_part = model_part
        self._part_item = part_item

        self._low_drag_bound = 0  # idx, not pos
        self._high_drag_bound = model_part.getProperty(
            'max_vhelix_length')  # idx, not pos
        self._moving_via_handle = False

        self.outline = PathWorkplaneOutline(self)
        self.resize_handle_group = ResizeHandleGroup(self.rect(),
                                                     self._HANDLE_SIZE,
                                                     styles.BLUE_STROKE,
                                                     True,
                                                     HandleEnum.LEFT
                                                     | HandleEnum.RIGHT,
                                                     self,
                                                     translates_in=AxisEnum.X)

        # Minimum size hint (darker internal rect, visible during resizing)
        self.model_bounds_hint = m_b_h = QGraphicsRectItem(self)
        m_b_h.setBrush(getBrushObj(styles.BLUE_FILL, alpha=64))
        m_b_h.setPen(getNoPen())
        m_b_h.hide()

        # Low and high idx labels
        self.resize_handle_group.updateText(HandleEnum.LEFT, self._idx_low)
        self.resize_handle_group.updateText(HandleEnum.RIGHT, self._idx_high)
示例#7
0
    def __init__(self,  model_part: NucleicAcidPartT,
                        part_item: PathNucleicAcidPartItemT):
        """
        Args:
            model_part:
            part_item:
        """
        super(QGraphicsRectItem, self).__init__(BASE_RECT, part_item.proxy())
        self.setAcceptHoverEvents(True)
        self.setBrush(getBrushObj(styles.BLUE_FILL, alpha=12))
        self.setPen(getNoPen())
        self.setZValue(styles.ZWORKPLANE)

        self._model_part = model_part
        self._part_item = part_item

        self._low_drag_bound = 0  # idx, not pos
        self._high_drag_bound = model_part.getProperty('max_vhelix_length')  # idx, not pos
        self._moving_via_handle = False

        self.outline = PathWorkplaneOutline(self)
        self.resize_handle_group = ResizeHandleGroup(self.rect(),
                                                     self._HANDLE_SIZE,
                                                     styles.BLUE_STROKE,
                                                     True,
                                                     HandleEnum.LEFT | HandleEnum.RIGHT,
                                                     self,
                                                     translates_in=AxisEnum.X)

        # Minimum size hint (darker internal rect, visible during resizing)
        self.model_bounds_hint = m_b_h = QGraphicsRectItem(self)
        m_b_h.setBrush(getBrushObj(styles.BLUE_FILL, alpha=64))
        m_b_h.setPen(getNoPen())
        m_b_h.hide()

        # Low and high idx labels
        self.resize_handle_group.updateText(HandleEnum.LEFT, self._idx_low)
        self.resize_handle_group.updateText(HandleEnum.RIGHT, self._idx_high)
示例#8
0
 def addToPart(self, part: NucleicAcidPartT, emit_signals: bool = False):
     self._part = part
     self.setParent(part)
     part._addOligoToSet(self, emit_signals)
示例#9
0
 def addToPart(self, part: NucleicAcidPartT, emit_signals: bool = False):
     self._part = part
     self.setParent(part)
     part._addOligoToSet(self, emit_signals)