示例#1
0
 def changeInstanceProperty(self, part_instance: ObjectInstance,
                                 view: str,
                                 key: str,
                                 value: Any,
                                 use_undostack: bool = True):
     c = ChangeInstancePropertyCommand(self, part_instance, view, key, value)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#2
0
    def splitStrand(self,
                    strand: StrandT,
                    base_idx: int,
                    update_sequence: bool = True,
                    use_undostack: bool = True) -> bool:
        """Break strand into two strands. Reapply sequence by default.

        Args:
            strand: the :class:`Strand`
            base_idx: the index
            update_sequence (optional): whether to emit signal, default=``True``
            use_undostack (optional): default=``True``

        Returns:
            ``True`` if successful, ``False`` otherwise
                TODO consider return strands instead
        """
        if self.strandCanBeSplit(strand, base_idx):
            if self.isStrandInSet(strand):
                c = SplitCommand(strand, base_idx, update_sequence)
                util.doCmd(self, c, use_undostack=use_undostack)
                return True
            else:
                return False
        else:
            return False
示例#3
0
    def mergeStrands(self,
                     priority_strand: StrandT,
                     other_strand: StrandT,
                     use_undostack: bool = True) -> bool:
        """Merge the priority_strand and other_strand into a single new strand.
        The oligo of priority should be propagated to the other and all of
        its connections.

        Args:
            priority_strand: priority strand
            other_strand: other strand
            use_undostack (optional): default=``True``

        Returns:
            ``True`` if strands were merged, ``False`` otherwise
        """
        low_and_high_strands = self.strandsCanBeMerged(priority_strand,
                                                       other_strand)
        if low_and_high_strands:
            strand_low, strand_high = low_and_high_strands
            if self.isStrandInSet(strand_low):
                c = MergeCommand(strand_low, strand_high, priority_strand)
                util.doCmd(self, c, use_undostack=use_undostack)
                return True
        else:
            return False
示例#4
0
    def splitStrand(self,
                    strand,
                    base_idx,
                    update_sequence=True,
                    use_undostack=True):
        """Break strand into two strands. Reapply sequence by default.

        Args:
            strand (Strand): the :class:`Strand`
            base_idx (int): the index
            update_sequence (:obj:`bool`, optional): whether to emit signal, default=True
            use_undostack (:obj:`bool`, optional): default=True

        Returns:
            bool: True if successful, False otherwise
            TODO consider return strands instead
        """
        if self.strandCanBeSplit(strand, base_idx):
            if self.isStrandInSet(strand):
                c = SplitCommand(strand, base_idx, update_sequence)
                util.doCmd(self, c, use_undostack=use_undostack)
                return True
            else:
                return False
        else:
            return False
示例#5
0
 def removeMods(self, document: DocT, mod_id: str, idx: int, use_undostack: bool = True):
     """Used to add mods during a merge operation."""
     idx_low, idx_high = self.idxs()
     print("attempting to remove")
     if idx_low == idx or idx == idx_high:
         print("removing a modification at {}".format(idx))
         c = RemoveModsCommand(document, self, idx, mod_id)
         util.doCmd(self, c, use_undostack=use_undostack)
示例#6
0
 def removeMods(self, document, mod_id, idx, use_undostack=True):
     """Used to add mods during a merge operation."""
     idx_low, idx_high = self.idxs()
     print("attempting to remove")
     if idx_low == idx or idx == idx_high:
         print("removing a modification at {}".format(idx))
         c = RemoveModsCommand(document, self, idx, mod_id)
         util.doCmd(self, c, use_undostack=use_undostack)
示例#7
0
    def createMod(self,
                  params: dict,
                  mid: str = None,
                  use_undostack: bool = True) -> Tuple[dict, str]:
        """Create a modification

        Args:
            params:
            mid: optional, modification ID string
            use_undostack: optional, default is ``True``

        Returns:
            tuple of :obj:`dict`, :obj:`str` of form::

                (dictionary of modification paramemters, modification ID string)

        Raises:
            KeyError: Duplicate mod ID
        """
        if mid is None:
            mid = uuid4().hex
        elif mid in self._mods:
            raise KeyError("createMod: Duplicate mod id: {}".format(mid))

        name = params.get('name', mid)
        color = params.get('color', '#00FF00')
        seq5p = params.get('seq5p', '')
        seq3p = params.get('seq3p', '')
        seqInt = params.get('seqInt', '')
        note = params.get('note', '')

        cmdparams = {
            'props': {
                'name': name,
                'color': color,
                'note': note,
                'seq5p': seq5p,
                'seq3p': seq3p,
                'seqInt': seqInt,
            },
            'ext_locations':
            set(),  # external mods, mod belongs to idx outside of strand
            'int_locations':
            set()  # internal mods, mod belongs between idx and idx + 1
        }

        item = {
            'name': name,
            'color': color,
            'note': note,
            'seq5p': seq5p,
            'seq3p': seq3p,
            'seqInt': seqInt
        }
        c = AddModCommand(self, cmdparams, mid)
        util.doCmd(self, c, use_undostack=use_undostack)
        return item, mid
