Skip to content

SSSOM-PY: sssom merge adds creator_id as a List object

https://github.com/mapping-commons/sssom-py/issues/364

Given this sssom file, obo_omop.cpath.sssom.tsv:

# creator_id:
# - orcid:0000-0001-5839-2535
# curie_map:
#   HP: http://purl.obolibrary.org/obo/HP_
#   omop: https://athena.ohdsi.org/search-terms/terms/
#   orcid: https://orcid.org/
#   owl: http://www.w3.org/2002/07/owl#
#   rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
#   rdfs: http://www.w3.org/2000/01/rdf-schema#
#   semapv: https://w3id.org/semapv/
#   skos: http://www.w3.org/2004/02/skos/core#
#   sssom: https://w3id.org/sssom/
# license: https://creativecommons.org/licenses/by-nc/4.0/
# mapping_set_description: All C-Path generated mappings of OBO terms to OMOP terms
# mapping_set_id: cpath_obo_omop
subject_id	subject_label	predicate_id	object_id	object_label	mapping_justification	mapping_date	confidence
HP:0001250	Seizure	skos:exactMatch	omop:377091	Seizure	semapv:ManualMappingCuration	2023-01-01	1.0
HP:0001324	Muscle weakness	skos:exactMatch	omop:79908	Muscle weakness	semapv:ManualMappingCuration	2023-01-01	1.0

Running the following merge command

sssom merge obo_omop.cpath.sssom.tsv --output mappings.owl-merged.sssom.tsv 

produces this output file:

# curie_map:
#   HP: http://purl.obolibrary.org/obo/HP_
#   omop: https://athena.ohdsi.org/search-terms/terms/
#   orcid: https://orcid.org/
#   owl: http://www.w3.org/2002/07/owl#
#   rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
#   rdfs: http://www.w3.org/2000/01/rdf-schema#
#   semapv: https://w3id.org/semapv/
#   skos: http://www.w3.org/2004/02/skos/core#
#   sssom: https://w3id.org/sssom/
subject_id	subject_label	predicate_id	object_id	object_label	mapping_justification	mapping_date	confidence	creator_id	license
HP:0001250	Seizure	skos:exactMatch	omop:377091	Seizure	semapv:ManualMappingCuration	2023-01-01	1.0	['orcid:0000-0001-5839-2535']	https://creativecommons.org/licenses/by-nc/4.0/
HP:0001324	Muscle weakness	skos:exactMatch	omop:79908	Muscle weakness	semapv:ManualMappingCuration	2023-01-01	1.0	['orcid:0000-0001-5839-2535']	https://creativecommons.org/licenses/by-nc/4.0/

As you can see, the creator_id from the header in obo_omop.cpath.sssom.tsv has been added as a column in mappings.owl-merged.sssom.tsv with the value represented as a List object ['orcid:0000-0001-5839-2535'] instead of as a string. Then when I run

sssom convert mappings.owl-merged.sssom.tsv  --output mappings.owl-converted.sssom.owl

I get the error

Traceback (most recent call last):
  File "/usr/local/bin/sssom", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/sssom/cli.py", line 163, in convert
    convert_file(input_path=input, output=output, output_format=output_format)
  File "/usr/local/lib/python3.10/dist-packages/sssom/io.py", line 54, in convert_file
    doc = parse_sssom_table(input_path)
  File "/usr/local/lib/python3.10/dist-packages/sssom/parsers.py", line 183, in parse_sssom_table
    msdf = from_sssom_dataframe(
  File "/usr/local/lib/python3.10/dist-packages/sssom/parsers.py", line 388, in from_sssom_dataframe
    mlist.append(_prepare_mapping(Mapping(**mdict)))
  File "<string>", line 42, in __init__
  File "/usr/local/lib/python3.10/dist-packages/sssom_schema/datamodel/sssom_schema.py", line 298, in __post_init__
    self.creator_id = [v if isinstance(v, EntityReference) else EntityReference(v) for v in self.creator_id]
  File "/usr/local/lib/python3.10/dist-packages/sssom_schema/datamodel/sssom_schema.py", line 298, in <listcomp>
    self.creator_id = [v if isinstance(v, EntityReference) else EntityReference(v) for v in self.creator_id]
  File "/usr/local/lib/python3.10/dist-packages/linkml_runtime/utils/metamodelcore.py", line 100, in __init__
    raise ValueError(f"{v} is not a valid URI or CURIE")
ValueError: ['orcid:0000-0001-5839-2535'] is not a valid URI or CURIE