Skip to content

Commit

Permalink
Merge pull request #527 from ptth222/load-table-checks-improvement
Browse files Browse the repository at this point in the history
Added better messaging
  • Loading branch information
proccaserra authored Apr 12, 2024
2 parents 874c7b5 + 682611d commit 8aba97f
Showing 1 changed file with 9 additions and 35 deletions.
44 changes: 9 additions & 35 deletions isatools/isatab/validate/rules/rules_40xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def load_table_checks(df, filename):
and not _RX_COMMENT.match(col):
spl = ("(E) Expected only Characteristics, "
"Factor Values or Comments following {} "
"columns but found {} at offset {}".format(prop_name, col, x + 1, filename))
"columns but found {} at offset {} in file {}".format(prop_name, col, x + 1, filename))
log.error(spl)
error = {
"message": "Unrecognised header",
Expand All @@ -489,7 +489,7 @@ def load_table_checks(df, filename):
and not _RX_PARAMETER_VALUE.match(col) \
and not _RX_COMMENT.match(col):
spl = ("(E) Unexpected column heading following {} "
"column. Found {} at offset {}".format(prop_name, col, x + 1, filename))
"column. Found {} at offset {} in file {}".format(prop_name, col, x + 1, filename))
log.error(spl)
error = {
"message": "Unrecognised header",
Expand All @@ -504,26 +504,14 @@ def load_table_checks(df, filename):
and not _RX_COMMENT.match(col):
spl = ("(E) Expected only Characteristics, "
"Comments following {} "
"columns but found {} at offset {}".format(prop_name, col, x + 1, filename))
"columns but found {} at offset {} in file {}".format(prop_name, col, x + 1, filename))
log.error(spl)
error = {
"message": "Unrecognised header",
"supplemental": spl,
"code": 4014
}
validator.add_error(**error)
# if len(object_columns) > 1:
#
# spl = ("Unexpected column heading(s) following {} column. "
# "Found {} at offset {}".format(
# prop_name, object_columns[1:], 2), filename)
# log.error(spl)
# error = {
# "message": "Unrecognised header",
# "supplemental": spl,
# "code": 4014
# }
# validator.add_error(**error)
elif prop_name == 'Labeled Extract Name':
if len(object_columns) > 1:
if object_columns[1] == 'Label':
Expand All @@ -532,7 +520,7 @@ def load_table_checks(df, filename):
'Term Accession Number']:
spl = ("(E) Unexpected column heading "
"following {} column. Found {} at "
"offset {}".format(prop_name, col, x + 1, filename))
"offset {} in file {}".format(prop_name, col, x + 1, filename))
log.error(spl)
error = {
"message": "Unrecognised header",
Expand All @@ -548,7 +536,7 @@ def load_table_checks(df, filename):
and not _RX_COMMENT.match(col):
spl = ("(E) Expected only Characteristics, "
"Comments following {} "
"columns but found {} at offset {}".format(prop_name, col, x + 1, filename))
"columns but found {} at offset {} in file {}".format(prop_name, col, x + 1, filename))
log.error(spl)
error = {
"message": "Unrecognised header",
Expand All @@ -558,7 +546,7 @@ def load_table_checks(df, filename):
validator.add_error(**error)
else:
spl = ("Expected Label column after Labeled Extract Name "
"but none found")
"but none found in file {}".format(filename))
log.error(spl)
error = {
"message": "Unrecognised header",
Expand All @@ -567,23 +555,10 @@ def load_table_checks(df, filename):
}
validator.add_error(**error)
elif prop_name in DATA_FILE_LABELS:
# [
# 'Raw Data File',
# 'Raw Spectral Data File',
# 'Free Induction Decay Data File',
# 'Image File',
# 'Derived Data File',
# 'Derived Spectral Data File',
# 'Derived Array Data File',
# 'Array Data File',
# 'Protein Assignment File',
# 'Peptide Assignment File',
# 'Post Translational Modification Assignment File'
# ]
for x, col in enumerate(object_columns[1:]):
if not _RX_COMMENT.match(col):
spl = ("(E) Expected only Comments following {} "
"columns but found {} at offset {}".format(prop_name, col, x + 1, filename))
"columns but found {} at offset {} in file {}".format(prop_name, col, x + 1, filename))
log.error(spl)
error = {
"message": "Unrecognised header",
Expand All @@ -594,9 +569,8 @@ def load_table_checks(df, filename):
elif _RX_FACTOR_VALUE.match(prop_name):
for x, col in enumerate(object_columns[2:]):
if col not in ['Term Source REF', 'Term Accession Number']:
spl = (
"(E) Unexpected column heading following {} column. "
"Found {} at offset {}".format(prop_name, col, x + 1, filename))
spl = ("(E) Unexpected column heading following {} column. "
"Found {} at offset {} in file {}".format(prop_name, col, x + 1, filename))
log.error(spl)
error = {
"message": "Unrecognised header",
Expand Down

0 comments on commit 8aba97f

Please sign in to comment.