Skip to content

Commit

Permalink
adding a test to check if comments on assay declaration are properly …
Browse files Browse the repository at this point in the history
…serialized in isatab2json conversion
  • Loading branch information
proccaserra committed Nov 15, 2023
1 parent 034291f commit 818332d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/convert/test_isatab2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
from isatools.tests import utils
from isatools import isajson
from isatools import isatab
import tempfile
import shutil

Expand Down Expand Up @@ -113,3 +114,28 @@ def test_isatab2json_convert_repeated_measure(self):
with open(os.path.join(self._tmp_dir, 'isa.json')) as actual_json:
report = isajson.validate(actual_json)
self.assertEqual(len(report['errors']), 0)

def test_isatab2json_convert_comment(self):
with open(os.path.join(self._tab_data_dir, 'issue200', 'i_Investigation.txt')) as fp:
ISA = isatab.load(fp)
self.assertEqual(ISA.studies[0].assays[0].comments[0].value, "ena")
self.assertEqual(ISA.ontology_source_references[0].comments[0].name, "onto_comment")
self.assertEqual(ISA.ontology_source_references[0].comments[0].value, "onto_stuff")
self.assertEqual(ISA.studies[0].protocols[0].comments[0].value, "another protocol related comment")
self.assertEqual(ISA.studies[0].protocols[2].comments[0].value, "protocol related comment")
self.assertEqual(ISA.studies[0].protocols[3].comments[0].value, "")
self.assertEqual(ISA.studies[0].contacts[0].comments[0].name, "person comment")
self.assertEqual(ISA.studies[0].factors[0].comments[0].value, "stf_cmt")

test_case = "issue200"
actual_json = isatab2json.convert(
os.path.join(self._tab_data_dir, test_case), validate_first=False,
use_new_parser=True)
with open(os.path.join(self._tmp_dir, 'isa.json'), 'w') as out_fp:
json.dump(actual_json, out_fp)

with open(os.path.join(self._tmp_dir, 'isa.json')) as isa_json:
isajson_read = json.load(isa_json)
self.assertEqual(isajson_read["studies"][0]["filename"], "s_Study id.txt")
self.assertEqual(isajson_read["studies"][0]["assays"][0]["comments"][0]["value"], "ena")

0 comments on commit 818332d

Please sign in to comment.