예제 #1
0
파일: part.py 프로젝트: cadnano/cadnano2.5
 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)