|
a |
|
b/tests/test_annotations.py |
|
|
1 |
from openomics.database.annotation import GTEx |
|
|
2 |
from openomics.database.ontology import GeneOntology |
|
|
3 |
from openomics.database.sequence import RNAcentral |
|
|
4 |
|
|
|
5 |
from .test_multiomics import * |
|
|
6 |
@pytest.fixture |
|
|
7 |
def generate_RNACentral_ftp(): |
|
|
8 |
rnacentral = RNAcentral(path="https://ftp.ebi.ac.uk/pub/databases/RNAcentral/current_release/") |
|
|
9 |
rnacentral.data = rnacentral.data.sample(frac=0.01) |
|
|
10 |
return rnacentral |
|
|
11 |
|
|
|
12 |
@pytest.fixture |
|
|
13 |
def generate_GTEx_expressions(): |
|
|
14 |
return GTEx(path="https://storage.googleapis.com/gtex_analysis_v8/rna_seq_data/", ) |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
@pytest.fixture |
|
|
18 |
def generate_GeneOntology(): |
|
|
19 |
go = GeneOntology(path="http://geneontology.org/gene-associations/", species='human') |
|
|
20 |
go.data = go.data.sample(frac=0.01) |
|
|
21 |
return go |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
def test_import_rnacentral_db(generate_RNACentral_ftp): |
|
|
25 |
assert generate_RNACentral_ftp.data_path == 'https://ftp.ebi.ac.uk/pub/databases/RNAcentral/current_release/' |
|
|
26 |
|
|
|
27 |
|
|
|
28 |
def test_import_GTEx(generate_GTEx_expressions): |
|
|
29 |
assert generate_GTEx_expressions.data_path == "https://storage.googleapis.com/gtex_analysis_v8/rna_seq_data/" |
|
|
30 |
assert not generate_GTEx_expressions.get_expressions(index="gene_name").empty |
|
|
31 |
assert not generate_GTEx_expressions.get_expressions(index="gene_id").empty |
|
|
32 |
|
|
|
33 |
|
|
|
34 |
def test_import_GeneOntology(generate_GeneOntology): |
|
|
35 |
assert generate_GeneOntology.data_path == "http://geneontology.org/gene-associations/" |
|
|
36 |
|
|
|
37 |
|
|
|
38 |
def test_annotate_rnacentral(generate_TCGA_LUAD, generate_RNACentral_ftp): |
|
|
39 |
generate_TCGA_LUAD.MicroRNA.annotate_attributes(database=generate_RNACentral_ftp, |
|
|
40 |
on="gene_name", |
|
|
41 |
columns=['gene_name', 'RNA type']) |
|
|
42 |
assert {'RNA type'}.issubset(generate_TCGA_LUAD.MicroRNA.annotations.columns) |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
def test_annotate_expressions_GTEx(generate_TCGA_LUAD, generate_GTEx_expressions): |
|
|
46 |
generate_TCGA_LUAD.LncRNA.annotate_expressions(database=generate_GTEx_expressions, index="gene_id") |
|
|
47 |
assert not generate_TCGA_LUAD.LncRNA.get_annotation_expressions().empty |
|
|
48 |
|
|
|
49 |
|
|
|
50 |
def test_annotate_GeneOntology(generate_TCGA_LUAD, generate_GeneOntology): |
|
|
51 |
generate_TCGA_LUAD.MessengerRNA.annotate_attributes(database=generate_GeneOntology, on="gene_name", |
|
|
52 |
columns=['go_id']) |
|
|
53 |
assert {'go_id'}.issubset(generate_TCGA_LUAD.MessengerRNA.annotations.columns) |
|
|
54 |
assert not generate_TCGA_LUAD.MessengerRNA.annotations["go_id"].empty |