Skip to content

Commit

Permalink
Merge branch 'developer' of https://github.com/nfdi4plants/Swate into…
Browse files Browse the repository at this point in the history
… developer
  • Loading branch information
Freymaurer committed Oct 9, 2024
2 parents e72634a + 7eee2d1 commit 57f58bc
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 123 deletions.
8 changes: 4 additions & 4 deletions src/Client/OfficeInterop/Functions/BuildingBlockFunctions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ let toTermSearchable (buildingBlock:BuildingBlock) =
// get all units from cells
|> Array.map (fun cell -> cell.Unit, cell.Index)
// filter units to unique
|> Array.choose (fun (unitName,rowInd) -> if unitName.IsSome then Some (unitName.Value,rowInd) else None)
|> Array.choose (fun (unitName, rowInd) -> if unitName.IsSome then Some (unitName.Value, rowInd) else None)
|> Array.groupBy fst
// get only units where unit.isSome
|> Array.map (fun (unitTerm,cellInfoArr) ->
|> Array.map (fun (unitTerm, cellInfoArr) ->
let cellRowIndices = cellInfoArr |> Array.map snd |> Array.distinct
// will not contain termAccession
TermSearchable.create unitTerm None true colIndex cellRowIndices
Expand All @@ -314,10 +314,10 @@ let toTermSearchable (buildingBlock:BuildingBlock) =
// get all terms from cells
|> Array.map (fun cell -> cell.Value, cell.Index)
// get only values where value.isSome
|> Array.choose (fun (valueName,rowInd) -> if valueName.IsSome then Some (valueName.Value,rowInd) else None)
|> Array.choose (fun (valueName, rowInd) -> if valueName.IsSome then Some (valueName.Value, rowInd) else None)
|> Array.groupBy fst
// filter terms to unique
|> Array.map (fun (valueName,cellInfoArr) ->
|> Array.map (fun (valueName, cellInfoArr) ->
let cellRowIndices = cellInfoArr |> Array.map snd |> Array.distinct
let tryFindAccession =
buildingBlock.TAN.Value.Cells
Expand Down
209 changes: 160 additions & 49 deletions src/Client/OfficeInterop/OfficeInterop.fs

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/Client/SidebarComponents/Navbar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ let private shortCutIconList model dispatch =
Html.i [prop.className "fa-solid fa-pen"]
],
(fun _ ->
SpreadsheetInterface.ValidateAnnotationTable |> InterfaceMsg |> dispatch
SpreadsheetInterface.UpdateTermColumns |> InterfaceMsg |> dispatch
SpreadsheetInterface.RectifyTermColumns |> InterfaceMsg |> dispatch
)
)
QuickAccessButton.create(
Expand Down
2 changes: 1 addition & 1 deletion src/Client/States/OfficeInteropState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Msg =
| GetParentTerm
// table+database interconnected functions
///
| FillHiddenColsRequest
| RectifyTermColumns
///
| FillHiddenColumns of TermSearchable []
///
Expand Down
2 changes: 1 addition & 1 deletion src/Client/States/Spreadsheet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ type Msg =
| InitFromArcFile of ArcFiles
| InsertOntologyAnnotation of OntologyAnnotation
| InsertOntologyAnnotations of OntologyAnnotation []
| UpdateTermColumns
| RectifyTermColumns
| UpdateTermColumnsResponse of TermTypes.TermSearchable []
/// Starts chain to export active table to isa json
| ExportJson of ArcFiles * JsonExportFormat
Expand Down
3 changes: 1 addition & 2 deletions src/Client/States/SpreadsheetInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ open ARCtrl
type Msg =
| Initialize of Swatehost
| CreateAnnotationTable of tryUsePrevOutput:bool
| ValidateAnnotationTable
| RemoveBuildingBlock
| UpdateDatamap of DataMap option
| UpdateDataMapDataContextAt of index: int * DataContext
Expand All @@ -31,5 +30,5 @@ type Msg =
/// Starts chain to export active table to isa json
| ExportJson of ArcFiles * JsonExportFormat
| UpdateUnitForCells
| UpdateTermColumns
| RectifyTermColumns
| UpdateTermColumnsResponse of TermTypes.TermSearchable []
15 changes: 3 additions & 12 deletions src/Client/Update/InterfaceUpdate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ module Interface =
let cmd = Spreadsheet.CreateAnnotationTable usePrevOutput |> SpreadsheetMsg |> Cmd.ofMsg
model, cmd
| _ -> failwith "not implemented"
| ValidateAnnotationTable ->
match host with
| Some Swatehost.Excel ->
let cmd = OfficeInterop.ValidateAnnotationTable |> OfficeInteropMsg |> Cmd.ofMsg
model, cmd
//| Some Swatehost.Browser | Some Swatehost.ARCitect ->
// let cmd = Spreadsheet.CreateAnnotationTable usePrevOutput |> SpreadsheetMsg |> Cmd.ofMsg
// model, cmd
| _ -> failwith "not implemented"
| UpdateDatamap datamapOption ->
match host with
| Some Swatehost.Excel ->
Expand Down Expand Up @@ -276,13 +267,13 @@ module Interface =
let cmd = OfficeInterop.UpdateUnitForCells |> OfficeInteropMsg |> Cmd.ofMsg
model, cmd
| _ -> failwith "not implemented"
| UpdateTermColumns ->
| RectifyTermColumns ->
match host with
| Some Swatehost.Excel ->
let cmd = OfficeInterop.FillHiddenColsRequest |> OfficeInteropMsg |> Cmd.ofMsg
let cmd = OfficeInterop.RectifyTermColumns |> OfficeInteropMsg |> Cmd.ofMsg
model, cmd
| Some Swatehost.Browser | Some Swatehost.ARCitect ->
let cmd = Spreadsheet.UpdateTermColumns |> SpreadsheetMsg |> Cmd.ofMsg
let cmd = Spreadsheet.RectifyTermColumns |> SpreadsheetMsg |> Cmd.ofMsg
model, cmd
| _ -> failwith "not implemented"
| UpdateTermColumnsResponse terms ->
Expand Down
27 changes: 11 additions & 16 deletions src/Client/Update/OfficeInteropUpdate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ open OfficeInterop
open Shared
open OfficeInteropTypes
open Model
open ARCtrl

module OfficeInterop =
let update (state: OfficeInterop.Model) (model:Model) (msg: OfficeInterop.Msg) : OfficeInterop.Model * Model * Cmd<Messages.Msg> =
Expand Down Expand Up @@ -126,16 +125,6 @@ module OfficeInterop =
(curry GenericInteropLogs (AnnotationtableCreated |> OfficeInteropMsg |> Cmd.ofMsg) >> DevMsg) //success
(curry GenericError Cmd.none >> DevMsg) //error
state, model,cmd

| ValidateAnnotationTable ->
let cmd =
Cmd.OfPromise.either
OfficeInterop.Core.validateAnnotationTable
()
(curry GenericInteropLogs (AnnotationtableCreated |> OfficeInteropMsg |> Cmd.ofMsg) >> DevMsg) //success
(curry GenericError Cmd.none >> DevMsg) //error
state, model,cmd

| AnnotationtableCreated ->
let nextState = {
model.ExcelState with
Expand All @@ -159,14 +148,14 @@ module OfficeInterop =
(fun tmin -> tmin |> Option.map (fun t -> ARCtrl.OntologyAnnotation.fromTerm t.toTerm) |> TermSearch.UpdateParentTerm |> TermSearchMsg)
(curry GenericError Cmd.none >> DevMsg)
state, model, cmd
//
| FillHiddenColsRequest ->
failwith "FillHiddenColsRequest Not implemented yet"

| RectifyTermColumns ->
//failwith "FillHiddenColsRequest Not implemented yet"
//let cmd =
// Cmd.OfPromise.either
// OfficeInterop.Core.getAllAnnotationBlockDetails
// ()
// (fun (searchTerms,deprecationLogs) ->
// (fun (searchTerms, deprecationLogs) ->
// // Push possible deprecation messages by piping through "GenericInteropLogs"
// GenericInteropLogs (
// // This will be executed after "deprecationLogs" are handled by "GenericInteropLogs"
Expand All @@ -179,7 +168,13 @@ module OfficeInterop =
// (curry GenericError (UpdateFillHiddenColsState FillHiddenColsState.Inactive |> OfficeInteropMsg |> Cmd.ofMsg) >> DevMsg)
//let stateCmd = UpdateFillHiddenColsState FillHiddenColsState.ExcelCheckHiddenCols |> OfficeInteropMsg |> Cmd.ofMsg
//let cmds = Cmd.batch [cmd; stateCmd]
state, model, Cmd.none
let cmd =
Cmd.OfPromise.either
OfficeInterop.Core.rectifyTermColumns
()
(curry GenericInteropLogs Cmd.none >> DevMsg)
(curry GenericError Cmd.none >> DevMsg)
state, model, cmd

| FillHiddenColumns (termsWithSearchResult) ->
let nextState = {
Expand Down
8 changes: 1 addition & 7 deletions src/Client/Update/SpreadsheetUpdate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ open Messages
open Elmish
open Spreadsheet
open LocalHistory
open Spreadsheet
open Model
open Shared
open Fable.Remoting.Client
open FsSpreadsheet
open FsSpreadsheet.Js
open ARCtrl
open ARCtrl.Spreadsheet
Expand All @@ -17,10 +15,6 @@ open ARCtrl.Json
module Spreadsheet =

module Helper =
open Browser
open Fable.Core
open Fable.Core.JS
open Fable.Core.JsInterop

let download(filename, bytes:byte []) = bytes.SaveFileAs(filename)

Expand Down Expand Up @@ -382,7 +376,7 @@ module Spreadsheet =
| ExportXlsxDownload (name,xlsxBytes) ->
let _ = Helper.download (name ,xlsxBytes)
state, model, Cmd.none
| UpdateTermColumns ->
| RectifyTermColumns ->
//let getUpdateTermColumns() = promise {
// return Controller.getUpdateTermColumns state
//}
Expand Down
56 changes: 27 additions & 29 deletions src/Shared/Shared.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module SorensenDice =

let inline calculateDistance (x : Set<'T>) (y : Set<'T>) =
match (x.Count, y.Count) with
| (0,0) -> 1.
| (0, 0) -> 1.
| (xCount,yCount) -> (2. * (Set.intersect x y |> Set.count |> float)) / ((xCount + yCount) |> float)

let createBigrams (s:string) =
Expand Down Expand Up @@ -47,18 +47,18 @@ type IDagAPIv1 = {
}

type IISADotNetCommonAPIv1 = {
toAssayJson : byte [] -> Async<obj>
toSwateTemplateJson : byte [] -> Async<obj>
toInvestigationJson : byte [] -> Async<obj>
toProcessSeqJson : byte [] -> Async<obj>
toAssayJson : byte [] -> Async<obj>
toSwateTemplateJson : byte [] -> Async<obj>
toInvestigationJson : byte [] -> Async<obj>
toProcessSeqJson : byte [] -> Async<obj>
//toTableJson : byte [] -> Async<obj>
toAssayJsonStr : byte [] -> Async<string>
toSwateTemplateJsonStr : byte [] -> Async<string>
toInvestigationJsonStr : byte [] -> Async<string>
toProcessSeqJsonStr : byte [] -> Async<string>
toAssayJsonStr : byte [] -> Async<string>
toSwateTemplateJsonStr : byte [] -> Async<string>
toInvestigationJsonStr : byte [] -> Async<string>
toProcessSeqJsonStr : byte [] -> Async<string>
//toTableJsonStr : byte [] -> Async<string>
testPostNumber : int -> Async<string>
getTestNumber : unit -> Async<string>
testPostNumber : int -> Async<string>
getTestNumber : unit -> Async<string>
}

type ISwateJsonAPIv1 = {
Expand All @@ -74,16 +74,16 @@ type ISwateJsonAPIv1 = {
}

type IExportAPIv1 = {
toAssayXlsx : (string * OfficeInteropTypes.BuildingBlock []) [] -> Async<byte []>
toAssayXlsx : (string * OfficeInteropTypes.BuildingBlock []) [] -> Async<byte []>
}

/// <summary>Deprecated</summary>
type IOntologyAPIv1 = {
// Development
getTestNumber : unit -> Async<int>
getTestNumber : unit -> Async<int>

// Ontology related requests
getAllOntologies : unit -> Async<Ontology []>
getAllOntologies : unit -> Async<Ontology []>

// Term related requests
///
Expand All @@ -104,45 +104,43 @@ type IOntologyAPIv1 = {

type IOntologyAPIv2 = {
// Development
getTestNumber : unit -> Async<int>
getTestNumber : unit -> Async<int>

// Ontology related requests
getAllOntologies : unit -> Async<Ontology []>
getAllOntologies : unit -> Async<Ontology []>

// Term related requests
///
getTermSuggestions : {| n: int; query: string; ontology: string option|} -> Async<Term []>
getTermSuggestions : {| n: int; query: string; ontology: string option|} -> Async<Term []>
/// (nOfReturnedResults*queryString*parentOntology). If parentOntology = "" then isNull -> Error.
getTermSuggestionsByParentTerm : {| n: int; query: string; parent_term: TermMinimal |} -> Async<Term []>
getAllTermsByParentTerm : TermMinimal -> Async<Term []>
getTermSuggestionsByParentTerm : {| n: int; query: string; parent_term: TermMinimal |} -> Async<Term []>
getAllTermsByParentTerm : TermMinimal -> Async<Term []>
/// (nOfReturnedResults*queryString*parentOntology). If parentOntology = "" then isNull -> Error.
getTermSuggestionsByChildTerm : {| n: int; query: string; child_term: TermMinimal |} -> Async<Term []>
getAllTermsByChildTerm : TermMinimal -> Async<Term []>
getTermsForAdvancedSearch : (AdvancedSearchTypes.AdvancedSearchOptions) -> Async<Term []>
getTermSuggestionsByChildTerm : {| n: int; query: string; child_term: TermMinimal |} -> Async<Term []>
getAllTermsByChildTerm : TermMinimal -> Async<Term []>
getTermsForAdvancedSearch : (AdvancedSearchTypes.AdvancedSearchOptions) -> Async<Term []>
getUnitTermSuggestions : {| n: int; query: string|} -> Async<Term []>
getTermsByNames : TermSearchable [] -> Async<TermSearchable []>
getTermsByNames : TermSearchable [] -> Async<TermSearchable []>

// Tree related requests
getTreeByAccession : string -> Async<TreeTypes.Tree>
getTreeByAccession : string -> Async<TreeTypes.Tree>
}

type IOntologyAPIv3 = {
// Development
getTestNumber :
unit -> Async<int>
searchTerms:
{| limit: int; query: string; ontologies: string list |} -> Async<Term []>
{| limit: int; query: string; ontologies: string list |} -> Async<Term []>
/// ontologies currently unused
searchTermsByParent:
{| limit: int; query: string; parentTAN: string |} -> Async<Term []>
{| limit: int; query: string; parentTAN: string |} -> Async<Term []>
getTermById:
string -> Async<Term option>
string -> Async<Term option>
}

type ITemplateAPIv1 = {
// must return template as string, fable remoting cannot do conversion automatically
getTemplates : unit -> Async<string>
getTemplateById : string -> Async<string>
}


0 comments on commit 57f58bc

Please sign in to comment.