コード例 #1
0
ファイル: oligo.py プロジェクト: ggirelli/ifpd2
 def focus_window(self, focus_window):
     ass.ert_type(focus_window, tuple, "focus window")
     if len(focus_window) != 2:
         raise AssertionError
     if focus_window[1] <= focus_window[0]:
         raise AssertionError
     self._focus_window = focus_window
コード例 #2
0
 def convert_paths_to_probes(path_list, oData):
     # Converts a list of paths into a list of probes
     ass.ert_type(path_list, list, "path list")
     probe_list = []
     if len(path_list) != 0:
         for path in path_list:
             probe_list.append(OligoProbeBuilder.path2probe(path, oData))
     return probe_list
コード例 #3
0
ファイル: oligo.py プロジェクト: ggirelli/ifpd2
 def __init__(self, oligo, i):
     super(Oligo, self).__init__()
     ass.ert_type(i, int, "oligo id")
     if i < 0:
         raise AssertionError
     self._raw_data = oligo.strip().split("\t")
     for i in [2, 3, 9, 10]:
         self._raw_data[i] = int(self._raw_data[i])
     for i in [4, 5, 6, 7, 11, 12]:
         self._raw_data[i] = float(self._raw_data[i])
     self._idx = i
コード例 #4
0
    def get_non_overlapping_paths(oData, D):
        # Gets all paths of consecutive non-overlapping oligos with minimum
        # distance equal to D
        ass.ert_type(oData, pd.DataFrame, "oData")

        start_positions = oData["start"].values
        end_positions = oData["end"].values

        edges = [
            np.logical_or(
                end_positions + D < oData["start"].values[i],
                start_positions - D >= oData["end"].values[i],
            ) for i in range(oData.shape[0])
        ]
        return OligoPathBuilder.get_paths(np.vstack(edges).astype("i"))
コード例 #5
0
    def filter_paths(self, path_set, oData):
        # Selects oligo paths based on length, melting temperature, size, and
        # presence of gaps.
        ass.ert_type(oData, pd.DataFrame, "oData")

        exit_polls = {"P": 0, "N": 0, "S": 0, "H": 0, "T": 0}

        selected_paths = set()
        for path in list(self.__size_paths(path_set, exit_polls)):
            if path in selected_paths:
                continue
            passed, comment = self.__path_passes(path, oData)
            exit_polls[comment] = exit_polls[comment] + 1
            if not passed:
                continue
            selected_paths.add(path)

        comment = "".join(f"{r}{c}" for (c, r) in exit_polls.items())
        return (list(selected_paths), comment)
コード例 #6
0
ファイル: walker.py プロジェクト: ggirelli/ifpd2
    def _assert(self):
        ass.ert_type(self.C, str, "C")
        ass.ert_type(self.S, int, "S")
        ass.ert_nonNeg(self.S, "S", True)
        ass.ert_type(self.E, int, "E")
        ass.ert_nonNeg(self.E, "E", True)
        if self.S > self.E:
            raise AssertionError

        ass.ert_multiTypes(self.X, [int, type(None)], "X")
        ass.ert_multiTypes(self.Ws, [int, type(None)], "Ws")
        if isinstance(self.X, int):
            ass.ert_type(self.Ws, type(None), "Ws")
            ass.ert_nonNeg(self.X, "X")
        else:
            ass.ert_type(self.Ws, int, "Ws")

        ass.ert_multiTypes(self.Ws, [int, type(None)], "Ws")
        if isinstance(self.Ws, int):
            ass.ert_type(self.X, type(None), "X")
            ass.ert_nonNeg(self.Ws, "Ws")
        else:
            ass.ert_type(self.X, int, "X")

        ass.ert_type(self.Wh, float, "Wh")
        ass.ert_inInterv(self.Wh, 0, 1, "Wh")

        ass.ert_multiTypes(self.Rs, [int, float], "Rs")
        if self.Rs > 1:
            self.Rs = int(self.Rs)
        else:
            ass.ert_inInterv(self.Rs, 0, 1, "Rs")

        ass.ert_multiTypes(self.Rt, [int, float], "Rt")
        if self.Rt > 1:
            self.Rt = int(self.Rt)
        else:
            ass.ert_inInterv(self.Rt, 0, 1, "Rt")
コード例 #7
0
ファイル: walker.py プロジェクト: ggirelli/ifpd2
 def threads(self, threads):
     ass.ert_type(threads, int, threads)
     threads = max(1, min(threads, mp.cpu_count()))
     self._threads = threads
コード例 #8
0
    def _assert(self):
        OligoPathBuilder._assert(self)

        if not isinstance(self.k, type(None)):
            ass.ert_type(self.k, int, "k")
            ass.ert_nonNeg(self.k, "k")
            if (self.k + self.D) * self.N > self.Ps:
                raise AssertionError

        if isinstance(self.F, tuple):
            self.F = list(self.F)
        ass.ert_type(self.F, list, "F")
        if len(self.F) != 2:
            raise AssertionError
        for i in range(2):
            ass.ert_type(self.F[i], int, f"F[{i}]")
            if self.F[i] < 0:
                raise AssertionError
        if self.F[1] < self.F[0]:
            raise AssertionError

        if isinstance(self.Gs, tuple):
            self.Gs = list(self.Gs)
        ass.ert_type(self.Gs, list, "Gs")
        if len(self.Gs) != 2:
            raise AssertionError
        for i in range(2):
            ass.ert_type(self.Gs[i], float, f"Gs[{i}]")
            if self.Gs[i] > 1:
                raise AssertionError
        if not all(np.array(self.Gs) < 0) and not all(np.array(self.Gs) >= 0):
            raise AssertionError
        if self.Gs[0] >= 0:
            if self.Gs[1] < self.Gs[0]:
                raise AssertionError
        elif self.Gs[1] > self.Gs[0]:
            raise AssertionError

        ass.ert_type(self.Ot, float, "Ot")
        if self.Ot <= 0 or self.Ot > 1:
            raise AssertionError
コード例 #9
0
    def _assert(self):
        ass.ert_type(self.N, int, "N")
        ass.ert_nonNeg(self.N, "N")

        ass.ert_type(self.D, int, "D")
        ass.ert_nonNeg(self.D, "D")

        ass.ert_type(self.Tr, float, "Tr")
        ass.ert_nonNeg(self.Tr, "Tr")

        ass.ert_type(self.Ps, int, "Ps")
        if self.Ps <= 1:
            raise AssertionError

        ass.ert_type(self.Ph, float, "Ph")
        ass.ert_inInterv(self.Ph, 0, 1, "Ph")

        ass.ert_type(self.Po, float, "Po")
        ass.ert_inInterv(self.Po, 0, 1, "Po")