Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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:
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.