IHEC / ihec-ecosystems

This repo is for code and documentation associated with the ihec-ecosystems working group
Apache License 2.0
5 stars 6 forks source link

Assertion Error with missing EXPERIMENT_TYPE or BIOMATERIAL_TYPE #101

Closed juettemann closed 4 years ago

juettemann commented 4 years ago

Missing EXPERIMENT_TYPE or BIOMATERIAL_TYPE results in an assertion error. Can this be caught in the prevalidation?

If possible, an assertion error should only happen if there is a syntax mistake (e.g. missing closing tag) in the XML. Further, I could not see a way to identify the erroneous record in case the XML contains multiple records.

Test files

Output

Traceback (most recent call last):
  File "/homes/juettema/src/anaconda3/envs/v/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/homes/juettema/src/anaconda3/envs/v/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/homes/juettema/src/ihec-ecosystems/version_metadata/__main__.py", line 52, in <module>
    main(Config.sys())
  File "/homes/juettema/src/ihec-ecosystems/version_metadata/__main__.py", line 39, in main
    validate_sample.main(args)
  File "/homes/juettema/src/ihec-ecosystems/version_metadata/validate_sample.py", line 74, in main
    return validate_main.main(args, versioned_xml, validated, nObjs, sample_validator, xml_validator)
  File "/homes/juettema/src/ihec-ecosystems/version_metadata/validate_main.py", line 33, in main
    errlog = io_adaptor.format_errlog(errlog)
  File "/homes/juettema/src/ihec-ecosystems/version_metadata/io_adaptor.py", line 36, in format_errlog
    v['errors'] = clean_prevalidate(v)
  File "/homes/juettema/src/ihec-ecosystems/version_metadata/io_adaptor.py", line 26, in clean_prevalidate
    assert len(v['errors']) == 2, v['errors']
AssertionError: ['missing biomaterial_type']
sitag commented 4 years ago

@juettemann those xmls are not in your branch. i have fixed this in feb2020, with these xmls:

python -m version_metadata -overwrite-outfile -out:./delete_me -experiment version_metadata/examples/experiment.one_invalid_missing_type.xml 

and

python -m version_metadata -overwrite-outfile -out:./delete_me -sample version_metadata/examples/sample-Primary_Tissue-missing_biomaterial.xml 
{
    "version_metadata/examples/sample-Primary_Tissue-missing_biomaterial.xml": [
        {
            "ENCBS054KUO": {
                "error_type": "__prevalidation__",
                "errors": [
                    "missing biomaterial_type : prevalidation"
                ],
                "ok": false,
                "version": "1.1"
            }
        },
        {
            "ENCBS054KUO": {
                "error_type": "__prevalidation__",
                "errors": [
                    "missing biomaterial_type : prevalidation"
                ],
                "ok": false,
                "version": "1.0"
            }
        }
    ]
}
juettemann commented 4 years ago

@sitag The branches have been merged with master and deleted 5 days ago, all tests should be there. This looks great and is working. I am closing it, if something else arises I'll open a new issue.