How to use the pyranges.pyranges function in pyranges

To help you get started, we’ve selected a few pyranges examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github biocore-ntnu / pyranges / pyranges / pyranges.py View on Github external
def new_position(self, new_pos, strand=None, **kwargs):

        from pyranges.methods.new_position import _new_position

        kwargs["sparse"] = {"self": False}
        kwargs["new_pos"] = new_pos
        kwargs = fill_kwargs(kwargs)

        if strand is None:
            strand = self.stranded

        dfs = pyrange_apply_single(_new_position, self, strand, kwargs)

        return pr.PyRanges(dfs)
github biocore-ntnu / pyranges / pyranges / pyranges.py View on Github external
def unstrand(self):

        if not self.stranded:
            return self

        gr = pr.concat([self["+"], self["-"]])

        gr = gr.apply(lambda df: df.drop("Strand", axis=1).reset_index(drop=
                                                                       True))

        return pr.PyRanges(gr.dfs)
github biocore-ntnu / pyranges / pyranges / pyranges.py View on Github external
def k_nearest(self, other, k=1, **kwargs):

        from pyranges.methods.k_nearest import _nearest
        from sorted_nearest import get_all_ties, get_different_ties

        kwargs = fill_kwargs(kwargs)
        kwargs["stranded"] = self.stranded and other.stranded

        overlap = kwargs.get("overlap", True)
        ties = kwargs.get("ties", False)

        self = pr.PyRanges({k: v.copy() for k, v in self.dfs.items()})

        try: # if k is an array
            k = k.values
        except:
            pass

        self.__k__ = k
        self.__IX__ = np.arange(len(self))


        # from time import time
        # start = time()
        dfs = pyrange_apply(_nearest, self, other, **kwargs)
        # end = time()
        # print("nearest", end - start)
github biocore-ntnu / pyranges / pyranges / pyranges.py View on Github external
def overlap(self, other, **kwargs):

        kwargs["sparse"] = {"self": False, "other": True}
        kwargs["how"] = "first"
        kwargs = fill_kwargs(kwargs)

        dfs = pyrange_apply(_overlap, self, other, **kwargs)

        # if kwargs.get("return_indexes"):
        #     return dfs
        # else:
        return pr.PyRanges(dfs)