Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spras/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self, dataset_params: DatasetSchema):
# Load generic node tables
self.node_table = pd.DataFrame(node_set, columns=[self.NODE_ID])
for node_file in node_data_files:
single_node_table = pd.read_table(os.path.join(data_loc, node_file))
single_node_table = pd.read_table(os.path.join(data_loc, node_file), index_col=False)
# If we have only 1 column, assume this is an indicator variable
if len(single_node_table.columns) == 1:
single_node_table = pd.read_table(
Expand Down
2 changes: 2 additions & 0 deletions test/dataset/fixtures/toy-372/input-interactome.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C D 0.77 U
N O 0.66 U
3 changes: 3 additions & 0 deletions test/dataset/fixtures/toy-372/input-nodes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NODEID prize active dummy sources targets
N
C 5.7 True True
22 changes: 22 additions & 0 deletions test/dataset/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pandas
import pytest
import numpy as np

from spras.config.dataset import DatasetSchema
from spras.dataset import Dataset
Expand Down Expand Up @@ -59,3 +60,24 @@ def test_standard(self):
))

assert len(dataset.get_interactome()) == 2

# 372 is a PR, but for the relevant comment, see
# https://github.com/Reed-CompBio/spras/pull/372/files#r2291953612.
# Note that the input-nodes file has more tabs than the original fixture.
def test_372(self):
dataset = Dataset({
'label': 'toy-372',
'edge_files': ['input-interactome.txt'],
'node_files': ['input-nodes.txt'],
'data_dir': FIXTURES_PATH / 'toy-372',
'other_files': []
})

node_table = dataset.node_table
assert node_table is not None

assert node_table[node_table[Dataset.NODE_ID] == 'C'].iloc[0]['prize'] == 5.7
assert node_table[node_table[Dataset.NODE_ID] == 'C'].iloc[0]['active'] == True

assert np.isnan(node_table[node_table[Dataset.NODE_ID] == 'C'].iloc[0]['sources'])
assert node_table[node_table[Dataset.NODE_ID] == 'C'].iloc[0]['targets'] == True
Loading