ropensci / RNeXML

Implementing semantically rich NeXML I/O in R
https://docs.ropensci.org/RNeXML
Other
13 stars 9 forks source link

Polymorphic (and probably uncertain) states fail to get written out in write.nexml() #191

Closed hlapp closed 5 years ago

hlapp commented 5 years ago

As the title says, if I read in a NeXML file that has polymorphic states and write it back out without further modification, the polymorphic states are gone, turning them essentially into missing values. (Since there the problems with the treatment of polymorphic states found so far would have applied equally to uncertain states, I suspect this will be the case here, too, though I don't hold proof.)

After investigating where this might be happening, it turns out that it is the coercion of the nexml object to an XMLInternalNode object that loses them. Specifically, while <state/> children of the <states/> element get passed on just fine, a <polymorphic_state_set/> child, if present, does not (and I suspect neither would a <uncertain_state_set/>):

f <- system.file("examples", "ontotrace-result.xml", package="RNeXML")
nex <- read.nexml(f)
as(nex, "XMLInternalNode")
# ...
#      <states id="sa75ef9ac-e74e-4015-846d-27d793868951">
#        <state label="present" id="UBERON_2002002_1" symbol="1"/>
#        <state label="absent" id="UBERON_2002002_0" symbol="0"/>
#       </states>
#       <states id="s99d94a8b-9bab-4b56-990a-a3fcc85900f4">
#         <state label="present" id="UBERON_2001788_1" symbol="1"/>
#         <state label="absent" id="UBERON_2001788_0" symbol="0"/>
#       </states>
#       <states id="sb29f0f18-addb-4e9b-bcef-833065cba124">
#         <state label="present" id="UBERON_2002001_1" symbol="1"/>
#         <state label="absent" id="UBERON_2002001_0" symbol="0"/>
#       </states>
# ...

The first two <states/> elements should have had included a polymorphic state set. Any idea @cboettig as to what might prevent the <polymorphic_state_set/> element from getting passed on?

cboettig commented 5 years ago

@hlapp See PR #192, should fix this I think.

hlapp commented 5 years ago

Fixed in #192.

hlapp commented 5 years ago

Thanks @cboettig 🙏