units-of-measurement / units-of-measurement

BSD 3-Clause "New" or "Revised" License
9 stars 4 forks source link

Trouble encoding mm[Hg] (UO:0000272) in UOM #40

Open cmungall opened 2 years ago

cmungall commented 2 years ago

I think some kind of idiot's guide to things like mapping UO to UOM would be useful

E.g. UO:0000272 millimetres of mercury

I am not sure if the web interface or the command line script can help here?

I tried looking at the mapping files:

$  grep 0000272 units_of_measurement/resources/mappings.csv
http://purl.obolibrary.org/obo/UO_0000272,millimetres of mercury
http://purl.obolibrary.org/obo/UO_0000272,mm[Hg]

It's not clear why it's not 1:1... maybe SSSOM would help here?

Anyway the second entry seems to be correct:

https://ucum.nlm.nih.gov/ucum-service/v1/isValidUCUM/mm%5BHg%5D

=> true

However both

https://units-of-measurement.org/mm[Hg] https://units-of-measurement.org/mm%5BHg%5D

yield

Oops! 'mm[Hg]' is not a valid UCUM code. Go back.

jamesaoverton commented 2 years ago

I'm confused about this one. @kaiiam?

jamesaoverton commented 2 years ago

The grammar includes m[Hg], but maybe it's not being crossed with the SI prefixes?

https://github.com/units-of-measurement/units-of-measurement/blob/main/units_of_measurement/grammar.py#L147

kaiiam commented 2 years ago

Thanks @cmungall

The following error:

Oops! 'mm[Hg]' is not a valid UCUM code.

is happening because at the moment our UOM python parser (handling UCUM codes) isn't' allowing for the crossing of metric prefixes with non metric UCUM base codes. Originally we thought that was the correct thing to do (scientifically speaking) but since it seems UCUM and https://ucum.nlm.nih.gov/ucum-lhc/demo.html allow for it we'll need to update it accordingly. This is on my list of things to fix when I get a chance to get back to this. If anyone needs this fixed urgently you can make a PR. Otherwise I'll get to it in a couple months (I'm in the middle of dissertation writing).

@alanruttenberg this is the same basic issue you describe in #36. Sorry for the slow response to that.

$ grep 0000272 units_of_measurement/resources/mappings.csv http://purl.obolibrary.org/obo/UO_0000272,millimetres of mercury http://purl.obolibrary.org/obo/UO_0000272,mm[Hg]

The current mappings were semi-manually semi-automatically made so I think it not being 1:1 here is mistake or artifact of the original mapping not being fully cleaned/vetted. The the plan is to further clean them up and convert them into SSSOM mappings that are 1:1 UOM to other unit systems.