Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed missing required properties to error #532

Closed
wants to merge 5 commits into from
Closed
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
19 changes: 3 additions & 16 deletions isatools/isatab/validate/rules/rules_40xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,16 @@ def check_investigation_against_config(i_df_dict, configs):
code = 4003
message = "A required property is missing"

# def add_warning(index, column, value_index):
# if index > 0:
# spl = "A property value in {}.{} of investigation file at column {} is required"
# spl = spl.format(column, index + 1, value_index + 1)
# validator.add_warning(message=message, supplemental=spl, code=code)
# log.warning("(W) {}".format(spl))
# else:
# spl = "A property value in {} of investigation file at column {} is required"
# spl = spl.format(column, value_index + 1)
# validator.add_warning(message=message, supplemental=spl, code=code)
# log.warning("(W) {}".format(spl))

def add_error(index, column, value_index):
if index > 0:
spl = "A property value in {}.{} of investigation file at column {} is required"
spl = spl.format(column, index + 1, value_index + 1)
validator.add_error(message=message, supplemental=spl, code=code)
log.error("(E) {}".format(spl))
else:
spl = "A property value in {} of investigation file at column {} is required"
spl = spl.format(column, value_index + 1)
validator.add_error(message=message, supplemental=spl, code=code)
log.error("(E) {}".format(spl))
validator.add_error(message=message, supplemental=spl, code=code)
log.error("(E) {}".format(spl))


def check_section_against_required_fields_one_value(section, required, i=0):
fields_required = [i for i in section.columns if i in required]
Expand Down
5 changes: 2 additions & 3 deletions tests/convert/test_mzml2isa.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def test_mzml2isa_convert_investigation(self):
study_id = 'MTBLS267'
report = mzml2isa.convert(os.path.join(self._mzml_data_dir, study_id + '-partial'), self._tmp_dir, study_id,
validate_output=True)
# self.assertTrue(report['validation_finished'])
self.assertEqual(len(report['warnings']), 8)
self.assertEqual(len(report['errors']), 5)

Expand All @@ -43,9 +42,9 @@ def test_mzml2isa_convert_study_table(self):
study_id = 'MTBLS267'
report = mzml2isa.convert(os.path.join(self._mzml_data_dir, study_id + '-partial'), self._tmp_dir, study_id,
validate_output=True)
# self.assertTrue(report['validation_finished'])
self.assertEqual(len(report['warnings']), 8)
self.assertEqual(len(report['errors']), 5)

with open(os.path.join(self._tmp_dir, 's_{}.txt'.format(study_id))) as out_fp:
with open(os.path.join(self._tab_data_dir, study_id + '-partial', 's_{}.txt'.format(study_id))) as reference_fp:
self.assertTrue(assert_tab_content_equal(out_fp, reference_fp))
Expand All @@ -54,9 +53,9 @@ def test_mzml2isa_convert_assay_table(self):
study_id = 'MTBLS267'
report = mzml2isa.convert(os.path.join(self._mzml_data_dir, study_id + '-partial'), self._tmp_dir, study_id,
validate_output=True)
self.assertTrue(report['validation_finished'])
self.assertEqual(len(report['warnings']), 8)
self.assertEqual(len(report['errors']), 5)

with open(os.path.join(self._tmp_dir, 'a_{}_metabolite_profiling_mass_spectrometry.txt'.format(study_id))) as out_fp:
with open(os.path.join(self._tab_data_dir, study_id + '-partial', 'a_{}_metabolite_profiling_mass_spectrometry.txt'.format(study_id))) as reference_fp:
self.assertTrue(assert_tab_content_equal(out_fp, reference_fp))
3 changes: 1 addition & 2 deletions tests/isatab/validate/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def test_b_ii_s_3(self):
r = validate(fp=data_file, config_dir=self.default_conf, origin="")
self.assertEqual(len(r['warnings']), 2)


def test_mtbls267(self):
data_path = path.join(path.dirname(path.abspath(__file__)), '..', '..', 'data', 'tab', 'MTBLS267-partial')
with open(path.join(data_path, 'i_Investigation.txt'), 'r') as data_file:
Expand All @@ -33,6 +32,7 @@ def test_mtbls_1846(self):
r = validate(fp=data_file, config_dir=self.default_conf)
self.assertEqual(len(r['errors']), 33)


def test_bii_i_1(self):
data_path = path.join(path.dirname(path.abspath(__file__)), '..', '..', 'data', 'tab', 'BII-I-1')
with open(path.join(data_path, 'i_investigation.txt'), 'r') as data_file:
Expand Down Expand Up @@ -85,7 +85,6 @@ def is_investigation(investigation_df):
r = validate(data_file, rules=rules)
self.assertEqual(len(r['warnings']), 2)


rule = '12000'
expected_error = {
'message': 'Unknown/System Error',
Expand Down
8 changes: 2 additions & 6 deletions tests/test_clients/test_mw2isa.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ def test_conversion_ms(self):
log.info("conversion successful, invoking the validator for " + study_id)
with open(os.path.join(self._tmp_dir, study_id, 'i_investigation.txt')) as fp:
report = isatab.validate(fp)
# print(report)
# for error in report['errors']:
# print("ERROR:", error)
# self.assertEqual(error['code'], 4014)
# self.assertIn(error['code'], [4003, 4014])
self.assertTrue(len(report['errors']) > 0)
for error in report['errors']:
self.assertIn(error['code'], [4014, 4003])
else:
self.fail("conversion failed, validation was not invoked")

Expand Down
Loading
Loading