def test_import_bii_s_7(self):
     test_case = 'BII-S-7'
     json_expected = json.load(
         open(
             os.path.join(utils.JSON_DATA_DIR, test_case,
                          test_case + '.json')))
     from isatools.sampledata import bii_s_7
     utils.assert_json_equal(json_expected, bii_s_7.json)
Пример #2
0
 def test_isatab2json_convert_charac_param_factor(self):
     test_case = 'TEST-ISA-charac-param-factor'
     actual_json = isatab2json.convert(
         os.path.join(self._tab_data_dir, test_case), self.identifier_type)
     expected_json = json.load(
         open(os.path.join(self._json_data_dir, test_case + '.json')))
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #3
0
 def test_isatab2json_convert_sample_pool(self):
     test_case = 'TEST-ISA-sample-pool'
     actual_json = isatab2json.convert(
         os.path.join(self._tab_data_dir, test_case), self.identifier_type)
     expected_json = json.load(
         open(os.path.join(self._json_data_dir, test_case + '.json')))
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #4
0
 def test_isatab2json_convert_source_split_with_error(self):
     test_case = 'TEST-ISA-source-split-with-error'
     actual_json = isatab2json.convert(
         os.path.join(self._tab_data_dir, test_case), self.identifier_type)
     expected_json = json.load(
         open(os.path.join(self._json_data_dir, test_case + '.json')))
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #5
0
 def test_json2isatab_isatab2json_2way_convert_sample_pool(self):
     test_case = 'TEST-ISA-sample-pool'
     test_json = open(os.path.join(self._json_data_dir, test_case + '.json'))
     json2isatab.convert(test_json, self._tmp_dir, validate_first=False)
     test_json.seek(0)  # reset pointer
     expected_json = json.load(test_json)
     actual_json = isatab2json.convert(self._tmp_dir, validate_first=False)
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
 def test_json2isatab_isatab2json_2way_convert_sample_pool(self):
     test_case = 'TEST-ISA-sample-pool'
     test_json = open(os.path.join(self._json_data_dir, test_case + '.json'))
     json2isatab.convert(test_json, self._tmp_dir)
     test_json.seek(0)  # reset pointer
     expected_json = json.load(test_json)
     actual_json = isatab2json.convert(self._tmp_dir)
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
 def test_isatab2cedar_convert_mtbls3(self):
     test_case = 'MTBLS3'
     isa2cedar = ISATab2CEDAR("http://www.isa-tools.org/")
     isa2cedar.createCEDARjson(os.path.join(self._tab_data_dir, test_case), self._tmp_dir, True)
     expected_json = json.load(open(os.path.join(self._json_data_dir, 'cedar', test_case + '.json')))
     actual_json = json.load(open(os.path.join(self._tmp_dir, test_case + '.json')))
     utils.strip_ids(expected_json)
     utils.strip_ids(actual_json)
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #8
0
 def test_isatab2json_convert_mtbls1(self):
     test_case = 'MTBLS1'
     actual_json = isatab2json.convert(
         os.path.join(self._tab_data_dir, test_case), self.identifier_type)
     expected_json = json.load(
         open(
             os.path.join(self._json_data_dir, test_case,
                          test_case + '.json')))
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #9
0
 def test_isatab2json_convert_sample_pool(self):
     test_case = 'TEST-ISA-sample-pool'
     actual_json = isatab2json.convert(os.path.join(self._tab_data_dir,
                                                    test_case),
                                       validate_first=False)
     with open(os.path.join(self._json_data_dir,
                            test_case + '.json')) as expected_file:
         expected_json = json.load(expected_file)
         self.assertTrue(utils.assert_json_equal(expected_json,
                                                 actual_json))
Пример #10
0
 def test_isatab2json_convert_charac_param_factor(self):
     test_case = 'TEST-ISA-charac-param-factor'
     actual_json = isatab2json.convert(os.path.join(self._tab_data_dir,
                                                    test_case),
                                       validate_first=False)
     with open(os.path.join(self._json_data_dir,
                            test_case + '.json')) as expected_file:
         expected_json = json.load(expected_file)
         self.assertTrue(utils.assert_json_equal(expected_json,
                                                 actual_json))
Пример #11
0
 def test_isatab2json_convert_source_split_with_error(self):
     test_case = 'TEST-ISA-source-split-with-error'
     actual_json = isatab2json.convert(os.path.join(self._tab_data_dir,
                                                    test_case),
                                       validate_first=False)
     with open(os.path.join(self._json_data_dir,
                            test_case + '.json')) as expected_file:
         expected_json = json.load(expected_file)
         self.assertTrue(utils.assert_json_equal(expected_json,
                                                 actual_json))
Пример #12
0
 def test_isatab2json_convert_bii_s_7(self):
     test_case = 'BII-S-7'
     actual_json = isatab2json.convert(os.path.join(self._tab_data_dir,
                                                    test_case),
                                       validate_first=False)
     with open(
             os.path.join(self._json_data_dir, test_case,
                          test_case + '.json')) as expected_file:
         expected_json = json.load(expected_file)
         self.assertTrue(utils.assert_json_equal(expected_json,
                                                 actual_json))
