Skip to content

Commit 1b4551f

Browse files
authored
Merge pull request #19 from galaxy-genome-annotation/expression_fix
Fix loading of expression data when first column header is not empty
2 parents 27f5edc + 442f6a3 commit 1b4551f

5 files changed

Lines changed: 34 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ $ chakin feature load_fasta \
8787
8888
## History
8989
90+
- 2.3.7
91+
- Fix loading of expression data when first column header is not empty
92+
9093
- 2.3.6
9194
- Fix loading of GO terms from GFF
9295

chado/expression/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,11 @@ def _process_matrix_file(self, file_path, separator):
584584
with open(file_path) as f:
585585
reader = csv.reader(f, delimiter=separator)
586586
# Get headers (biomat list)
587-
# TODO : python2 compat (reader.next())
588-
biomaterial__full_list = next(reader)
587+
biomaterial_full_list = next(reader)
588+
# Remove first col (=transcript ids)
589+
biomaterial_full_list = biomaterial_full_list[1:]
589590
# Cleanup empty strings
590-
biomaterial_list = [x for x in biomaterial__full_list if x]
591+
biomaterial_list = [x for x in biomaterial_full_list if x]
591592
expected_len = len(biomaterial_list)
592593
for line in reader:
593594
# Get feature name

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="chado",
9-
version='2.3.6',
9+
version='2.3.7',
1010
description="Chado library",
1111
author="Anthony Bretaudeau",
1212
author_email="anthony.bretaudeau@inrae.fr",

test-data/expression_title.matrix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
transcript Biomat1 Biomat2 Biomat3 Biomat4 Biomat5 Biomat6 Biomat7 Biomat8
2+
Q02123|VNBP_POPMV 0.01 0.02 0.06 0.08 1.11111 1.21 1.98 1.88855
3+
P16654|VNBP_PVSP 2.68 9.84 2.65 4.2 0 0.2 85.1 1.0
4+
Q00572|VNBP_HELVS 2.01 2.5 1.1 8.65 50.0 0 1.6 9

test/expression_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ def test_add_expression(self):
7676

7777
assert elements.count() == 24
7878

79+
def test_add_expression_title(self):
80+
81+
# Setup testing data
82+
# Expression file
83+
expression_file_path = "./test-data/expression_title.matrix"
84+
85+
org = self._create_fake_org()
86+
an = self._create_fake_an()
87+
88+
# Feature file (fasta)
89+
feature_file_path = "./test-data/proteins.fa"
90+
self.ci.feature.load_fasta(fasta=feature_file_path, analysis_id=an['analysis_id'], organism_id=org['organism_id'], sequence_type='mRNA')
91+
self.ci.expression.add_expression(org['organism_id'], an['analysis_id'], expression_file_path, separator="\t")
92+
93+
biomat_list = self.ci.expression.get_biomaterials()
94+
assert len(biomat_list) == 8, "Unexpected number of biomaterials created"
95+
96+
elements = self.ci.session.query(self.ci.model.element.arraydesign_id, self.ci.model.elementresult.quantification_id, self.ci.model.elementresult.signal) \
97+
.join(self.ci.model.elementresult, self.ci.model.element.element_id == self.ci.model.elementresult.element_id)
98+
99+
assert elements.count() == 24
100+
79101
def setUp(self):
80102

81103
self.ci = ci

0 commit comments

Comments
 (0)