How to use the pyranges.data 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 / tests / hypothesis_helper.py View on Github external
def genomicfeature(draw):

    dataset_name = draw(feature_data)
    print("dataset name " * 5, dataset_name)
    dataset = getattr(pr.data, dataset_name)()
    dataset = dataset[dataset.Feature.isin(["gene", "transcript", "exon"])]

    # subsetter = draw(arrays(np.bool, shape=len(dataset)))
    gene_ids = list(dataset.gene_id.drop_duplicates())
    genes = draw(
        st.lists(st.sampled_from(gene_ids), unique="True", min_size=1))
    dataset = dataset[dataset.gene_id.isin(genes)]

    return dataset
github biocore-ntnu / pyranges / tests / hypothesis_helper.py View on Github external
def genomicfeature(draw):

    dataset_name = draw(feature_data)
    print("dataset name " * 5, dataset_name)
    dataset = getattr(pr.data, dataset_name)()
    dataset = dataset[dataset.Feature.isin(["gene", "transcript", "exon"])]

    # subsetter = draw(arrays(np.bool, shape=len(dataset)))
    gene_ids = list(dataset.gene_id.drop_duplicates())
    genes = draw(
        st.lists(st.sampled_from(gene_ids), unique="True", min_size=1))
    dataset = dataset[dataset.gene_id.isin(genes)]

    return dataset
github biocore-ntnu / pyranges / tests / test_genomicfeatures.py View on Github external
def test_introns_single():

    "Assert that our fast method of computing introns is the same as the slow, correct one in compute_introns_single"

    gr = pr.data.gencode_gtf()[["gene_id", "Feature"]]
    exons = gr[gr.Feature == "exon"].merge(by="gene_id")
    exons.Feature = "exon"
    exons = exons.df
    df = pd.concat([gr[gr.Feature == "gene"].df, exons], sort=False)
    print(df)

    for gid, gdf in df.groupby("gene_id"):
        print("-------" * 20)
        print(gid)
        print(gdf)
        print("gdf", len(gdf))
        expected = compute_introns_single(gdf, by="gene")
        print("expected", len(expected))
        actual = pr.PyRanges(gdf).features.introns().df
        print("actual", len(actual))
        if actual.empty:
github biocore-ntnu / pyranges / pyranges / __init__.py View on Github external
import pyranges as pr

import pkg_resources

from pyranges.pyranges import PyRanges
from pyranges import data
from pyranges.methods.concat import concat

from pyrle import PyRles, Rle

from pyranges.version import __version__

from natsort import natsorted

get_example_path = data.get_example_path



from pyranges.multioverlap import count_overlaps

def from_dict(d, int64=False):

    """Create a PyRanges from dict.

    Parameters
    ----------
    d : dict of array-like

        Dict with data.

    int64 : bool, default False.