Пример #13
0
 def test_isatab2cedar_convert_mtbls1(self):
     test_case = 'MTBLS1'
     isa2cedar = ISATab2CEDAR("http://www.isa-tools.org/")
     isa2cedar.createCEDARjson(os.path.join(self._tab_data_dir, test_case),
                               self._tmp_dir, True)
     with open(os.path.join(self._json_data_dir, 'cedar', test_case + '.json')) as expected_file, \
             open(os.path.join(self._tmp_dir, '1425901783014' + '.json')) as actual_file:
         expected_json = json.load(expected_file)
         actual_json = json.load(actual_file)
         utils.strip_ids(expected_json)
         utils.strip_ids(actual_json)
         self.assertTrue(utils.assert_json_equal(expected_json,
                                                 actual_json))
Пример #14
0
 def test_isatab2cedar_convert_charac_param_factor(self):
     test_case = 'TEST-ISA-charac-param-factor'
     isa2cedar = ISATab2CEDAR("http://www.isa-tools.org/")
     isa2cedar.createCEDARjson(os.path.join(self._tab_data_dir, test_case),
                               self._tmp_dir, True)
     with open(os.path.join(self._json_data_dir, 'cedar', test_case + '.json')) as expected_file, \
             open(os.path.join(self._tmp_dir, test_case + '.json')) as actual_file:
         expected_json = json.load(expected_file)
         actual_json = json.load(actual_file)
         utils.strip_ids(expected_json)
         utils.strip_ids(actual_json)
         self.assertTrue(utils.assert_json_equal(expected_json,
                                                 actual_json))
    def test_json2isatab_isatab2json_2way_convert_source_split(self):
        test_case = 'TEST-ISA-source-split'
        test_json = open(os.path.join(self._json_data_dir, test_case + '.json'))
        json2isatab.convert(test_json, self._tmp_dir)
        test_json.seek(0)  # reset pointer
        expected_json = json.load(test_json)
        actual_json = isatab2json.convert(self._tmp_dir)
        self.assertTrue(utils.assert_json_equal(expected_json, actual_json))

    # def test_json2isatab_isatab2json_2way_convert_bii_i_1(self):
    #     #  FIXME: Get error in isatab2json.createUnitsCategories
    #     #  json_item.update(self.createOntologyAnnotation(value_attributes.Unit, value_attributes.Term_Source_REF, value_attributes.Term_Accession_Number))
    #     #  AttributeError: 'Attrs' object has no attribute 'Term_Source_REF'
    #     #  Are Units always OntologyAnnotations? (i.e. Unit column alway accompanied by Term Accession and
    #     #  Term Source REF?
    #     test_case = 'BII-I-1'
    #     test_json = open(os.path.join(self._json_data_dir, test_case, test_case + '.json'))
    #     json2isatab.convert(test_json, self._tmp_dir)
    #     test_json.seek(0)  # reset pointer
    #     expected_json = json.load(test_json)
    #     actual_json = isatab2json.convert(self._tmp_dir)
    #     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
    #
    # def test_json2isatab_isatab2json_2way_convert_bii_s_3(self):
    #     #  FIXME: Get error in isatab2json.createUnitsCategories
    #     #  json_item.update(self.createOntologyAnnotation(value_attributes.Unit, value_attributes.Term_Source_REF, value_attributes.Term_Accession_Number))
    #     #  AttributeError: 'Attrs' object has no attribute 'Term_Source_REF'
    #     #  Are Units always OntologyAnnotations? (i.e. Unit column alway accompanied by Term Accession and
    #     #  Term Source REF? If so, related to below bii_s_7 error
    #     test_case = 'BII-S-3'
    #     test_json = open(os.path.join(self._json_data_dir, test_case, test_case + '.json'))
    #     json2isatab.convert(test_json, self._tmp_dir)
    #     test_json.seek(0)  # reset pointer
    #     expected_json = json.load(test_json)
    #     actual_json = isatab2json.convert(self._tmp_dir)
    #     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
    #
    # def test_json2isatab_isatab2json_2way_convert_bii_s_7(self):
    #     #  FIXME: It reports a big diff because when doing json2isatab, if Term Accession and Term Source REF columns
    #     #  are empty it strips them out. When going back from isatab2json, it converts as string and not
    #     #  OntologyAnnotation since there is no extra info to be able to cast back to original
    #     test_case = 'BII-S-7'
    #     test_json = open(os.path.join(self._json_data_dir, test_case, test_case + '.json'))
    #     json2isatab.convert(test_json, self._tmp_dir)
    #     test_json.seek(0)  # reset pointer
    #     expected_json = json.load(test_json)
    #     actual_json = isatab2json.convert(self._tmp_dir)
    #     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #16
