nfdi4plants/ARCtrl

[BUG] Incorrect handling of new mutable OntologyAnnotation

Freymaurer opened this issue · 6 comments

I assume quite some functions still use OntologyAnnotation in a way, which expects it to be immutable.
This change was introduced to unify object handling in ARCtrl not only within f# type but also for native js objects.

The following code replicates the specific case i encountered, in which i create a table, add an empty column, then update the oa in one of the columns:

#r "nuget: ARCtrl, 2.0.0-alpha.6.swate"

open ARCtrl

let assay = ArcAssay.init("My Assay")
let table = assay.InitTable("My Table")

table.AddColumn(CompositeHeader.Input IOType.Source, [|for i in 0 .. 4 do CompositeCell.FreeText $"Source {i}"|])

table.AddColumn(CompositeHeader.Component (OntologyAnnotation.create("instrument model", "MS", "MS:424242")))


match table.Values.[(1,0)] with
| CompositeCell.Term oa -> 
  oa.Name <- Some "New Name"
| _ -> failwith "Expected a term"

table

Expected outcome

First cell in second columns has updated name

Actual outcome

-------------
Input [Source Name]     |       Component [instrument model]
Source 0        |       New Name
Source 1        |       New Name
Source 2        |       New Name
Source 3        |       New Name
Source 4        |       New Name

Well in the case you provided I would expect exactly this behaviour 😅

By updating the name of cell (1,0) you would expect the table to update all cells in the same column?

match table.Values.[(1,0)] with
| CompositeCell.Term oa -> 
  oa.Name <- Some "New Name"
| _ -> failwith "Expected a term"

How about we add some static members to OntologyAnnotation like we did with other types and make those function immutably. Additionally a CompositeCell copy might be helpful.

By updating the name of cell (1,0) you would expect the table to update all cells in the same column?

match table.Values.[(1,0)] with
| CompositeCell.Term oa -> 
  oa.Name <- Some "New Name"
| _ -> failwith "Expected a term"

You're very explicitly not updating the name of the cell but the name of the OntologyAnnotation, making use of mutable patterns.

So yes, if I defined the table like you did I would expect it.

So yes, if I defined the table like you did I would expect it.

Please explain in detail, how you would expect this behavior on a column, added without any cells.

Okay nevermind, didn't notice this made use of FillMissingCells.