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

dic2owl error on building cif_core.dic #194

Open
stuchalk opened this issue May 13, 2024 · 2 comments
Open

dic2owl error on building cif_core.dic #194

stuchalk opened this issue May 13, 2024 · 2 comments

Comments

@stuchalk
Copy link
Collaborator

When using dic2owl to create cif_core.tll I get the following error:

Traceback (most recent call last):
  File "/Users/n00002621/Library/Python/3.11/bin/dic2owl", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/cli.py", line 95, in main
    dic2owl_run(
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/dic2owl.py", line 274, in main
    onto = gen.generate()
           ^^^^^^^^^^^^^^
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/dic2owl.py", line 118, in generate
    self._add_item(item)
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/dic2owl.py", line 129, in _add_item
    self._add_data_value(item)
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/dic2owl.py", line 185, in _add_data_value
    self._add_item(parent)
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/dic2owl.py", line 127, in _add_item
    self._add_category(item)
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/dic2owl.py", line 162, in _add_category
    self._add_category(parent_item)
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/dic2owl.py", line 162, in _add_category
    self._add_category(parent_item)
  File "/Users/n00002621/PycharmProjects/CIF-ontology/dic2owl/dic2owl/dic2owl.py", line 165, in _add_category
    cls = types.new_class(name, (self.onto[parent_name],))
                                 ~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontopy/ontology.py", line 249, in __getitem__
    item = self.get_by_label(name)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontopy/ontology.py", line 422, in get_by_label
    raise NoSuchLabelError(f"No label annotations matches '{label}'")
ontopy.utils.NoSuchLabelError: No label annotations matches 'CIF_CORE'

Any ideas how to fix?
I am using the most recent version of the cif_core.dic (3.3.0 5/2/24) and the latest version of dic2owl (commits up through Commits on Nov 9, 2023)

Stuart

@vaitkus
Copy link
Collaborator

vaitkus commented May 14, 2024

Temporary workaround

Open the cif_core.dic file and do the following changes:

  1. Line 8: "data_CIF_CORE" => data_CIF_CORE_DIC
  2. Line 10: " _dictionary.title CIF_CORE" -> "_dictionary.title CIF_CORE_DIC"
  3. Line 35: " _name.category_id CIF_CORE" -> "_name.category_id CIF_CORE_DIC"

After this, running dic2owl cif_core.dic should successfully build the cif_core.tll file.

The problem

Recently, the CIF_CORE dictionary was internally renamed from CORE_DIC to CIF_CORE to adhere to the newly agreed upon conventions. However, this also resulted in a CIF file in which the data block (top level container) and a save frame (lower level container) both have the same name (CORE_DIC). While this is perfectly valid in CIF, the dic2owl script seems to not process this very well. At least that is my educated guess.

Long term solution

There have been discussions in the CIF_CORE repository to also change the name of the save frame so the issue might just go away on its own. However, it would still make sense to also update the dic2owl script to properly process such valid CIF dictionary files.

@vaitkus
Copy link
Collaborator

vaitkus commented May 17, 2024

@stuchalk Ok, so with the recent changes to the CIF_CORE dictionary (COMCIFS/cif_core#492), this bug no longer manifests. Just remove all of the ignored/generated files and rerun the ttl file build command.

While the underlying issue in the software is still present, it is unlikely to manifest again with the IUCr CIF dictionaries given the recently agreed upon naming conventions (COMCIFS/cif_core#488). Patching the bug would be nice, but the issue should be viewed as having a much lower priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants