-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import os | ||
import tempfile | ||
import pandas as pd | ||
from unittest import TestCase, skip | ||
|
||
from parameterized import parameterized | ||
|
||
from kg_covid_19.transform_utils.string_ppi import StringTransform | ||
|
||
|
||
class TestString(TestCase): | ||
"""Tests the string ingest""" | ||
def setUp(self) -> None: | ||
self.input_dir = "tests/resources/string/" | ||
self.output_dir = tempfile.gettempdir() | ||
self.string_output_dir = os.path.join(self.output_dir, "STRING") | ||
self.string = StringTransform(self.input_dir, self.output_dir) | ||
|
||
@parameterized.expand([ | ||
['ensembl2ncbi_map', dict, 'ENSG00000121410', 1], | ||
['gene_info_map', dict, '1', | ||
{'ENSEMBL': 'ENSG00000121410', 'symbol': 'A1BG', | ||
'description': 'alpha-1-B glycoprotein'}], | ||
['protein_gene_map', dict, 'ENSP00000263100', 'ENSG00000121410'], | ||
]) | ||
def test_instance_vars(self, variable, type, key, val): | ||
this_var = getattr(self.string, variable) | ||
self.assertTrue(isinstance(this_var, type)) | ||
self.assertTrue(key in this_var) | ||
self.assertTrue(this_var[key], val) | ||
|
||
def test_output_dir(self): | ||
self.assertEqual(self.string.output_dir, self.string_output_dir) | ||
|
||
def test_input_dir(self): | ||
self.assertEqual(self.string.input_base_dir, self.input_dir) | ||
|
||
def test_output_edge_file(self): | ||
self.assertEqual(self.string.output_edge_file, | ||
os.path.join(self.string_output_dir, "edges.tsv")) | ||
|
||
def test_output_node_file(self): | ||
self.assertEqual(self.string.output_node_file, | ||
os.path.join(self.string_output_dir, "nodes.tsv")) | ||
|
||
def test_source_name(self): | ||
self.assertEqual(self.string.source_name, 'STRING') | ||
|
||
def test_run(self): | ||
self.assertTrue(isinstance(self.string.run, object)) | ||
self.string.run() | ||
self.assertTrue(os.path.isdir(self.string_output_dir)) | ||
|
||
def test_nodes_file(self): | ||
self.string.run() | ||
node_file = os.path.join(self.string_output_dir, "nodes.tsv") | ||
self.assertTrue(os.path.isfile(node_file)) | ||
node_df = pd.read_csv(node_file, sep="\t", header=0) | ||
self.assertEqual((11, 6), node_df.shape) | ||
self.assertEqual(['id', 'name', 'category', 'description', 'alias', | ||
'provided_by'], list(node_df.columns)) | ||
self.assertCountEqual(['UniprotKB:P84085', 'ENSEMBL:ENSP00000000233', | ||
'ENSEMBL:ENSP00000272298', 'ENSEMBL:ENSP00000253401', | ||
'ENSEMBL:ENSP00000401445', 'ENSEMBL:ENSP00000418915', | ||
'ENSEMBL:ENSP00000327801', 'ENSEMBL:ENSP00000466298', | ||
'ENSEMBL:ENSP00000232564', 'ENSEMBL:ENSP00000393379', | ||
'ENSEMBL:ENSP00000371253'], | ||
list(node_df.id.unique())) | ||
|
||
def test_edges_file(self): | ||
self.string.run() | ||
edge_file = os.path.join(self.string_output_dir, "edges.tsv") | ||
self.assertTrue(os.path.isfile(edge_file)) | ||
edge_df = pd.read_csv(edge_file, sep="\t", header=0) | ||
self.assertEqual((10, 19), edge_df.shape) | ||
self.assertEqual(['subject', 'edge_label', 'object', 'relation', 'provided_by', | ||
'combined_score', 'neighborhood', 'neighborhood_transferred', | ||
'fusion', 'cooccurence', 'homology', 'coexpression', | ||
'coexpression_transferred', 'experiments', | ||
'experiments_transferred', 'database', 'database_transferred', | ||
'textmining', 'textmining_transferred', ], | ||
list(edge_df.columns)) |