示例#8
0
 def changeInstanceProperty(self,
                            part_instance,
                            view,
                            key,
                            value,
                            use_undostack=True):
     c = ChangeInstancePropertyCommand(self, part_instance, view, key,
                                       value)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#9
0
 def changeInstanceProperty(self,
                            part_instance: ObjectInstance,
                            view: str,
                            key: str,
                            value: Any,
                            use_undostack: bool = True):
     c = ChangeInstancePropertyCommand(self, part_instance, view, key,
                                       value)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#10
0
    def destroyMod(self, mid, use_undostack=True):
        """Destroy an existing modification

        Args:
            mid (str): optional, modification ID string
            use_undostack (bool): optional, default is True
        """
        if mid in self._mods:
            c = RemoveModCommand(self, mid)
            util.doCmd(self, c, use_undostack=use_undostack)
示例#11
0
    def destroyMod(self, mid: str, use_undostack: bool = True):
        """Destroy an existing modification

        Args:
            mid: optional, modification ID string
            use_undostack: optional, default is ``True``
        """
        if mid in self._mods:
            c = RemoveModCommand(self, mid)
            util.doCmd(self, c, use_undostack=use_undostack)
示例#12
0
    def modifyMod(self, params, mid, use_undostack=True):
        """Modify an existing modification

        Args:
            params (dict):
            mid (str): optional, modification ID string
            use_undostack (bool): optional, default is True
        """
        if mid in self._mods:
            c = ModifyModCommand(self, params, mid)
            util.doCmd(self, c, use_undostack=use_undostack)
示例#13
0
    def modifyMod(self, params, mid, use_undostack=True):
        """Modify an existing modification

        Args:
            params (dict):
            mid (str): optional, modification ID string
            use_undostack (bool): optional, default is True
        """
        if mid in self._mods:
            c = ModifyModCommand(self, params, mid)
            util.doCmd(self, c, use_undostack=use_undostack)
示例#14
0
    def modifyMod(self, params: dict, mid: str, use_undostack: bool = True):
        """Modify an existing modification

        Args:
            params:
            mid: optional, modification ID string
            use_undostack: optional, default is ``True``
        """
        if mid in self._mods:
            c = ModifyModCommand(self, params, mid)
            util.doCmd(self, c, use_undostack=use_undostack)
示例#15
0
    def modifyMod(self, params: dict, mid: str, use_undostack: bool = True):
        """Modify an existing modification

        Args:
            params:
            mid: optional, modification ID string
            use_undostack: optional, default is ``True``
        """
        if mid in self._mods:
            c = ModifyModCommand(self, params, mid)
            util.doCmd(self, c, use_undostack=use_undostack)
示例#16
0
    def createMod(  self,
                    params: dict,
                    mid: str = None,
                    use_undostack: bool = True) -> Tuple[dict, str]:
        """Create a modification

        Args:
            params:
            mid: optional, modification ID string
            use_undostack: optional, default is ``True``

        Returns:
            tuple of :obj:`dict`, :obj:`str` of form::

                (dictionary of modification paramemters, modification ID string)

        Raises:
            KeyError: Duplicate mod ID
        """
        if mid is None:
            mid = uuid4().hex
        elif mid in self._mods:
            raise KeyError("createMod: Duplicate mod id: {}".format(mid))

        name = params.get('name', mid)
        color = params.get('color', '#00FF00')
        seq5p = params.get('seq5p', '')
        seq3p = params.get('seq3p', '')
        seqInt = params.get('seqInt', '')
        note = params.get('note', '')

        cmdparams = {
            'props': {'name': name,
                      'color': color,
                      'note': note,
                      'seq5p': seq5p,
                      'seq3p': seq3p,
                      'seqInt': seqInt,
                      },
            'ext_locations': set(),  # external mods, mod belongs to idx outside of strand
            'int_locations': set()   # internal mods, mod belongs between idx and idx + 1
        }

        item = {'name': name,
                'color': color,
                'note': note,
                'seq5p': seq5p,
                'seq3p': seq3p,
                'seqInt': seqInt
                }
        c = AddModCommand(self, cmdparams, mid)
        util.doCmd(self, c, use_undostack=use_undostack)
        return item, mid
