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)
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
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
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
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)
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)
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
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)
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)
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)
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)
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)
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
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
def _addPart(self, part, use_undostack=True): """Add part to the document via AddInstanceCommand. """ c = AddInstanceCommand(self, part) util.doCmd(self, c, use_undostack)
def remove(self, use_undostack=True): c = RemoveOligoCommand(self) util.doCmd(self, c, use_undostack=use_undostack)
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)
def applySequence(self, sequence, use_undostack=True): c = ApplySequenceCommand(self, sequence) util.doCmd(self, c, use_undostack=use_undostack)
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)