當前位置: 首頁>>代碼示例>>Python>>正文


Python Strand.resize方法代碼示例

本文整理匯總了Python中cadnano.strand.Strand.resize方法的典型用法代碼示例。如果您正苦於以下問題:Python Strand.resize方法的具體用法?Python Strand.resize怎麽用?Python Strand.resize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cadnano.strand.Strand的用法示例。


在下文中一共展示了Strand.resize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: resizeSelection

# 需要導入模塊: from cadnano.strand import Strand [as 別名]
# 或者: from cadnano.strand.Strand import resize [as 別名]
    def resizeSelection(self, delta, use_undostack=True):
        """
        Moves the selected idxs by delta by first iterating over all strands
        to calculate new idxs (method will return if snap-to behavior would
        create illegal state), then applying a resize command to each strand.
        """
        resize_list = []

        # calculate new idxs
        for strandset_dict in self._selection_dict.values():
            for strand, selected in strandset_dict.items():
                part = strand.virtualHelix().part()
                idxL, idxH = strand.idxs()
                newL, newH = strand.idxs()
                deltaL = deltaH = delta

                # process xovers to get revised delta
                if selected[0] and strand.connectionLow():
                    newL = part.xoverSnapTo(strand, idxL, delta)
                    if newL == None:
                        return
                    deltaH = newL-idxL
                if selected[1] and strand.connectionHigh():
                    newH = part.xoverSnapTo(strand, idxH, delta)
                    if newH == None:
                        return
                    deltaL = newH-idxH

                # process endpoints
                if selected[0] and not strand.connectionLow():
                    newL = idxL + deltaL
                if selected[1] and not strand.connectionHigh():
                    newH = idxH + deltaH

                if newL > newH:  # check for illegal state
                    return

                resize_list.append((strand, newL, newH))
            # end for
        # end for

        # execute the resize commands
        if use_undostack:
            self.undoStack().beginMacro("Resize Selection")

        for strand, idxL, idxH in resize_list:
            Strand.resize(strand, (idxL, idxH), use_undostack)

        if use_undostack:
            self.undoStack().endMacro()
開發者ID:Rebelofold,項目名稱:cadnano2.5,代碼行數:52,代碼來源:document.py

示例2: resizeSelection

# 需要導入模塊: from cadnano.strand import Strand [as 別名]
# 或者: from cadnano.strand.Strand import resize [as 別名]
    def resizeSelection(self, delta, use_undostack=True):
        """ Moves the selected idxs by delta by first iterating over all strands
        to calculate new idxs (method will return if snap-to behavior would
        create illegal state), then applying a resize command to each strand.

        Args:
            delta (float):
            use_undostack (bool): optional, default is True
        """
        resize_list = []
        vh_set = set()
        # calculate new idxs
        part = None
        for strandset_dict in self._selection_dict.values():
            for strand, selected in strandset_dict.items():
                if part is None:
                    part = strand.part()
                idx_low, idx_high = strand.idxs()
                new_low, new_high = strand.idxs()
                delta_low = delta_high = delta

                # process xovers to get revised delta
                if selected[0] and strand.connectionLow():
                    new_low = part.xoverSnapTo(strand, idx_low, delta)
                    if new_low is None:
                        return
                    delta_high = new_low - idx_low
                if selected[1] and strand.connectionHigh():
                    new_high = part.xoverSnapTo(strand, idx_high, delta)
                    if new_high is None:
                        return
                    delta_low = new_high - idx_high

                # process endpoints
                if selected[0] and not strand.connectionLow():
                    new_low = idx_low + delta_low
                if selected[1] and not strand.connectionHigh():
                    new_high = idx_high + delta_high

                if new_low > new_high:  # check for illegal state
                    return

                vh_set.add(strand.idNum())
                resize_list.append((strand, new_low, new_high))
            # end for
        # end for

        # execute the resize commands
        us = self.undoStack()
        if use_undostack:
            us.beginMacro("Resize Selection")

        for strand, idx_low, idx_high in resize_list:
            Strand.resize(strand,
                          (idx_low, idx_high),
                          use_undostack,
                          update_segments=False)
        if resize_list:
            cmd = RefreshSegmentsCommand(part, vh_set)
            if use_undostack:
                us.push(cmd)
            else:
                cmd.redo()

        if use_undostack:
            us.endMacro()
開發者ID:hadim,項目名稱:cadnano2.5,代碼行數:68,代碼來源:document.py


注:本文中的cadnano.strand.Strand.resize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。