示例#17
0
    def splitStrand(self, strand, base_idx, update_sequence=True, use_undostack=True):
        """Break strand into two strands. Reapply sequence by default.

        Args:
            strand (Strand): the :class:`Strand`
            base_idx (int): the index
            update_sequence (:obj:`bool`, optional): whether to emit signal, default=True
            use_undostack (:obj:`bool`, optional): default=True

        Returns:
            bool: True if successful, False otherwise
            TODO consider return strands instead
        """
        if self.strandCanBeSplit(strand, base_idx):
            if self.isStrandInSet(strand):
                c = SplitCommand(strand, base_idx, update_sequence)
                util.doCmd(self, c, use_undostack=use_undostack)
                return True
            else:
                return False
        else:
            return False
示例#18
0
    def mergeStrands(self, priority_strand, other_strand, use_undostack=True):
        """Merge the priority_strand and other_strand into a single new strand.
        The oligo of priority should be propagated to the other and all of
        its connections.

        Args:
            priority_strand (Strand): priority strand
            other_strand (Strand): other strand
            use_undostack (:obj:`bool`, optional): default=True

        Returns:
            bool: True if strands were merged, False otherwise
        """
        low_and_high_strands = self.strandsCanBeMerged(priority_strand, other_strand)
        if low_and_high_strands:
            strand_low, strand_high = low_and_high_strands
            if self.isStrandInSet(strand_low):
                c = MergeCommand(strand_low, strand_high, priority_strand)
                util.doCmd(self, c, use_undostack=use_undostack)
                return True
        else:
            return False
示例#19
0
    def splitStrand(self, strand: StrandT, base_idx: int,
                        update_sequence: bool = True,
                        use_undostack: bool = True) -> bool:
        """Break strand into two strands. Reapply sequence by default.

        Args:
            strand: the :class:`Strand`
            base_idx: the index
            update_sequence (optional): whether to emit signal, default=``True``
            use_undostack (optional): default=``True``

        Returns:
            ``True`` if successful, ``False`` otherwise
                TODO consider return strands instead
        """
        if self.strandCanBeSplit(strand, base_idx):
            if self.isStrandInSet(strand):
                c = SplitCommand(strand, base_idx, update_sequence)
                util.doCmd(self, c, use_undostack=use_undostack)
                return True
            else:
                return False
        else:
            return False
示例#20
0
 def _addPart(self, part, use_undostack=True):
     """Add part to the document via AddInstanceCommand.
     """
     c = AddInstanceCommand(self, part)
     util.doCmd(self, c, use_undostack)
示例#21
0
文件: oligo.py 项目: hadim/cadnano2.5
 def remove(self, use_undostack=True):
     c = RemoveOligoCommand(self)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#22
0
文件: oligo.py 项目: hadim/cadnano2.5
 def applyColor(self, color, use_undostack=True):
     if color == self.getColor():
         return  # oligo already has this color
     c = ApplyColorCommand(self, color)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#23
0
文件: oligo.py 项目: hadim/cadnano2.5
 def applySequence(self, sequence, use_undostack=True):
     c = ApplySequenceCommand(self, sequence)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#24
0
文件: part.py 项目: hadim/cadnano2.5
 def changeInstanceProperty(self, part_instance, view, key, value, use_undostack=True):
     c = ChangeInstancePropertyCommand(self, part_instance, view, key, value)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#25
0
 def applySequence(self, sequence, use_undostack=True):
     c = ApplySequenceCommand(self, sequence)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#26
0
 def applyColor(self, color, use_undostack=True):
     if color == self.getColor():
         return  # oligo already has this color
     c = ApplyColorCommand(self, color)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#27
0
 def remove(self, use_undostack=True):
     c = RemoveOligoCommand(self)
     util.doCmd(self, c, use_undostack=use_undostack)
示例#28
0
 def _addPart(self, part: Part, use_undostack: bool = True):
     """Add part to the document via AddInstanceCommand.
     """
     c = AddInstanceCommand(self, part)
     util.doCmd(self, c, use_undostack)