0
    def test_json2isatab_isatab2json_2way_convert_source_split(self):
        test_case = 'TEST-ISA-source-split'
        test_json = open(os.path.join(self._json_data_dir, test_case + '.json'))
        json2isatab.convert(test_json, self._tmp_dir, validate_first=False)
        test_json.seek(0)  # reset pointer
        expected_json = json.load(test_json)
        actual_json = isatab2json.convert(self._tmp_dir, validate_first=False)
        self.assertTrue(utils.assert_json_equal(expected_json, actual_json))

    # def test_json2isatab_isatab2json_2way_convert_bii_i_1(self):
    #     #  FIXME: Get error in isatab2json.createUnitsCategories
    #     #  json_item.update(self.createOntologyAnnotation(value_attributes.Unit, value_attributes.Term_Source_REF, value_attributes.Term_Accession_Number))
    #     #  AttributeError: 'Attrs' object has no attribute 'Term_Source_REF'
    #     #  Are Units always OntologyAnnotations? (i.e. Unit column alway accompanied by Term Accession and
    #     #  Term Source REF?
    #     test_case = 'BII-I-1'
    #     test_json = open(os.path.join(self._json_data_dir, test_case, test_case + '.json'))
    #     json2isatab.convert(test_json, self._tmp_dir)
    #     test_json.seek(0)  # reset pointer
    #     expected_json = json.load(test_json)
    #     actual_json = isatab2json.convert(self._tmp_dir)
    #     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
    #
    # def test_json2isatab_isatab2json_2way_convert_bii_s_3(self):
    #     #  FIXME: Get error in isatab2json.createUnitsCategories
    #     #  json_item.update(self.createOntologyAnnotation(value_attributes.Unit, value_attributes.Term_Source_REF, value_attributes.Term_Accession_Number))
    #     #  AttributeError: 'Attrs' object has no attribute 'Term_Source_REF'
    #     #  Are Units always OntologyAnnotations? (i.e. Unit column alway accompanied by Term Accession and
    #     #  Term Source REF? If so, related to below bii_s_7 error
    #     test_case = 'BII-S-3'
    #     test_json = open(os.path.join(self._json_data_dir, test_case, test_case + '.json'))
    #     json2isatab.convert(test_json, self._tmp_dir)
    #     test_json.seek(0)  # reset pointer
    #     expected_json = json.load(test_json)
    #     actual_json = isatab2json.convert(self._tmp_dir)
    #     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
    #
    # def test_json2isatab_isatab2json_2way_convert_bii_s_7(self):
    #     #  FIXME: It reports a big diff because when doing json2isatab, if Term Accession and Term Source REF columns
    #     #  are empty it strips them out. When going back from isatab2json, it converts as string and not
    #     #  OntologyAnnotation since there is no extra info to be able to cast back to original
    #     test_case = 'BII-S-7'
    #     test_json = open(os.path.join(self._json_data_dir, test_case, test_case + '.json'))
    #     json2isatab.convert(test_json, self._tmp_dir)
    #     test_json.seek(0)  # reset pointer
    #     expected_json = json.load(test_json)
    #     actual_json = isatab2json.convert(self._tmp_dir)
    #     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #17
0
    def test_import_bii_s_7(self):
        test_case = "BII-S-7"
        json_expected = json.load(open(os.path.join(utils.JSON_DATA_DIR, test_case, test_case + ".json")))
        from isatools.sampledata import bii_s_7

        utils.assert_json_equal(json_expected, bii_s_7.json)
Пример #18
0
 def test_isatab2json_convert_mtbls1(self):
     test_case = "MTBLS1"
     actual_json = isatab2json.convert(os.path.join(self._tab_data_dir, test_case), self.identifier_type)
     expected_json = json.load(open(os.path.join(self._json_data_dir, test_case, test_case + ".json")))
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #19
0
 def test_isatab2json_convert_source_split_with_error(self):
     test_case = "TEST-ISA-source-split-with-error"
     actual_json = isatab2json.convert(os.path.join(self._tab_data_dir, test_case), self.identifier_type)
     expected_json = json.load(open(os.path.join(self._json_data_dir, test_case + ".json")))
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #20
0
 def test_isatab2json_convert_sample_pool(self):
     test_case = "TEST-ISA-sample-pool"
     actual_json = isatab2json.convert(os.path.join(self._tab_data_dir, test_case), self.identifier_type)
     expected_json = json.load(open(os.path.join(self._json_data_dir, test_case + ".json")))
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #21
0
 def test_isatab2json_convert_charac_param_factor(self):
     test_case = "TEST-ISA-charac-param-factor"
     actual_json = isatab2json.convert(os.path.join(self._tab_data_dir, test_case), self.identifier_type)
     expected_json = json.load(open(os.path.join(self._json_data_dir, test_case + ".json")))
     self.assertTrue(utils.assert_json_equal(expected_json, actual_json))
Пример #22
0
 def test_assert_json_equal(self):
     self.assertTrue(utils.assert_json_equal(self.j1, self.j2))
     self.assertFalse(utils.assert_json_equal(self.j1, self.j3))