diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b9b06cea..a4ddebef 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -7,6 +7,12 @@ "commands": [ "fable" ] + }, + "paket": { + "version": "7.2.1", + "commands": [ + "paket" + ] } } } \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6167018c..b21a6086 100644 --- a/.gitignore +++ b/.gitignore @@ -349,9 +349,11 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ +#Paket dependency manager +paket-files/ # Custom ignored files -pkg/ +dist/ tmp/ /tests/FileSystem/FileSystem.Tests/js /tests/ISA/ISA.Json.Tests/js @@ -361,3 +363,4 @@ tmp/ /tests/Python/ARCtrl /tests/ARCtrl/js /tests/FileSystem/js + diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets new file mode 100644 index 00000000..4deb15bc --- /dev/null +++ b/.paket/Paket.Restore.targets @@ -0,0 +1,557 @@ + + + + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + $(MSBuildVersion) + 15.0.0 + false + true + + true + $(MSBuildThisFileDirectory) + $(MSBuildThisFileDirectory)..\ + $(PaketRootPath)paket-files\paket.restore.cached + $(PaketRootPath)paket.lock + classic + proj + assembly + native + /Library/Frameworks/Mono.framework/Commands/mono + mono + + + $(PaketRootPath)paket.bootstrapper.exe + $(PaketToolsPath)paket.bootstrapper.exe + $([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\ + + "$(PaketBootStrapperExePath)" + $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)" + + + + + true + true + + + True + + + False + + $(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/')) + + + + + + + + + $(PaketRootPath)paket + $(PaketToolsPath)paket + + + + + + $(PaketRootPath)paket.exe + $(PaketToolsPath)paket.exe + + + + + + <_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json")) + <_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"')) + <_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false + + + + + + + + + + + <_PaketCommand>dotnet paket + + + + + + $(PaketToolsPath)paket + $(PaketBootStrapperExeDir)paket + + + paket + + + + + <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)")) + <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)" + <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)" + <_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)" + + + + + + + + + + + + + + + + + + + + + true + $(NoWarn);NU1603;NU1604;NU1605;NU1608 + false + true + + + + + + + + + $([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)')) + + + + + + + $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``)) + $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``)) + + + + + %(PaketRestoreCachedKeyValue.Value) + %(PaketRestoreCachedKeyValue.Value) + + + + + true + false + true + + + + + true + + + + + + + + + + + + + + + + + + + $(PaketIntermediateOutputPath)\$(MSBuildProjectFile).paket.references.cached + + $(MSBuildProjectFullPath).paket.references + + $(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references + + $(MSBuildProjectDirectory)\paket.references + + false + true + true + references-file-or-cache-not-found + + + + + $([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)')) + $([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)')) + references-file + false + + + + + false + + + + + true + target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths) + + + + + + + + + + + false + true + + + + + + + + + + + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7]) + + + %(PaketReferencesFileLinesInfo.PackageVersion) + All + runtime + $(ExcludeAssets);contentFiles + $(ExcludeAssets);build;buildMultitargeting;buildTransitive + true + true + + + + + $(PaketIntermediateOutputPath)/$(MSBuildProjectFile).paket.clitools + + + + + + + + + $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[0]) + $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[1]) + + + %(PaketCliToolFileLinesInfo.PackageVersion) + + + + + + + + + + false + + + + + + <_NuspecFilesNewLocation Include="$(PaketIntermediateOutputPath)\$(Configuration)\*.nuspec"/> + + + + + + $(MSBuildProjectDirectory)/$(MSBuildProjectFile) + true + false + true + false + true + false + true + false + true + false + true + $(PaketIntermediateOutputPath)\$(Configuration) + $(PaketIntermediateOutputPath) + + + + <_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.$(PackageVersion.Split(`+`)[0]).nuspec"/> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ARCtrl.sln b/ARCtrl.sln index 8c608dcc..8ceaef60 100644 --- a/ARCtrl.sln +++ b/ARCtrl.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .config\dotnet-tools.json = .config\dotnet-tools.json global.json = global.json package.json = package.json + paket.dependencies = paket.dependencies README.md = README.md RELEASE_NOTES.md = RELEASE_NOTES.md EndProjectSection @@ -20,63 +21,12 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCtrl.CWL", "src\CWL\ARCtr EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCtrl.FileSystem", "src\FileSystem\ARCtrl.FileSystem.fsproj", "{F47E23C3-8415-4725-9E85-57271694DEB3}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "js", "js", "{A3669129-8963-4F6E-A1D6-C691555EF125}" - ProjectSection(SolutionItems) = preProject - js\ARC.js = js\ARC.js - js\ARCPath.js = js\ARCPath.js - js\ARCStrich.js = js\ARCStrich.js - test.js = test.js - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ts", "ts", "{DB179B36-D77B-4340-A6AB-0C9F52882624}" - ProjectSection(SolutionItems) = preProject - ts\ARC.ts = ts\ARC.ts - ts\ARCPath.ts = ts\ARCPath.ts - ts\ARCStrich.ts = ts\ARCStrich.ts - ts\test.ts = ts\test.ts - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CWL", "CWL", "{D55C23D0-6A31-4727-850C-4BE604EE3A25}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FileSystem", "FileSystem", "{6A68446C-46F7-4DEB-BBD1-EE2CBB696EE2}" - ProjectSection(SolutionItems) = preProject - js\FileSystem\Commit.js = js\FileSystem\Commit.js - js\FileSystem\FileSystem.js = js\FileSystem\FileSystem.js - js\FileSystem\FileSystemTree.js = js\FileSystem\FileSystemTree.js - js\FileSystem\Path.js = js\FileSystem\Path.js - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISA", "ISA", "{A4B8D64B-8B9A-4BEC-B56E-7B5E0DE4F823}" - ProjectSection(SolutionItems) = preProject - js\ISA\Assay.js = js\ISA\Assay.js - js\ISA\Investigation.js = js\ISA\Investigation.js - js\ISA\Study.js = js\ISA\Study.js - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISA", "ISA", "{C3E09F95-660E-49B9-AE59-979BA3E347B8}" - ProjectSection(SolutionItems) = preProject - ts\ISA\Assay.ts = ts\ISA\Assay.ts - ts\ISA\Investigation.ts = ts\ISA\Investigation.ts - ts\ISA\Study.ts = ts\ISA\Study.ts - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CWL", "CWL", "{8C99A701-CC88-4710-94BD-38843B437621}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FileSystem", "FileSystem", "{49B4F154-3E60-4FAD-9924-9409DAA5DCD6}" - ProjectSection(SolutionItems) = preProject - ts\FileSystem\Commit.ts = ts\FileSystem\Commit.ts - ts\FileSystem\FileSystem.ts = ts\FileSystem\FileSystem.ts - ts\FileSystem\FileSystemTree.ts = ts\FileSystem\FileSystemTree.ts - ts\FileSystem\Path.ts = ts\FileSystem\Path.ts - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6DA2330B-D407-4FB1-AF05-B0184034EC44}" EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Build", "build\Build.fsproj", "{5EAFB0CD-1168-4FCA-AA61-E96AD6C85819}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISA", "ISA", "{C61B3F43-2255-4585-9110-F8AB74F02654}" ProjectSection(SolutionItems) = preProject - src\ISA\ISA\ArcTypes\ArcInvestigation.fs = src\ISA\ISA\ArcTypes\ArcInvestigation.fs src\ISA\package.json = src\ISA\package.json src\ISA\README.md = src\ISA\README.md EndProjectSection @@ -97,10 +47,6 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCtrl.ISA.Spreadsheet", "s EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ISA.Spreadsheet.Tests", "tests\ISA\ISA.Spreadsheet.Tests\ISA.Spreadsheet.Tests.fsproj", "{656E8DAF-EFCF-472E-91D0-987D09B74523}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FileSystem", "FileSystem", "{E36B41EF-DD2A-45EB-912C-E637BBDBFDDE}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FileSystem.Tests", "tests\FileSystem\FileSystem.Tests\FileSystem.Tests.fsproj", "{D7397A55-93AE-4165-9E2D-D83A52C22D41}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "playground", "playground", "{45E972BE-0BFA-4DE3-B84A-D9F13C4E9D08}" ProjectSection(SolutionItems) = preProject playground\KevinF.fsx = playground\KevinF.fsx @@ -109,6 +55,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "playground", "playground", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "JavaScript", "JavaScript", "{913222CA-261F-49CB-A823-CC7C335F964A}" ProjectSection(SolutionItems) = preProject + tests\JavaScript\ISA.Person.js = tests\JavaScript\ISA.Person.js tests\JavaScript\Main.js = tests\JavaScript\Main.js EndProjectSection EndProject @@ -118,6 +65,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCtrl.Tests", "tests\ARCtr EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCtrl.Contract", "src\Contract\ARCtrl.Contract.fsproj", "{1945EE8A-F105-43A9-91C9-8C4422B9873E}" EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FileSystem.Tests", "tests\FileSystem\FileSystem.Tests.fsproj", "{D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -160,10 +109,6 @@ Global {656E8DAF-EFCF-472E-91D0-987D09B74523}.Debug|Any CPU.Build.0 = Debug|Any CPU {656E8DAF-EFCF-472E-91D0-987D09B74523}.Release|Any CPU.ActiveCfg = Release|Any CPU {656E8DAF-EFCF-472E-91D0-987D09B74523}.Release|Any CPU.Build.0 = Release|Any CPU - {D7397A55-93AE-4165-9E2D-D83A52C22D41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7397A55-93AE-4165-9E2D-D83A52C22D41}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7397A55-93AE-4165-9E2D-D83A52C22D41}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D7397A55-93AE-4165-9E2D-D83A52C22D41}.Release|Any CPU.Build.0 = Release|Any CPU {9BE5D83D-EA90-4382-A132-174FD158227F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9BE5D83D-EA90-4382-A132-174FD158227F}.Debug|Any CPU.Build.0 = Debug|Any CPU {9BE5D83D-EA90-4382-A132-174FD158227F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -176,6 +121,10 @@ Global {1945EE8A-F105-43A9-91C9-8C4422B9873E}.Debug|Any CPU.Build.0 = Debug|Any CPU {1945EE8A-F105-43A9-91C9-8C4422B9873E}.Release|Any CPU.ActiveCfg = Release|Any CPU {1945EE8A-F105-43A9-91C9-8C4422B9873E}.Release|Any CPU.Build.0 = Release|Any CPU + {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -183,12 +132,6 @@ Global GlobalSection(NestedProjects) = preSolution {1CD34A01-D19A-441F-8F3D-6EF69D9DDA8D} = {6DA2330B-D407-4FB1-AF05-B0184034EC44} {F47E23C3-8415-4725-9E85-57271694DEB3} = {6DA2330B-D407-4FB1-AF05-B0184034EC44} - {D55C23D0-6A31-4727-850C-4BE604EE3A25} = {A3669129-8963-4F6E-A1D6-C691555EF125} - {6A68446C-46F7-4DEB-BBD1-EE2CBB696EE2} = {A3669129-8963-4F6E-A1D6-C691555EF125} - {A4B8D64B-8B9A-4BEC-B56E-7B5E0DE4F823} = {A3669129-8963-4F6E-A1D6-C691555EF125} - {C3E09F95-660E-49B9-AE59-979BA3E347B8} = {DB179B36-D77B-4340-A6AB-0C9F52882624} - {8C99A701-CC88-4710-94BD-38843B437621} = {DB179B36-D77B-4340-A6AB-0C9F52882624} - {49B4F154-3E60-4FAD-9924-9409DAA5DCD6} = {DB179B36-D77B-4340-A6AB-0C9F52882624} {C61B3F43-2255-4585-9110-F8AB74F02654} = {6DA2330B-D407-4FB1-AF05-B0184034EC44} {67CF6725-6AC0-47FB-A725-6DC2192713B5} = {C61B3F43-2255-4585-9110-F8AB74F02654} {2CA397B2-0220-49A3-AD79-2F9F53633EC1} = {C61B3F43-2255-4585-9110-F8AB74F02654} @@ -197,12 +140,11 @@ Global {04789F17-3DC2-4A09-848D-376E5D269740} = {D1BBD7AE-35C8-498F-BABA-C93FFAE68037} {07C7942E-FC34-4C27-82C1-6B2972654BA7} = {C61B3F43-2255-4585-9110-F8AB74F02654} {656E8DAF-EFCF-472E-91D0-987D09B74523} = {D1BBD7AE-35C8-498F-BABA-C93FFAE68037} - {E36B41EF-DD2A-45EB-912C-E637BBDBFDDE} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38} - {D7397A55-93AE-4165-9E2D-D83A52C22D41} = {E36B41EF-DD2A-45EB-912C-E637BBDBFDDE} {913222CA-261F-49CB-A823-CC7C335F964A} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38} {9BE5D83D-EA90-4382-A132-174FD158227F} = {6DA2330B-D407-4FB1-AF05-B0184034EC44} {801247D5-7EE5-49C8-AB26-F822A415BA49} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38} {1945EE8A-F105-43A9-91C9-8C4422B9873E} = {6DA2330B-D407-4FB1-AF05-B0184034EC44} + {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1E354DE6-99BA-421E-9EF8-E808B855A85F} diff --git a/README.md b/README.md index 20fad725..2f41e7a2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ARCtrl +# ARCtrl Top level ARC DataModel and API function descriptions. - [ARCtrl](#arctrl) @@ -14,7 +14,7 @@ Top level ARC DataModel and API function descriptions. [ISA README.md](src/ISA/README.md) :books: -[Contracts README.md](src/ArcContract/README.md) :books: +[Contracts README.md](src/Contract/README.md) :books: # Jargon/Nomenclature @@ -265,3 +265,13 @@ export class Study extends Record implements IEquatable, IComparable Shell.cleanDirs } diff --git a/build/Build.fsproj b/build/Build.fsproj index 7f32a29b..202222b5 100644 --- a/build/Build.fsproj +++ b/build/Build.fsproj @@ -1,11 +1,11 @@ - - + + net6.0 Exe - + @@ -16,7 +16,6 @@ - @@ -27,7 +26,7 @@ - + - - + + \ No newline at end of file diff --git a/build/PackageTasks.fs b/build/PackageTasks.fs index d2da8e96..c72c4f56 100644 --- a/build/PackageTasks.fs +++ b/build/PackageTasks.fs @@ -17,7 +17,7 @@ let private replaceCommitLink input = let commitLinkPattern = @"\[\[#[a-z0-9]*\]\(.*\)\] " Regex.Replace(input,commitLinkPattern,"") -let pack = BuildTask.create "Pack" [clean; build; (*runTests*)] { +let pack = BuildTask.create "Pack" [clean; build; runTests] { if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag ) then !! "src/**/*.*proj" @@ -39,7 +39,7 @@ let pack = BuildTask.create "Pack" [clean; build; (*runTests*)] { else failwith "aborted" } -let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean; build; runTests] { +let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean; build; (*runTests*)] { if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag ) then !! "src/**/*.*proj" diff --git a/build/ProjectInfo.fs b/build/ProjectInfo.fs index fff0d93c..553c5c0b 100644 --- a/build/ProjectInfo.fs +++ b/build/ProjectInfo.fs @@ -9,7 +9,7 @@ let testProjects = "tests/ISA/ISA.Tests" "tests/ISA/ISA.Json.Tests" "tests/ISA/ISA.Spreadsheet.Tests" - "tests/FileSystem/FileSystem.Tests" + "tests/FileSystem" ] let solutionFile = $"{project}.sln" @@ -22,7 +22,7 @@ let gitHome = $"https://github.com/{gitOwner}" let projectRepo = $"https://github.com/{gitOwner}/{project}" -let pkgDir = "pkg" +let pkgDir = "dist/pkg" // Create RELEASE_NOTES.md if not existing. Or "release" would throw an error. Fake.Extensions.Release.ReleaseNotes.ensure() diff --git a/build/ReleaseTasks.fs b/build/ReleaseTasks.fs index 31488c86..6add80f6 100644 --- a/build/ReleaseTasks.fs +++ b/build/ReleaseTasks.fs @@ -22,7 +22,7 @@ let createTag = BuildTask.create "CreateTag" [clean; build; runTests; pack] { failwith "aborted" } -let createPrereleaseTag = BuildTask.create "CreatePrereleaseTag" [setPrereleaseTag; clean; build; runTests; packPrerelease] { +let createPrereleaseTag = BuildTask.create "CreatePrereleaseTag" [setPrereleaseTag; clean; build (*runTests*); packPrerelease] { if promptYesNo (sprintf "tagging branch with %s OK?" prereleaseTag ) then Git.Branches.tag "" prereleaseTag Git.Branches.pushTag "" projectRepo prereleaseTag diff --git a/build/TestTasks.fs b/build/TestTasks.fs index 7062c906..eb67904a 100644 --- a/build/TestTasks.fs +++ b/build/TestTasks.fs @@ -114,7 +114,7 @@ module RunTests = run npm "run testJson" "" run npm "run testSpreadsheet" "" run npm "run testFS" "" - run npm "run testJavaScript" "" + run npm "run testjs" "" } let runTestsDotnet = BuildTask.create "runTestsDotnet" [clean; build] { diff --git a/build/paket.references b/build/paket.references new file mode 100644 index 00000000..640cf914 --- /dev/null +++ b/build/paket.references @@ -0,0 +1 @@ +FSharp.Core \ No newline at end of file diff --git a/js/ARCtrl.js b/js/ARCtrl.js deleted file mode 100644 index f70f7c7d..00000000 --- a/js/ARCtrl.js +++ /dev/null @@ -1,102 +0,0 @@ -import { tryFind, exactlyOne, choose, map } from "./fable_modules/fable-library.4.1.4/Array.js"; -import { fromFsWorkbook } from "./ISA/ISA.Spreadsheet/ArcAssay.js"; -import { tryFromContract } from "./Contracts/Contracts.ArcAssay.js"; -import { fromFsWorkbook as fromFsWorkbook_1 } from "./ISA/ISA.Spreadsheet/ArcStudy.js"; -import { tryFromContract as tryFromContract_1 } from "./Contracts/Contracts.ArcStudy.js"; -import { fromFsWorkbook as fromFsWorkbook_2 } from "./ISA/ISA.Spreadsheet/InvestigationFile/Investigation.js"; -import { tryFromContract as tryFromContract_2 } from "./Contracts/Contracts.ArcInvestigation.js"; -import { FileSystem_$reflection, FileSystem as FileSystem_1 } from "./FileSystem/FileSystem.js"; -import { tryISAReadContractFromPath } from "./Contracts/Contracts.ARCtrl.js"; -import { defaultArg } from "./fable_modules/fable-library.4.1.4/Option.js"; -import { iterate } from "./fable_modules/fable-library.4.1.4/Seq.js"; -import { printf, toConsole } from "./fable_modules/fable-library.4.1.4/String.js"; -import { Record } from "./fable_modules/fable-library.4.1.4/Types.js"; -import { ArcInvestigation_$reflection } from "./ISA/ISA/ArcTypes/ArcInvestigation.js"; -import { record_type, unit_type, option_type } from "./fable_modules/fable-library.4.1.4/Reflection.js"; - -export function ARCAux_getArcAssaysFromContracts(contracts) { - return map(fromFsWorkbook, choose(tryFromContract, contracts)); -} - -export function ARCAux_getArcStudiesFromContracts(contracts) { - return map(fromFsWorkbook_1, choose(tryFromContract_1, contracts)); -} - -export function ARCAux_getArcInvestigationFromContracts(contracts) { - return fromFsWorkbook_2(exactlyOne(choose(tryFromContract_2, contracts))); -} - -export class ARC extends Record { - constructor(ISA, CWL, FileSystem) { - super(); - this.ISA = ISA; - this.CWL = CWL; - this.FileSystem = FileSystem; - } - static create(isa, cwl, fs) { - return new ARC(isa, cwl, fs); - } - static fromFilePaths(filePaths) { - const fs = FileSystem_1.fromFilePaths(filePaths); - return ARC.create(void 0, void 0, fs); - } - addFSFromFilePaths(filePaths) { - const this$ = this; - return new ARC(this$.ISA, this$.CWL, FileSystem_1.fromFilePaths(filePaths)); - } - getReadContracts() { - const this$ = this; - const matchValue = this$.FileSystem; - if (matchValue == null) { - throw new Error("Cannot create READ contracts from ARC without FileSystem.\r\n\r\nYou could initialized your ARC with `ARC.fromFilePaths` or run `yourArc.addFSFromFilePaths` to avoid this issue."); - } - else { - const fs = matchValue; - return choose(tryISAReadContractFromPath, fs.Tree.ToFilePaths()); - } - } - addISAFromContracts(contracts, enableLogging) { - const this$ = this; - const enableLogging_1 = defaultArg(enableLogging, false); - const investigation = ARCAux_getArcInvestigationFromContracts(contracts); - const studies = ARCAux_getArcStudiesFromContracts(contracts); - const assays = ARCAux_getArcAssaysFromContracts(contracts); - const copy = investigation.Copy(); - iterate((studyRegisteredIdent) => { - const studyOpt = tryFind((s) => (s.Identifier === studyRegisteredIdent), studies); - if (studyOpt == null) { - if (enableLogging_1) { - toConsole(printf("Unable to find registered study \'%s\' in fullfilled READ contracts!"))(studyRegisteredIdent); - } - } - else { - const study = studyOpt; - if (enableLogging_1) { - toConsole(printf("Found study: %s"))(studyRegisteredIdent); - } - iterate((assayRegisteredIdent) => { - const assayOpt = tryFind((a) => (a.Identifier === assayRegisteredIdent), assays); - if (assayOpt == null) { - if (enableLogging_1) { - toConsole(printf("Unable to find registered assay \'%s\' in fullfilled READ contracts!"))(assayRegisteredIdent); - } - } - else { - const assay = assayOpt; - if (enableLogging_1) { - toConsole(printf("Found assay: %s - %s"))(studyRegisteredIdent)(assayRegisteredIdent); - } - study.AddAssay(assay); - } - }, copy.GetStudy(studyRegisteredIdent).AssayIdentifiers); - investigation.SetStudy(studyRegisteredIdent, study); - } - }, copy.StudyIdentifiers); - return new ARC(investigation, this$.CWL, this$.FileSystem); - } -} - -export function ARC_$reflection() { - return record_type("ARCtrl.ARC", [], ARC, () => [["ISA", option_type(ArcInvestigation_$reflection())], ["CWL", option_type(unit_type)], ["FileSystem", option_type(FileSystem_$reflection())]]); -} - diff --git a/js/Contract/Contract.js b/js/Contract/Contract.js deleted file mode 100644 index f9e4c468..00000000 --- a/js/Contract/Contract.js +++ /dev/null @@ -1,51 +0,0 @@ -import { Record } from "../fable_modules/fable-library.4.1.4/Types.js"; -import { class_type, option_type, record_type, array_type, string_type } from "../fable_modules/fable-library.4.1.4/Reflection.js"; -import { defaultArg } from "../fable_modules/fable-library.4.1.4/Option.js"; - -export class CLITool extends Record { - constructor(Name, Arguments) { - super(); - this.Name = Name; - this.Arguments = Arguments; - } - static create(name, arguments$) { - return new CLITool(name, arguments$); - } -} - -export function CLITool_$reflection() { - return record_type("Contract.CLITool", [], CLITool, () => [["Name", string_type], ["Arguments", array_type(string_type)]]); -} - -export class Contract extends Record { - constructor(Operation, Path, DTOType, DTO) { - super(); - this.Operation = Operation; - this.Path = Path; - this.DTOType = DTOType; - this.DTO = DTO; - } - static create(op, path, { dtoType, dto }) { - return new Contract(op, path, dtoType, dto); - } - static createCreate(path, dtoType, dto) { - return new Contract("CREATE", path, dtoType, dto); - } - static createUpdate(path, dtoType, dto) { - return new Contract("UPDATE", path, dtoType, dto); - } - static createDelete(path) { - return new Contract("DELETE", path, void 0, void 0); - } - static createRead(path, dtoType) { - return new Contract("READ", path, dtoType, void 0); - } - static createExecute(dto, { path }) { - return new Contract("EXECUTE", defaultArg(path, ""), "Cli", dto); - } -} - -export function Contract_$reflection() { - return record_type("Contract.Contract", [], Contract, () => [["Operation", string_type], ["Path", string_type], ["DTOType", option_type(string_type)], ["DTO", option_type(class_type("Contract.DTO"))]]); -} - diff --git a/js/Contracts/Contracts.ARCtrl.js b/js/Contracts/Contracts.ARCtrl.js deleted file mode 100644 index 6e6a0beb..00000000 --- a/js/Contracts/Contracts.ARCtrl.js +++ /dev/null @@ -1,35 +0,0 @@ -import { split as split_1 } from "../FileSystem/Path.js"; -import { $007CInvestigationPath$007C_$007C } from "./Contracts.ArcInvestigation.js"; -import { Contract } from "../Contract/Contract.js"; -import { $007CAssayPath$007C_$007C } from "./Contracts.ArcAssay.js"; -import { $007CStudyPath$007C_$007C } from "./Contracts.ArcStudy.js"; - -/** - * Tries to create READ contract with DTOType = ISA_Assay, ISA_Study or ISA_Investigation from given path relative to ARC root. - */ -export function tryISAReadContractFromPath(path) { - const split = split_1(path); - const activePatternResult = $007CInvestigationPath$007C_$007C(split); - if (activePatternResult != null) { - const p = activePatternResult; - return Contract.createRead(p, "ISA_Investigation"); - } - else { - const activePatternResult_1 = $007CAssayPath$007C_$007C(split); - if (activePatternResult_1 != null) { - const p_1 = activePatternResult_1; - return Contract.createRead(p_1, "ISA_Assay"); - } - else { - const activePatternResult_2 = $007CStudyPath$007C_$007C(split); - if (activePatternResult_2 != null) { - const p_2 = activePatternResult_2; - return Contract.createRead(p_2, "ISA_Study"); - } - else { - return void 0; - } - } - } -} - diff --git a/js/Contracts/Contracts.ArcAssay.js b/js/Contracts/Contracts.ArcAssay.js deleted file mode 100644 index 776ce097..00000000 --- a/js/Contracts/Contracts.ArcAssay.js +++ /dev/null @@ -1,70 +0,0 @@ -import { FsWorkbook } from "../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; -import { combineMany } from "../FileSystem/Path.js"; -import { equalsWith } from "../fable_modules/fable-library.4.1.4/Array.js"; -import { defaultOf } from "../fable_modules/fable-library.4.1.4/Util.js"; - -export function tryFromContract(c) { - let matchResult, fsworkbook; - if (c.Operation === "READ") { - if (c.DTOType != null) { - if (c.DTOType === "ISA_Assay") { - if (c.DTO != null) { - if (c.DTO instanceof FsWorkbook) { - matchResult = 0; - fsworkbook = c.DTO; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return fsworkbook; - default: - return void 0; - } -} - -export function $007CAssayPath$007C_$007C(input) { - let matchResult; - if (!equalsWith((x, y) => (x === y), input, defaultOf()) && (input.length === 3)) { - if (input[0] === "assays") { - if (input[2] === "isa.assay.xlsx") { - matchResult = 0; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: { - const anyAssayName = input[1]; - return combineMany(input); - } - default: - return void 0; - } -} - diff --git a/js/Contracts/Contracts.ArcInvestigation.js b/js/Contracts/Contracts.ArcInvestigation.js deleted file mode 100644 index 40630567..00000000 --- a/js/Contracts/Contracts.ArcInvestigation.js +++ /dev/null @@ -1,63 +0,0 @@ -import { FsWorkbook } from "../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; -import { combineMany } from "../FileSystem/Path.js"; -import { equalsWith } from "../fable_modules/fable-library.4.1.4/Array.js"; -import { defaultOf } from "../fable_modules/fable-library.4.1.4/Util.js"; - -export function tryFromContract(c) { - let matchResult, fsworkbook; - if (c.Operation === "READ") { - if (c.DTOType != null) { - if (c.DTOType === "ISA_Investigation") { - if (c.DTO != null) { - if (c.DTO instanceof FsWorkbook) { - matchResult = 0; - fsworkbook = c.DTO; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return fsworkbook; - default: - return void 0; - } -} - -export function $007CInvestigationPath$007C_$007C(input) { - let matchResult; - if (!equalsWith((x, y) => (x === y), input, defaultOf()) && (input.length === 1)) { - if (input[0] === "isa.investigation.xlsx") { - matchResult = 0; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return combineMany(input); - default: - return void 0; - } -} - diff --git a/js/Contracts/Contracts.ArcStudy.js b/js/Contracts/Contracts.ArcStudy.js deleted file mode 100644 index 15da7b1d..00000000 --- a/js/Contracts/Contracts.ArcStudy.js +++ /dev/null @@ -1,70 +0,0 @@ -import { FsWorkbook } from "../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; -import { combineMany } from "../FileSystem/Path.js"; -import { equalsWith } from "../fable_modules/fable-library.4.1.4/Array.js"; -import { defaultOf } from "../fable_modules/fable-library.4.1.4/Util.js"; - -export function tryFromContract(c) { - let matchResult, fsworkbook; - if (c.Operation === "READ") { - if (c.DTOType != null) { - if (c.DTOType === "ISA_Study") { - if (c.DTO != null) { - if (c.DTO instanceof FsWorkbook) { - matchResult = 0; - fsworkbook = c.DTO; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return fsworkbook; - default: - return void 0; - } -} - -export function $007CStudyPath$007C_$007C(input) { - let matchResult; - if (!equalsWith((x, y) => (x === y), input, defaultOf()) && (input.length === 3)) { - if (input[0] === "studies") { - if (input[2] === "isa.study.xlsx") { - matchResult = 0; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: { - const anyStudyName = input[1]; - return combineMany(input); - } - default: - return void 0; - } -} - diff --git a/js/FileSystem/Commit.js b/js/FileSystem/Commit.js deleted file mode 100644 index d8e6d0cb..00000000 --- a/js/FileSystem/Commit.js +++ /dev/null @@ -1,18 +0,0 @@ -import { Record } from "../fable_modules/fable-library.4.1.4/Types.js"; -import { record_type, class_type, string_type } from "../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class Commit extends Record { - constructor(Hash, UserName, UserEmail, Date$, Message) { - super(); - this.Hash = Hash; - this.UserName = UserName; - this.UserEmail = UserEmail; - this.Date = Date$; - this.Message = Message; - } -} - -export function Commit_$reflection() { - return record_type("FileSystem.Commit", [], Commit, () => [["Hash", string_type], ["UserName", string_type], ["UserEmail", string_type], ["Date", class_type("System.DateTime")], ["Message", string_type]]); -} - diff --git a/js/FileSystem/FileSystem.js b/js/FileSystem/FileSystem.js deleted file mode 100644 index 8d9bdb86..00000000 --- a/js/FileSystem/FileSystem.js +++ /dev/null @@ -1,34 +0,0 @@ -import { defaultArg } from "../fable_modules/fable-library.4.1.4/Option.js"; -import { FileSystemTree_$reflection, FileSystemTree } from "./FileSystemTree.js"; -import { Record } from "../fable_modules/fable-library.4.1.4/Types.js"; -import { Commit_$reflection } from "./Commit.js"; -import { record_type, array_type } from "../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class FileSystem extends Record { - constructor(Tree, History) { - super(); - this.Tree = Tree; - this.History = History; - } - static create({ tree, history }) { - return new FileSystem(tree, defaultArg(history, [])); - } - AddFile(path) { - const this$ = this; - return new FileSystem(this$.Tree.AddFile(path), this$.History); - } - static addFile(path) { - return (fs) => fs.AddFile(path); - } - static fromFilePaths(paths) { - const tree = FileSystemTree.fromFilePaths(paths); - return FileSystem.create({ - tree: tree, - }); - } -} - -export function FileSystem_$reflection() { - return record_type("FileSystem.FileSystem", [], FileSystem, () => [["Tree", FileSystemTree_$reflection()], ["History", array_type(Commit_$reflection())]]); -} - diff --git a/js/FileSystem/FileSystemTree.js b/js/FileSystem/FileSystemTree.js deleted file mode 100644 index aa2bc50f..00000000 --- a/js/FileSystem/FileSystemTree.js +++ /dev/null @@ -1,145 +0,0 @@ -import { unwrap, defaultArg } from "../fable_modules/fable-library.4.1.4/Option.js"; -import { singleton, append, delay, toArray } from "../fable_modules/fable-library.4.1.4/Seq.js"; -import { choose, equalsWith, tail, head, map } from "../fable_modules/fable-library.4.1.4/Array.js"; -import { Array_distinct, Array_groupBy } from "../fable_modules/fable-library.4.1.4/Seq2.js"; -import { curry2, arrayHash, stringHash } from "../fable_modules/fable-library.4.1.4/Util.js"; -import { combineMany, split } from "./Path.js"; -import { empty, reverse, toArray as toArray_1, cons } from "../fable_modules/fable-library.4.1.4/List.js"; -import { Union } from "../fable_modules/fable-library.4.1.4/Types.js"; -import { union_type, array_type, string_type } from "../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class FileSystemTree extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["File", "Folder"]; - } - get Name() { - const this$ = this; - let n; - if (this$.tag === 1) { - n = this$.fields[0]; - } - else { - n = this$.fields[0]; - } - return n; - } - get isFolder() { - const this$ = this; - return this$.tag === 1; - } - get isFile() { - const this$ = this; - return this$.tag === 0; - } - static get ROOT_NAME() { - return "root"; - } - static createFile(name) { - return new FileSystemTree(0, [name]); - } - static createFolder(name, children) { - return new FileSystemTree(1, [name, defaultArg(children, [])]); - } - AddFile(path) { - const this$ = this; - const existingPaths = this$.ToFilePaths(); - const filePaths = toArray(delay(() => append(singleton(path), delay(() => existingPaths)))); - return FileSystemTree.fromFilePaths(filePaths); - } - static addFile(path) { - return (tree) => tree.AddFile(path); - } - static fromFilePaths(paths) { - const loop = (paths_1, parent) => { - const files = map((arg_1) => { - const arg = head(arg_1); - return FileSystemTree.createFile(arg); - }, paths_1.filter((p) => (p.length === 1))); - const folders = map((tupledArg) => { - const parent_1 = FileSystemTree.createFolder(tupledArg[0], []); - return loop(map(tail, tupledArg[1]), parent_1); - }, Array_groupBy(head, paths_1.filter((p_1) => (p_1.length > 1)), { - Equals: (x_3, y_2) => (x_3 === y_2), - GetHashCode: stringHash, - })); - if (parent.tag === 1) { - return FileSystemTree.createFolder(parent.fields[0], toArray(delay(() => append(files, delay(() => folders))))); - } - else { - return parent; - } - }; - return loop(Array_distinct(map(split, paths), { - Equals: (x, y) => equalsWith((x_1, y_1) => (x_1 === y_1), x, y), - GetHashCode: arrayHash, - }), FileSystemTree.createFolder(FileSystemTree.ROOT_NAME, [])); - } - ToFilePaths(removeRoot) { - const this$ = this; - const res = []; - const loop = (output, parent) => { - if (parent.tag === 1) { - parent.fields[1].forEach((filest) => { - loop(cons(parent.fields[0], output), filest); - }); - } - else { - const arg = combineMany(toArray_1(reverse(cons(parent.fields[0], output)))); - void (res.push(arg)); - } - }; - if (defaultArg(removeRoot, true)) { - if (this$.tag === 0) { - void (res.push(this$.fields[0])); - } - else { - const action_1 = curry2(loop)(empty()); - this$.fields[1].forEach(action_1); - } - } - else { - loop(empty(), this$); - } - return Array.from(res); - } - static toFilePaths(removeRoot) { - return (root) => root.ToFilePaths(unwrap(removeRoot)); - } - Filter(predicate) { - const this$ = this; - const loop = (parent) => { - if (parent.tag === 1) { - const filteredChildren = choose(loop, parent.fields[1]); - if (filteredChildren.length === 0) { - return void 0; - } - else { - return new FileSystemTree(1, [parent.fields[0], filteredChildren]); - } - } - else { - const n = parent.fields[0]; - if (predicate(n)) { - return new FileSystemTree(0, [n]); - } - else { - return void 0; - } - } - }; - return loop(this$); - } - static filter(predicate) { - return (tree) => tree.Filter(predicate); - } -} - -export function FileSystemTree_$reflection() { - return union_type("FileSystem.FileSystemTree", [], FileSystemTree, () => [[["name", string_type]], [["name", string_type], ["children", array_type(FileSystemTree_$reflection())]]]); -} - diff --git a/js/FileSystem/Path.js b/js/FileSystem/Path.js deleted file mode 100644 index 5558d04f..00000000 --- a/js/FileSystem/Path.js +++ /dev/null @@ -1,38 +0,0 @@ -import { trim, join, trimStart, trimEnd, split as split_1 } from "../fable_modules/fable-library.4.1.4/String.js"; -import { last, mapIndexed } from "../fable_modules/fable-library.4.1.4/Array.js"; - -export const seperators = ["/", "\\"]; - -export function split(path) { - return split_1(path, seperators, void 0, 3); -} - -export function combine(path1, path2) { - return (trimEnd(path1, ...seperators) + "/") + trimStart(path2, ...seperators); -} - -export function combineMany(paths) { - return join("/", mapIndexed((i, p) => { - if (i === 0) { - return trimEnd(p, ...seperators); - } - else if (i === (paths.length - 1)) { - return trimStart(p, ...seperators); - } - else { - return trim(p, ...seperators); - } - }, paths)); -} - -export function getFileName(path) { - return last(split(path)); -} - -/** - * Checks if `path` points to a file with the name `fileName` - */ -export function isFile(fileName, path) { - return getFileName(path) === fileName; -} - diff --git a/js/ISA/ISA.Json/Assay.js b/js/ISA/ISA.Json/Assay.js deleted file mode 100644 index 56eaa72a..00000000 --- a/js/ISA/ISA.Json/Assay.js +++ /dev/null @@ -1,123 +0,0 @@ -import { toString, nil, object as object_22 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { ofArray, choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { tryInclude } from "./GEncode.js"; -import { Data_decoder, Data_encoder, Sample_decoder, Sample_encoder } from "./Data.js"; -import { MaterialAttribute_decoder, MaterialAttribute_encoder, Material_decoder, Material_encoder } from "./Material.js"; -import { string, list as list_1, object as object_23 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { AssayMaterials } from "../ISA/JsonTypes/AssayMaterials.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { Process_decoder, Process_encoder } from "./Process.js"; -import { decoder as decoder_5, encoder } from "./Comment.js"; -import { fromString, uri } from "./Decode.js"; -import { Assay } from "../ISA/JsonTypes/Assay.js"; -import { ArcAssay } from "../ISA/ArcTypes/ArcAssay.js"; - -export function AssayMaterials_encoder(options, oa) { - return object_22(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, ofArray([tryInclude("samples", (oa_1) => Sample_encoder(options, oa_1), oa["Samples"]), tryInclude("otherMaterials", (oa_2) => Material_encoder(options, oa_2), oa["OtherMaterials"])]))); -} - -export function AssayMaterials_decoder(options) { - return (path_2) => ((v) => object_23((get$) => { - let objectArg, objectArg_1; - return new AssayMaterials((objectArg = get$.Optional, objectArg.Field("samples", (path, value) => list_1((s, json) => Sample_decoder(options, s, json), path, value))), (objectArg_1 = get$.Optional, objectArg_1.Field("otherMaterials", (path_1, value_1) => list_1((s_1, json_1) => Material_decoder(options, s_1, json_1), path_1, value_1)))); - }, path_2, v)); -} - -export function Assay_genID(a) { - const matchValue = a.ID; - if (matchValue == null) { - const matchValue_1 = a.FileName; - if (matchValue_1 == null) { - return "#EmptyAssay"; - } - else { - return matchValue_1; - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function Assay_encoder(options, oa) { - return object_22(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Assay_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Assay", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("filename", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["FileName"])), delay(() => append(singleton(tryInclude("measurementType", (oa_1) => OntologyAnnotation_encoder(options, oa_1), oa["MeasurementType"])), delay(() => append(singleton(tryInclude("technologyType", (oa_2) => OntologyAnnotation_encoder(options, oa_2), oa["TechnologyType"])), delay(() => append(singleton(tryInclude("technologyPlatform", (value_10) => { - let s_4; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_4 = value_11, s_4)) : nil; - }, oa["TechnologyPlatform"])), delay(() => append(singleton(tryInclude("dataFiles", (oa_3) => Data_encoder(options, oa_3), oa["DataFiles"])), delay(() => append(singleton(tryInclude("materials", (oa_4) => AssayMaterials_encoder(options, oa_4), oa["Materials"])), delay(() => append(singleton(tryInclude("characteristicCategories", (oa_5) => MaterialAttribute_encoder(options, oa_5), oa["CharacteristicCategories"])), delay(() => append(singleton(tryInclude("unitCategories", (oa_6) => OntologyAnnotation_encoder(options, oa_6), oa["UnitCategories"])), delay(() => append(singleton(tryInclude("processSequence", (oa_7) => Process_encoder(options, oa_7), oa["ProcessSequence"])), delay(() => singleton(tryInclude("comments", (comment) => encoder(options, comment), oa["Comments"])))))))))))))))))))))); - })); - })))); -} - -export function Assay_decoder(options) { - return (path_7) => ((v) => object_23((get$) => { - let objectArg, objectArg_1, arg_5, objectArg_2, arg_7, objectArg_3, objectArg_4, objectArg_5, arg_13, objectArg_6, arg_15, decoder_1, objectArg_7, arg_17, decoder_2, objectArg_8, arg_19, decoder_3, objectArg_9, arg_21, decoder_4, objectArg_10; - return new Assay((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("filename", string)), (arg_5 = OntologyAnnotation_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("measurementType", uncurry2(arg_5)))), (arg_7 = OntologyAnnotation_decoder(options), (objectArg_3 = get$.Optional, objectArg_3.Field("technologyType", uncurry2(arg_7)))), (objectArg_4 = get$.Optional, objectArg_4.Field("technologyPlatform", string)), (objectArg_5 = get$.Optional, objectArg_5.Field("dataFiles", (path_2, value_2) => list_1((s_1, json_1) => Data_decoder(options, s_1, json_1), path_2, value_2))), (arg_13 = AssayMaterials_decoder(options), (objectArg_6 = get$.Optional, objectArg_6.Field("materials", uncurry2(arg_13)))), (arg_15 = ((decoder_1 = MaterialAttribute_decoder(options), (path_3) => ((value_3) => list_1(uncurry2(decoder_1), path_3, value_3)))), (objectArg_7 = get$.Optional, objectArg_7.Field("characteristicCategories", uncurry2(arg_15)))), (arg_17 = ((decoder_2 = OntologyAnnotation_decoder(options), (path_4) => ((value_4) => list_1(uncurry2(decoder_2), path_4, value_4)))), (objectArg_8 = get$.Optional, objectArg_8.Field("unitCategories", uncurry2(arg_17)))), (arg_19 = ((decoder_3 = Process_decoder(options), (path_5) => ((value_5) => list_1(uncurry2(decoder_3), path_5, value_5)))), (objectArg_9 = get$.Optional, objectArg_9.Field("processSequence", uncurry2(arg_19)))), (arg_21 = ((decoder_4 = decoder_5(options), (path_6) => ((value_6) => list_1(uncurry2(decoder_4), path_6, value_6)))), (objectArg_10 = get$.Optional, objectArg_10.Field("comments", uncurry2(arg_21))))); - }, path_7, v)); -} - -export function Assay_fromString(s) { - return fromString(uncurry2(Assay_decoder(ConverterOptions_$ctor())), s); -} - -export function Assay_toString(p) { - return toString(2, Assay_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Assay_toStringLD(a) { - let returnVal; - return toString(2, Assay_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), a)); -} - -export function ArcAssay_fromString(s) { - const arg = fromString(uncurry2(Assay_decoder(ConverterOptions_$ctor())), s); - return ArcAssay.fromAssay(arg); -} - -export function ArcAssay_toString(a) { - return toString(2, Assay_encoder(ConverterOptions_$ctor(), a.ToAssay())); -} - -/** - * exports in json-ld format - */ -export function ArcAssay_toStringLD(a) { - let returnVal; - return toString(2, Assay_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), a.ToAssay())); -} - diff --git a/js/ISA/ISA.Json/Comment.js b/js/ISA/ISA.Json/Comment.js deleted file mode 100644 index 0deb1ed2..00000000 --- a/js/ISA/ISA.Json/Comment.js +++ /dev/null @@ -1,84 +0,0 @@ -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { value as value_13 } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { toString as toString_1, nil, object as object_6 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { string, object as object_7 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { fromString as fromString_1, uri } from "./Decode.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; - -export function genID(c) { - const matchValue = c.ID; - if (matchValue == null) { - const matchValue_1 = c.Name; - if (matchValue_1 == null) { - return "#EmptyComment"; - } - else { - const n = matchValue_1; - const v = (c.Value != null) ? ("_" + replace(value_13(c.Value), " ", "_")) : ""; - return ("#Comment_" + replace(n, " ", "_")) + v; - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function encoder(options, comment) { - return object_6(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = genID(comment), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, comment["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Comment", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("name", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, comment["Name"])), delay(() => singleton(tryInclude("value", (value_10) => { - let s_4; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_4 = value_11, s_4)) : nil; - }, comment["Value"])))))); - })); - })))); -} - -export function decoder(options) { - return (path_2) => ((v) => object_7((get$) => { - let objectArg, objectArg_1, objectArg_2; - return new Comment$((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("value", string))); - }, path_2, v)); -} - -export function fromString(s) { - return fromString_1(uncurry2(decoder(ConverterOptions_$ctor())), s); -} - -export function toString(c) { - return toString_1(2, encoder(ConverterOptions_$ctor(), c)); -} - -/** - * exports in json-ld format - */ -export function toStringLD(c) { - let returnVal; - return toString_1(2, encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), c)); -} - diff --git a/js/ISA/ISA.Json/ConverterOptions.js b/js/ISA/ISA.Json/ConverterOptions.js deleted file mode 100644 index 955b0b65..00000000 --- a/js/ISA/ISA.Json/ConverterOptions.js +++ /dev/null @@ -1,33 +0,0 @@ -import { class_type } from "../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class ConverterOptions { - constructor() { - this.setID = false; - this.includeType = false; - } -} - -export function ConverterOptions_$reflection() { - return class_type("ISA.Json.ConverterOptions", void 0, ConverterOptions); -} - -export function ConverterOptions_$ctor() { - return new ConverterOptions(); -} - -export function ConverterOptions__get_SetID(this$) { - return this$.setID; -} - -export function ConverterOptions__set_SetID_Z1FBCCD16(this$, setId) { - this$.setID = setId; -} - -export function ConverterOptions__get_IncludeType(this$) { - return this$.includeType; -} - -export function ConverterOptions__set_IncludeType_Z1FBCCD16(this$, iT) { - this$.includeType = iT; -} - diff --git a/js/ISA/ISA.Json/Data.js b/js/ISA/ISA.Json/Data.js deleted file mode 100644 index b61e63d6..00000000 --- a/js/ISA/ISA.Json/Data.js +++ /dev/null @@ -1,271 +0,0 @@ -import { DataFile } from "../ISA/JsonTypes/DataFile.js"; -import { toString, object as object_10, nil } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { list as list_1, object as object_11, string } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2 } from "../../fable_modules/fable-library.4.1.4/Choice.js"; -import { ErrorReason } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { ofArray, choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { decoder as decoder_3, encoder } from "./Comment.js"; -import { fromString, uri, hasUnknownFields } from "./Decode.js"; -import { Data } from "../ISA/JsonTypes/Data.js"; -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { MaterialAttributeValue_decoder, MaterialAttributeValue_encoder } from "./Material.js"; -import { Source } from "../ISA/JsonTypes/Source.js"; -import { FactorValue_decoder, FactorValue_encoder } from "./Factor.js"; -import { Sample } from "../ISA/JsonTypes/Sample.js"; - -export function DataFile_encoder(options, value) { - if (value instanceof DataFile) { - if (value.tag === 1) { - return "Derived Data File"; - } - else if (value.tag === 2) { - return "Image File"; - } - else { - return "Raw Data File"; - } - } - else { - return nil; - } -} - -export function DataFile_decoder(options, s, json) { - const matchValue = string(s, json); - if (matchValue.tag === 1) { - return new FSharpResult$2(1, [matchValue.fields[0]]); - } - else { - switch (matchValue.fields[0]) { - case "Raw Data File": - return new FSharpResult$2(0, [new DataFile(0, [])]); - case "Derived Data File": - return new FSharpResult$2(0, [new DataFile(1, [])]); - case "Image File": - return new FSharpResult$2(0, [new DataFile(2, [])]); - default: { - const s_1 = matchValue.fields[0]; - return new FSharpResult$2(1, [[`Could not parse ${s_1}.`, new ErrorReason(0, [s_1, nil])]]); - } - } - } -} - -export function Data_genID(d) { - const matchValue = d.ID; - if (matchValue == null) { - const matchValue_1 = d.Name; - if (matchValue_1 == null) { - return "#EmptyData"; - } - else { - return matchValue_1; - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function Data_encoder(options, oa) { - return object_10(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Data_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Data", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("name", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["Name"])), delay(() => append(singleton(tryInclude("type", (value_10) => DataFile_encoder(options, value_10), oa["DataType"])), delay(() => singleton(tryInclude("comments", (comment) => encoder(options, comment), oa["Comments"])))))))); - })); - })))); -} - -export function Data_decoder(options, s, json) { - if (hasUnknownFields(ofArray(["@id", "name", "type", "comments", "@type"]), json)) { - return new FSharpResult$2(1, [["Unknown fields in Data", new ErrorReason(0, [s, nil])]]); - } - else { - return object_11((get$) => { - let objectArg, objectArg_1, objectArg_2, arg_7, decoder, objectArg_3; - return new Data((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("type", (s_2, json_2) => DataFile_decoder(options, s_2, json_2))), (arg_7 = ((decoder = decoder_3(options), (path_1) => ((value_1) => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_3 = get$.Optional, objectArg_3.Field("comments", uncurry2(arg_7))))); - }, s, json); - } -} - -export function Data_fromString(s) { - let options; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1) => ((json) => Data_decoder(options, s_1, json)))), s); -} - -export function Data_toString(m) { - return toString(2, Data_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function Data_toStringLD(d) { - let returnVal; - return toString(2, Data_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), d)); -} - -export function Source_genID(s) { - const matchValue = s.ID; - if (matchValue == null) { - const matchValue_1 = s.Name; - if (matchValue_1 == null) { - return "#EmptySource"; - } - else { - return "#Source_" + replace(matchValue_1, " ", "_"); - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function Source_encoder(options, oa) { - return object_10(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s_1; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Source_genID(oa), (typeof value === "string") ? ((s_1 = value, s_1)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_2; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_2 = value_3, s_2)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_3; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Source", (typeof value_5 === "string") ? ((s_3 = value_5, s_3)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("name", (value_7) => { - let s_4; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_4 = value_8, s_4)) : nil; - }, oa["Name"])), delay(() => singleton(tryInclude("characteristics", (oa_1) => MaterialAttributeValue_encoder(options, oa_1), oa["Characteristics"])))))); - })); - })))); -} - -export function Source_decoder(options, s, json) { - if (hasUnknownFields(ofArray(["@id", "name", "characteristics", "@type"]), json)) { - return new FSharpResult$2(1, [["Unknown fields in Source", new ErrorReason(0, [s, nil])]]); - } - else { - return object_11((get$) => { - let objectArg, objectArg_1, arg_5, decoder, objectArg_2; - return new Source((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = ((decoder = MaterialAttributeValue_decoder(options), (path_1) => ((value_1) => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_2 = get$.Optional, objectArg_2.Field("characteristics", uncurry2(arg_5))))); - }, s, json); - } -} - -export function Source_fromString(s) { - let options; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1) => ((json) => Source_decoder(options, s_1, json)))), s); -} - -export function Source_toString(m) { - return toString(2, Source_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function Source_toStringLD(s) { - let returnVal; - return toString(2, Source_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), s)); -} - -export function Sample_genID(s) { - const matchValue = s.ID; - if (matchValue == null) { - const matchValue_1 = s.Name; - if (matchValue_1 == null) { - return "#EmptySample"; - } - else { - return "#Sample_" + replace(matchValue_1, " ", "_"); - } - } - else { - return matchValue; - } -} - -export function Sample_encoder(options, oa) { - return object_10(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s_1; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Sample_genID(oa), (typeof value === "string") ? ((s_1 = value, s_1)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_2; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_2 = value_3, s_2)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_3; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Sample", (typeof value_5 === "string") ? ((s_3 = value_5, s_3)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("name", (value_7) => { - let s_4; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_4 = value_8, s_4)) : nil; - }, oa["Name"])), delay(() => append(singleton(tryInclude("characteristics", (oa_1) => MaterialAttributeValue_encoder(options, oa_1), oa["Characteristics"])), delay(() => append(singleton(tryInclude("factorValues", (oa_2) => FactorValue_encoder(options, oa_2), oa["FactorValues"])), delay(() => singleton(tryInclude("derivesFrom", (oa_3) => Source_encoder(options, oa_3), oa["DerivesFrom"])))))))))); - })); - })))); -} - -export function Sample_decoder(options, s, json) { - if (hasUnknownFields(ofArray(["@id", "name", "characteristics", "factorValues", "derivesFrom", "@type"]), json)) { - return new FSharpResult$2(1, [["Unknown fields in Sample", new ErrorReason(0, [s, nil])]]); - } - else { - return object_11((get$) => { - let objectArg, objectArg_1, arg_5, decoder, objectArg_2, arg_7, decoder_1, objectArg_3, objectArg_4; - return new Sample((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = ((decoder = MaterialAttributeValue_decoder(options), (path_1) => ((value_1) => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_2 = get$.Optional, objectArg_2.Field("characteristics", uncurry2(arg_5)))), (arg_7 = ((decoder_1 = FactorValue_decoder(options), (path_2) => ((value_2) => list_1(uncurry2(decoder_1), path_2, value_2)))), (objectArg_3 = get$.Optional, objectArg_3.Field("factorValues", uncurry2(arg_7)))), (objectArg_4 = get$.Optional, objectArg_4.Field("derivesFrom", (path_3, value_3) => list_1((s_2, json_2) => Source_decoder(options, s_2, json_2), path_3, value_3)))); - }, s, json); - } -} - -export function Sample_fromString(s) { - let options; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1) => ((json) => Sample_decoder(options, s_1, json)))), s); -} - -export function Sample_toString(m) { - return toString(2, Sample_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function Sample_toStringLD(s) { - let returnVal; - return toString(2, Sample_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), s)); -} - diff --git a/js/ISA/ISA.Json/Decode.js b/js/ISA/ISA.Json/Decode.js deleted file mode 100644 index 5e635116..00000000 --- a/js/ISA/ISA.Json/Decode.js +++ /dev/null @@ -1,46 +0,0 @@ -import { fromString as fromString_1, string } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2 } from "../../fable_modules/fable-library.4.1.4/Choice.js"; -import { printf, toText } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { ErrorReason } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { contains, exists } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { stringHash } from "../../fable_modules/fable-library.4.1.4/Util.js"; - -export function isURI(s) { - return true; -} - -export function uri(s, json) { - const matchValue = string(s, json); - if (matchValue.tag === 1) { - return new FSharpResult$2(1, [matchValue.fields[0]]); - } - else if (isURI(matchValue.fields[0])) { - return new FSharpResult$2(0, [matchValue.fields[0]]); - } - else { - const s_3 = matchValue.fields[0]; - return new FSharpResult$2(1, [[s_3, new ErrorReason(6, [toText(printf("Expected URI, got %s"))(s_3)])]]); - } -} - -export function fromString(decoder, s) { - const matchValue = fromString_1(decoder, s); - if (matchValue.tag === 1) { - throw new Error(toText(printf("Error decoding string: %s"))(matchValue.fields[0])); - } - else { - return matchValue.fields[0]; - } -} - -export function getFieldNames(json) { - return Object.getOwnPropertyNames(json); -} - -export function hasUnknownFields(knownFields, json) { - return exists((x) => !contains(x, knownFields, { - Equals: (x_1, y) => (x_1 === y), - GetHashCode: stringHash, - }), getFieldNames(json)); -} - diff --git a/js/ISA/ISA.Json/Factor.js b/js/ISA/ISA.Json/Factor.js deleted file mode 100644 index c0a6e1f7..00000000 --- a/js/ISA/ISA.Json/Factor.js +++ /dev/null @@ -1,194 +0,0 @@ -import { Value } from "../ISA/JsonTypes/Value.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { object as object_8, toString, nil } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { list as list_1, object as object_9, string, float, int } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2 } from "../../fable_modules/fable-library.4.1.4/Choice.js"; -import { uri, fromString } from "./Decode.js"; -import { equals, uncurry2 } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID, ConverterOptions_$ctor } from "./ConverterOptions.js"; -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { tryInclude } from "./GEncode.js"; -import { decoder as decoder_1, encoder } from "./Comment.js"; -import { Factor } from "../ISA/JsonTypes/Factor.js"; -import { FactorValue } from "../ISA/JsonTypes/FactorValue.js"; - -export function Value_encoder(options, value) { - if (value instanceof Value) { - if (value.tag === 1) { - return value.fields[0]; - } - else if (value.tag === 3) { - return value.fields[0]; - } - else if (value.tag === 0) { - return OntologyAnnotation_encoder(options, value.fields[0]); - } - else { - return value.fields[0]; - } - } - else { - return nil; - } -} - -export function Value_decoder(options, s, json) { - const matchValue = int(s)(json); - if (matchValue.tag === 1) { - const matchValue_1 = float(s, json); - if (matchValue_1.tag === 1) { - const matchValue_2 = OntologyAnnotation_decoder(options)(s)(json); - if (matchValue_2.tag === 1) { - const matchValue_3 = string(s, json); - if (matchValue_3.tag === 1) { - return new FSharpResult$2(1, [matchValue_3.fields[0]]); - } - else { - return new FSharpResult$2(0, [new Value(3, [matchValue_3.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new Value(0, [matchValue_2.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new Value(2, [matchValue_1.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new Value(1, [matchValue.fields[0]])]); - } -} - -export function Value_fromString(s) { - let options; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1) => ((json) => Value_decoder(options, s_1, json)))), s); -} - -export function Value_toString(v) { - return toString(2, Value_encoder(ConverterOptions_$ctor(), v)); -} - -export function Factor_genID(f) { - const matchValue = f.ID; - if (matchValue == null) { - const matchValue_1 = f.Name; - if (matchValue_1 == null) { - return "#EmptyFactor"; - } - else { - return "#Factor_" + replace(matchValue_1, " ", "_"); - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function Factor_encoder(options, oa) { - return object_8(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Factor_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Factor", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("factorName", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["Name"])), delay(() => append(singleton(tryInclude("factorType", (oa_1) => OntologyAnnotation_encoder(options, oa_1), oa["FactorType"])), delay(() => singleton(tryInclude("comments", (comment) => encoder(options, comment), oa["Comments"])))))))); - })); - })))); -} - -export function Factor_decoder(options) { - return (path_2) => ((v) => object_9((get$) => { - let objectArg, objectArg_1, arg_5, objectArg_2, arg_7, decoder, objectArg_3; - return new Factor((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("factorName", string)), (arg_5 = OntologyAnnotation_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("factorType", uncurry2(arg_5)))), (arg_7 = ((decoder = decoder_1(options), (path_1) => ((value_1) => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_3 = get$.Optional, objectArg_3.Field("comments", uncurry2(arg_7))))); - }, path_2, v)); -} - -export function Factor_fromString(s) { - return fromString(uncurry2(Factor_decoder(ConverterOptions_$ctor())), s); -} - -export function Factor_toString(f) { - return toString(2, Factor_encoder(ConverterOptions_$ctor(), f)); -} - -/** - * exports in json-ld format - */ -export function Factor_toStringLD(f) { - let returnVal; - return toString(2, Factor_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), f)); -} - -export function FactorValue_genID(fv) { - const matchValue = fv.ID; - if (matchValue == null) { - return "#EmptyFactorValue"; - } - else { - return URIModule_toString(matchValue); - } -} - -export function FactorValue_encoder(options, oa) { - return object_8(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = FactorValue_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "FactorValue", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("category", (oa_1) => Factor_encoder(options, oa_1), oa["Category"])), delay(() => append(singleton(tryInclude("value", (value_7) => Value_encoder(options, value_7), oa["Value"])), delay(() => singleton(tryInclude("unit", (oa_2) => OntologyAnnotation_encoder(options, oa_2), oa["Unit"])))))))); - })); - })))); -} - -export function FactorValue_decoder(options) { - return (path) => ((v) => object_9((get$) => { - let objectArg, arg_3, objectArg_1, objectArg_2, arg_7, objectArg_3; - return new FactorValue((objectArg = get$.Optional, objectArg.Field("@id", uri)), (arg_3 = Factor_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("category", uncurry2(arg_3)))), (objectArg_2 = get$.Optional, objectArg_2.Field("value", (s_1, json_1) => Value_decoder(options, s_1, json_1))), (arg_7 = OntologyAnnotation_decoder(options), (objectArg_3 = get$.Optional, objectArg_3.Field("unit", uncurry2(arg_7))))); - }, path, v)); -} - -export function FactorValue_fromString(s) { - return fromString(uncurry2(FactorValue_decoder(ConverterOptions_$ctor())), s); -} - -export function FactorValue_toString(f) { - return toString(2, FactorValue_encoder(ConverterOptions_$ctor(), f)); -} - -/** - * exports in json-ld format - */ -export function FactorValue_toStringLD(f) { - let returnVal; - return toString(2, FactorValue_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), f)); -} - diff --git a/js/ISA/ISA.Json/GEncode.js b/js/ISA/ISA.Json/GEncode.js deleted file mode 100644 index fe977e63..00000000 --- a/js/ISA/ISA.Json/GEncode.js +++ /dev/null @@ -1,15 +0,0 @@ -import { value as value_1 } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { isIterable } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { nil, seq } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { map } from "../../fable_modules/fable-library.4.1.4/Seq.js"; - -/** - * Try to encode the given object using the given encoder, or return Encode.nil if the object is null - * - * If the object is a sequence, encode each element using the given encoder and return the resulting sequence - */ -export function tryInclude(name, encoder, value) { - let v, o; - return [name, (value != null) ? (isIterable(value_1(value)) ? ((v = value_1(value), seq(map(encoder, v)))) : ((o = value_1(value), encoder(o)))) : nil]; -} - diff --git a/js/ISA/ISA.Json/Investigation.js b/js/ISA/ISA.Json/Investigation.js deleted file mode 100644 index 40456453..00000000 --- a/js/ISA/ISA.Json/Investigation.js +++ /dev/null @@ -1,132 +0,0 @@ -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { toString, nil, object as object_24 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { empty as empty_1, choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologySourceReference_decoder, OntologySourceReference_encoder } from "./Ontology.js"; -import { decoder as decoder_5, encoder } from "./Publication.js"; -import { decoder as decoder_6, encoder as encoder_1 } from "./Person.js"; -import { Study_decoder, Study_encoder } from "./Study.js"; -import { decoder as decoder_7, encoder as encoder_2 } from "./Comment.js"; -import { list as list_1, string, object as object_25 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { Investigation } from "../ISA/JsonTypes/Investigation.js"; -import { fromString } from "./Decode.js"; -import { ArcInvestigation } from "../ISA/ArcTypes/ArcInvestigation.js"; - -export function Investigation_genID(i) { - const matchValue = i.ID; - if (matchValue == null) { - const matchValue_1 = i.FileName; - if (matchValue_1 == null) { - const matchValue_2 = i.Identifier; - if (matchValue_2 == null) { - const matchValue_3 = i.Title; - if (matchValue_3 == null) { - return "#EmptyStudy"; - } - else { - return "#Study_" + replace(matchValue_3, " ", "_"); - } - } - else { - return "#Study_" + replace(matchValue_2, " ", "_"); - } - } - else { - return "#Study_" + replace(matchValue_1, " ", "_"); - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function Investigation_encoder(options, oa) { - return object_24(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Investigation_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Investigation", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("filename", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["FileName"])), delay(() => append(singleton(tryInclude("identifier", (value_10) => { - let s_4; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_4 = value_11, s_4)) : nil; - }, oa["Identifier"])), delay(() => append(singleton(tryInclude("title", (value_13) => { - let s_5; - const value_14 = value_13; - return (typeof value_14 === "string") ? ((s_5 = value_14, s_5)) : nil; - }, oa["Title"])), delay(() => append(singleton(tryInclude("description", (value_16) => { - let s_6; - const value_17 = value_16; - return (typeof value_17 === "string") ? ((s_6 = value_17, s_6)) : nil; - }, oa["Description"])), delay(() => append(singleton(tryInclude("submissionDate", (value_19) => { - let s_7; - const value_20 = value_19; - return (typeof value_20 === "string") ? ((s_7 = value_20, s_7)) : nil; - }, oa["SubmissionDate"])), delay(() => append(singleton(tryInclude("publicReleaseDate", (value_22) => { - let s_8; - const value_23 = value_22; - return (typeof value_23 === "string") ? ((s_8 = value_23, s_8)) : nil; - }, oa["PublicReleaseDate"])), delay(() => append(singleton(tryInclude("ontologySourceReferences", (osr) => OntologySourceReference_encoder(options, osr), oa["OntologySourceReferences"])), delay(() => append(singleton(tryInclude("publications", (oa_1) => encoder(options, oa_1), oa["Publications"])), delay(() => append(singleton(tryInclude("people", (oa_2) => encoder_1(options, oa_2), oa["Contacts"])), delay(() => append(singleton(tryInclude("studies", (oa_3) => Study_encoder(options, oa_3), oa["Studies"])), delay(() => singleton(tryInclude("comments", (comment) => encoder_2(options, comment), oa["Comments"])))))))))))))))))))))))); - })); - })))); -} - -export function Investigation_decoder(options) { - return (path_12) => ((v) => object_25((get$) => { - let objectArg, objectArg_1, objectArg_2, objectArg_3, objectArg_4, objectArg_5, objectArg_6, arg_15, decoder, objectArg_7, arg_17, decoder_1, objectArg_8, arg_19, decoder_2, objectArg_9, arg_21, decoder_3, objectArg_10, arg_23, decoder_4, objectArg_11; - return new Investigation((objectArg = get$.Optional, objectArg.Field("@id", string)), (objectArg_1 = get$.Optional, objectArg_1.Field("filename", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("identifier", string)), (objectArg_3 = get$.Optional, objectArg_3.Field("title", string)), (objectArg_4 = get$.Optional, objectArg_4.Field("description", string)), (objectArg_5 = get$.Optional, objectArg_5.Field("submissionDate", string)), (objectArg_6 = get$.Optional, objectArg_6.Field("publicReleaseDate", string)), (arg_15 = ((decoder = OntologySourceReference_decoder(options), (path_7) => ((value_7) => list_1(uncurry2(decoder), path_7, value_7)))), (objectArg_7 = get$.Optional, objectArg_7.Field("ontologySourceReferences", uncurry2(arg_15)))), (arg_17 = ((decoder_1 = decoder_5(options), (path_8) => ((value_8) => list_1(uncurry2(decoder_1), path_8, value_8)))), (objectArg_8 = get$.Optional, objectArg_8.Field("publications", uncurry2(arg_17)))), (arg_19 = ((decoder_2 = decoder_6(options), (path_9) => ((value_9) => list_1(uncurry2(decoder_2), path_9, value_9)))), (objectArg_9 = get$.Optional, objectArg_9.Field("people", uncurry2(arg_19)))), (arg_21 = ((decoder_3 = Study_decoder(options), (path_10) => ((value_10) => list_1(uncurry2(decoder_3), path_10, value_10)))), (objectArg_10 = get$.Optional, objectArg_10.Field("studies", uncurry2(arg_21)))), (arg_23 = ((decoder_4 = decoder_7(options), (path_11) => ((value_11) => list_1(uncurry2(decoder_4), path_11, value_11)))), (objectArg_11 = get$.Optional, objectArg_11.Field("comments", uncurry2(arg_23)))), empty_1()); - }, path_12, v)); -} - -export function Investigation_fromString(s) { - return fromString(uncurry2(Investigation_decoder(ConverterOptions_$ctor())), s); -} - -export function Investigation_toString(p) { - return toString(2, Investigation_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Investigation_toStringLD(i) { - let returnVal; - return toString(2, Investigation_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), i)); -} - -export function ArcInvestigation_fromString(s) { - const arg = fromString(uncurry2(Investigation_decoder(ConverterOptions_$ctor())), s); - return ArcInvestigation.fromInvestigation(arg); -} - -export function ArcInvestigation_toString(a) { - return toString(2, Investigation_encoder(ConverterOptions_$ctor(), a.ToInvestigation())); -} - -/** - * exports in json-ld format - */ -export function ArcInvestigation_toStringLD(a) { - let returnVal; - return toString(2, Investigation_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), a.ToInvestigation())); -} - diff --git a/js/ISA/ISA.Json/Material.js b/js/ISA/ISA.Json/Material.js deleted file mode 100644 index c2aed565..00000000 --- a/js/ISA/ISA.Json/Material.js +++ /dev/null @@ -1,233 +0,0 @@ -import { MaterialType } from "../ISA/JsonTypes/MaterialType.js"; -import { toString, object as object_10, nil } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { list as list_1, object as object_11, string } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2 } from "../../fable_modules/fable-library.4.1.4/Choice.js"; -import { ErrorReason } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { ofArray, choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { hasUnknownFields, fromString, uri } from "./Decode.js"; -import { MaterialAttribute } from "../ISA/JsonTypes/MaterialAttribute.js"; -import { Value_decoder, Value_encoder } from "./Factor.js"; -import { MaterialAttributeValue } from "../ISA/JsonTypes/MaterialAttributeValue.js"; -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { Material } from "../ISA/JsonTypes/Material.js"; - -export function MaterialType_encoder(options, value) { - if (value instanceof MaterialType) { - if (value.tag === 1) { - return "Labeled Extract Name"; - } - else { - return "Extract Name"; - } - } - else { - return nil; - } -} - -export function MaterialType_decoder(options, s, json) { - const matchValue = string(s, json); - if (matchValue.tag === 1) { - return new FSharpResult$2(1, [matchValue.fields[0]]); - } - else { - switch (matchValue.fields[0]) { - case "Extract Name": - return new FSharpResult$2(0, [new MaterialType(0, [])]); - case "Labeled Extract Name": - return new FSharpResult$2(0, [new MaterialType(1, [])]); - default: { - const s_1 = matchValue.fields[0]; - return new FSharpResult$2(1, [[`Could not parse ${s_1}No other value than "Extract Name" or "Labeled Extract Name" allowed for materialtype`, new ErrorReason(0, [s_1, nil])]]); - } - } - } -} - -export function MaterialAttribute_genID(m) { - const matchValue = m.ID; - if (matchValue == null) { - return "#EmptyMaterialAttribute"; - } - else { - return URIModule_toString(matchValue); - } -} - -export function MaterialAttribute_encoder(options, oa) { - return object_10(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = MaterialAttribute_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "MaterialAttribute", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => singleton(tryInclude("characteristicType", (oa_1) => OntologyAnnotation_encoder(options, oa_1), oa["CharacteristicType"])))); - })); - })))); -} - -export function MaterialAttribute_decoder(options) { - return (path) => ((v) => object_11((get$) => { - let objectArg, arg_3, objectArg_1; - return new MaterialAttribute((objectArg = get$.Optional, objectArg.Field("@id", uri)), (arg_3 = OntologyAnnotation_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("characteristicType", uncurry2(arg_3))))); - }, path, v)); -} - -export function MaterialAttribute_fromString(s) { - return fromString(uncurry2(MaterialAttribute_decoder(ConverterOptions_$ctor())), s); -} - -export function MaterialAttribute_toString(m) { - return toString(2, MaterialAttribute_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function MaterialAttribute_toStringLD(m) { - let returnVal; - return toString(2, MaterialAttribute_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), m)); -} - -export function MaterialAttributeValue_genID(m) { - const matchValue = m.ID; - if (matchValue == null) { - return "#EmptyMaterialAttributeValue"; - } - else { - return URIModule_toString(matchValue); - } -} - -export function MaterialAttributeValue_encoder(options, oa) { - return object_10(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = MaterialAttributeValue_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "MaterialAttributeValue", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("category", (oa_1) => MaterialAttribute_encoder(options, oa_1), oa["Category"])), delay(() => append(singleton(tryInclude("value", (value_7) => Value_encoder(options, value_7), oa["Value"])), delay(() => singleton(tryInclude("unit", (oa_2) => OntologyAnnotation_encoder(options, oa_2), oa["Unit"])))))))); - })); - })))); -} - -export function MaterialAttributeValue_decoder(options) { - return (path) => ((v) => object_11((get$) => { - let objectArg, arg_3, objectArg_1, objectArg_2, arg_7, objectArg_3; - return new MaterialAttributeValue((objectArg = get$.Optional, objectArg.Field("@id", uri)), (arg_3 = MaterialAttribute_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("category", uncurry2(arg_3)))), (objectArg_2 = get$.Optional, objectArg_2.Field("value", (s_1, json_1) => Value_decoder(options, s_1, json_1))), (arg_7 = OntologyAnnotation_decoder(options), (objectArg_3 = get$.Optional, objectArg_3.Field("unit", uncurry2(arg_7))))); - }, path, v)); -} - -export function MaterialAttributeValue_fromString(s) { - return fromString(uncurry2(MaterialAttributeValue_decoder(ConverterOptions_$ctor())), s); -} - -export function MaterialAttributeValue_toString(m) { - return toString(2, MaterialAttributeValue_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function MaterialAttributeValue_toStringLD(m) { - let returnVal; - return toString(2, MaterialAttributeValue_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), m)); -} - -export function Material_genID(m) { - const matchValue = m.ID; - if (matchValue == null) { - const matchValue_1 = m.Name; - if (matchValue_1 == null) { - return "#EmptyMaterial"; - } - else { - return "#Material_" + replace(matchValue_1, " ", "_"); - } - } - else { - return matchValue; - } -} - -export function Material_encoder(options, oa) { - return object_10(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Material_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Material", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("name", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["Name"])), delay(() => append(singleton(tryInclude("type", (value_10) => MaterialType_encoder(options, value_10), oa["MaterialType"])), delay(() => append(singleton(tryInclude("characteristics", (oa_1) => MaterialAttributeValue_encoder(options, oa_1), oa["Characteristics"])), delay(() => singleton(tryInclude("derivesFrom", (oa_2) => Material_encoder(options, oa_2), oa["DerivesFrom"])))))))))); - })); - })))); -} - -export function Material_decoder(options, s, json) { - if (hasUnknownFields(ofArray(["@id", "@type", "name", "type", "characteristics", "derivesFrom"]), json)) { - return new FSharpResult$2(1, [["Unknown fields in material", new ErrorReason(0, [s, nil])]]); - } - else { - return object_11((get$) => { - let objectArg, objectArg_1, objectArg_2, arg_7, decoder, objectArg_3, objectArg_4; - return new Material((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("type", (s_2, json_2) => MaterialType_decoder(options, s_2, json_2))), (arg_7 = ((decoder = MaterialAttributeValue_decoder(options), (path_1) => ((value_1) => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_3 = get$.Optional, objectArg_3.Field("characteristics", uncurry2(arg_7)))), (objectArg_4 = get$.Optional, objectArg_4.Field("derivesFrom", (path_2, value_2) => list_1((s_3, json_3) => Material_decoder(options, s_3, json_3), path_2, value_2)))); - }, s, json); - } -} - -export function Material_fromString(s) { - let options; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1) => ((json) => Material_decoder(options, s_1, json)))), s); -} - -export function Material_toString(m) { - return toString(2, Material_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function Material_toStringLD(m) { - let returnVal; - return toString(2, Material_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), m)); -} - diff --git a/js/ISA/ISA.Json/Ontology.js b/js/ISA/ISA.Json/Ontology.js deleted file mode 100644 index 5f079540..00000000 --- a/js/ISA/ISA.Json/Ontology.js +++ /dev/null @@ -1,236 +0,0 @@ -import { AnnotationValue } from "../ISA/JsonTypes/AnnotationValue.js"; -import { toString, object as object_10, nil } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { list as list_1, object as object_11, string, float, int } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2 } from "../../fable_modules/fable-library.4.1.4/Choice.js"; -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { decoder as decoder_1, encoder } from "./Comment.js"; -import { fromString, uri } from "./Decode.js"; -import { OntologySourceReference } from "../ISA/JsonTypes/OntologySourceReference.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { ActivePatterns_$007CTermAnnotation$007C_$007C } from "../ISA/Regex.js"; -import { bind } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; - -export function AnnotationValue_encoder(options, value) { - if (value instanceof AnnotationValue) { - if (value.tag === 2) { - return value.fields[0]; - } - else if (value.tag === 0) { - return value.fields[0]; - } - else { - return value.fields[0]; - } - } - else { - return nil; - } -} - -export function AnnotationValue_decoder(options, s, json) { - const matchValue = int(s)(json); - if (matchValue.tag === 1) { - const matchValue_1 = float(s, json); - if (matchValue_1.tag === 1) { - const matchValue_2 = string(s, json); - if (matchValue_2.tag === 1) { - return new FSharpResult$2(1, [matchValue_2.fields[0]]); - } - else { - return new FSharpResult$2(0, [new AnnotationValue(0, [matchValue_2.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new AnnotationValue(1, [matchValue_1.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new AnnotationValue(2, [matchValue.fields[0]])]); - } -} - -export function OntologySourceReference_genID(o) { - const matchValue = o.File; - if (matchValue == null) { - const matchValue_1 = o.Name; - if (matchValue_1 == null) { - return "#DummyOntologySourceRef"; - } - else { - return "#OntologySourceRef_" + replace(matchValue_1, " ", "_"); - } - } - else { - return matchValue; - } -} - -export function OntologySourceReference_encoder(options, osr) { - return object_10(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = OntologySourceReference_genID(osr), (typeof value === "string") ? ((s = value, s)) : nil)]) : empty(), delay(() => { - let value_2, s_1; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_2 = "OntologySourceReference", (typeof value_2 === "string") ? ((s_1 = value_2, s_1)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("description", (value_4) => { - let s_2; - const value_5 = value_4; - return (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil; - }, osr["Description"])), delay(() => append(singleton(tryInclude("file", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, osr["File"])), delay(() => append(singleton(tryInclude("name", (value_10) => { - let s_4; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_4 = value_11, s_4)) : nil; - }, osr["Name"])), delay(() => append(singleton(tryInclude("version", (value_13) => { - let s_5; - const value_14 = value_13; - return (typeof value_14 === "string") ? ((s_5 = value_14, s_5)) : nil; - }, osr["Version"])), delay(() => singleton(tryInclude("comments", (comment) => encoder(options, comment), osr["Comments"])))))))))))); - })); - })))); -} - -export function OntologySourceReference_decoder(options) { - return (path_4) => ((v) => object_11((get$) => { - let objectArg, objectArg_1, objectArg_2, objectArg_3, arg_9, decoder, objectArg_4; - return new OntologySourceReference((objectArg = get$.Optional, objectArg.Field("description", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("file", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("name", string)), (objectArg_3 = get$.Optional, objectArg_3.Field("version", string)), (arg_9 = ((decoder = decoder_1(options), (path_3) => ((value_3) => list_1(uncurry2(decoder), path_3, value_3)))), (objectArg_4 = get$.Optional, objectArg_4.Field("comments", uncurry2(arg_9))))); - }, path_4, v)); -} - -export function OntologySourceReference_fromString(s) { - return fromString(uncurry2(OntologySourceReference_decoder(ConverterOptions_$ctor())), s); -} - -export function OntologySourceReference_toString(oa) { - return toString(2, OntologySourceReference_encoder(ConverterOptions_$ctor(), oa)); -} - -/** - * exports in json-ld format - */ -export function OntologySourceReference_toStringLD(oa) { - let returnVal; - return toString(2, OntologySourceReference_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), oa)); -} - -export function OntologyAnnotation_genID(o) { - const matchValue = o.ID; - if (matchValue == null) { - const matchValue_1 = o.TermAccessionNumber; - if (matchValue_1 == null) { - const matchValue_2 = o.TermSourceREF; - if (matchValue_2 == null) { - return "#DummyOntologyAnnotation"; - } - else { - return "#" + replace(matchValue_2, " ", "_"); - } - } - else { - return matchValue_1; - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function OntologyAnnotation_encoder(options, oa) { - return object_10(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = OntologyAnnotation_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "OntologyAnnotation", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("annotationValue", (value_7) => AnnotationValue_encoder(options, value_7), oa["Name"])), delay(() => append(singleton(tryInclude("termSource", (value_8) => { - let s_3; - const value_9 = value_8; - return (typeof value_9 === "string") ? ((s_3 = value_9, s_3)) : nil; - }, oa["TermSourceREF"])), delay(() => append(singleton(tryInclude("termAccession", (value_11) => { - let s_4; - const value_12 = value_11; - return (typeof value_12 === "string") ? ((s_4 = value_12, s_4)) : nil; - }, oa["TermAccessionNumber"])), delay(() => singleton(tryInclude("comments", (comment) => encoder(options, comment), oa["Comments"])))))))))); - })); - })))); -} - -export function OntologyAnnotation_localIDDecoder(s, json) { - const matchValue = string(s, json); - let matchResult, tan; - if (matchValue.tag === 0) { - const activePatternResult = ActivePatterns_$007CTermAnnotation$007C_$007C(matchValue.fields[0]); - if (activePatternResult != null) { - matchResult = 0; - tan = activePatternResult; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return new FSharpResult$2(0, [tan.TermSourceREF]); - default: - return new FSharpResult$2(0, [""]); - } -} - -export function OntologyAnnotation_decoder(options) { - return (path_3) => ((v) => object_11((get$) => { - let objectArg, objectArg_1, objectArg_2, objectArg_3, objectArg_4, arg_11, decoder, objectArg_5; - return new OntologyAnnotation((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("annotationValue", (s_1, json_1) => AnnotationValue_decoder(options, s_1, json_1))), (objectArg_2 = get$.Optional, objectArg_2.Field("termSource", string)), bind((s_3) => { - if (s_3 === "") { - return void 0; - } - else { - return s_3; - } - }, (objectArg_3 = get$.Optional, objectArg_3.Field("termAccession", OntologyAnnotation_localIDDecoder))), (objectArg_4 = get$.Optional, objectArg_4.Field("termAccession", string)), (arg_11 = ((decoder = decoder_1(options), (path_2) => ((value_2) => list_1(uncurry2(decoder), path_2, value_2)))), (objectArg_5 = get$.Optional, objectArg_5.Field("comments", uncurry2(arg_11))))); - }, path_3, v)); -} - -export function OntologyAnnotation_fromString(s) { - return fromString(uncurry2(OntologyAnnotation_decoder(ConverterOptions_$ctor())), s); -} - -export function OntologyAnnotation_toString(oa) { - return toString(2, OntologyAnnotation_encoder(ConverterOptions_$ctor(), oa)); -} - -/** - * exports in json-ld format - */ -export function OntologyAnnotation_toStringLD(oa) { - let returnVal; - return toString(2, OntologyAnnotation_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), oa)); -} - diff --git a/js/ISA/ISA.Json/Person.js b/js/ISA/ISA.Json/Person.js deleted file mode 100644 index b2522686..00000000 --- a/js/ISA/ISA.Json/Person.js +++ /dev/null @@ -1,198 +0,0 @@ -import { choose, tryPick } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { toString as toString_1, nil, object as object_22 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { decoder as decoder_3, encoder as encoder_1 } from "./Comment.js"; -import { list as list_1, string, object as object_23 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { fromString as fromString_1, uri } from "./Decode.js"; -import { Person } from "../ISA/JsonTypes/Person.js"; - -export function genID(p) { - const matchValue = p.ID; - if (matchValue == null) { - let orcid; - const matchValue_1 = p.Comments; - orcid = ((matchValue_1 == null) ? void 0 : tryPick((c) => { - const matchValue_2 = c.Name; - const matchValue_3 = c.Value; - let matchResult, n, v; - if (matchValue_2 != null) { - if (matchValue_3 != null) { - matchResult = 0; - n = matchValue_2; - v = matchValue_3; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - if (((n === "orcid") ? true : (n === "Orcid")) ? true : (n === "ORCID")) { - return v; - } - else { - return void 0; - } - default: - return void 0; - } - }, matchValue_1)); - if (orcid == null) { - const matchValue_5 = p.EMail; - if (matchValue_5 == null) { - const matchValue_6 = p.FirstName; - const matchValue_7 = p.MidInitials; - const matchValue_8 = p.LastName; - let matchResult_1, fn, ln, mn, fn_1, ln_1, ln_2, fn_2; - if (matchValue_6 == null) { - if (matchValue_7 == null) { - if (matchValue_8 != null) { - matchResult_1 = 2; - ln_2 = matchValue_8; - } - else { - matchResult_1 = 4; - } - } - else { - matchResult_1 = 4; - } - } - else if (matchValue_7 == null) { - if (matchValue_8 == null) { - matchResult_1 = 3; - fn_2 = matchValue_6; - } - else { - matchResult_1 = 1; - fn_1 = matchValue_6; - ln_1 = matchValue_8; - } - } - else if (matchValue_8 != null) { - matchResult_1 = 0; - fn = matchValue_6; - ln = matchValue_8; - mn = matchValue_7; - } - else { - matchResult_1 = 4; - } - switch (matchResult_1) { - case 0: - return (((("#" + replace(fn, " ", "_")) + "_") + replace(mn, " ", "_")) + "_") + replace(ln, " ", "_"); - case 1: - return (("#" + replace(fn_1, " ", "_")) + "_") + replace(ln_1, " ", "_"); - case 2: - return "#" + replace(ln_2, " ", "_"); - case 3: - return "#" + replace(fn_2, " ", "_"); - default: - return "#EmptyPerson"; - } - } - else { - return matchValue_5; - } - } - else { - return orcid; - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function encoder(options, oa) { - return object_22(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Person", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("firstName", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["FirstName"])), delay(() => append(singleton(tryInclude("lastName", (value_10) => { - let s_4; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_4 = value_11, s_4)) : nil; - }, oa["LastName"])), delay(() => append(singleton(tryInclude("midInitials", (value_13) => { - let s_5; - const value_14 = value_13; - return (typeof value_14 === "string") ? ((s_5 = value_14, s_5)) : nil; - }, oa["MidInitials"])), delay(() => append(singleton(tryInclude("email", (value_16) => { - let s_6; - const value_17 = value_16; - return (typeof value_17 === "string") ? ((s_6 = value_17, s_6)) : nil; - }, oa["EMail"])), delay(() => append(singleton(tryInclude("phone", (value_19) => { - let s_7; - const value_20 = value_19; - return (typeof value_20 === "string") ? ((s_7 = value_20, s_7)) : nil; - }, oa["Phone"])), delay(() => append(singleton(tryInclude("fax", (value_22) => { - let s_8; - const value_23 = value_22; - return (typeof value_23 === "string") ? ((s_8 = value_23, s_8)) : nil; - }, oa["Fax"])), delay(() => append(singleton(tryInclude("address", (value_25) => { - let s_9; - const value_26 = value_25; - return (typeof value_26 === "string") ? ((s_9 = value_26, s_9)) : nil; - }, oa["Address"])), delay(() => append(singleton(tryInclude("affiliation", (value_28) => { - let s_10; - const value_29 = value_28; - return (typeof value_29 === "string") ? ((s_10 = value_29, s_10)) : nil; - }, oa["Affiliation"])), delay(() => append(singleton(tryInclude("roles", (oa_1) => OntologyAnnotation_encoder(options, oa_1), oa["Roles"])), delay(() => singleton(tryInclude("comments", (comment) => encoder_1(options, comment), oa["Comments"])))))))))))))))))))))); - })); - })))); -} - -export function decoder(options) { - return (path_10) => ((v) => object_23((get$) => { - let objectArg_2, objectArg_3, objectArg_4, objectArg_5, objectArg_6, objectArg_7, objectArg_8, arg_19, decoder_1, objectArg_9, arg_21, decoder_2, objectArg_10; - let ID; - const objectArg = get$.Optional; - ID = objectArg.Field("@id", uri); - let FirstName; - const objectArg_1 = get$.Optional; - FirstName = objectArg_1.Field("firstName", string); - return new Person(ID, (objectArg_2 = get$.Optional, objectArg_2.Field("lastName", string)), FirstName, (objectArg_3 = get$.Optional, objectArg_3.Field("midInitials", string)), (objectArg_4 = get$.Optional, objectArg_4.Field("email", string)), (objectArg_5 = get$.Optional, objectArg_5.Field("phone", string)), (objectArg_6 = get$.Optional, objectArg_6.Field("fax", string)), (objectArg_7 = get$.Optional, objectArg_7.Field("address", string)), (objectArg_8 = get$.Optional, objectArg_8.Field("affiliation", string)), (arg_19 = ((decoder_1 = OntologyAnnotation_decoder(options), (path_8) => ((value_8) => list_1(uncurry2(decoder_1), path_8, value_8)))), (objectArg_9 = get$.Optional, objectArg_9.Field("roles", uncurry2(arg_19)))), (arg_21 = ((decoder_2 = decoder_3(options), (path_9) => ((value_9) => list_1(uncurry2(decoder_2), path_9, value_9)))), (objectArg_10 = get$.Optional, objectArg_10.Field("comments", uncurry2(arg_21))))); - }, path_10, v)); -} - -export function fromString(s) { - return fromString_1(uncurry2(decoder(ConverterOptions_$ctor())), s); -} - -export function toString(p) { - return toString_1(2, encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function toStringLD(p) { - let returnVal; - return toString_1(2, encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - diff --git a/js/ISA/ISA.Json/Process.js b/js/ISA/ISA.Json/Process.js deleted file mode 100644 index dcc67ee8..00000000 --- a/js/ISA/ISA.Json/Process.js +++ /dev/null @@ -1,291 +0,0 @@ -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { ProtocolParameter_getNameText_2762A46F } from "../ISA/JsonTypes/ProtocolParameter.js"; -import { Value_getText_Z277CD705 } from "../ISA/JsonTypes/Value.js"; -import { list as list_2, toString, nil, object as object_22 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { map, choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { Protocol_decoder, Protocol_encoder, ProtocolParameter_decoder, ProtocolParameter_encoder } from "./Protocol.js"; -import { Value_decoder, Value_encoder } from "./Factor.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { list as list_1, string, object as object_23 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { ProcessParameterValue } from "../ISA/JsonTypes/ProcessParameterValue.js"; -import { uri, fromString } from "./Decode.js"; -import { ProcessInput } from "../ISA/JsonTypes/ProcessInput.js"; -import { Data_decoder, Sample_decoder, Source_decoder, Source_encoder, Data_encoder, Sample_encoder } from "./Data.js"; -import { Material_decoder, Material_encoder } from "./Material.js"; -import { FSharpResult$2 } from "../../fable_modules/fable-library.4.1.4/Choice.js"; -import { ProcessOutput } from "../ISA/JsonTypes/ProcessOutput.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { decoder as decoder_4, encoder } from "./Comment.js"; -import { Process } from "../ISA/JsonTypes/Process.js"; - -export function ProcessParameterValue_genID(p) { - const matchValue = p.Value; - const matchValue_1 = p.Category; - let matchResult, c, v; - if (matchValue != null) { - if (matchValue_1 != null) { - matchResult = 0; - c = matchValue_1; - v = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return (("#Param_" + replace(ProtocolParameter_getNameText_2762A46F(c), " ", "_")) + "_") + replace(Value_getText_Z277CD705(v), " ", "_"); - default: - return "#EmptyParameterValue"; - } -} - -export function ProcessParameterValue_encoder(options, oa) { - return object_22(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = ProcessParameterValue_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : empty(), delay(() => { - let value_2, s_1; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_2 = "ProcessParameterValue", (typeof value_2 === "string") ? ((s_1 = value_2, s_1)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("category", (oa_1) => ProtocolParameter_encoder(options, oa_1), oa["Category"])), delay(() => append(singleton(tryInclude("value", (value_4) => Value_encoder(options, value_4), oa["Value"])), delay(() => singleton(tryInclude("unit", (oa_2) => OntologyAnnotation_encoder(options, oa_2), oa["Unit"])))))))); - })); - })))); -} - -export function ProcessParameterValue_decoder(options) { - return (path) => ((v) => object_23((get$) => { - let arg_1, objectArg, objectArg_1, arg_5, objectArg_2; - return new ProcessParameterValue((arg_1 = ProtocolParameter_decoder(options), (objectArg = get$.Optional, objectArg.Field("category", uncurry2(arg_1)))), (objectArg_1 = get$.Optional, objectArg_1.Field("value", (s, json) => Value_decoder(options, s, json))), (arg_5 = OntologyAnnotation_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("unit", uncurry2(arg_5))))); - }, path, v)); -} - -export function ProcessParameterValue_fromString(s) { - return fromString(uncurry2(ProcessParameterValue_decoder(ConverterOptions_$ctor())), s); -} - -export function ProcessParameterValue_toString(p) { - return toString(2, ProcessParameterValue_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function ProcessParameterValue_toStringLD(p) { - let returnVal; - return toString(2, ProcessParameterValue_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - -export function ProcessInput_encoder(options, value) { - if (value instanceof ProcessInput) { - if (value.tag === 1) { - return Sample_encoder(options, value.fields[0]); - } - else if (value.tag === 2) { - return Data_encoder(options, value.fields[0]); - } - else if (value.tag === 3) { - return Material_encoder(options, value.fields[0]); - } - else { - return Source_encoder(options, value.fields[0]); - } - } - else { - return nil; - } -} - -export function ProcessInput_decoder(options, s, json) { - const matchValue = Source_decoder(options, s, json); - if (matchValue.tag === 1) { - const matchValue_1 = Sample_decoder(options, s, json); - if (matchValue_1.tag === 1) { - const matchValue_2 = Data_decoder(options, s, json); - if (matchValue_2.tag === 1) { - const matchValue_3 = Material_decoder(options, s, json); - if (matchValue_3.tag === 1) { - return new FSharpResult$2(1, [matchValue_3.fields[0]]); - } - else { - return new FSharpResult$2(0, [new ProcessInput(3, [matchValue_3.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new ProcessInput(2, [matchValue_2.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new ProcessInput(1, [matchValue_1.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new ProcessInput(0, [matchValue.fields[0]])]); - } -} - -export function ProcessInput_fromString(s) { - let options; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1) => ((json) => ProcessInput_decoder(options, s_1, json)))), s); -} - -export function ProcessInput_toString(m) { - return toString(2, ProcessInput_encoder(ConverterOptions_$ctor(), m)); -} - -export function ProcessInput_toStringLD(m) { - let returnVal; - return toString(2, ProcessInput_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), m)); -} - -export function ProcessOutput_encoder(options, value) { - if (value instanceof ProcessOutput) { - if (value.tag === 1) { - return Data_encoder(options, value.fields[0]); - } - else if (value.tag === 2) { - return Material_encoder(options, value.fields[0]); - } - else { - return Sample_encoder(options, value.fields[0]); - } - } - else { - return nil; - } -} - -export function ProcessOutput_decoder(options, s, json) { - const matchValue = Sample_decoder(options, s, json); - if (matchValue.tag === 1) { - const matchValue_1 = Data_decoder(options, s, json); - if (matchValue_1.tag === 1) { - const matchValue_2 = Material_decoder(options, s, json); - if (matchValue_2.tag === 1) { - return new FSharpResult$2(1, [matchValue_2.fields[0]]); - } - else { - return new FSharpResult$2(0, [new ProcessOutput(2, [matchValue_2.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new ProcessOutput(1, [matchValue_1.fields[0]])]); - } - } - else { - return new FSharpResult$2(0, [new ProcessOutput(0, [matchValue.fields[0]])]); - } -} - -export function ProcessOutput_fromString(s) { - let options; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1) => ((json) => ProcessOutput_decoder(options, s_1, json)))), s); -} - -export function ProcessOutput_toString(m) { - return toString(2, ProcessOutput_encoder(ConverterOptions_$ctor(), m)); -} - -export function Process_genID(p) { - const matchValue = p.ID; - if (matchValue == null) { - const matchValue_1 = p.Name; - if (matchValue_1 == null) { - return "#EmptyProcess"; - } - else { - return "#Process_" + replace(matchValue_1, " ", "_"); - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function Process_encoder(options, oa) { - return object_22(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Process_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Process", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("name", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["Name"])), delay(() => append(singleton(tryInclude("executesProtocol", (oa_1) => Protocol_encoder(options, oa_1), oa["ExecutesProtocol"])), delay(() => append(singleton(tryInclude("parameterValues", (oa_2) => ProcessParameterValue_encoder(options, oa_2), oa["ParameterValues"])), delay(() => append(singleton(tryInclude("performer", (value_10) => { - let s_4; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_4 = value_11, s_4)) : nil; - }, oa["Performer"])), delay(() => append(singleton(tryInclude("date", (value_13) => { - let s_5; - const value_14 = value_13; - return (typeof value_14 === "string") ? ((s_5 = value_14, s_5)) : nil; - }, oa["Date"])), delay(() => append(singleton(tryInclude("previousProcess", (oa_3) => Process_encoder(options, oa_3), oa["PreviousProcess"])), delay(() => append(singleton(tryInclude("nextProcess", (oa_4) => Process_encoder(options, oa_4), oa["NextProcess"])), delay(() => append(singleton(tryInclude("inputs", (value_16) => ProcessInput_encoder(options, value_16), oa["Inputs"])), delay(() => append(singleton(tryInclude("outputs", (value_17) => ProcessOutput_encoder(options, value_17), oa["Outputs"])), delay(() => singleton(tryInclude("comments", (comment) => encoder(options, comment), oa["Comments"])))))))))))))))))))))); - })); - })))); -} - -export function Process_decoder(options) { - return (path_7) => ((v) => object_23((get$) => { - let objectArg, objectArg_1, arg_5, objectArg_2, arg_7, decoder, objectArg_3, objectArg_4, objectArg_5, arg_13, objectArg_6, arg_15, objectArg_7, objectArg_8, objectArg_9, arg_21, decoder_3, objectArg_10; - return new Process((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = Protocol_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("executesProtocol", uncurry2(arg_5)))), (arg_7 = ((decoder = ProcessParameterValue_decoder(options), (path_1) => ((value_1) => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_3 = get$.Optional, objectArg_3.Field("parameterValues", uncurry2(arg_7)))), (objectArg_4 = get$.Optional, objectArg_4.Field("performer", string)), (objectArg_5 = get$.Optional, objectArg_5.Field("date", string)), (arg_13 = Process_decoder(options), (objectArg_6 = get$.Optional, objectArg_6.Field("previousProcess", uncurry2(arg_13)))), (arg_15 = Process_decoder(options), (objectArg_7 = get$.Optional, objectArg_7.Field("nextProcess", uncurry2(arg_15)))), (objectArg_8 = get$.Optional, objectArg_8.Field("inputs", (path_4, value_4) => list_1((s_1, json_1) => ProcessInput_decoder(options, s_1, json_1), path_4, value_4))), (objectArg_9 = get$.Optional, objectArg_9.Field("outputs", (path_5, value_5) => list_1((s_2, json_2) => ProcessOutput_decoder(options, s_2, json_2), path_5, value_5))), (arg_21 = ((decoder_3 = decoder_4(options), (path_6) => ((value_6) => list_1(uncurry2(decoder_3), path_6, value_6)))), (objectArg_10 = get$.Optional, objectArg_10.Field("comments", uncurry2(arg_21))))); - }, path_7, v)); -} - -export function Process_fromString(s) { - return fromString(uncurry2(Process_decoder(ConverterOptions_$ctor())), s); -} - -export function Process_toString(p) { - return toString(2, Process_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Process_toStringLD(p) { - let returnVal; - return toString(2, Process_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - -export function ProcessSequence_fromString(s) { - let decoder; - return fromString(uncurry2((decoder = Process_decoder(ConverterOptions_$ctor()), (path) => ((value) => list_1(uncurry2(decoder), path, value)))), s); -} - -export function ProcessSequence_toString(p) { - let options; - return toString(2, list_2(map((options = ConverterOptions_$ctor(), (oa) => Process_encoder(options, oa)), p))); -} - -/** - * exports in json-ld format - */ -export function ProcessSequence_toStringLD(p) { - let options, returnVal; - return toString(2, list_2(map((options = ((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal))), (oa) => Process_encoder(options, oa)), p))); -} - diff --git a/js/ISA/ISA.Json/Protocol.js b/js/ISA/ISA.Json/Protocol.js deleted file mode 100644 index caffa99f..00000000 --- a/js/ISA/ISA.Json/Protocol.js +++ /dev/null @@ -1,242 +0,0 @@ -import { value as value_19 } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { toString, nil, object as object_18 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { list as list_1, string, object as object_19 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { fromString, uri } from "./Decode.js"; -import { ProtocolParameter } from "../ISA/JsonTypes/ProtocolParameter.js"; -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { Result_Map } from "../../fable_modules/fable-library.4.1.4/Choice.js"; -import { Component, Component_decomposeName_Z721C83C5 } from "../ISA/JsonTypes/Component.js"; -import { decoder as decoder_3, encoder } from "./Comment.js"; -import { Protocol } from "../ISA/JsonTypes/Protocol.js"; - -export function ProtocolParameter_genID(pp) { - const matchValue = pp.ID; - if (matchValue == null) { - const matchValue_1 = pp.ParameterName; - let matchResult, n_1; - if (matchValue_1 != null) { - if (!(matchValue_1.ID == null)) { - matchResult = 0; - n_1 = matchValue_1; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return "#Param_" + value_19(n_1.ID); - default: - return "#EmptyProtocolParameter"; - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function ProtocolParameter_encoder(options, oa) { - return object_18(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = ProtocolParameter_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "ProtocolParameter", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => singleton(tryInclude("parameterName", (oa_1) => OntologyAnnotation_encoder(options, oa_1), oa["ParameterName"])))); - })); - })))); -} - -export function ProtocolParameter_decoder(options) { - return (path) => ((v) => object_19((get$) => { - let objectArg, arg_3, objectArg_1; - return new ProtocolParameter((objectArg = get$.Optional, objectArg.Field("@id", uri)), (arg_3 = OntologyAnnotation_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("parameterName", uncurry2(arg_3))))); - }, path, v)); -} - -export function ProtocolParameter_fromString(s) { - return fromString(uncurry2(ProtocolParameter_decoder(ConverterOptions_$ctor())), s); -} - -export function ProtocolParameter_toString(p) { - return toString(2, ProtocolParameter_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function ProtocolParameter_toStringLD(p) { - let returnVal; - return toString(2, ProtocolParameter_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - -export function Component_genID(c) { - const matchValue = c.ComponentName; - if (matchValue == null) { - return "#EmptyComponent"; - } - else { - return "#Component_" + replace(matchValue, " ", "_"); - } -} - -export function Component_encoder(options, oa) { - return object_18(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Component_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : empty(), delay(() => { - let value_2, s_1; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_2 = "Component", (typeof value_2 === "string") ? ((s_1 = value_2, s_1)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("componentName", (value_4) => { - let s_2; - const value_5 = value_4; - return (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil; - }, oa["ComponentName"])), delay(() => singleton(tryInclude("componentType", (oa_1) => OntologyAnnotation_encoder(options, oa_1), oa["ComponentType"])))))); - })); - })))); -} - -export function Component_decoder(options, s, json) { - return Result_Map((c) => { - let patternInput; - const matchValue = c.ComponentName; - if (matchValue == null) { - patternInput = [void 0, void 0]; - } - else { - const tupledArg = Component_decomposeName_Z721C83C5(matchValue); - patternInput = [tupledArg[0], tupledArg[1]]; - } - return new Component(c.ComponentName, patternInput[0], patternInput[1], c.ComponentType); - }, object_19((get$) => { - let objectArg, arg_3, objectArg_1; - return new Component((objectArg = get$.Optional, objectArg.Field("componentName", uri)), void 0, void 0, (arg_3 = OntologyAnnotation_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("componentType", uncurry2(arg_3))))); - }, s, json)); -} - -export function Component_fromString(s) { - let options; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1) => ((json) => Component_decoder(options, s_1, json)))), s); -} - -export function Component_toString(p) { - return toString(2, Component_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Component_toStringLD(p) { - let returnVal; - return toString(2, Component_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - -export function Protocol_genID(p) { - const matchValue = p.ID; - if (matchValue == null) { - const matchValue_1 = p.Uri; - if (matchValue_1 == null) { - const matchValue_2 = p.Name; - if (matchValue_2 == null) { - return "#EmptyProtocol"; - } - else { - return "#Protocol_" + replace(matchValue_2, " ", "_"); - } - } - else { - return matchValue_1; - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function Protocol_encoder(options, oa) { - return object_18(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Protocol_genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_1; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_1 = value_3, s_1)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_2; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Protocol", (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("name", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["Name"])), delay(() => append(singleton(tryInclude("protocolType", (oa_1) => OntologyAnnotation_encoder(options, oa_1), oa["ProtocolType"])), delay(() => append(singleton(tryInclude("description", (value_10) => { - let s_4; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_4 = value_11, s_4)) : nil; - }, oa["Description"])), delay(() => append(singleton(tryInclude("uri", (value_13) => { - let s_5; - const value_14 = value_13; - return (typeof value_14 === "string") ? ((s_5 = value_14, s_5)) : nil; - }, oa["Uri"])), delay(() => append(singleton(tryInclude("version", (value_16) => { - let s_6; - const value_17 = value_16; - return (typeof value_17 === "string") ? ((s_6 = value_17, s_6)) : nil; - }, oa["Version"])), delay(() => append(singleton(tryInclude("parameters", (oa_2) => ProtocolParameter_encoder(options, oa_2), oa["Parameters"])), delay(() => append(singleton(tryInclude("components", (oa_3) => Component_encoder(options, oa_3), oa["Components"])), delay(() => singleton(tryInclude("comments", (comment) => encoder(options, comment), oa["Comments"])))))))))))))))))); - })); - })))); -} - -export function Protocol_decoder(options) { - return (path_6) => ((v) => object_19((get$) => { - let objectArg, objectArg_1, arg_5, objectArg_2, objectArg_3, objectArg_4, objectArg_5, arg_13, decoder, objectArg_6, objectArg_7, arg_17, decoder_2, objectArg_8; - return new Protocol((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = OntologyAnnotation_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("protocolType", uncurry2(arg_5)))), (objectArg_3 = get$.Optional, objectArg_3.Field("description", string)), (objectArg_4 = get$.Optional, objectArg_4.Field("uri", uri)), (objectArg_5 = get$.Optional, objectArg_5.Field("version", string)), (arg_13 = ((decoder = ProtocolParameter_decoder(options), (path_3) => ((value_3) => list_1(uncurry2(decoder), path_3, value_3)))), (objectArg_6 = get$.Optional, objectArg_6.Field("parameters", uncurry2(arg_13)))), (objectArg_7 = get$.Optional, objectArg_7.Field("components", (path_4, value_4) => list_1((s_2, json_2) => Component_decoder(options, s_2, json_2), path_4, value_4))), (arg_17 = ((decoder_2 = decoder_3(options), (path_5) => ((value_5) => list_1(uncurry2(decoder_2), path_5, value_5)))), (objectArg_8 = get$.Optional, objectArg_8.Field("comments", uncurry2(arg_17))))); - }, path_6, v)); -} - -export function Protocol_fromString(s) { - return fromString(uncurry2(Protocol_decoder(ConverterOptions_$ctor())), s); -} - -export function Protocol_toString(p) { - return toString(2, Protocol_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Protocol_toStringLD(p) { - let returnVal; - return toString(2, Protocol_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - diff --git a/js/ISA/ISA.Json/Publication.js b/js/ISA/ISA.Json/Publication.js deleted file mode 100644 index 2fa74e78..00000000 --- a/js/ISA/ISA.Json/Publication.js +++ /dev/null @@ -1,92 +0,0 @@ -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { toString as toString_1, nil, object as object_12 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { decoder as decoder_2, encoder as encoder_1 } from "./Comment.js"; -import { list as list_1, string, object as object_13 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { fromString as fromString_1, uri } from "./Decode.js"; -import { Publication } from "../ISA/JsonTypes/Publication.js"; - -export function genID(p) { - const matchValue = p.DOI; - if (matchValue == null) { - const matchValue_1 = p.PubMedID; - if (matchValue_1 == null) { - const matchValue_2 = p.Title; - if (matchValue_2 == null) { - return "#EmptyPublication"; - } - else { - return "#Pub_" + replace(matchValue_2, " ", "_"); - } - } - else { - return matchValue_1; - } - } - else { - return matchValue; - } -} - -export function encoder(options, oa) { - return object_12(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = genID(oa), (typeof value === "string") ? ((s = value, s)) : nil)]) : empty(), delay(() => { - let value_2, s_1; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_2 = "Publication", (typeof value_2 === "string") ? ((s_1 = value_2, s_1)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("pubMedID", (value_4) => { - let s_2; - const value_5 = value_4; - return (typeof value_5 === "string") ? ((s_2 = value_5, s_2)) : nil; - }, oa["PubMedID"])), delay(() => append(singleton(tryInclude("doi", (value_7) => { - let s_3; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_3 = value_8, s_3)) : nil; - }, oa["DOI"])), delay(() => append(singleton(tryInclude("authorList", (value_10) => { - let s_4; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_4 = value_11, s_4)) : nil; - }, oa["Authors"])), delay(() => append(singleton(tryInclude("title", (value_13) => { - let s_5; - const value_14 = value_13; - return (typeof value_14 === "string") ? ((s_5 = value_14, s_5)) : nil; - }, oa["Title"])), delay(() => append(singleton(tryInclude("status", (oa_1) => OntologyAnnotation_encoder(options, oa_1), oa["Status"])), delay(() => singleton(tryInclude("comments", (comment) => encoder_1(options, comment), oa["Comments"])))))))))))))); - })); - })))); -} - -export function decoder(options) { - return (path_4) => ((v) => object_13((get$) => { - let objectArg, objectArg_1, objectArg_2, objectArg_3, arg_9, objectArg_4, arg_11, decoder_1, objectArg_5; - return new Publication((objectArg = get$.Optional, objectArg.Field("pubMedID", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("doi", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("authorList", string)), (objectArg_3 = get$.Optional, objectArg_3.Field("title", string)), (arg_9 = OntologyAnnotation_decoder(options), (objectArg_4 = get$.Optional, objectArg_4.Field("status", uncurry2(arg_9)))), (arg_11 = ((decoder_1 = decoder_2(options), (path_3) => ((value_3) => list_1(uncurry2(decoder_1), path_3, value_3)))), (objectArg_5 = get$.Optional, objectArg_5.Field("comments", uncurry2(arg_11))))); - }, path_4, v)); -} - -export function fromString(s) { - return fromString_1(uncurry2(decoder(ConverterOptions_$ctor())), s); -} - -export function toString(p) { - return toString_1(2, encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function toStringLD(p) { - let returnVal; - return toString_1(2, encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - diff --git a/js/ISA/ISA.Json/Study.js b/js/ISA/ISA.Json/Study.js deleted file mode 100644 index a5d19f7a..00000000 --- a/js/ISA/ISA.Json/Study.js +++ /dev/null @@ -1,230 +0,0 @@ -import { toString, nil, object as object_36 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { ofArray, choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { tryInclude } from "./GEncode.js"; -import { Sample_decoder, Source_decoder, Sample_encoder, Source_encoder } from "./Data.js"; -import { MaterialAttribute_decoder, MaterialAttribute_encoder, Material_decoder, Material_encoder } from "./Material.js"; -import { string, list as list_1, object as object_37 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { StudyMaterials } from "../ISA/JsonTypes/StudyMaterials.js"; -import { replace } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { decoder as decoder_10, encoder } from "./Publication.js"; -import { decoder as decoder_11, encoder as encoder_1 } from "./Person.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { Protocol_decoder, Protocol_encoder } from "./Protocol.js"; -import { Process_decoder, Process_encoder } from "./Process.js"; -import { Assay_decoder, Assay_encoder } from "./Assay.js"; -import { Factor_decoder, Factor_encoder } from "./Factor.js"; -import { decoder as decoder_12, encoder as encoder_2 } from "./Comment.js"; -import { fromString, uri } from "./Decode.js"; -import { Study } from "../ISA/JsonTypes/Study.js"; -import { ArcStudy } from "../ISA/ArcTypes/ArcStudy.js"; - -export function StudyMaterials_encoder(options, oa) { - return object_36(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, ofArray([tryInclude("sources", (oa_1) => Source_encoder(options, oa_1), oa["Sources"]), tryInclude("samples", (oa_2) => Sample_encoder(options, oa_2), oa["Samples"]), tryInclude("otherMaterials", (oa_3) => Material_encoder(options, oa_3), oa["OtherMaterials"])]))); -} - -export function StudyMaterials_decoder(options) { - return (path_3) => ((v) => object_37((get$) => { - let objectArg, objectArg_1, objectArg_2; - return new StudyMaterials((objectArg = get$.Optional, objectArg.Field("sources", (path, value) => list_1((s, json) => Source_decoder(options, s, json), path, value))), (objectArg_1 = get$.Optional, objectArg_1.Field("samples", (path_1, value_1) => list_1((s_1, json_1) => Sample_decoder(options, s_1, json_1), path_1, value_1))), (objectArg_2 = get$.Optional, objectArg_2.Field("otherMaterials", (path_2, value_2) => list_1((s_2, json_2) => Material_decoder(options, s_2, json_2), path_2, value_2)))); - }, path_3, v)); -} - -export function Study_genID(s) { - const matchValue = s.ID; - if (matchValue == null) { - const matchValue_1 = s.FileName; - if (matchValue_1 == null) { - const matchValue_2 = s.Identifier; - if (matchValue_2 == null) { - const matchValue_3 = s.Title; - if (matchValue_3 == null) { - return "#EmptyStudy"; - } - else { - return "#Study_" + replace(matchValue_3, " ", "_"); - } - } - else { - return "#Study_" + replace(matchValue_2, " ", "_"); - } - } - else { - return "#Study" + replace(matchValue_1, " ", "_"); - } - } - else { - return URIModule_toString(matchValue); - } -} - -export function Study_encoder(options, oa) { - return object_36(choose((tupledArg) => { - const v = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v]; - } - }, toList(delay(() => { - let value, s_1; - return append(ConverterOptions__get_SetID(options) ? singleton(["@id", (value = Study_genID(oa), (typeof value === "string") ? ((s_1 = value, s_1)) : nil)]) : singleton(tryInclude("@id", (value_2) => { - let s_2; - const value_3 = value_2; - return (typeof value_3 === "string") ? ((s_2 = value_3, s_2)) : nil; - }, oa["ID"])), delay(() => { - let value_5, s_3; - return append(ConverterOptions__get_IncludeType(options) ? singleton(["@type", (value_5 = "Study", (typeof value_5 === "string") ? ((s_3 = value_5, s_3)) : nil)]) : empty(), delay(() => append(singleton(tryInclude("filename", (value_7) => { - let s_4; - const value_8 = value_7; - return (typeof value_8 === "string") ? ((s_4 = value_8, s_4)) : nil; - }, oa["FileName"])), delay(() => append(singleton(tryInclude("identifier", (value_10) => { - let s_5; - const value_11 = value_10; - return (typeof value_11 === "string") ? ((s_5 = value_11, s_5)) : nil; - }, oa["Identifier"])), delay(() => append(singleton(tryInclude("title", (value_13) => { - let s_6; - const value_14 = value_13; - return (typeof value_14 === "string") ? ((s_6 = value_14, s_6)) : nil; - }, oa["Title"])), delay(() => append(singleton(tryInclude("description", (value_16) => { - let s_7; - const value_17 = value_16; - return (typeof value_17 === "string") ? ((s_7 = value_17, s_7)) : nil; - }, oa["Description"])), delay(() => append(singleton(tryInclude("submissionDate", (value_19) => { - let s_8; - const value_20 = value_19; - return (typeof value_20 === "string") ? ((s_8 = value_20, s_8)) : nil; - }, oa["SubmissionDate"])), delay(() => append(singleton(tryInclude("publicReleaseDate", (value_22) => { - let s_9; - const value_23 = value_22; - return (typeof value_23 === "string") ? ((s_9 = value_23, s_9)) : nil; - }, oa["PublicReleaseDate"])), delay(() => append(singleton(tryInclude("publications", (oa_1) => encoder(options, oa_1), oa["Publications"])), delay(() => append(singleton(tryInclude("people", (oa_2) => encoder_1(options, oa_2), oa["Contacts"])), delay(() => append(singleton(tryInclude("studyDesignDescriptors", (oa_3) => OntologyAnnotation_encoder(options, oa_3), oa["StudyDesignDescriptors"])), delay(() => append(singleton(tryInclude("protocols", (oa_4) => Protocol_encoder(options, oa_4), oa["Protocols"])), delay(() => append(singleton(tryInclude("materials", (oa_5) => StudyMaterials_encoder(options, oa_5), oa["Materials"])), delay(() => append(singleton(tryInclude("processSequence", (oa_6) => Process_encoder(options, oa_6), oa["ProcessSequence"])), delay(() => append(singleton(tryInclude("assays", (oa_7) => Assay_encoder(options, oa_7), oa["Assays"])), delay(() => append(singleton(tryInclude("factors", (oa_8) => Factor_encoder(options, oa_8), oa["Factors"])), delay(() => append(singleton(tryInclude("characteristicCategories", (oa_9) => MaterialAttribute_encoder(options, oa_9), oa["CharacteristicCategories"])), delay(() => append(singleton(tryInclude("unitCategories", (oa_10) => OntologyAnnotation_encoder(options, oa_10), oa["UnitCategories"])), delay(() => singleton(tryInclude("comments", (comment) => encoder_2(options, comment), oa["Comments"])))))))))))))))))))))))))))))))))))); - })); - })))); -} - -export function Study_decoder(options) { - return (path_16) => ((v) => object_37((get$) => { - let arg_33, decoder_8, objectArg_16, arg_35, decoder_9, objectArg_17; - let ID; - const objectArg = get$.Optional; - ID = objectArg.Field("@id", uri); - let FileName; - const objectArg_1 = get$.Optional; - FileName = objectArg_1.Field("filename", string); - let Identifier; - const objectArg_2 = get$.Optional; - Identifier = objectArg_2.Field("identifier", string); - let Title; - const objectArg_3 = get$.Optional; - Title = objectArg_3.Field("title", string); - let Description; - const objectArg_4 = get$.Optional; - Description = objectArg_4.Field("description", string); - let SubmissionDate; - const objectArg_5 = get$.Optional; - SubmissionDate = objectArg_5.Field("submissionDate", string); - let PublicReleaseDate; - const objectArg_6 = get$.Optional; - PublicReleaseDate = objectArg_6.Field("publicReleaseDate", string); - let Publications; - let arg_15; - const decoder = decoder_10(options); - arg_15 = ((path_6) => ((value_6) => list_1(uncurry2(decoder), path_6, value_6))); - const objectArg_7 = get$.Optional; - Publications = objectArg_7.Field("publications", uncurry2(arg_15)); - let Contacts; - let arg_17; - const decoder_1 = decoder_11(options); - arg_17 = ((path_7) => ((value_7) => list_1(uncurry2(decoder_1), path_7, value_7))); - const objectArg_8 = get$.Optional; - Contacts = objectArg_8.Field("people", uncurry2(arg_17)); - let StudyDesignDescriptors; - let arg_19; - const decoder_2 = OntologyAnnotation_decoder(options); - arg_19 = ((path_8) => ((value_8) => list_1(uncurry2(decoder_2), path_8, value_8))); - const objectArg_9 = get$.Optional; - StudyDesignDescriptors = objectArg_9.Field("studyDesignDescriptors", uncurry2(arg_19)); - let Protocols; - let arg_21; - const decoder_3 = Protocol_decoder(options); - arg_21 = ((path_9) => ((value_9) => list_1(uncurry2(decoder_3), path_9, value_9))); - const objectArg_10 = get$.Optional; - Protocols = objectArg_10.Field("protocols", uncurry2(arg_21)); - let Materials; - const arg_23 = StudyMaterials_decoder(options); - const objectArg_11 = get$.Optional; - Materials = objectArg_11.Field("materials", uncurry2(arg_23)); - let Assays; - let arg_25; - const decoder_4 = Assay_decoder(options); - arg_25 = ((path_10) => ((value_10) => list_1(uncurry2(decoder_4), path_10, value_10))); - const objectArg_12 = get$.Optional; - Assays = objectArg_12.Field("assays", uncurry2(arg_25)); - let Factors; - let arg_27; - const decoder_5 = Factor_decoder(options); - arg_27 = ((path_11) => ((value_11) => list_1(uncurry2(decoder_5), path_11, value_11))); - const objectArg_13 = get$.Optional; - Factors = objectArg_13.Field("factors", uncurry2(arg_27)); - let CharacteristicCategories; - let arg_29; - const decoder_6 = MaterialAttribute_decoder(options); - arg_29 = ((path_12) => ((value_12) => list_1(uncurry2(decoder_6), path_12, value_12))); - const objectArg_14 = get$.Optional; - CharacteristicCategories = objectArg_14.Field("characteristicCategories", uncurry2(arg_29)); - let UnitCategories; - let arg_31; - const decoder_7 = OntologyAnnotation_decoder(options); - arg_31 = ((path_13) => ((value_13) => list_1(uncurry2(decoder_7), path_13, value_13))); - const objectArg_15 = get$.Optional; - UnitCategories = objectArg_15.Field("unitCategories", uncurry2(arg_31)); - return new Study(ID, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, Publications, Contacts, StudyDesignDescriptors, Protocols, Materials, (arg_33 = ((decoder_8 = Process_decoder(options), (path_14) => ((value_14) => list_1(uncurry2(decoder_8), path_14, value_14)))), (objectArg_16 = get$.Optional, objectArg_16.Field("processSequence", uncurry2(arg_33)))), Assays, Factors, CharacteristicCategories, UnitCategories, (arg_35 = ((decoder_9 = decoder_12(options), (path_15) => ((value_15) => list_1(uncurry2(decoder_9), path_15, value_15)))), (objectArg_17 = get$.Optional, objectArg_17.Field("comments", uncurry2(arg_35))))); - }, path_16, v)); -} - -export function Study_fromString(s) { - return fromString(uncurry2(Study_decoder(ConverterOptions_$ctor())), s); -} - -export function Study_toString(p) { - return toString(2, Study_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Study_toStringLD(s) { - let returnVal; - return toString(2, Study_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), s)); -} - -export function ArcStudy_fromString(s) { - const arg = fromString(uncurry2(Study_decoder(ConverterOptions_$ctor())), s); - return ArcStudy.fromStudy(arg); -} - -export function ArcStudy_toString(a) { - return toString(2, Study_encoder(ConverterOptions_$ctor(), a.ToStudy())); -} - -/** - * exports in json-ld format - */ -export function ArcStudy_toStringLD(a) { - let returnVal; - return toString(2, Study_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), a.ToStudy())); -} - diff --git a/js/ISA/ISA.Json/Validation/Fable.js b/js/ISA/ISA.Json/Validation/Fable.js deleted file mode 100644 index b2ced3c8..00000000 --- a/js/ISA/ISA.Json/Validation/Fable.js +++ /dev/null @@ -1,69 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { bool_type, option_type, array_type, record_type, string_type, obj_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { map } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { singleton } from "../../../fable_modules/fable-library.4.1.4/AsyncBuilder.js"; -import { awaitPromise } from "../../../fable_modules/fable-library.4.1.4/Async.js"; -import * as JsonValidation from "../../../../src/ISA/ISA.Json/Validation/JsonValidation.js"; -import { value } from "../../../fable_modules/fable-library.4.1.4/Option.js"; - -export class ValidationError extends Record { - constructor(path, property, message, schema, instance, name, argument, stack) { - super(); - this.path = path; - this.property = property; - this.message = message; - this.schema = schema; - this.instance = instance; - this.name = name; - this.argument = argument; - this.stack = stack; - } -} - -export function ValidationError_$reflection() { - return record_type("ISA.Json.Fable.ValidationError", [], ValidationError, () => [["path", obj_type], ["property", string_type], ["message", string_type], ["schema", obj_type], ["instance", obj_type], ["name", string_type], ["argument", obj_type], ["stack", string_type]]); -} - -export function ValidationError__ToErrorString(this$) { - return `Property ${this$.property} (${this$.instance}) ${this$.message}.`; -} - -export class ValidatorResult extends Record { - constructor(instance, schema, options, path, propertyPath, errors, throwError, throFirst, throwAll, disableFormat) { - super(); - this.instance = instance; - this.schema = schema; - this.options = options; - this.path = path; - this.propertyPath = propertyPath; - this.errors = errors; - this.throwError = throwError; - this.throFirst = throFirst; - this.throwAll = throwAll; - this.disableFormat = disableFormat; - } -} - -export function ValidatorResult_$reflection() { - return record_type("ISA.Json.Fable.ValidatorResult", [], ValidatorResult, () => [["instance", obj_type], ["schema", obj_type], ["options", obj_type], ["path", array_type(obj_type)], ["propertyPath", string_type], ["errors", array_type(ValidationError_$reflection())], ["throwError", option_type(obj_type)], ["throFirst", option_type(obj_type)], ["throwAll", option_type(obj_type)], ["disableFormat", bool_type]]); -} - -export function ValidatorResult__ToValidationResult(this$) { - if (this$.errors.length === 0) { - return [true, []]; - } - else { - return [false, map(ValidationError__ToErrorString, this$.errors)]; - } -} - -export function validate(schemaURL, objectString) { - let validationResult = void 0; - return singleton.Delay(() => singleton.Bind(awaitPromise(JsonValidation.validateAgainstSchema(objectString, schemaURL).then((o) => { - validationResult = o; - })), () => { - const output = ValidatorResult__ToValidationResult(value(validationResult)); - return singleton.Return(output); - })); -} - diff --git a/js/ISA/ISA.Json/Validation/JsonSchemaValidation.js b/js/ISA/ISA.Json/Validation/JsonSchemaValidation.js deleted file mode 100644 index e7248513..00000000 --- a/js/ISA/ISA.Json/Validation/JsonSchemaValidation.js +++ /dev/null @@ -1,88 +0,0 @@ -import { singleton } from "../../../fable_modules/fable-library.4.1.4/AsyncBuilder.js"; -import { validate } from "./Fable.js"; -import { ValidationResult, ValidationResult_OfJSchemaOutput_Z6EC48F6B } from "./ValidationResult.js"; - -export function Validation_validate(schemaURL, objectString) { - return singleton.Delay(() => singleton.TryWith(singleton.Delay(() => singleton.Bind(validate(schemaURL, objectString), (_arg) => singleton.Return(ValidationResult_OfJSchemaOutput_Z6EC48F6B([_arg[0], _arg[1]])))), (_arg_1) => singleton.Return(new ValidationResult(1, [[_arg_1.message]])))); -} - -export function Validation_validateAssay(assayString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/assay_schema.json", assayString); -} - -export function Validation_validateComment(commentString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/comment_schema.json", commentString); -} - -export function Validation_validateData(dataString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/data_schema.json", dataString); -} - -export function Validation_validateFactor(factorString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/factor_schema.json", factorString); -} - -export function Validation_validateFactorValue(factorValueString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/factor_value_schema.json", factorValueString); -} - -export function Validation_validateInvestigation(investigationString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/investigation_schema.json", investigationString); -} - -export function Validation_validateMaterialAttribute(materialAttributeString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/material_attribute_schema.json", materialAttributeString); -} - -export function Validation_validateMaterialAttributeValue(materialAttributeValueString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/material_attribute_value_schema.json", materialAttributeValueString); -} - -export function Validation_validateMaterial(materialString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/material_schema.json", materialString); -} - -export function Validation_validateOntologyAnnotation(ontologyAnnotationString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/ontology_annotation_schema.json", ontologyAnnotationString); -} - -export function Validation_validateOntologySourceReference(ontologySourceReferenceString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/ontology_source_reference_schema.json", ontologySourceReferenceString); -} - -export function Validation_validatePerson(personString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/person_schema.json", personString); -} - -export function Validation_validateProcessParameterValue(processParameterValueString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/process_parameter_value_schema.json", processParameterValueString); -} - -export function Validation_validateProcess(processString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/process_schema.json", processString); -} - -export function Validation_validateProtocolParameter(protocolParameterString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/protocol_parameter_schema.json", protocolParameterString); -} - -export function Validation_validateProtocol(protocolString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/protocol_schema.json", protocolString); -} - -export function Validation_validatePublication(publicationString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/publication_schema.json", publicationString); -} - -export function Validation_validateSample(sampleString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/sample_schema.json", sampleString); -} - -export function Validation_validateSource(sourceString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/source_schema.json", sourceString); -} - -export function Validation_validateStudy(studyString) { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/study_schema.json", studyString); -} - diff --git a/js/ISA/ISA.Json/Validation/ValidationResult.js b/js/ISA/ISA.Json/Validation/ValidationResult.js deleted file mode 100644 index bc2a8767..00000000 --- a/js/ISA/ISA.Json/Validation/ValidationResult.js +++ /dev/null @@ -1,45 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { union_type, array_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class ValidationResult extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Ok", "Failed"]; - } -} - -export function ValidationResult_$reflection() { - return union_type("ISA.Json.ValidationTypes.ValidationResult", [], ValidationResult, () => [[], [["Item", array_type(string_type)]]]); -} - -export function ValidationResult__get_Success(this$) { - if (this$.tag === 0) { - return true; - } - else { - return false; - } -} - -export function ValidationResult__GetErrors(this$) { - if (this$.tag === 1) { - return this$.fields[0]; - } - else { - return []; - } -} - -export function ValidationResult_OfJSchemaOutput_Z6EC48F6B(output) { - if (output[0]) { - return new ValidationResult(0, []); - } - else { - return new ValidationResult(1, [output[1]]); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/ArcAssay.js b/js/ISA/ISA.Spreadsheet/ArcAssay.js deleted file mode 100644 index 73faa39d..00000000 --- a/js/ISA/ISA.Spreadsheet/ArcAssay.js +++ /dev/null @@ -1,149 +0,0 @@ -import { FsWorksheet } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { iterate, tryHead, head, exists, map, singleton, append, delay, iterateIndexed } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { SparseRowModule_tryGetValueAt, SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_writeToSheet } from "./SparseTable.js"; -import { fromRows as fromRows_1, toRows as toRows_1 } from "./InvestigationFile/Assays.js"; -import { choose, empty, isEmpty, singleton as singleton_1 } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { fromRows as fromRows_2, toRows as toRows_2 } from "./InvestigationFile/Contacts.js"; -import { getEnumerator } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { ArcAssay } from "../ISA/ArcTypes/ArcAssay.js"; -import { createMissingIdentifier } from "../ISA/ArcTypes/Identifier.js"; -import { defaultArg } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { printf, toConsole } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { toFsWorksheet, tryFromFsWorksheet } from "./ArcTable.js"; -import { FsWorkbook } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; - -export function toMetadataSheet(assay) { - let assay_1; - const sheet = new FsWorksheet("isa_assay"); - iterateIndexed((rowI, r) => { - SparseRowModule_writeToSheet(rowI + 1, r, sheet); - }, (assay_1 = assay, delay(() => append(singleton(SparseRowModule_fromValues(["ASSAY"])), delay(() => append(toRows_1("Assay", singleton_1(assay_1)), delay(() => append(singleton(SparseRowModule_fromValues(["ASSAY PERFORMERS"])), delay(() => toRows_2("Assay Person", assay_1.Performers)))))))))); - return sheet; -} - -export function fromMetadataSheet(sheet) { - const rows_1 = map(SparseRowModule_fromFsRow, sheet.Rows); - const patternInput = exists((row) => { - const s = head(row)[1]; - return s.indexOf("Assay") === 0; - }, rows_1) ? ["Assay", "Assay Person"] : [void 0, void 0]; - const en = getEnumerator(rows_1); - const loop = (lastLine_mut, assays_mut, contacts_mut, lineNumber_mut) => { - let k; - loop: - while (true) { - const lastLine = lastLine_mut, assays = assays_mut, contacts = contacts_mut, lineNumber = lineNumber_mut; - let matchResult, k_2, k_3, k_4; - if (lastLine != null) { - if ((k = lastLine, (k === "ASSAY") ? true : (k === "ASSAY METADATA"))) { - matchResult = 0; - k_2 = lastLine; - } - else if (lastLine === "ASSAY PERFORMERS") { - matchResult = 1; - k_3 = lastLine; - } - else { - matchResult = 2; - k_4 = lastLine; - } - } - else { - matchResult = 2; - k_4 = lastLine; - } - switch (matchResult) { - case 0: { - const patternInput_1 = fromRows_1(patternInput[0], lineNumber + 1, en); - lastLine_mut = patternInput_1[0]; - assays_mut = patternInput_1[3]; - contacts_mut = contacts; - lineNumber_mut = patternInput_1[1]; - continue loop; - } - case 1: { - const patternInput_2 = fromRows_2(patternInput[1], lineNumber + 1, en); - lastLine_mut = patternInput_2[0]; - assays_mut = assays; - contacts_mut = patternInput_2[3]; - lineNumber_mut = patternInput_2[1]; - continue loop; - } - default: { - let matchResult_1, assays_2, contacts_2; - if (isEmpty(assays)) { - if (isEmpty(contacts)) { - matchResult_1 = 0; - } - else { - matchResult_1 = 1; - assays_2 = assays; - contacts_2 = contacts; - } - } - else { - matchResult_1 = 1; - assays_2 = assays; - contacts_2 = contacts; - } - switch (matchResult_1) { - case 0: - return ArcAssay.create(createMissingIdentifier()); - default: { - const arg_1 = defaultArg(tryHead(assays_2), ArcAssay.create(createMissingIdentifier())); - return ArcAssay.setPerformers(contacts_2, arg_1); - } - } - } - } - break; - } - }; - if (en["System.Collections.IEnumerator.MoveNext"]()) { - return loop(SparseRowModule_tryGetValueAt(0, en["System.Collections.Generic.IEnumerator`1.get_Current"]()), empty(), empty(), 1); - } - else { - throw new Error("empty assay metadata sheet"); - } -} - -/** - * Reads an assay from a spreadsheet - */ -export function fromFsWorkbook(doc) { - let assayMetaData; - const matchValue = doc.TryGetWorksheetByName("isa_assay"); - if (matchValue == null) { - const matchValue_1 = doc.TryGetWorksheetByName("Assay"); - if (matchValue_1 == null) { - toConsole(printf("Cannot retrieve metadata: Assay file does not contain \"%s\" or \"%s\" sheet."))("isa_assay")("Assay"); - assayMetaData = ArcAssay.create(createMissingIdentifier()); - } - else { - assayMetaData = fromMetadataSheet(matchValue_1); - } - } - else { - assayMetaData = fromMetadataSheet(matchValue); - } - const sheets = choose(tryFromFsWorksheet, doc.GetWorksheets()); - if (isEmpty(sheets)) { - return assayMetaData; - } - else { - assayMetaData.Tables = Array.from(sheets); - return assayMetaData; - } -} - -export function toFsWorkbook(assay) { - const doc = new FsWorkbook(); - const metaDataSheet = toMetadataSheet(assay); - doc.AddWorksheet(metaDataSheet); - iterate((arg_1) => { - const arg = toFsWorksheet(arg_1); - doc.AddWorksheet(arg); - }, assay.Tables); - return doc; -} - diff --git a/js/ISA/ISA.Spreadsheet/ArcStudy.js b/js/ISA/ISA.Spreadsheet/ArcStudy.js deleted file mode 100644 index 90c45a53..00000000 --- a/js/ISA/ISA.Spreadsheet/ArcStudy.js +++ /dev/null @@ -1,66 +0,0 @@ -import { FsWorksheet } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { iterate, map, singleton, append, delay, iterateIndexed } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_writeToSheet } from "./SparseTable.js"; -import { fromRows as fromRows_1, StudyInfo_toRows_331096F } from "./InvestigationFile/Study.js"; -import { defaultArg } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { getEnumerator } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { ArcStudy } from "../ISA/ArcTypes/ArcStudy.js"; -import { createMissingIdentifier } from "../ISA/ArcTypes/Identifier.js"; -import { printf, toConsole } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { isEmpty, choose } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { toFsWorksheet, tryFromFsWorksheet } from "./ArcTable.js"; -import { FsWorkbook } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; - -export function toMetadataSheet(study) { - const sheet = new FsWorksheet("isa_study"); - iterateIndexed((rowI, r) => { - SparseRowModule_writeToSheet(rowI + 1, r, sheet); - }, delay(() => append(singleton(SparseRowModule_fromValues(["STUDY"])), delay(() => StudyInfo_toRows_331096F(study))))); - return sheet; -} - -export function fromMetadataSheet(sheet) { - let en; - return defaultArg((en = getEnumerator(map(SparseRowModule_fromFsRow, sheet.Rows)), (void en["System.Collections.IEnumerator.MoveNext"](), fromRows_1(2, en)[3])), ArcStudy.create(createMissingIdentifier())); -} - -/** - * Reads an assay from a spreadsheet - */ -export function fromFsWorkbook(doc) { - let studyMetadata; - const matchValue = doc.TryGetWorksheetByName("isa_study"); - if (matchValue == null) { - const matchValue_1 = doc.TryGetWorksheetByName("Study"); - if (matchValue_1 == null) { - toConsole(printf("Cannot retrieve metadata: Study file does not contain \"%s\" or \"%s\" sheet."))("isa_study")("Study"); - studyMetadata = ArcStudy.create(createMissingIdentifier()); - } - else { - studyMetadata = fromMetadataSheet(matchValue_1); - } - } - else { - studyMetadata = fromMetadataSheet(matchValue); - } - const sheets = choose(tryFromFsWorksheet, doc.GetWorksheets()); - if (isEmpty(sheets)) { - return studyMetadata; - } - else { - studyMetadata.Tables = Array.from(sheets); - return studyMetadata; - } -} - -export function toFsWorkbook(study) { - const doc = new FsWorkbook(); - const metaDataSheet = toMetadataSheet(study); - doc.AddWorksheet(metaDataSheet); - iterate((arg_1) => { - const arg = toFsWorksheet(arg_1); - doc.AddWorksheet(arg); - }, study.Tables); - return doc; -} - diff --git a/js/ISA/ISA.Spreadsheet/ArcTable.js b/js/ISA/ISA.Spreadsheet/ArcTable.js deleted file mode 100644 index a935b0ab..00000000 --- a/js/ISA/ISA.Spreadsheet/ArcTable.js +++ /dev/null @@ -1,118 +0,0 @@ -import { iterateIndexed, length, sortBy, collect, toArray, empty, tail, head, isEmpty, cons, singleton, fold, map, reverse } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { tryParseTermAnnotation } from "../ISA/Regex.js"; -import { map as map_1, toList, tryFind } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { toFsColumns, fixDeprecatedIOHeader, fromFsColumns } from "./CompositeColumn.js"; -import { ArcTable } from "../ISA/ArcTypes/ArcTable.js"; -import { FsWorksheet } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { comparePrimitives } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { FsRangeAddress_$ctor_7E77A4A0 } from "../../fable_modules/FsSpreadsheet.3.1.1/Ranges/FsRangeAddress.fs.js"; -import { FsAddress_$ctor_Z37302880 } from "../../fable_modules/FsSpreadsheet.3.1.1/FsAddress.fs.js"; -import { FsRangeBase__Cell_Z3407A44B } from "../../fable_modules/FsSpreadsheet.3.1.1/Ranges/FsRangeBase.fs.js"; - -/** - * Iterates over elements of the input list and groups adjacent elements. - * A new group is started when the specified predicate holds about the element - * of the list (and at the beginning of the iteration). - * - * For example: - * List.groupWhen isOdd [3;3;2;4;1;2] = [[3]; [3; 2; 4]; [1; 2]] - */ -export function Aux_List_groupWhen(f, list) { - return reverse(map(reverse, fold((acc, e) => { - const matchValue = f(e); - if (matchValue) { - return cons(singleton(e), acc); - } - else if (!isEmpty(acc)) { - return cons(cons(e, head(acc)), tail(acc)); - } - else { - return singleton(singleton(e)); - } - }, empty(), list))); -} - -export function classifyHeaderOrder(header) { - switch (header.tag) { - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - return 2; - case 0: - case 1: - case 2: - case 3: - case 13: - return 3; - case 12: - return 4; - default: - return 1; - } -} - -export function classifyColumnOrder(column) { - return classifyHeaderOrder(column.Header); -} - -export function groupColumnsByHeader(columns) { - return Aux_List_groupWhen((c) => { - if (tryParseTermAnnotation(c.Item(1).Value) == null) { - return c.Item(1).Value !== "Unit"; - } - else { - return false; - } - }, columns); -} - -/** - * Returns the annotation table of the worksheet if it exists, else returns None - */ -export function tryAnnotationTable(sheet) { - return tryFind((t) => (t.Name.indexOf("annotationTable") === 0), sheet.Tables); -} - -/** - * Groups and parses a collection of single columns into the according ISA composite columns - */ -export function composeColumns(columns) { - return toArray(map(fromFsColumns, groupColumnsByHeader(toList(columns)))); -} - -/** - * Returns the protocol described by the headers and a function for parsing the values of the matrix to the processes of this protocol - */ -export function tryFromFsWorksheet(sheet) { - const matchValue = tryAnnotationTable(sheet); - if (matchValue == null) { - return void 0; - } - else { - const t = matchValue; - const compositeColumns = composeColumns(map_1(fixDeprecatedIOHeader, t.GetColumns(sheet.CellCollection))); - return ArcTable.addColumns(compositeColumns)(ArcTable.init(sheet.Name)); - } -} - -export function toFsWorksheet(table) { - const ws = new FsWorksheet(table.Name); - const columns = collect(toFsColumns, sortBy(classifyColumnOrder, table.Columns, { - Compare: comparePrimitives, - })); - const maxRow = length(head(columns)) | 0; - const maxCol = length(columns) | 0; - const fsTable = ws.Table("annotationTable", FsRangeAddress_$ctor_7E77A4A0(FsAddress_$ctor_Z37302880(1, 1), FsAddress_$ctor_Z37302880(maxRow, maxCol))); - iterateIndexed((colI, col) => { - iterateIndexed((rowI, cell) => { - const address = FsAddress_$ctor_Z37302880(rowI + 1, colI + 1); - FsRangeBase__Cell_Z3407A44B(fsTable, address, ws.CellCollection).SetValueAs(cell.Value); - }, col); - }, columns); - return ws; -} - diff --git a/js/ISA/ISA.Spreadsheet/CollectionAux.js b/js/ISA/ISA.Spreadsheet/CollectionAux.js deleted file mode 100644 index f40c9e5d..00000000 --- a/js/ISA/ISA.Spreadsheet/CollectionAux.js +++ /dev/null @@ -1,160 +0,0 @@ -import { tryFind, maxBy, skip } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { defaultOf, comparePrimitives, disposeSafe, getEnumerator } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { reverse, tryPick, empty, ofArrayWithTail, cons, head, tail, singleton, isEmpty } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { tryItem, skip as skip_1, initialize } from "../../fable_modules/fable-library.4.1.4/Array.js"; -import { some, value } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { tryGetValue } from "../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { FSharpRef } from "../../fable_modules/fable-library.4.1.4/Types.js"; - -/** - * If at least i values exist in seq a, builds a new array that contains the elements of the given seq, exluding the first i elements - */ -export function Seq_trySkip(i, s) { - try { - return skip(i, s); - } - catch (matchValue) { - return void 0; - } -} - -function Seq_groupWhen(withOverlap, predicate, input) { - let matchValue, t_4, h_4; - const en = getEnumerator(input); - try { - const loop = (cont_mut) => { - loop: - while (true) { - const cont = cont_mut; - if (en["System.Collections.IEnumerator.MoveNext"]()) { - const temp = en["System.Collections.Generic.IEnumerator`1.get_Current"](); - if (predicate(temp)) { - cont_mut = ((y) => cont(isEmpty(y) ? singleton(singleton(temp)) : (withOverlap ? ofArrayWithTail([singleton(temp), cons(temp, head(y))], tail(y)) : ofArrayWithTail([empty(), cons(temp, head(y))], tail(y))))); - continue loop; - } - else { - cont_mut = ((y_1) => cont(isEmpty(y_1) ? singleton(singleton(temp)) : cons(cons(temp, head(y_1)), tail(y_1)))); - continue loop; - } - } - else { - return cont(empty()); - } - break; - } - }; - return (matchValue = loop((x) => x), isEmpty(matchValue) ? empty() : ((t_4 = tail(matchValue), (h_4 = head(matchValue), isEmpty(h_4) ? t_4 : (isEmpty(tail(h_4)) ? ((predicate(head(h_4)) && withOverlap) ? t_4 : cons(h_4, t_4)) : cons(h_4, t_4)))))); - } - finally { - disposeSafe(en); - } -} - -export function Array_ofIndexedSeq(s) { - return initialize(1 + maxBy((tuple) => tuple[0], s, { - Compare: comparePrimitives, - })[0], (i) => { - const matchValue = tryFind((arg) => (i === arg[0]), s); - if (matchValue == null) { - return ""; - } - else { - const i_1 = matchValue[0] | 0; - return matchValue[1]; - } - }); -} - -/** - * If at least i values exist in array a, builds a new array that contains the elements of the given array, exluding the first i elements - */ -export function Array_trySkip(i, a) { - try { - return skip_1(i, a); - } - catch (matchValue) { - return void 0; - } -} - -/** - * Returns Item of array at index i if existing, else returns default value - */ -export function Array_tryItemDefault(i, d, a) { - const matchValue = tryItem(i, a); - if (matchValue == null) { - return d; - } - else { - return value(matchValue); - } -} - -export function Array_map4(f, aa, ba, ca, da) { - if (!(((aa.length === ba.length) && (ba.length === ca.length)) && (ca.length === da.length))) { - throw new Error(""); - } - return initialize(aa.length, (i) => f(aa[i], ba[i], ca[i], da[i])); -} - -export function List_tryPickDefault(chooser, d, list) { - const matchValue = tryPick(chooser, list); - if (matchValue == null) { - return d; - } - else { - return value(matchValue); - } -} - -export function List_unzip4(l) { - const loop = (la_mut, lb_mut, lc_mut, ld_mut, l_1_mut) => { - loop: - while (true) { - const la = la_mut, lb = lb_mut, lc = lc_mut, ld = ld_mut, l_1 = l_1_mut; - if (isEmpty(l_1)) { - return [reverse(la), reverse(lb), reverse(lc), reverse(ld)]; - } - else { - la_mut = cons(head(l_1)[0], la); - lb_mut = cons(head(l_1)[1], lb); - lc_mut = cons(head(l_1)[2], lc); - ld_mut = cons(head(l_1)[3], ld); - l_1_mut = tail(l_1); - continue loop; - } - break; - } - }; - return loop(empty(), empty(), empty(), empty(), l); -} - -export function Dictionary_tryGetValue(k, dict) { - let patternInput; - let outArg = defaultOf(); - patternInput = [tryGetValue(dict, k, new FSharpRef(() => outArg, (v) => { - outArg = v; - })), outArg]; - if (patternInput[0]) { - return some(patternInput[1]); - } - else { - return void 0; - } -} - -export function Dictionary_tryGetString(k, dict) { - let patternInput; - let outArg = defaultOf(); - patternInput = [tryGetValue(dict, k, new FSharpRef(() => outArg, (v) => { - outArg = v; - })), outArg]; - const v_1 = patternInput[1]; - if (patternInput[0] && (v_1.trim() !== "")) { - return v_1.trim(); - } - else { - return void 0; - } -} - diff --git a/js/ISA/ISA.Spreadsheet/Comment.js b/js/ISA/ISA.Spreadsheet/Comment.js deleted file mode 100644 index 06e87d07..00000000 --- a/js/ISA/ISA.Spreadsheet/Comment.js +++ /dev/null @@ -1,58 +0,0 @@ -import { defaultArg, bind } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { match } from "../../fable_modules/fable-library.4.1.4/RegExp.js"; -import { printf, toText } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { Comment_make } from "../ISA/JsonTypes/Comment.js"; -import { Option_fromValueWithDefault } from "./Conversions.js"; - -export const Comment_commentRegex = /(?<=Comment\[<).*(?=>\])/gu; - -export const Comment_commentRegexNoAngleBrackets = /(?<=Comment\[).*(?=\])/gu; - -export function Comment_$007CComment$007C_$007C(key) { - return bind((k) => { - const r = match(Comment_commentRegex, k); - if (r != null) { - return r[0]; - } - else { - const r_1 = match(Comment_commentRegexNoAngleBrackets, k); - if (r_1 != null) { - return r_1[0]; - } - else { - return void 0; - } - } - }, key); -} - -export function Comment_wrapCommentKey(k) { - return toText(printf("Comment[%s]"))(k); -} - -export function Comment_fromString(k, v) { - return Comment_make(void 0, Option_fromValueWithDefault("", k), Option_fromValueWithDefault("", v)); -} - -export function Comment_toString(c) { - return [defaultArg(c.Name, ""), defaultArg(c.Value, "")]; -} - -export const Remark_remarkRegex = /(?<=#).*/gu; - -export function Remark_$007CRemark$007C_$007C(key) { - return bind((k) => { - const r = match(Remark_remarkRegex, k); - if (r != null) { - return r[0]; - } - else { - return void 0; - } - }, key); -} - -export function Remark_wrapRemark(r) { - return toText(printf("#%s"))(r); -} - diff --git a/js/ISA/ISA.Spreadsheet/CompositeCell.js b/js/ISA/ISA.Spreadsheet/CompositeCell.js deleted file mode 100644 index 53608779..00000000 --- a/js/ISA/ISA.Spreadsheet/CompositeCell.js +++ /dev/null @@ -1,79 +0,0 @@ -import { singleton, ofArray, head, tail, isEmpty, map } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { CompositeCell } from "../ISA/ArcTypes/CompositeCell.js"; -import { printf, toFail } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { FsCell } from "../../fable_modules/FsSpreadsheet.3.1.1/Cells/FsCell.fs.js"; -import { OntologyAnnotation__get_TermAccessionOntobeeUrl, OntologyAnnotation__get_TermSourceREFString, OntologyAnnotation__get_NameText } from "../ISA/JsonTypes/OntologyAnnotation.js"; - -export function fromFsCells(cells) { - const cellValues = map((c) => c.Value, cells); - let matchResult, v, v1, v2, v3, v1_1, v2_1, v3_1, v4; - if (!isEmpty(cellValues)) { - if (!isEmpty(tail(cellValues))) { - if (!isEmpty(tail(tail(cellValues)))) { - if (!isEmpty(tail(tail(tail(cellValues))))) { - if (isEmpty(tail(tail(tail(tail(cellValues)))))) { - matchResult = 2; - v1_1 = head(cellValues); - v2_1 = head(tail(cellValues)); - v3_1 = head(tail(tail(cellValues))); - v4 = head(tail(tail(tail(cellValues)))); - } - else { - matchResult = 3; - } - } - else { - matchResult = 1; - v1 = head(cellValues); - v2 = head(tail(cellValues)); - v3 = head(tail(tail(cellValues))); - } - } - else { - matchResult = 3; - } - } - else { - matchResult = 0; - v = head(cellValues); - } - } - else { - matchResult = 3; - } - switch (matchResult) { - case 0: - return CompositeCell.createFreeText(v); - case 1: - return CompositeCell.createTermFromString(v1, v2, v3); - case 2: - return CompositeCell.createUnitizedFromString(v1_1, v2_1, v3_1, v4); - default: - return toFail(printf("Dafuq")); - } -} - -export function toFsCells(isTerm, hasUnit, cell) { - switch (cell.tag) { - case 0: - if (hasUnit) { - return ofArray([new FsCell(OntologyAnnotation__get_NameText(cell.fields[0])), new FsCell(""), new FsCell(OntologyAnnotation__get_TermSourceREFString(cell.fields[0])), new FsCell(OntologyAnnotation__get_TermAccessionOntobeeUrl(cell.fields[0]))]); - } - else { - return ofArray([new FsCell(OntologyAnnotation__get_NameText(cell.fields[0])), new FsCell(OntologyAnnotation__get_TermSourceREFString(cell.fields[0])), new FsCell(OntologyAnnotation__get_TermAccessionOntobeeUrl(cell.fields[0]))]); - } - case 2: - return ofArray([new FsCell(cell.fields[0]), new FsCell(OntologyAnnotation__get_NameText(cell.fields[1])), new FsCell(OntologyAnnotation__get_TermSourceREFString(cell.fields[1])), new FsCell(OntologyAnnotation__get_TermAccessionOntobeeUrl(cell.fields[1]))]); - default: - if (hasUnit) { - return ofArray([new FsCell(cell.fields[0]), new FsCell(""), new FsCell(""), new FsCell("")]); - } - else if (isTerm) { - return ofArray([new FsCell(cell.fields[0]), new FsCell(""), new FsCell("")]); - } - else { - return singleton(new FsCell(cell.fields[0])); - } - } -} - diff --git a/js/ISA/ISA.Spreadsheet/CompositeColumn.js b/js/ISA/ISA.Spreadsheet/CompositeColumn.js deleted file mode 100644 index 3356ade8..00000000 --- a/js/ISA/ISA.Spreadsheet/CompositeColumn.js +++ /dev/null @@ -1,59 +0,0 @@ -import { CompositeHeader, IOType } from "../ISA/ArcTypes/CompositeHeader.js"; -import { toString } from "../../fable_modules/fable-library.4.1.4/Types.js"; -import { toFsCells, fromFsCells } from "./CompositeHeader.js"; -import { singleton as singleton_1, ofArray, item, map } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { FsAddress__get_RowNumber } from "../../fable_modules/FsSpreadsheet.3.1.1/FsAddress.fs.js"; -import { FsRangeAddress__get_LastAddress } from "../../fable_modules/FsSpreadsheet.3.1.1/Ranges/FsRangeAddress.fs.js"; -import { FsRangeBase__get_RangeAddress } from "../../fable_modules/FsSpreadsheet.3.1.1/Ranges/FsRangeBase.fs.js"; -import { singleton, append, toList, exists, map as map_1, delay, toArray } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { toFsCells as toFsCells_1, fromFsCells as fromFsCells_1 } from "./CompositeCell.js"; -import { rangeDouble } from "../../fable_modules/fable-library.4.1.4/Range.js"; -import { CompositeColumn } from "../ISA/ArcTypes/CompositeColumn.js"; -import { map as map_2 } from "../../fable_modules/fable-library.4.1.4/Array.js"; - -/** - * Checks if the column header is a deprecated IO Header. If so, fixes it. - * - * The old format of IO Headers was only the type of IO so, e.g. "Source Name" or "Raw Data File". - * - * A "Source Name" column will now be mapped to the propper "Input [Source Name]", and all other IO types will be mapped to "Output []". - */ -export function fixDeprecatedIOHeader(col) { - const matchValue = IOType.ofString(col.Item(1).Value); - switch (matchValue.tag) { - case 6: - return col; - case 0: { - col.Item(1).SetValueAs(toString(new CompositeHeader(11, [new IOType(0, [])]))); - return col; - } - default: { - col.Item(1).SetValueAs(toString(new CompositeHeader(12, [matchValue]))); - return col; - } - } -} - -export function fromFsColumns(columns) { - const header = fromFsCells(map((c) => c.Item(1), columns)); - const l = FsAddress__get_RowNumber(FsRangeAddress__get_LastAddress(FsRangeBase__get_RangeAddress(item(0, columns)))) | 0; - const cells_2 = toArray(delay(() => map_1((i) => fromFsCells_1(map((c_1) => c_1.Item(i), columns)), rangeDouble(2, 1, l)))); - return CompositeColumn.create(header, cells_2); -} - -export function toFsColumns(column) { - const hasUnit = exists((c) => c.isUnitized, column.Cells); - const isTerm = column.Header.IsTermColumn; - const header = toFsCells(hasUnit, column.Header); - const cells = map_2((cell) => toFsCells_1(isTerm, hasUnit, cell), column.Cells); - if (hasUnit) { - return ofArray([toList(delay(() => append(singleton(item(0, header)), delay(() => map_1((i) => item(0, cells[i]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay(() => append(singleton(item(1, header)), delay(() => map_1((i_1) => item(1, cells[i_1]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay(() => append(singleton(item(2, header)), delay(() => map_1((i_2) => item(2, cells[i_2]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay(() => append(singleton(item(3, header)), delay(() => map_1((i_3) => item(3, cells[i_3]), rangeDouble(0, 1, column.Cells.length - 1))))))]); - } - else if (isTerm) { - return ofArray([toList(delay(() => append(singleton(item(0, header)), delay(() => map_1((i_4) => item(0, cells[i_4]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay(() => append(singleton(item(1, header)), delay(() => map_1((i_5) => item(1, cells[i_5]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay(() => append(singleton(item(2, header)), delay(() => map_1((i_6) => item(2, cells[i_6]), rangeDouble(0, 1, column.Cells.length - 1))))))]); - } - else { - return singleton_1(toList(delay(() => append(singleton(item(0, header)), delay(() => map_1((i_7) => item(0, cells[i_7]), rangeDouble(0, 1, column.Cells.length - 1))))))); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/CompositeHeader.js b/js/ISA/ISA.Spreadsheet/CompositeHeader.js deleted file mode 100644 index d4673fe6..00000000 --- a/js/ISA/ISA.Spreadsheet/CompositeHeader.js +++ /dev/null @@ -1,460 +0,0 @@ -import { printf, toFail } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { singleton, tail, head, isEmpty, map } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation_fromString_Z7D8EB286 } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { ActivePatterns_$007COutputColumnHeader$007C_$007C, ActivePatterns_$007CInputColumnHeader$007C_$007C, tryParseCharacteristicColumnHeader, tryParseFactorColumnHeader, tryParseParameterColumnHeader, ActivePatterns_$007CUnitColumnHeader$007C_$007C, ActivePatterns_$007CTANColumnHeader$007C_$007C, ActivePatterns_$007CTSRColumnHeader$007C_$007C } from "../ISA/Regex.js"; -import { IOType, CompositeHeader } from "../ISA/ArcTypes/CompositeHeader.js"; -import { FsCell } from "../../fable_modules/FsSpreadsheet.3.1.1/Cells/FsCell.fs.js"; -import { toString } from "../../fable_modules/fable-library.4.1.4/Types.js"; -import { empty, singleton as singleton_1, append, delay, toList } from "../../fable_modules/fable-library.4.1.4/Seq.js"; - -export function ActivePattern_mergeTerms(tsr1, tan1, tsr2, tan2) { - if (tsr1 !== tsr2) { - toFail(printf("TermSourceRef %s and %s do not match"))(tsr1)(tsr2); - } - if (tan1 !== tan2) { - toFail(printf("TermAccessionNumber %s and %s do not match"))(tan1)(tan2); - } - return { - TermAccessionNumber: tan1, - TermSourceRef: tsr1, - }; -} - -export function ActivePattern_$007CTerm$007C_$007C(categoryParser, f, cells) { - const $007CAC$007C_$007C = categoryParser; - const cellValues = map((c) => c.Value, cells); - let matchResult, name; - if (!isEmpty(cellValues)) { - const activePatternResult = $007CAC$007C_$007C(head(cellValues)); - if (activePatternResult != null) { - if (isEmpty(tail(cellValues))) { - matchResult = 0; - name = activePatternResult; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return f(OntologyAnnotation_fromString_Z7D8EB286(name)); - default: { - let matchResult_1, name_1, term1, term2; - if (!isEmpty(cellValues)) { - const activePatternResult_1 = $007CAC$007C_$007C(head(cellValues)); - if (activePatternResult_1 != null) { - if (!isEmpty(tail(cellValues))) { - const activePatternResult_2 = ActivePatterns_$007CTSRColumnHeader$007C_$007C(head(tail(cellValues))); - if (activePatternResult_2 != null) { - if (!isEmpty(tail(tail(cellValues)))) { - const activePatternResult_3 = ActivePatterns_$007CTANColumnHeader$007C_$007C(head(tail(tail(cellValues)))); - if (activePatternResult_3 != null) { - if (!isEmpty(tail(tail(tail(cellValues))))) { - const activePatternResult_4 = ActivePatterns_$007CTANColumnHeader$007C_$007C(head(tail(tail(tail(cellValues))))); - if (activePatternResult_4 != null) { - if (isEmpty(tail(tail(tail(tail(cellValues)))))) { - const activePatternResult_5 = ActivePatterns_$007CTSRColumnHeader$007C_$007C(head(tail(tail(cellValues)))); - if (activePatternResult_5 != null) { - if (ActivePatterns_$007CUnitColumnHeader$007C_$007C(head(tail(cellValues))) != null) { - matchResult_1 = 0; - name_1 = activePatternResult_1; - term1 = activePatternResult_5; - term2 = activePatternResult_4; - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 0; - name_1 = activePatternResult_1; - term1 = activePatternResult_2; - term2 = activePatternResult_3; - } - } - else { - const activePatternResult_7 = ActivePatterns_$007CTSRColumnHeader$007C_$007C(head(tail(tail(cellValues)))); - if (activePatternResult_7 != null) { - if (!isEmpty(tail(tail(tail(cellValues))))) { - const activePatternResult_8 = ActivePatterns_$007CTANColumnHeader$007C_$007C(head(tail(tail(tail(cellValues))))); - if (activePatternResult_8 != null) { - if (isEmpty(tail(tail(tail(tail(cellValues)))))) { - if (ActivePatterns_$007CUnitColumnHeader$007C_$007C(head(tail(cellValues))) != null) { - matchResult_1 = 0; - name_1 = activePatternResult_1; - term1 = activePatternResult_7; - term2 = activePatternResult_8; - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - } - else { - matchResult_1 = 1; - } - } - else if (ActivePatterns_$007CUnitColumnHeader$007C_$007C(head(tail(cellValues))) != null) { - if (!isEmpty(tail(tail(cellValues)))) { - const activePatternResult_11 = ActivePatterns_$007CTSRColumnHeader$007C_$007C(head(tail(tail(cellValues)))); - if (activePatternResult_11 != null) { - if (!isEmpty(tail(tail(tail(cellValues))))) { - const activePatternResult_12 = ActivePatterns_$007CTANColumnHeader$007C_$007C(head(tail(tail(tail(cellValues))))); - if (activePatternResult_12 != null) { - if (isEmpty(tail(tail(tail(tail(cellValues)))))) { - matchResult_1 = 0; - name_1 = activePatternResult_1; - term1 = activePatternResult_11; - term2 = activePatternResult_12; - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - switch (matchResult_1) { - case 0: { - const term = ActivePattern_mergeTerms(term1.TermSourceREF, term1.TermAccessionNumber, term2.TermSourceREF, term2.TermAccessionNumber); - return f(OntologyAnnotation_fromString_Z7D8EB286(name_1, term.TermSourceRef, term.TermAccessionNumber)); - } - default: - return void 0; - } - } - } -} - -export function ActivePattern_$007CParameter$007C_$007C(cells) { - const activePatternResult = ActivePattern_$007CTerm$007C_$007C(tryParseParameterColumnHeader, (arg) => (new CompositeHeader(3, [arg])), cells); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -export function ActivePattern_$007CFactor$007C_$007C(cells) { - const activePatternResult = ActivePattern_$007CTerm$007C_$007C(tryParseFactorColumnHeader, (arg) => (new CompositeHeader(2, [arg])), cells); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -export function ActivePattern_$007CCharacteristic$007C_$007C(cells) { - const activePatternResult = ActivePattern_$007CTerm$007C_$007C(tryParseCharacteristicColumnHeader, (arg) => (new CompositeHeader(1, [arg])), cells); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -export function ActivePattern_$007CInput$007C_$007C(cells) { - const cellValues = map((c) => c.Value, cells); - let matchResult, ioType; - if (!isEmpty(cellValues)) { - const activePatternResult = ActivePatterns_$007CInputColumnHeader$007C_$007C(head(cellValues)); - if (activePatternResult != null) { - if (isEmpty(tail(cellValues))) { - matchResult = 0; - ioType = activePatternResult; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return new CompositeHeader(11, [IOType.ofString(ioType)]); - default: - return void 0; - } -} - -export function ActivePattern_$007COutput$007C_$007C(cells) { - const cellValues = map((c) => c.Value, cells); - let matchResult, ioType; - if (!isEmpty(cellValues)) { - const activePatternResult = ActivePatterns_$007COutputColumnHeader$007C_$007C(head(cellValues)); - if (activePatternResult != null) { - if (isEmpty(tail(cellValues))) { - matchResult = 0; - ioType = activePatternResult; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return new CompositeHeader(12, [IOType.ofString(ioType)]); - default: - return void 0; - } -} - -export function ActivePattern_$007CProtocolHeader$007C_$007C(cells) { - const cellValues = map((c) => c.Value, cells); - let matchResult; - if (!isEmpty(cellValues)) { - switch (head(cellValues)) { - case "Protocol Type": { - matchResult = 0; - break; - } - case "Protocol REF": { - if (isEmpty(tail(cellValues))) { - matchResult = 1; - } - else { - matchResult = 7; - } - break; - } - case "Protocol Description": { - if (isEmpty(tail(cellValues))) { - matchResult = 2; - } - else { - matchResult = 7; - } - break; - } - case "Protocol Uri": { - if (isEmpty(tail(cellValues))) { - matchResult = 3; - } - else { - matchResult = 7; - } - break; - } - case "Protocol Version": { - if (isEmpty(tail(cellValues))) { - matchResult = 4; - } - else { - matchResult = 7; - } - break; - } - case "Performer": { - if (isEmpty(tail(cellValues))) { - matchResult = 5; - } - else { - matchResult = 7; - } - break; - } - case "Date": { - if (isEmpty(tail(cellValues))) { - matchResult = 6; - } - else { - matchResult = 7; - } - break; - } - default: - matchResult = 7; - } - } - else { - matchResult = 7; - } - switch (matchResult) { - case 0: - return new CompositeHeader(4, []); - case 1: - return new CompositeHeader(8, []); - case 2: - return new CompositeHeader(5, []); - case 3: - return new CompositeHeader(6, []); - case 4: - return new CompositeHeader(7, []); - case 5: - return new CompositeHeader(9, []); - case 6: - return new CompositeHeader(10, []); - default: - return void 0; - } -} - -export function ActivePattern_$007CFreeText$007C_$007C(cells) { - const cellValues = map((c) => c.Value, cells); - let matchResult, text; - if (!isEmpty(cellValues)) { - if (isEmpty(tail(cellValues))) { - matchResult = 0; - text = head(cellValues); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return new CompositeHeader(13, [text]); - default: - return void 0; - } -} - -export function fromFsCells(cells) { - const activePatternResult = ActivePattern_$007CParameter$007C_$007C(cells); - if (activePatternResult != null) { - const p = activePatternResult; - return p; - } - else { - const activePatternResult_1 = ActivePattern_$007CFactor$007C_$007C(cells); - if (activePatternResult_1 != null) { - const f = activePatternResult_1; - return f; - } - else { - const activePatternResult_2 = ActivePattern_$007CCharacteristic$007C_$007C(cells); - if (activePatternResult_2 != null) { - const c = activePatternResult_2; - return c; - } - else { - const activePatternResult_3 = ActivePattern_$007CInput$007C_$007C(cells); - if (activePatternResult_3 != null) { - const i = activePatternResult_3; - return i; - } - else { - const activePatternResult_4 = ActivePattern_$007COutput$007C_$007C(cells); - if (activePatternResult_4 != null) { - const o = activePatternResult_4; - return o; - } - else { - const activePatternResult_5 = ActivePattern_$007CProtocolHeader$007C_$007C(cells); - if (activePatternResult_5 != null) { - const ph = activePatternResult_5; - return ph; - } - else { - const activePatternResult_6 = ActivePattern_$007CFreeText$007C_$007C(cells); - if (activePatternResult_6 != null) { - const ft = activePatternResult_6; - return ft; - } - else { - throw new Error("parseCompositeHeader"); - } - } - } - } - } - } - } -} - -export function toFsCells(hasUnit, header) { - if (header.IsSingleColumn) { - return singleton(new FsCell(toString(header))); - } - else if (header.IsTermColumn) { - return toList(delay(() => append(singleton_1(new FsCell(toString(header))), delay(() => append(hasUnit ? singleton_1(new FsCell("Unit")) : empty(), delay(() => append(singleton_1(new FsCell(`Term Source REF (${header.GetColumnAccessionShort})`)), delay(() => singleton_1(new FsCell(`Term Accession Number (${header.GetColumnAccessionShort})`)))))))))); - } - else { - return toFail(printf("header %O is neither single nor term column"))(header); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/Conversions.js b/js/ISA/ISA.Spreadsheet/Conversions.js deleted file mode 100644 index 0ee69d25..00000000 --- a/js/ISA/ISA.Spreadsheet/Conversions.js +++ /dev/null @@ -1,180 +0,0 @@ -import { equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { value, some } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { fill, map3, fold } from "../../fable_modules/fable-library.4.1.4/Array.js"; -import { toText, printf, toFail } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { map, fold as fold_1, ofArray, empty } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_fromString_Z7D8EB286 } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { Array_map4 } from "./CollectionAux.js"; -import { Component_toString_Z7E9B32A1, Component_fromString_55205B02 } from "../ISA/JsonTypes/Component.js"; -import { ProtocolParameter_toString_2762A46F, ProtocolParameter_make } from "../ISA/JsonTypes/ProtocolParameter.js"; - -/** - * If the value matches the default, a None is returned, else a Some is returned - */ -export function Option_fromValueWithDefault(d, v) { - if (equals(d, v)) { - return void 0; - } - else { - return some(v); - } -} - -/** - * Applies the function f on the value of the option if it exists, else applies it on the default value. If the result value matches the default, a None is returned - */ -export function Option_mapDefault(d, f, o) { - return Option_fromValueWithDefault(d, (o == null) ? f(d) : f(value(o))); -} - -/** - * Returns the length of a subpropertylist from the aggregated strings - * - * In ISATab format, some subproperties which are stored as lists in ISAJson are stored as semicolon delimited tables - * - * These strings should either contain the same number of semicolon delimited elements or be empty. - */ -export function OntologyAnnotation_getLengthOfAggregatedStrings(separator, strings) { - return fold((l, s) => { - if (s === "") { - return l | 0; - } - else if (l === 0) { - return s.split(separator).length | 0; - } - else if (l === s.split(separator).length) { - return l | 0; - } - else { - return toFail(printf("The length of the aggregated string %s does not match the length of the others"))(s) | 0; - } - }, 0, strings); -} - -/** - * Returns a list of ISAJson OntologyAnnotation objects from ISATab aggregated strings - */ -export function OntologyAnnotation_fromAggregatedStrings(separator, terms, source, accessions) { - const l = OntologyAnnotation_getLengthOfAggregatedStrings(separator, [terms, source, accessions]) | 0; - if (l === 0) { - return empty(); - } - else { - return ofArray(map3(OntologyAnnotation_fromString_Z7D8EB286, (terms === "") ? fill(new Array(l), 0, l, "") : terms.split(separator), (source === "") ? fill(new Array(l), 0, l, "") : source.split(separator), (accessions === "") ? fill(new Array(l), 0, l, "") : accessions.split(separator))); - } -} - -/** - * Returns the aggregated ISATab OntologyAnnotation Name, ontology source and Accession number from a list of ISAJson OntologyAnnotation objects - */ -export function OntologyAnnotation_toAggregatedStrings(separator, oas) { - let first = true; - if (equals(oas, empty())) { - return { - TermAccessionNumberAgg: "", - TermNameAgg: "", - TermSourceREFAgg: "", - }; - } - else { - const tupledArg_1 = fold_1((tupledArg, term) => { - if (first) { - first = false; - return [term.TermName, term.TermSourceREF, term.TermAccessionNumber]; - } - else { - return [toText(printf("%s%c%s"))(tupledArg[0])(separator)(term.TermName), toText(printf("%s%c%s"))(tupledArg[1])(separator)(term.TermSourceREF), toText(printf("%s%c%s"))(tupledArg[2])(separator)(term.TermAccessionNumber)]; - } - }, ["", "", ""], map(OntologyAnnotation_toString_473B9D79, oas)); - return { - TermAccessionNumberAgg: tupledArg_1[2], - TermNameAgg: tupledArg_1[0], - TermSourceREFAgg: tupledArg_1[1], - }; - } -} - -/** - * Returns a list of ISAJson Component objects from ISATab aggregated strings - */ -export function Component_fromAggregatedStrings(separator, names, terms, source, accessions) { - const l = OntologyAnnotation_getLengthOfAggregatedStrings(separator, [names, terms, source, accessions]) | 0; - if (l === 0) { - return empty(); - } - else { - return ofArray(Array_map4(Component_fromString_55205B02, (names === "") ? fill(new Array(l), 0, l, "") : names.split(separator), (terms === "") ? fill(new Array(l), 0, l, "") : terms.split(separator), (source === "") ? fill(new Array(l), 0, l, "") : source.split(separator), (accessions === "") ? fill(new Array(l), 0, l, "") : accessions.split(separator))); - } -} - -/** - * Returns the aggregated ISATAb Component Name, Ontology Annotation value, Accession number and ontology source from a list of ISAJson Component objects - */ -export function Component_toAggregatedStrings(separator, cs) { - let first = true; - if (equals(cs, empty())) { - return { - NameAgg: "", - TermAccessionNumberAgg: "", - TermNameAgg: "", - TermSourceREFAgg: "", - }; - } - else { - const tupledArg_2 = fold_1((tupledArg, tupledArg_1) => { - const name = tupledArg_1[0]; - const term = tupledArg_1[1]; - if (first) { - first = false; - return [name, term.TermName, term.TermSourceREF, term.TermAccessionNumber]; - } - else { - return [toText(printf("%s%c%s"))(tupledArg[0])(separator)(name), toText(printf("%s%c%s"))(tupledArg[1])(separator)(term.TermName), toText(printf("%s%c%s"))(tupledArg[2])(separator)(term.TermSourceREF), toText(printf("%s%c%s"))(tupledArg[3])(separator)(term.TermAccessionNumber)]; - } - }, ["", "", "", ""], map(Component_toString_Z7E9B32A1, cs)); - return { - NameAgg: tupledArg_2[0], - TermAccessionNumberAgg: tupledArg_2[3], - TermNameAgg: tupledArg_2[1], - TermSourceREFAgg: tupledArg_2[2], - }; - } -} - -/** - * Returns a list of ISAJson ProtocolParameter objects from ISATab aggregated strings - */ -export function ProtocolParameter_fromAggregatedStrings(separator, terms, source, accessions) { - return map((arg_3) => ((arg_2) => ProtocolParameter_make(void 0, arg_2))(arg_3), OntologyAnnotation_fromAggregatedStrings(separator, terms, source, accessions)); -} - -/** - * Returns the aggregated ISATAb Ontology Annotation value, Accession number and ontology source from a list of ISAJson ProtocolParameter objects - */ -export function ProtocolParameter_toAggregatedStrings(separator, oas) { - let first = true; - if (equals(oas, empty())) { - return { - TermAccessionNumberAgg: "", - TermNameAgg: "", - TermSourceREFAgg: "", - }; - } - else { - const tupledArg_1 = fold_1((tupledArg, term) => { - if (first) { - first = false; - return [term.TermName, term.TermSourceREF, term.TermAccessionNumber]; - } - else { - return [toText(printf("%s%c%s"))(tupledArg[0])(separator)(term.TermName), toText(printf("%s%c%s"))(tupledArg[1])(separator)(term.TermSourceREF), toText(printf("%s%c%s"))(tupledArg[2])(separator)(term.TermAccessionNumber)]; - } - }, ["", "", ""], map(ProtocolParameter_toString_2762A46F, oas)); - return { - TermAccessionNumberAgg: tupledArg_1[2], - TermNameAgg: tupledArg_1[0], - TermSourceREFAgg: tupledArg_1[1], - }; - } -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/Assays.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/Assays.js deleted file mode 100644 index cab3659b..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/Assays.js +++ /dev/null @@ -1,76 +0,0 @@ -import { reverse, cons, iterate, isEmpty, iterateIndexed, map, initialize, singleton, length, empty, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286 } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { ArcAssay } from "../../ISA/ArcTypes/ArcAssay.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValue_11FD62A8, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Assay_fileNameFromIdentifier, removeMissingIdentifier, Assay_identifierFromFileName, createMissingIdentifier } from "../../ISA/ArcTypes/Identifier.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { unwrap, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -export const labels = ofArray(["Measurement Type", "Measurement Type Term Accession Number", "Measurement Type Term Source REF", "Technology Type", "Technology Type Term Accession Number", "Technology Type Term Source REF", "Technology Platform", "File Name"]); - -export function fromString(measurementType, measurementTypeTermSourceREF, measurementTypeTermAccessionNumber, technologyType, technologyTypeTermSourceREF, technologyTypeTermAccessionNumber, technologyPlatform, fileName, comments) { - const measurementType_1 = OntologyAnnotation_fromString_Z7D8EB286(measurementType, measurementTypeTermSourceREF, measurementTypeTermAccessionNumber); - const technologyType_1 = OntologyAnnotation_fromString_Z7D8EB286(technologyType, technologyTypeTermSourceREF, technologyTypeTermAccessionNumber); - const arg_1 = Option_fromValueWithDefault(OntologyAnnotation_get_empty(), measurementType_1); - const arg_2 = Option_fromValueWithDefault(OntologyAnnotation_get_empty(), technologyType_1); - const arg_3 = Option_fromValueWithDefault("", technologyPlatform); - return ArcAssay.make(fileName, arg_1, arg_2, arg_3, [], empty(), comments); -} - -export function fromSparseTable(matrix) { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - const comments = SparseTable_GetEmptyComments_Z15A4F148(matrix); - return singleton(ArcAssay.create(createMissingIdentifier(), void 0, void 0, void 0, void 0, void 0, comments)); - } - else { - return initialize(matrix.ColumnCount, (i) => { - const comments_1 = map((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Measurement Type", i]), SparseTable__TryGetValue_11FD62A8(matrix, ["Measurement Type Term Source REF", i]), SparseTable__TryGetValue_11FD62A8(matrix, ["Measurement Type Term Accession Number", i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Technology Type", i]), SparseTable__TryGetValue_11FD62A8(matrix, ["Technology Type Term Source REF", i]), SparseTable__TryGetValue_11FD62A8(matrix, ["Technology Type Term Accession Number", i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Technology Platform", i]), Assay_identifierFromFileName(SparseTable__TryGetValueDefault_5BAE6133(matrix, createMissingIdentifier(), ["File Name", i])), comments_1); - }); - } -} - -export function toSparseTable(assays) { - const matrix = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(assays) + 1); - let commentKeys = empty(); - iterateIndexed((i, a) => { - const processedFileName = (a.Identifier.indexOf("MISSING_IDENTIFIER_") === 0) ? removeMissingIdentifier(a.Identifier) : Assay_fileNameFromIdentifier(a.Identifier); - const i_1 = (i + 1) | 0; - const mt_1 = OntologyAnnotation_toString_473B9D79(defaultArg(a.MeasurementType, OntologyAnnotation_get_empty()), true); - const tt_1 = OntologyAnnotation_toString_473B9D79(defaultArg(a.TechnologyType, OntologyAnnotation_get_empty()), true); - addToDict(matrix.Matrix, ["Measurement Type", i_1], mt_1.TermName); - addToDict(matrix.Matrix, ["Measurement Type Term Accession Number", i_1], mt_1.TermAccessionNumber); - addToDict(matrix.Matrix, ["Measurement Type Term Source REF", i_1], mt_1.TermSourceREF); - addToDict(matrix.Matrix, ["Technology Type", i_1], tt_1.TermName); - addToDict(matrix.Matrix, ["Technology Type Term Accession Number", i_1], tt_1.TermAccessionNumber); - addToDict(matrix.Matrix, ["Technology Type Term Source REF", i_1], tt_1.TermSourceREF); - addToDict(matrix.Matrix, ["Technology Platform", i_1], defaultArg(a.TechnologyPlatform, "")); - addToDict(matrix.Matrix, ["File Name", i_1], processedFileName); - if (!isEmpty(a.Comments)) { - iterate((comment) => { - const patternInput = Comment_toString(comment); - const n = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1], patternInput[1]); - }, a.Comments); - } - }, assays); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix, lineNumber, rows) { - const tupledArg = SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, unwrap(prefix)); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])]; -} - -export function toRows(prefix, assays) { - return SparseTable_ToRows_584133C0(toSparseTable(assays), unwrap(prefix)); -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.js deleted file mode 100644 index 80b7620c..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.js +++ /dev/null @@ -1,99 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map, initialize, singleton, length, empty, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation_toAggregatedStrings, Option_fromValueWithDefault, OntologyAnnotation_fromAggregatedStrings } from "../Conversions.js"; -import { Person_create_28E835CB, Person_make } from "../../ISA/JsonTypes/Person.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { unwrap, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -export const lastNameLabel = "Last Name"; - -export const firstNameLabel = "First Name"; - -export const midInitialsLabel = "Mid Initials"; - -export const emailLabel = "Email"; - -export const phoneLabel = "Phone"; - -export const faxLabel = "Fax"; - -export const addressLabel = "Address"; - -export const affiliationLabel = "Affiliation"; - -export const rolesLabel = "Roles"; - -export const rolesTermAccessionNumberLabel = "Roles Term Accession Number"; - -export const rolesTermSourceREFLabel = "Roles Term Source REF"; - -export const labels = ofArray([lastNameLabel, firstNameLabel, midInitialsLabel, emailLabel, phoneLabel, faxLabel, addressLabel, affiliationLabel, rolesLabel, rolesTermAccessionNumberLabel, rolesTermSourceREFLabel]); - -export function fromString(lastName, firstName, midInitials, email, phone, fax, address, affiliation, role, rolesTermAccessionNumber, rolesTermSourceREF, comments) { - const roles = OntologyAnnotation_fromAggregatedStrings(";", role, rolesTermSourceREF, rolesTermAccessionNumber); - return Person_make(void 0, Option_fromValueWithDefault("", lastName), Option_fromValueWithDefault("", firstName), Option_fromValueWithDefault("", midInitials), Option_fromValueWithDefault("", email), Option_fromValueWithDefault("", phone), Option_fromValueWithDefault("", fax), Option_fromValueWithDefault("", address), Option_fromValueWithDefault("", affiliation), Option_fromValueWithDefault(empty(), roles), Option_fromValueWithDefault(empty(), comments)); -} - -export function fromSparseTable(matrix) { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(Person_create_28E835CB(void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i) => { - const comments_1 = map((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [lastNameLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [firstNameLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [midInitialsLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [emailLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [phoneLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [faxLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [addressLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [affiliationLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [rolesLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [rolesTermAccessionNumberLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [rolesTermSourceREFLabel, i]), comments_1); - }); - } -} - -export function toSparseTable(persons) { - const matrix = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(persons) + 1); - let commentKeys = empty(); - iterateIndexed((i, p) => { - const i_1 = (i + 1) | 0; - const rAgg = OntologyAnnotation_toAggregatedStrings(";", defaultArg(p.Roles, empty())); - addToDict(matrix.Matrix, [lastNameLabel, i_1], defaultArg(p.LastName, "")); - addToDict(matrix.Matrix, [firstNameLabel, i_1], defaultArg(p.FirstName, "")); - addToDict(matrix.Matrix, [midInitialsLabel, i_1], defaultArg(p.MidInitials, "")); - addToDict(matrix.Matrix, [emailLabel, i_1], defaultArg(p.EMail, "")); - addToDict(matrix.Matrix, [phoneLabel, i_1], defaultArg(p.Phone, "")); - addToDict(matrix.Matrix, [faxLabel, i_1], defaultArg(p.Fax, "")); - addToDict(matrix.Matrix, [addressLabel, i_1], defaultArg(p.Address, "")); - addToDict(matrix.Matrix, [affiliationLabel, i_1], defaultArg(p.Affiliation, "")); - addToDict(matrix.Matrix, [rolesLabel, i_1], rAgg.TermNameAgg); - addToDict(matrix.Matrix, [rolesTermAccessionNumberLabel, i_1], rAgg.TermAccessionNumberAgg); - addToDict(matrix.Matrix, [rolesTermSourceREFLabel, i_1], rAgg.TermSourceREFAgg); - const matchValue = p.Comments; - if (matchValue != null) { - iterate((comment) => { - const patternInput = Comment_toString(comment); - const n = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1], patternInput[1]); - }, matchValue); - } - }, persons); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix, lineNumber, rows) { - const tupledArg = SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, unwrap(prefix)); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])]; -} - -export function toRows(prefix, persons) { - const m = toSparseTable(persons); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, prefix); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/DesignDescriptors.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/DesignDescriptors.js deleted file mode 100644 index 207668fb..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/DesignDescriptors.js +++ /dev/null @@ -1,68 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, empty, map, initialize, singleton, length, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_create_131C8C9D } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -export const designTypeLabel = "Type"; - -export const designTypeTermAccessionNumberLabel = "Type Term Accession Number"; - -export const designTypeTermSourceREFLabel = "Type Term Source REF"; - -export const labels = ofArray([designTypeLabel, designTypeTermAccessionNumberLabel, designTypeTermSourceREFLabel]); - -export function fromSparseTable(matrix) { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(OntologyAnnotation_create_131C8C9D(void 0, void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i) => { - const comments_1 = map((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i])), matrix.CommentKeys); - return OntologyAnnotation_fromString_Z7D8EB286(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [designTypeLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [designTypeTermSourceREFLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [designTypeTermAccessionNumberLabel, i]), comments_1); - }); - } -} - -export function toSparseTable(designs) { - const matrix = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(designs) + 1); - let commentKeys = empty(); - iterateIndexed((i, d) => { - const i_1 = (i + 1) | 0; - const oa = OntologyAnnotation_toString_473B9D79(d, true); - addToDict(matrix.Matrix, [designTypeLabel, i_1], oa.TermName); - addToDict(matrix.Matrix, [designTypeTermAccessionNumberLabel, i_1], oa.TermAccessionNumber); - addToDict(matrix.Matrix, [designTypeTermSourceREFLabel, i_1], oa.TermSourceREF); - const matchValue = d.Comments; - if (matchValue != null) { - iterate((comment) => { - const patternInput = Comment_toString(comment); - const n = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1], patternInput[1]); - }, matchValue); - } - }, designs); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix, lineNumber, rows) { - const tupledArg = (prefix == null) ? SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber) : SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, prefix); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])]; -} - -export function toRows(prefix, designs) { - const m = toSparseTable(designs); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, prefix); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/Factors.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/Factors.js deleted file mode 100644 index 0c0656fc..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/Factors.js +++ /dev/null @@ -1,79 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map, initialize, singleton, length, empty, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286 } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Factor_create_Z3D2B374F, Factor_make } from "../../ISA/JsonTypes/Factor.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValue_11FD62A8, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -export const nameLabel = "Name"; - -export const factorTypeLabel = "Type"; - -export const typeTermAccessionNumberLabel = "Type Term Accession Number"; - -export const typeTermSourceREFLabel = "Type Term Source REF"; - -export const labels = ofArray([nameLabel, factorTypeLabel, typeTermAccessionNumberLabel, typeTermSourceREFLabel]); - -export function fromString(name, designType, typeTermSourceREF, typeTermAccessionNumber, comments) { - const factorType = OntologyAnnotation_fromString_Z7D8EB286(designType, typeTermSourceREF, typeTermAccessionNumber); - return Factor_make(void 0, Option_fromValueWithDefault("", name), Option_fromValueWithDefault(OntologyAnnotation_get_empty(), factorType), Option_fromValueWithDefault(empty(), comments)); -} - -export function fromSparseTable(matrix) { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(Factor_create_Z3D2B374F(void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i) => { - const comments_1 = map((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [nameLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [factorTypeLabel, i]), SparseTable__TryGetValue_11FD62A8(matrix, [typeTermSourceREFLabel, i]), SparseTable__TryGetValue_11FD62A8(matrix, [typeTermAccessionNumberLabel, i]), comments_1); - }); - } -} - -export function toSparseTable(factors) { - const matrix = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(factors) + 1); - let commentKeys = empty(); - iterateIndexed((i, f) => { - const i_1 = (i + 1) | 0; - const ft = OntologyAnnotation_toString_473B9D79(defaultArg(f.FactorType, OntologyAnnotation_get_empty()), true); - addToDict(matrix.Matrix, [nameLabel, i_1], defaultArg(f.Name, "")); - addToDict(matrix.Matrix, [factorTypeLabel, i_1], ft.TermName); - addToDict(matrix.Matrix, [typeTermAccessionNumberLabel, i_1], ft.TermAccessionNumber); - addToDict(matrix.Matrix, [typeTermSourceREFLabel, i_1], ft.TermSourceREF); - const matchValue = f.Comments; - if (matchValue != null) { - iterate((comment) => { - const patternInput = Comment_toString(comment); - const n = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1], patternInput[1]); - }, matchValue); - } - }, factors); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix, lineNumber, rows) { - const tupledArg = (prefix == null) ? SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber) : SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, prefix); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])]; -} - -export function toRows(prefix, factors) { - const m = toSparseTable(factors); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, prefix); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/Investigation.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/Investigation.js deleted file mode 100644 index 37be53fd..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/Investigation.js +++ /dev/null @@ -1,296 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { record_type, list_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Remark_toTuple_Z2023CF4E, Comment$_$reflection } from "../../ISA/JsonTypes/Comment.js"; -import { head, tail, ofSeq, append, reverse, cons, iterate, isEmpty, empty, map, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { Remark_wrapRemark, Comment_toString, Comment_fromString } from "../Comment.js"; -import { SparseRowModule_writeToSheet, SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_tryGetValueAt, SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133 } from "../SparseTable.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { value as value_1, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { comparePrimitives, getEnumerator, stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { ArcInvestigation } from "../../ISA/ArcTypes/ArcInvestigation.js"; -import { toRows as toRows_1, fromRows as fromRows_1 } from "./OntologySourceReference.js"; -import { toRows as toRows_2, fromRows as fromRows_2 } from "./Publication.js"; -import { toRows as toRows_3, fromRows as fromRows_3 } from "./Contacts.js"; -import { toRows as toRows_4, fromRows as fromRows_4 } from "./Study.js"; -import { iterateIndexed, map as map_1, toList, collect, singleton, append as append_1, delay } from "../../../fable_modules/fable-library.4.1.4/Seq.js"; -import { tryFind, ofList } from "../../../fable_modules/fable-library.4.1.4/Map.js"; -import { printf, toFail } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { FsWorksheet } from "../../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { FsWorkbook } from "../../../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; - -export class InvestigationInfo extends Record { - constructor(Identifier, Title, Description, SubmissionDate, PublicReleaseDate, Comments) { - super(); - this.Identifier = Identifier; - this.Title = Title; - this.Description = Description; - this.SubmissionDate = SubmissionDate; - this.PublicReleaseDate = PublicReleaseDate; - this.Comments = Comments; - } -} - -export function InvestigationInfo_$reflection() { - return record_type("ISA.Spreadsheet.ArcInvestigation.InvestigationInfo", [], InvestigationInfo, () => [["Identifier", string_type], ["Title", string_type], ["Description", string_type], ["SubmissionDate", string_type], ["PublicReleaseDate", string_type], ["Comments", list_type(Comment$_$reflection())]]); -} - -export function InvestigationInfo_create(identifier, title, description, submissionDate, publicReleaseDate, comments) { - return new InvestigationInfo(identifier, title, description, submissionDate, publicReleaseDate, comments); -} - -export function InvestigationInfo_get_Labels() { - return ofArray(["Investigation Identifier", "Investigation Title", "Investigation Description", "Investigation Submission Date", "Investigation Public Release Date"]); -} - -export function InvestigationInfo_FromSparseTable_Z15A4F148(matrix) { - const comments = map((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, 0])), matrix.CommentKeys); - return InvestigationInfo_create(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Identifier", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Title", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Description", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Submission Date", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Public Release Date", 0]), comments); -} - -export function InvestigationInfo_ToSparseTable_Z1FC82C0(investigation) { - const matrix = SparseTable_Create_Z2192E64B(void 0, InvestigationInfo_get_Labels(), void 0, 2); - let commentKeys = empty(); - addToDict(matrix.Matrix, ["Investigation Identifier", 1], investigation.Identifier); - addToDict(matrix.Matrix, ["Investigation Title", 1], defaultArg(investigation.Title, "")); - addToDict(matrix.Matrix, ["Investigation Description", 1], defaultArg(investigation.Description, "")); - addToDict(matrix.Matrix, ["Investigation Submission Date", 1], defaultArg(investigation.SubmissionDate, "")); - addToDict(matrix.Matrix, ["Investigation Public Release Date", 1], defaultArg(investigation.PublicReleaseDate, "")); - if (!isEmpty(investigation.Comments)) { - iterate((comment) => { - const patternInput = Comment_toString(comment); - const n = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, 1], patternInput[1]); - }, investigation.Comments); - } - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function InvestigationInfo_fromRows(lineNumber, rows) { - const tupledArg = SparseTable_FromRows_Z5579EC29(rows, InvestigationInfo_get_Labels(), lineNumber); - return [tupledArg[0], tupledArg[1], tupledArg[2], InvestigationInfo_FromSparseTable_Z15A4F148(tupledArg[3])]; -} - -export function InvestigationInfo_toRows_Z1FC82C0(investigation) { - return SparseTable_ToRows_584133C0(InvestigationInfo_ToSparseTable_Z1FC82C0(investigation)); -} - -export function fromParts(investigationInfo, ontologySourceReference, publications, contacts, studies, remarks) { - const arg_1 = Option_fromValueWithDefault("", investigationInfo.Title); - const arg_2 = Option_fromValueWithDefault("", investigationInfo.Description); - const arg_3 = Option_fromValueWithDefault("", investigationInfo.SubmissionDate); - const arg_4 = Option_fromValueWithDefault("", investigationInfo.PublicReleaseDate); - const arg_8 = Array.from(studies); - return ArcInvestigation.make(investigationInfo.Identifier, arg_1, arg_2, arg_3, arg_4, ontologySourceReference, publications, contacts, arg_8, investigationInfo.Comments, remarks); -} - -export function fromRows(rows) { - const en = getEnumerator(rows); - const emptyInvestigationInfo = InvestigationInfo_create("", "", "", "", "", empty()); - const loop = (lastLine_mut, ontologySourceReferences_mut, investigationInfo_mut, publications_mut, contacts_mut, studies_mut, remarks_mut, lineNumber_mut) => { - loop: - while (true) { - const lastLine = lastLine_mut, ontologySourceReferences = ontologySourceReferences_mut, investigationInfo = investigationInfo_mut, publications = publications_mut, contacts = contacts_mut, studies = studies_mut, remarks = remarks_mut, lineNumber = lineNumber_mut; - let matchResult, k_5, k_6, k_7, k_8, k_9, k_10; - if (lastLine != null) { - switch (lastLine) { - case "ONTOLOGY SOURCE REFERENCE": { - matchResult = 0; - k_5 = lastLine; - break; - } - case "INVESTIGATION": { - matchResult = 1; - k_6 = lastLine; - break; - } - case "INVESTIGATION PUBLICATIONS": { - matchResult = 2; - k_7 = lastLine; - break; - } - case "INVESTIGATION CONTACTS": { - matchResult = 3; - k_8 = lastLine; - break; - } - case "STUDY": { - matchResult = 4; - k_9 = lastLine; - break; - } - default: { - matchResult = 5; - k_10 = lastLine; - } - } - } - else { - matchResult = 5; - k_10 = lastLine; - } - switch (matchResult) { - case 0: { - const patternInput = fromRows_1(lineNumber + 1, en); - lastLine_mut = patternInput[0]; - ontologySourceReferences_mut = patternInput[3]; - investigationInfo_mut = investigationInfo; - publications_mut = publications; - contacts_mut = contacts; - studies_mut = studies; - remarks_mut = append(remarks, patternInput[2]); - lineNumber_mut = patternInput[1]; - continue loop; - } - case 1: { - const patternInput_1 = InvestigationInfo_fromRows(lineNumber + 1, en); - lastLine_mut = patternInput_1[0]; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = patternInput_1[3]; - publications_mut = publications; - contacts_mut = contacts; - studies_mut = studies; - remarks_mut = append(remarks, patternInput_1[2]); - lineNumber_mut = patternInput_1[1]; - continue loop; - } - case 2: { - const patternInput_2 = fromRows_2("Investigation Publication", lineNumber + 1, en); - lastLine_mut = patternInput_2[0]; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = investigationInfo; - publications_mut = patternInput_2[3]; - contacts_mut = contacts; - studies_mut = studies; - remarks_mut = append(remarks, patternInput_2[2]); - lineNumber_mut = patternInput_2[1]; - continue loop; - } - case 3: { - const patternInput_3 = fromRows_3("Investigation Person", lineNumber + 1, en); - lastLine_mut = patternInput_3[0]; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = investigationInfo; - publications_mut = publications; - contacts_mut = patternInput_3[3]; - studies_mut = studies; - remarks_mut = append(remarks, patternInput_3[2]); - lineNumber_mut = patternInput_3[1]; - continue loop; - } - case 4: { - const patternInput_4 = fromRows_4(lineNumber + 1, en); - const study = patternInput_4[3]; - const newRemarks_4 = patternInput_4[2]; - const lineNumber_5 = patternInput_4[1] | 0; - const currentLine_4 = patternInput_4[0]; - if (study != null) { - lastLine_mut = currentLine_4; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = investigationInfo; - publications_mut = publications; - contacts_mut = contacts; - studies_mut = cons(value_1(study), studies); - remarks_mut = append(remarks, newRemarks_4); - lineNumber_mut = lineNumber_5; - continue loop; - } - else { - lastLine_mut = currentLine_4; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = investigationInfo; - publications_mut = publications; - contacts_mut = contacts; - studies_mut = studies; - remarks_mut = append(remarks, newRemarks_4); - lineNumber_mut = lineNumber_5; - continue loop; - } - } - default: - return fromParts(investigationInfo, ontologySourceReferences, publications, contacts, reverse(studies), remarks); - } - break; - } - }; - if (en["System.Collections.IEnumerator.MoveNext"]()) { - return loop(SparseRowModule_tryGetValueAt(0, en["System.Collections.Generic.IEnumerator`1.get_Current"]()), empty(), emptyInvestigationInfo, empty(), empty(), empty(), empty(), 1); - } - else { - throw new Error("emptyInvestigationFile"); - } -} - -export function toRows(investigation) { - let remarks, rows; - return (remarks = investigation.Remarks, (rows = delay(() => append_1(singleton(SparseRowModule_fromValues(["ONTOLOGY SOURCE REFERENCE"])), delay(() => append_1(toRows_1(investigation.OntologySourceReferences), delay(() => append_1(singleton(SparseRowModule_fromValues(["INVESTIGATION"])), delay(() => append_1(InvestigationInfo_toRows_Z1FC82C0(investigation), delay(() => append_1(singleton(SparseRowModule_fromValues(["INVESTIGATION PUBLICATIONS"])), delay(() => append_1(toRows_2("Investigation Publication", investigation.Publications), delay(() => append_1(singleton(SparseRowModule_fromValues(["INVESTIGATION CONTACTS"])), delay(() => append_1(toRows_3("Investigation Person", investigation.Contacts), delay(() => collect((study) => append_1(singleton(SparseRowModule_fromValues(["STUDY"])), delay(() => toRows_4(study))), ofSeq(investigation.Studies))))))))))))))))))), (() => { - try { - const rm = ofList(map(Remark_toTuple_Z2023CF4E, remarks), { - Compare: comparePrimitives, - }); - const loop = (i_mut, l_mut, nl_mut) => { - loop: - while (true) { - const i = i_mut, l = l_mut, nl = nl_mut; - const matchValue = tryFind(i, rm); - if (matchValue == null) { - if (!isEmpty(l)) { - i_mut = (i + 1); - l_mut = tail(l); - nl_mut = cons(head(l), nl); - continue loop; - } - else { - return nl; - } - } - else { - const remark = matchValue; - i_mut = (i + 1); - l_mut = l; - nl_mut = cons(SparseRowModule_fromValues([Remark_wrapRemark(remark)]), nl); - continue loop; - } - break; - } - }; - return reverse(loop(1, ofSeq(rows), empty())); - } - catch (matchValue_1) { - return toList(rows); - } - })())); -} - -export function fromFsWorkbook(doc) { - let arg; - try { - return fromRows(map_1(SparseRowModule_fromFsRow, (arg = head(doc.GetWorksheets()), FsWorksheet.getRows(arg)))); - } - catch (err) { - const arg_1 = err.message; - return toFail(printf("Could not read investigation from spreadsheet: %s"))(arg_1); - } -} - -export function toFsWorkbook(investigation) { - try { - const wb = new FsWorkbook(); - const sheet = new FsWorksheet("Investigation"); - iterateIndexed((rowI, r) => { - SparseRowModule_writeToSheet(rowI + 1, r, sheet); - }, toRows(investigation)); - wb.AddWorksheet(sheet); - return wb; - } - catch (err) { - const arg = err.message; - return toFail(printf("Could not write investigation to spreadsheet: %s"))(arg); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.js deleted file mode 100644 index 050e4401..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.js +++ /dev/null @@ -1,70 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map, initialize, singleton, length, empty, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologySourceReference_create_55205B02, OntologySourceReference_make } from "../../ISA/JsonTypes/OntologySourceReference.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -export const nameLabel = "Term Source Name"; - -export const fileLabel = "Term Source File"; - -export const versionLabel = "Term Source Version"; - -export const descriptionLabel = "Term Source Description"; - -export const labels = ofArray([nameLabel, fileLabel, versionLabel, descriptionLabel]); - -export function fromString(description, file, name, version, comments) { - return OntologySourceReference_make(Option_fromValueWithDefault("", description), Option_fromValueWithDefault("", file), Option_fromValueWithDefault("", name), Option_fromValueWithDefault("", version), Option_fromValueWithDefault(empty(), comments)); -} - -export function fromSparseTable(matrix) { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(OntologySourceReference_create_55205B02(void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i) => { - const comments_1 = map((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [descriptionLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [fileLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [nameLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [versionLabel, i]), comments_1); - }); - } -} - -export function toSparseTable(ontologySources) { - const matrix = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(ontologySources) + 1); - let commentKeys = empty(); - iterateIndexed((i, o) => { - const i_1 = (i + 1) | 0; - addToDict(matrix.Matrix, [nameLabel, i_1], defaultArg(o.Name, "")); - addToDict(matrix.Matrix, [fileLabel, i_1], defaultArg(o.File, "")); - addToDict(matrix.Matrix, [versionLabel, i_1], defaultArg(o.Version, "")); - addToDict(matrix.Matrix, [descriptionLabel, i_1], defaultArg(o.Description, "")); - const matchValue = o.Comments; - if (matchValue != null) { - iterate((comment) => { - const patternInput = Comment_toString(comment); - const n = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1], patternInput[1]); - }, matchValue); - } - }, ontologySources); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(lineNumber, rows) { - const tupledArg = SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])]; -} - -export function toRows(termSources) { - return SparseTable_ToRows_584133C0(toSparseTable(termSources)); -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/Protocols.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/Protocols.js deleted file mode 100644 index 078fe3d5..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/Protocols.js +++ /dev/null @@ -1,114 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map as map_1, initialize, singleton, length, empty, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286 } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Component_toAggregatedStrings, ProtocolParameter_toAggregatedStrings, Option_fromValueWithDefault, Component_fromAggregatedStrings, ProtocolParameter_fromAggregatedStrings } from "../Conversions.js"; -import { Protocol_create_Z4D717767, Protocol_make } from "../../ISA/JsonTypes/Protocol.js"; -import { defaultArg, map } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { URIModule_fromString } from "../../ISA/JsonTypes/URI.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValue_11FD62A8, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -export const nameLabel = "Name"; - -export const protocolTypeLabel = "Type"; - -export const typeTermAccessionNumberLabel = "Type Term Accession Number"; - -export const typeTermSourceREFLabel = "Type Term Source REF"; - -export const descriptionLabel = "Description"; - -export const uriLabel = "URI"; - -export const versionLabel = "Version"; - -export const parametersNameLabel = "Parameters Name"; - -export const parametersTermAccessionNumberLabel = "Parameters Term Accession Number"; - -export const parametersTermSourceREFLabel = "Parameters Term Source REF"; - -export const componentsNameLabel = "Components Name"; - -export const componentsTypeLabel = "Components Type"; - -export const componentsTypeTermAccessionNumberLabel = "Components Type Term Accession Number"; - -export const componentsTypeTermSourceREFLabel = "Components Type Term Source REF"; - -export const labels = ofArray([nameLabel, protocolTypeLabel, typeTermAccessionNumberLabel, typeTermSourceREFLabel, descriptionLabel, uriLabel, versionLabel, parametersNameLabel, parametersTermAccessionNumberLabel, parametersTermSourceREFLabel, componentsNameLabel, componentsTypeLabel, componentsTypeTermAccessionNumberLabel, componentsTypeTermSourceREFLabel]); - -export function fromString(name, protocolType, typeTermAccessionNumber, typeTermSourceREF, description, uri, version, parametersName, parametersTermAccessionNumber, parametersTermSourceREF, componentsName, componentsType, componentsTypeTermAccessionNumber, componentsTypeTermSourceREF, comments) { - const protocolType_1 = OntologyAnnotation_fromString_Z7D8EB286(protocolType, typeTermSourceREF, typeTermAccessionNumber); - const parameters = ProtocolParameter_fromAggregatedStrings(";", parametersName, parametersTermSourceREF, parametersTermAccessionNumber); - const components = Component_fromAggregatedStrings(";", componentsName, componentsType, componentsTypeTermSourceREF, componentsTypeTermAccessionNumber); - return Protocol_make(void 0, map(URIModule_fromString, Option_fromValueWithDefault("", name)), Option_fromValueWithDefault(OntologyAnnotation_get_empty(), protocolType_1), Option_fromValueWithDefault("", description), map(URIModule_fromString, Option_fromValueWithDefault("", uri)), Option_fromValueWithDefault("", version), Option_fromValueWithDefault(empty(), parameters), Option_fromValueWithDefault(empty(), components), Option_fromValueWithDefault(empty(), comments)); -} - -export function fromSparseTable(matrix) { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(Protocol_create_Z4D717767(void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i) => { - const comments_1 = map_1((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [nameLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [protocolTypeLabel, i]), SparseTable__TryGetValue_11FD62A8(matrix, [typeTermAccessionNumberLabel, i]), SparseTable__TryGetValue_11FD62A8(matrix, [typeTermSourceREFLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [descriptionLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [uriLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [versionLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [parametersNameLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [parametersTermAccessionNumberLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [parametersTermSourceREFLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [componentsNameLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [componentsTypeLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [componentsTypeTermAccessionNumberLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [componentsTypeTermSourceREFLabel, i]), comments_1); - }); - } -} - -export function toSparseTable(protocols) { - const matrix = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(protocols) + 1); - let commentKeys = empty(); - iterateIndexed((i, p) => { - const i_1 = (i + 1) | 0; - const pt_1 = OntologyAnnotation_toString_473B9D79(defaultArg(p.ProtocolType, OntologyAnnotation_get_empty()), true); - const pAgg = ProtocolParameter_toAggregatedStrings(";", defaultArg(p.Parameters, empty())); - const cAgg = Component_toAggregatedStrings(";", defaultArg(p.Components, empty())); - addToDict(matrix.Matrix, [nameLabel, i_1], defaultArg(p.Name, "")); - addToDict(matrix.Matrix, [protocolTypeLabel, i_1], pt_1.TermName); - addToDict(matrix.Matrix, [typeTermAccessionNumberLabel, i_1], pt_1.TermAccessionNumber); - addToDict(matrix.Matrix, [typeTermSourceREFLabel, i_1], pt_1.TermSourceREF); - addToDict(matrix.Matrix, [descriptionLabel, i_1], defaultArg(p.Description, "")); - addToDict(matrix.Matrix, [uriLabel, i_1], defaultArg(p.Uri, "")); - addToDict(matrix.Matrix, [versionLabel, i_1], defaultArg(p.Version, "")); - addToDict(matrix.Matrix, [parametersNameLabel, i_1], pAgg.TermNameAgg); - addToDict(matrix.Matrix, [parametersTermAccessionNumberLabel, i_1], pAgg.TermAccessionNumberAgg); - addToDict(matrix.Matrix, [parametersTermSourceREFLabel, i_1], pAgg.TermSourceREFAgg); - addToDict(matrix.Matrix, [componentsNameLabel, i_1], cAgg.NameAgg); - addToDict(matrix.Matrix, [componentsTypeLabel, i_1], cAgg.TermNameAgg); - addToDict(matrix.Matrix, [componentsTypeTermAccessionNumberLabel, i_1], cAgg.TermAccessionNumberAgg); - addToDict(matrix.Matrix, [componentsTypeTermSourceREFLabel, i_1], cAgg.TermSourceREFAgg); - const matchValue = p.Comments; - if (matchValue != null) { - iterate((comment) => { - const patternInput = Comment_toString(comment); - const n = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1], patternInput[1]); - }, matchValue); - } - }, protocols); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix, lineNumber, rows) { - const tupledArg = (prefix == null) ? SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber) : SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, prefix); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])]; -} - -export function toRows(prefix, protocols) { - const m = toSparseTable(protocols); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, prefix); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/Publication.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/Publication.js deleted file mode 100644 index d4802be9..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/Publication.js +++ /dev/null @@ -1,89 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map as map_1, initialize, singleton, length, empty, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286 } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Publication_create_Z3E55064F, Publication_make } from "../../ISA/JsonTypes/Publication.js"; -import { defaultArg, map } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { URIModule_fromString } from "../../ISA/JsonTypes/URI.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValue_11FD62A8, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -export const pubMedIDLabel = "PubMed ID"; - -export const doiLabel = "DOI"; - -export const authorListLabel = "Author List"; - -export const titleLabel = "Title"; - -export const statusLabel = "Status"; - -export const statusTermAccessionNumberLabel = "Status Term Accession Number"; - -export const statusTermSourceREFLabel = "Status Term Source REF"; - -export const labels = ofArray([pubMedIDLabel, doiLabel, authorListLabel, titleLabel, statusLabel, statusTermAccessionNumberLabel, statusTermSourceREFLabel]); - -export function fromString(pubMedID, doi, author, title, status, statusTermSourceREF, statusTermAccessionNumber, comments) { - const status_1 = OntologyAnnotation_fromString_Z7D8EB286(status, statusTermSourceREF, statusTermAccessionNumber); - return Publication_make(map(URIModule_fromString, Option_fromValueWithDefault("", pubMedID)), Option_fromValueWithDefault("", doi), Option_fromValueWithDefault("", author), Option_fromValueWithDefault("", title), Option_fromValueWithDefault(OntologyAnnotation_get_empty(), status_1), Option_fromValueWithDefault(empty(), comments)); -} - -export function fromSparseTable(matrix) { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(Publication_create_Z3E55064F(void 0, void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i) => { - const comments_1 = map_1((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [pubMedIDLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [doiLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [authorListLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [titleLabel, i]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [statusLabel, i]), SparseTable__TryGetValue_11FD62A8(matrix, [statusTermSourceREFLabel, i]), SparseTable__TryGetValue_11FD62A8(matrix, [statusTermAccessionNumberLabel, i]), comments_1); - }); - } -} - -export function toSparseTable(publications) { - const matrix = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(publications) + 1); - let commentKeys = empty(); - iterateIndexed((i, p) => { - const i_1 = (i + 1) | 0; - const s_1 = OntologyAnnotation_toString_473B9D79(defaultArg(p.Status, OntologyAnnotation_get_empty()), true); - addToDict(matrix.Matrix, [pubMedIDLabel, i_1], defaultArg(p.PubMedID, "")); - addToDict(matrix.Matrix, [doiLabel, i_1], defaultArg(p.DOI, "")); - addToDict(matrix.Matrix, [authorListLabel, i_1], defaultArg(p.Authors, "")); - addToDict(matrix.Matrix, [titleLabel, i_1], defaultArg(p.Title, "")); - addToDict(matrix.Matrix, [statusLabel, i_1], s_1.TermName); - addToDict(matrix.Matrix, [statusTermAccessionNumberLabel, i_1], s_1.TermAccessionNumber); - addToDict(matrix.Matrix, [statusTermSourceREFLabel, i_1], s_1.TermSourceREF); - const matchValue = p.Comments; - if (matchValue != null) { - iterate((comment) => { - const patternInput = Comment_toString(comment); - const n = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1], patternInput[1]); - }, matchValue); - } - }, publications); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix, lineNumber, rows) { - const tupledArg = (prefix == null) ? SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber) : SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, prefix); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])]; -} - -export function toRows(prefix, publications) { - const m = toSparseTable(publications); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, prefix); - } -} - diff --git a/js/ISA/ISA.Spreadsheet/InvestigationFile/Study.js b/js/ISA/ISA.Spreadsheet/InvestigationFile/Study.js deleted file mode 100644 index cba9b07a..00000000 --- a/js/ISA/ISA.Spreadsheet/InvestigationFile/Study.js +++ /dev/null @@ -1,252 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { record_type, list_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Comment$_$reflection } from "../../ISA/JsonTypes/Comment.js"; -import { ofSeq, append, reverse, cons, iterate, isEmpty, empty, map, ofArray } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { SparseRowModule_fromValues, SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133 } from "../SparseTable.js"; -import { Study_fileNameFromIdentifier } from "../../ISA/ArcTypes/Identifier.js"; -import { addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { ArcTable } from "../../ISA/ArcTypes/ArcTable.js"; -import { ArcStudy } from "../../ISA/ArcTypes/ArcStudy.js"; -import { toRows as toRows_1, fromRows as fromRows_1 } from "./DesignDescriptors.js"; -import { toRows as toRows_2, fromRows as fromRows_2 } from "./Publication.js"; -import { toRows as toRows_3, fromRows as fromRows_3 } from "./Factors.js"; -import { toRows as toRows_4, fromRows as fromRows_4 } from "./Assays.js"; -import { toRows as toRows_5, fromRows as fromRows_5 } from "./Protocols.js"; -import { toRows as toRows_6, fromRows as fromRows_6 } from "./Contacts.js"; -import { singleton, append as append_1, delay, collect } from "../../../fable_modules/fable-library.4.1.4/Seq.js"; - -export class StudyInfo extends Record { - constructor(Identifier, Title, Description, SubmissionDate, PublicReleaseDate, FileName, Comments) { - super(); - this.Identifier = Identifier; - this.Title = Title; - this.Description = Description; - this.SubmissionDate = SubmissionDate; - this.PublicReleaseDate = PublicReleaseDate; - this.FileName = FileName; - this.Comments = Comments; - } -} - -export function StudyInfo_$reflection() { - return record_type("ISA.Spreadsheet.Studies.StudyInfo", [], StudyInfo, () => [["Identifier", string_type], ["Title", string_type], ["Description", string_type], ["SubmissionDate", string_type], ["PublicReleaseDate", string_type], ["FileName", string_type], ["Comments", list_type(Comment$_$reflection())]]); -} - -export function StudyInfo_create(identifier, title, description, submissionDate, publicReleaseDate, fileName, comments) { - return new StudyInfo(identifier, title, description, submissionDate, publicReleaseDate, fileName, comments); -} - -export function StudyInfo_get_Labels() { - return ofArray(["Study Identifier", "Study Title", "Study Description", "Study Submission Date", "Study Public Release Date", "Study File Name"]); -} - -export function StudyInfo_FromSparseTable_Z15A4F148(matrix) { - const comments = map((k) => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, 0])), matrix.CommentKeys); - return StudyInfo_create(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Identifier", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Title", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Description", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Submission Date", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Public Release Date", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study File Name", 0]), comments); -} - -export function StudyInfo_ToSparseTable_331096F(study) { - const matrix = SparseTable_Create_Z2192E64B(void 0, StudyInfo_get_Labels(), void 0, 2); - let commentKeys = empty(); - const patternInput = (study.Identifier.indexOf("MISSING_IDENTIFIER_") === 0) ? ["", ""] : [study.Identifier, Study_fileNameFromIdentifier(study.Identifier)]; - addToDict(matrix.Matrix, ["Study Identifier", 1], patternInput[0]); - addToDict(matrix.Matrix, ["Study Title", 1], defaultArg(study.Title, "")); - addToDict(matrix.Matrix, ["Study Description", 1], defaultArg(study.Description, "")); - addToDict(matrix.Matrix, ["Study Submission Date", 1], defaultArg(study.SubmissionDate, "")); - addToDict(matrix.Matrix, ["Study Public Release Date", 1], defaultArg(study.PublicReleaseDate, "")); - addToDict(matrix.Matrix, ["Study File Name", 1], patternInput[1]); - if (!isEmpty(study.Comments)) { - iterate((comment) => { - const patternInput_1 = Comment_toString(comment); - const n = patternInput_1[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, 1], patternInput_1[1]); - }, study.Comments); - } - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function StudyInfo_fromRows(lineNumber, rows) { - const tupledArg = SparseTable_FromRows_Z5579EC29(rows, StudyInfo_get_Labels(), lineNumber); - return [tupledArg[0], tupledArg[1], tupledArg[2], StudyInfo_FromSparseTable_Z15A4F148(tupledArg[3])]; -} - -export function StudyInfo_toRows_331096F(study) { - return SparseTable_ToRows_584133C0(StudyInfo_ToSparseTable_331096F(study)); -} - -export function fromParts(studyInfo, designDescriptors, publications, factors, assays, protocols, contacts) { - let arcstudy; - const arg_1 = Option_fromValueWithDefault("", studyInfo.Title); - const arg_2 = Option_fromValueWithDefault("", studyInfo.Description); - const arg_3 = Option_fromValueWithDefault("", studyInfo.SubmissionDate); - const arg_4 = Option_fromValueWithDefault("", studyInfo.PublicReleaseDate); - let arg_8; - const arg_13 = map((arg_12) => ArcTable.fromProtocol(arg_12), protocols); - arg_8 = Array.from(arg_13); - const arg_9 = Array.from(assays); - arcstudy = ArcStudy.make(studyInfo.Identifier, arg_1, arg_2, arg_3, arg_4, publications, contacts, designDescriptors, arg_8, arg_9, factors, studyInfo.Comments); - if (arcstudy.isEmpty && (arcstudy.Identifier === "")) { - return void 0; - } - else { - return arcstudy; - } -} - -export function fromRows(lineNumber, en) { - const loop = (lastLine_mut, studyInfo_mut, designDescriptors_mut, publications_mut, factors_mut, assays_mut, protocols_mut, contacts_mut, remarks_mut, lineNumber_1_mut) => { - loop: - while (true) { - const lastLine = lastLine_mut, studyInfo = studyInfo_mut, designDescriptors = designDescriptors_mut, publications = publications_mut, factors = factors_mut, assays = assays_mut, protocols = protocols_mut, contacts = contacts_mut, remarks = remarks_mut, lineNumber_1 = lineNumber_1_mut; - let matchResult, k_6, k_7, k_8, k_9, k_10, k_11, k_12; - if (lastLine != null) { - switch (lastLine) { - case "STUDY DESIGN DESCRIPTORS": { - matchResult = 0; - k_6 = lastLine; - break; - } - case "STUDY PUBLICATIONS": { - matchResult = 1; - k_7 = lastLine; - break; - } - case "STUDY FACTORS": { - matchResult = 2; - k_8 = lastLine; - break; - } - case "STUDY ASSAYS": { - matchResult = 3; - k_9 = lastLine; - break; - } - case "STUDY PROTOCOLS": { - matchResult = 4; - k_10 = lastLine; - break; - } - case "STUDY CONTACTS": { - matchResult = 5; - k_11 = lastLine; - break; - } - default: { - matchResult = 6; - k_12 = lastLine; - } - } - } - else { - matchResult = 6; - k_12 = lastLine; - } - switch (matchResult) { - case 0: { - const patternInput = fromRows_1("Study Design", lineNumber_1 + 1, en); - lastLine_mut = patternInput[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = patternInput[3]; - publications_mut = publications; - factors_mut = factors; - assays_mut = assays; - protocols_mut = protocols; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput[2]); - lineNumber_1_mut = patternInput[1]; - continue loop; - } - case 1: { - const patternInput_1 = fromRows_2("Study Publication", lineNumber_1 + 1, en); - lastLine_mut = patternInput_1[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = patternInput_1[3]; - factors_mut = factors; - assays_mut = assays; - protocols_mut = protocols; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput_1[2]); - lineNumber_1_mut = patternInput_1[1]; - continue loop; - } - case 2: { - const patternInput_2 = fromRows_3("Study Factor", lineNumber_1 + 1, en); - lastLine_mut = patternInput_2[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = publications; - factors_mut = patternInput_2[3]; - assays_mut = assays; - protocols_mut = protocols; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput_2[2]); - lineNumber_1_mut = patternInput_2[1]; - continue loop; - } - case 3: { - const patternInput_3 = fromRows_4("Study Assay", lineNumber_1 + 1, en); - lastLine_mut = patternInput_3[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = publications; - factors_mut = factors; - assays_mut = patternInput_3[3]; - protocols_mut = protocols; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput_3[2]); - lineNumber_1_mut = patternInput_3[1]; - continue loop; - } - case 4: { - const patternInput_4 = fromRows_5("Study Protocol", lineNumber_1 + 1, en); - lastLine_mut = patternInput_4[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = publications; - factors_mut = factors; - assays_mut = assays; - protocols_mut = patternInput_4[3]; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput_4[2]); - lineNumber_1_mut = patternInput_4[1]; - continue loop; - } - case 5: { - const patternInput_5 = fromRows_6("Study Person", lineNumber_1 + 1, en); - lastLine_mut = patternInput_5[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = publications; - factors_mut = factors; - assays_mut = assays; - protocols_mut = protocols; - contacts_mut = patternInput_5[3]; - remarks_mut = append(remarks, patternInput_5[2]); - lineNumber_1_mut = patternInput_5[1]; - continue loop; - } - default: - return [k_12, lineNumber_1, remarks, fromParts(studyInfo, designDescriptors, publications, factors, assays, protocols, contacts)]; - } - break; - } - }; - const patternInput_6 = StudyInfo_fromRows(lineNumber, en); - return loop(patternInput_6[0], patternInput_6[3], empty(), empty(), empty(), empty(), empty(), empty(), patternInput_6[2], patternInput_6[1]); -} - -export function toRows(study) { - const protocols = ofSeq(collect((p) => p.GetProtocols(), study.Tables)); - return delay(() => append_1(StudyInfo_toRows_331096F(study), delay(() => append_1(singleton(SparseRowModule_fromValues(["STUDY DESIGN DESCRIPTORS"])), delay(() => append_1(toRows_1("Study Design", study.StudyDesignDescriptors), delay(() => append_1(singleton(SparseRowModule_fromValues(["STUDY PUBLICATIONS"])), delay(() => append_1(toRows_2("Study Publication", study.Publications), delay(() => append_1(singleton(SparseRowModule_fromValues(["STUDY FACTORS"])), delay(() => append_1(toRows_3("Study Factor", study.Factors), delay(() => append_1(singleton(SparseRowModule_fromValues(["STUDY ASSAYS"])), delay(() => append_1(toRows_4("Study Assay", ofSeq(study.Assays)), delay(() => append_1(singleton(SparseRowModule_fromValues(["STUDY PROTOCOLS"])), delay(() => append_1(toRows_5("Study Protocol", protocols), delay(() => append_1(singleton(SparseRowModule_fromValues(["STUDY CONTACTS"])), delay(() => toRows_6("Study Person", study.Contacts)))))))))))))))))))))))))); -} - diff --git a/js/ISA/ISA.Spreadsheet/SparseTable.js b/js/ISA/ISA.Spreadsheet/SparseTable.js deleted file mode 100644 index 93b0755b..00000000 --- a/js/ISA/ISA.Spreadsheet/SparseTable.js +++ /dev/null @@ -1,441 +0,0 @@ -import { append as append_1, delay, tryItem, length as length_1, isEmpty, iterate, fold, tryPick, maxBy, initialize, choose, map, indexed } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { defaultArg, map as map_1 } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { tryFind, ofSeq } from "../../fable_modules/fable-library.4.1.4/Map.js"; -import { arrayHash, equalArrays, equals, comparePrimitives } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { RowBuilder_get_Empty, RowBuilder__Combine_19F30600, RowBuilder_$ctor } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/RowBuilder.fs.js"; -import { CellBuilder_$ctor, CellBuilder__AsCellElement_825BA8D } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/CellBuilder.fs.js"; -import { Messages_format, SheetEntity$1_some_2B595 } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/Types.fs.js"; -import { DataType } from "../../fable_modules/FsSpreadsheet.3.1.1/Cells/FsCell.fs.js"; -import { map as map_2, initialize as initialize_1, exists, find, cons, append, empty, singleton } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { ColumnIndex, RowElement } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/Types.fs.js"; -import { Record } from "../../fable_modules/fable-library.4.1.4/Types.js"; -import { record_type, list_type, class_type, tuple_type, int32_type, string_type } from "../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Seq_trySkip, Dictionary_tryGetValue } from "./CollectionAux.js"; -import { addToDict, getItemFromDict } from "../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { Dictionary } from "../../fable_modules/fable-library.4.1.4/MutableMap.js"; -import { printf, toFail } from "../../fable_modules/fable-library.4.1.4/String.js"; -import { Comment_create_250E0578, Remark_make } from "../ISA/JsonTypes/Comment.js"; -import { Comment_wrapCommentKey, Comment_$007CComment$007C_$007C, Remark_$007CRemark$007C_$007C } from "./Comment.js"; - -export function SparseRowModule_fromValues(v) { - return indexed(v); -} - -export function SparseRowModule_getValues(i) { - return map((tuple) => tuple[1], i); -} - -export function SparseRowModule_fromAllValues(v) { - return choose((tupledArg) => map_1((v_1) => [tupledArg[0], v_1], tupledArg[1]), indexed(v)); -} - -export function SparseRowModule_getAllValues(i) { - const m = ofSeq(i, { - Compare: comparePrimitives, - }); - return initialize(maxBy((tuple) => tuple[0], i, { - Compare: comparePrimitives, - })[0] + 1, (i_1) => tryFind(i_1, m)); -} - -export function SparseRowModule_fromFsRow(r) { - return map((c) => [c.ColumnNumber - 1, c.Value], r.Cells); -} - -export function SparseRowModule_tryGetValueAt(i, vs) { - return tryPick((tupledArg) => { - if (tupledArg[0] === i) { - return tupledArg[1]; - } - else { - return void 0; - } - }, vs); -} - -export function SparseRowModule_toDSLRow(vs) { - const builder$0040 = RowBuilder_$ctor(); - let this$_9; - const arg = map((_arg) => { - const v = _arg; - if (v == null) { - let c_1; - const this$_5 = CellBuilder__AsCellElement_825BA8D(CellBuilder_$ctor(), SheetEntity$1_some_2B595(singleton([new DataType(0, []), ""]))); - let matchResult, errs_1, f_1, ms_2_1; - switch (this$_5.tag) { - case 1: { - if (equals(this$_5.fields[0], empty())) { - matchResult = 1; - ms_2_1 = this$_5.fields[0]; - } - else { - matchResult = 2; - } - break; - } - case 2: { - if (equals(this$_5.fields[0], empty())) { - matchResult = 1; - ms_2_1 = this$_5.fields[0]; - } - else { - matchResult = 2; - } - break; - } - default: { - matchResult = 0; - errs_1 = this$_5.fields[1]; - f_1 = this$_5.fields[0]; - } - } - switch (matchResult) { - case 0: { - c_1 = f_1; - break; - } - case 1: { - throw new Error("SheetEntity does not contain Value."); - break; - } - default: { - let matchResult_1, ms_3_1; - switch (this$_5.tag) { - case 1: { - matchResult_1 = 0; - ms_3_1 = this$_5.fields[0]; - break; - } - case 2: { - matchResult_1 = 0; - ms_3_1 = this$_5.fields[0]; - break; - } - default: - matchResult_1 = 1; - } - switch (matchResult_1) { - case 0: { - throw new Error(`SheetEntity does not contain Value: - ${Messages_format(ms_3_1)}`); - break; - } - default: - throw new Error("Match failure: FsSpreadsheet.DSL.SheetEntity`1"); - } - } - } - return SheetEntity$1_some_2B595(singleton((c_1[1] == null) ? (new RowElement(1, [c_1[0]])) : (new RowElement(0, [new ColumnIndex(c_1[1]), c_1[0]])))); - } - else { - const v_1 = v; - let c; - const this$_2 = CellBuilder__AsCellElement_825BA8D(CellBuilder_$ctor(), SheetEntity$1_some_2B595(singleton([new DataType(0, []), v_1]))); - let matchResult_2, errs, f, ms_2; - switch (this$_2.tag) { - case 1: { - if (equals(this$_2.fields[0], empty())) { - matchResult_2 = 1; - ms_2 = this$_2.fields[0]; - } - else { - matchResult_2 = 2; - } - break; - } - case 2: { - if (equals(this$_2.fields[0], empty())) { - matchResult_2 = 1; - ms_2 = this$_2.fields[0]; - } - else { - matchResult_2 = 2; - } - break; - } - default: { - matchResult_2 = 0; - errs = this$_2.fields[1]; - f = this$_2.fields[0]; - } - } - switch (matchResult_2) { - case 0: { - c = f; - break; - } - case 1: { - throw new Error("SheetEntity does not contain Value."); - break; - } - default: { - let matchResult_3, ms_3; - switch (this$_2.tag) { - case 1: { - matchResult_3 = 0; - ms_3 = this$_2.fields[0]; - break; - } - case 2: { - matchResult_3 = 0; - ms_3 = this$_2.fields[0]; - break; - } - default: - matchResult_3 = 1; - } - switch (matchResult_3) { - case 0: { - throw new Error(`SheetEntity does not contain Value: - ${Messages_format(ms_3)}`); - break; - } - default: - throw new Error("Match failure: FsSpreadsheet.DSL.SheetEntity`1"); - } - } - } - return SheetEntity$1_some_2B595(singleton((c[1] == null) ? (new RowElement(1, [c[0]])) : (new RowElement(0, [new ColumnIndex(c[1]), c[0]])))); - } - }, SparseRowModule_getAllValues(vs)); - this$_9 = fold((state, we) => RowBuilder__Combine_19F30600(builder$0040, state, we), RowBuilder_get_Empty(), arg); - let matchResult_4, errs_2, f_3, ms_2_2; - switch (this$_9.tag) { - case 1: { - if (equals(this$_9.fields[0], empty())) { - matchResult_4 = 1; - ms_2_2 = this$_9.fields[0]; - } - else { - matchResult_4 = 2; - } - break; - } - case 2: { - if (equals(this$_9.fields[0], empty())) { - matchResult_4 = 1; - ms_2_2 = this$_9.fields[0]; - } - else { - matchResult_4 = 2; - } - break; - } - default: { - matchResult_4 = 0; - errs_2 = this$_9.fields[1]; - f_3 = this$_9.fields[0]; - } - } - switch (matchResult_4) { - case 0: - return f_3; - case 1: - throw new Error("SheetEntity does not contain Value."); - default: { - let matchResult_5, ms_3_2; - switch (this$_9.tag) { - case 1: { - matchResult_5 = 0; - ms_3_2 = this$_9.fields[0]; - break; - } - case 2: { - matchResult_5 = 0; - ms_3_2 = this$_9.fields[0]; - break; - } - default: - matchResult_5 = 1; - } - switch (matchResult_5) { - case 0: - throw new Error(`SheetEntity does not contain Value: - ${Messages_format(ms_3_2)}`); - default: - throw new Error("Match failure: FsSpreadsheet.DSL.SheetEntity`1"); - } - } - } -} - -export function SparseRowModule_readFromSheet(sheet) { - return map(SparseRowModule_fromFsRow, sheet.Rows); -} - -export function SparseRowModule_writeToSheet(rowI, row, sheet) { - const fsRow = sheet.Row(rowI); - iterate((tupledArg) => { - fsRow.Item(tupledArg[0] + 1).SetValueAs(tupledArg[1]); - }, row); -} - -export class SparseTable extends Record { - constructor(Matrix, Keys, CommentKeys, ColumnCount) { - super(); - this.Matrix = Matrix; - this.Keys = Keys; - this.CommentKeys = CommentKeys; - this.ColumnCount = (ColumnCount | 0); - } -} - -export function SparseTable_$reflection() { - return record_type("ISA.Spreadsheet.SparseTable", [], SparseTable, () => [["Matrix", class_type("System.Collections.Generic.Dictionary`2", [tuple_type(string_type, int32_type), string_type])], ["Keys", list_type(string_type)], ["CommentKeys", list_type(string_type)], ["ColumnCount", int32_type]]); -} - -export function SparseTable__TryGetValue_11FD62A8(this$, key) { - return Dictionary_tryGetValue(key, this$.Matrix); -} - -export function SparseTable__TryGetValueDefault_5BAE6133(this$, defaultValue, key) { - if (this$.Matrix.has(key)) { - return getItemFromDict(this$.Matrix, key); - } - else { - return defaultValue; - } -} - -export function SparseTable_Create_Z2192E64B(matrix, keys, commentKeys, length) { - return new SparseTable(defaultArg(matrix, new Dictionary([], { - Equals: equalArrays, - GetHashCode: arrayHash, - })), defaultArg(keys, empty()), defaultArg(commentKeys, empty()), defaultArg(length, 0)); -} - -export function SparseTable_AddRow(key, values, matrix) { - iterate((tupledArg) => { - addToDict(matrix.Matrix, [key, tupledArg[0]], tupledArg[1]); - }, values); - const length = (isEmpty(values) ? 0 : (1 + maxBy((tuple) => tuple[0], values, { - Compare: comparePrimitives, - })[0])) | 0; - return new SparseTable(matrix.Matrix, append(matrix.Keys, singleton(key)), matrix.CommentKeys, (length > matrix.ColumnCount) ? length : matrix.ColumnCount); -} - -export function SparseTable_AddEmptyComment(key, matrix) { - return new SparseTable(matrix.Matrix, matrix.Keys, append(matrix.CommentKeys, singleton(key)), matrix.ColumnCount); -} - -export function SparseTable_AddComment(key, values, matrix) { - if (length_1(values) === 0) { - return SparseTable_AddEmptyComment(key, matrix); - } - else { - iterate((tupledArg) => { - addToDict(matrix.Matrix, [key, tupledArg[0]], tupledArg[1]); - }, values); - const length = (isEmpty(values) ? 0 : (1 + maxBy((tuple) => tuple[0], values, { - Compare: comparePrimitives, - })[0])) | 0; - return new SparseTable(matrix.Matrix, matrix.Keys, append(matrix.CommentKeys, singleton(key)), (length > matrix.ColumnCount) ? length : matrix.ColumnCount); - } -} - -export function SparseTable_FromRows_Z5579EC29(en, labels, lineNumber, prefix) { - try { - const prefix_1 = (prefix == null) ? "" : (prefix + " "); - const loop = (matrix_mut, remarks_mut, lineNumber_1_mut) => { - let v_2, k_1; - loop: - while (true) { - const matrix = matrix_mut, remarks = remarks_mut, lineNumber_1 = lineNumber_1_mut; - if (en["System.Collections.IEnumerator.MoveNext"]()) { - const row = map((tupledArg) => [tupledArg[0] - 1, tupledArg[1]], en["System.Collections.Generic.IEnumerator`1.get_Current"]()); - const matchValue = map_1((tuple) => tuple[1], tryItem(0, row)); - const vals = Seq_trySkip(1, row); - const key = matchValue; - let matchResult, k, v_1; - const activePatternResult = Comment_$007CComment$007C_$007C(key); - if (activePatternResult != null) { - if (vals != null) { - matchResult = 0; - k = activePatternResult; - v_1 = vals; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: { - matrix_mut = SparseTable_AddComment(k, v_1, matrix); - remarks_mut = remarks; - lineNumber_1_mut = (lineNumber_1 + 1); - continue loop; - } - default: { - let matchResult_1, k_2, k_3, v_3, k_4; - const activePatternResult_1 = Remark_$007CRemark$007C_$007C(key); - if (activePatternResult_1 != null) { - matchResult_1 = 0; - k_2 = activePatternResult_1; - } - else if (key != null) { - if (vals != null) { - if ((v_2 = vals, (k_1 = key, exists((label) => (k_1 === (prefix_1 + label)), labels)))) { - matchResult_1 = 1; - k_3 = key; - v_3 = vals; - } - else { - matchResult_1 = 2; - k_4 = key; - } - } - else { - matchResult_1 = 2; - k_4 = key; - } - } - else { - matchResult_1 = 3; - } - switch (matchResult_1) { - case 0: { - matrix_mut = matrix; - remarks_mut = cons(Remark_make(lineNumber_1, k_2), remarks); - lineNumber_1_mut = (lineNumber_1 + 1); - continue loop; - } - case 1: { - matrix_mut = SparseTable_AddRow(find((label_1) => (k_3 === (prefix_1 + label_1)), labels), v_3, matrix); - remarks_mut = remarks; - lineNumber_1_mut = (lineNumber_1 + 1); - continue loop; - } - case 2: - return [k_4, lineNumber_1, remarks, matrix]; - default: - return [void 0, lineNumber_1, remarks, matrix]; - } - } - } - } - else { - return [void 0, lineNumber_1, remarks, matrix]; - } - break; - } - }; - return loop(SparseTable_Create_Z2192E64B(), empty(), lineNumber); - } - catch (err) { - const arg_9 = err.message; - return toFail(printf("Error parsing block in investigation file starting from line number %i: %s"))(lineNumber)(arg_9); - } -} - -export function SparseTable_ToRows_584133C0(matrix, prefix) { - const prefix_1 = (prefix == null) ? "" : (prefix + " "); - return delay(() => append_1(map((key) => SparseRowModule_fromValues(cons(prefix_1 + key, initialize_1(matrix.ColumnCount - 1, (i) => SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [key, i + 1])))), matrix.Keys), delay(() => map((key_1) => SparseRowModule_fromValues(cons(Comment_wrapCommentKey(key_1), initialize_1(matrix.ColumnCount - 1, (i_1) => SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [key_1, i_1 + 1])))), matrix.CommentKeys)))); -} - -export function SparseTable_GetEmptyComments_Z15A4F148(matrix) { - return map_2((key) => Comment_create_250E0578(void 0, key), matrix.CommentKeys); -} - diff --git a/js/ISA/ISA/ArcTypes/ArcAssay.js b/js/ISA/ISA/ArcTypes/ArcAssay.js deleted file mode 100644 index 4f6b3403..00000000 --- a/js/ISA/ISA/ArcTypes/ArcAssay.js +++ /dev/null @@ -1,469 +0,0 @@ -import { defaultArg, map, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { ArcTables_fromProcesses_Z31821267, ArcTables__get_Tables, ArcTables__GetProcesses, ArcTables__GetRow_Z18115A39, ArcTables__GetRowAt_Z37302880, ArcTables__UpdateRow_Z5E65B4B1, ArcTables__UpdateRowAt_Z596C2D98, ArcTables__RemoveRow_Z18115A39, ArcTables__RemoveRowAt_Z37302880, ArcTables__AddRow_1177C4AF, ArcTables__AddRowAt_Z57F91678, ArcTables__GetColumn_Z18115A39, ArcTables__GetColumnAt_Z37302880, ArcTables__UpdateColumn_Z774BF72A, ArcTables__UpdateColumnAt_Z155350AF, ArcTables__RemoveColumn_Z18115A39, ArcTables__RemoveColumnAt_Z37302880, ArcTables__AddColumn_Z4FC90944, ArcTables__AddColumnAt_6647579B, ArcTables__RenameTable_Z384F8060, ArcTables__RenameTableAt_Z176EF219, ArcTables__MapTable_4E415F2F, ArcTables__MapTableAt_61602D68, ArcTables__RemoveTable_Z721C83C5, ArcTables__RemoveTableAt_Z524259A4, ArcTables__UpdateTable_4976F045, ArcTables__UpdateTableAt_66578202, ArcTables__GetTable_Z721C83C5, ArcTables__GetTableAt_Z524259A4, ArcTables__InitTables_7B28792B, ArcTables__InitTable_3B406CA4, ArcTables__AddTables_3601F24E, ArcTables__AddTable_16F700A1, ArcTables__get_TableNames, ArcTables_$ctor_Z68BECB99, ArcTables__get_Count } from "./ArcTables.js"; -import { disposeSafe, getEnumerator } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { AssayMaterials_get_empty, AssayMaterials_create_1CB3546D } from "../JsonTypes/AssayMaterials.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { empty } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { getUnits, getCharacteristics, getData, getMaterials, getSamples } from "../JsonTypes/ProcessSequence.js"; -import { Assay_create_ABF59A4 } from "../JsonTypes/Assay.js"; -import { Assay_identifierFromFileName, createMissingIdentifier, Assay_fileNameFromIdentifier, isMissingIdentifier } from "./Identifier.js"; -import { class_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class ArcAssay { - constructor(identifier, measurementType, technologyType, technologyPlatform, tables, performers, comments) { - const tables_1 = defaultArg(tables, []); - const performers_1 = defaultArg(performers, empty()); - const comments_1 = defaultArg(comments, empty()); - this["identifier@13"] = identifier; - this["MeasurementType@"] = measurementType; - this["TechnologyType@"] = technologyType; - this["TechnologyPlatform@"] = technologyPlatform; - this["Tables@"] = tables_1; - this["Performers@"] = performers_1; - this["Comments@"] = comments_1; - } - get Identifier() { - const this$ = this; - return this$["identifier@13"]; - } - set Identifier(i) { - const this$ = this; - this$["identifier@13"] = i; - } - static get FileName() { - return "isa.assay.xlsx"; - } - get MeasurementType() { - const __ = this; - return unwrap(__["MeasurementType@"]); - } - set MeasurementType(v) { - const __ = this; - __["MeasurementType@"] = v; - } - get TechnologyType() { - const __ = this; - return unwrap(__["TechnologyType@"]); - } - set TechnologyType(v) { - const __ = this; - __["TechnologyType@"] = v; - } - get TechnologyPlatform() { - const __ = this; - return unwrap(__["TechnologyPlatform@"]); - } - set TechnologyPlatform(v) { - const __ = this; - __["TechnologyPlatform@"] = v; - } - get Tables() { - const __ = this; - return __["Tables@"]; - } - set Tables(v) { - const __ = this; - __["Tables@"] = v; - } - get Performers() { - const __ = this; - return __["Performers@"]; - } - set Performers(v) { - const __ = this; - __["Performers@"] = v; - } - get Comments() { - const __ = this; - return __["Comments@"]; - } - set Comments(v) { - const __ = this; - __["Comments@"] = v; - } - static init(identifier) { - return new ArcAssay(identifier); - } - static create(identifier, measurementType, technologyType, technologyPlatform, tables, performers, comments) { - return new ArcAssay(identifier, unwrap(measurementType), unwrap(technologyType), unwrap(technologyPlatform), unwrap(tables), unwrap(performers), unwrap(comments)); - } - static make(identifier, measurementType, technologyType, technologyPlatform, tables, performers, comments) { - return new ArcAssay(identifier, unwrap(measurementType), unwrap(technologyType), unwrap(technologyPlatform), tables, performers, comments); - } - get TableCount() { - const this$ = this; - return ArcTables__get_Count(ArcTables_$ctor_Z68BECB99(this$.Tables)) | 0; - } - get TableNames() { - const this$ = this; - return ArcTables__get_TableNames(ArcTables_$ctor_Z68BECB99(this$.Tables)); - } - AddTable(table, index) { - const this$ = this; - ArcTables__AddTable_16F700A1(ArcTables_$ctor_Z68BECB99(this$.Tables), table, unwrap(index)); - } - static addTable(table, index) { - return (assay) => { - const c = assay.Copy(); - c.AddTable(table, unwrap(index)); - return c; - }; - } - AddTables(tables, index) { - const this$ = this; - ArcTables__AddTables_3601F24E(ArcTables_$ctor_Z68BECB99(this$.Tables), tables, unwrap(index)); - } - static addTables(tables, index) { - return (assay) => { - const c = assay.Copy(); - c.AddTables(tables, unwrap(index)); - return c; - }; - } - InitTable(tableName, index) { - const this$ = this; - ArcTables__InitTable_3B406CA4(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, unwrap(index)); - } - static initTable(tableName, index) { - return (assay) => { - const c = assay.Copy(); - c.InitTable(tableName, unwrap(index)); - return c; - }; - } - InitTables(tableNames, index) { - const this$ = this; - ArcTables__InitTables_7B28792B(ArcTables_$ctor_Z68BECB99(this$.Tables), tableNames, unwrap(index)); - } - static initTables(tableNames, index) { - return (assay) => { - const c = assay.Copy(); - c.InitTables(tableNames, unwrap(index)); - return c; - }; - } - GetTableAt(index) { - const this$ = this; - return ArcTables__GetTableAt_Z524259A4(ArcTables_$ctor_Z68BECB99(this$.Tables), index); - } - static getTableAt(index) { - return (assay) => { - const newAssay = assay.Copy(); - return newAssay.GetTableAt(index); - }; - } - GetTable(name) { - const this$ = this; - return ArcTables__GetTable_Z721C83C5(ArcTables_$ctor_Z68BECB99(this$.Tables), name); - } - static getTable(name) { - return (assay) => { - const newAssay = assay.Copy(); - return newAssay.GetTable(name); - }; - } - UpdateTableAt(index, table) { - const this$ = this; - ArcTables__UpdateTableAt_66578202(ArcTables_$ctor_Z68BECB99(this$.Tables), index, table); - } - static updateTableAt(index, table) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.UpdateTableAt(index, table); - return newAssay; - }; - } - UpdateTable(name, table) { - const this$ = this; - ArcTables__UpdateTable_4976F045(ArcTables_$ctor_Z68BECB99(this$.Tables), name, table); - } - static updateTable(name, table) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.UpdateTable(name, table); - return newAssay; - }; - } - RemoveTableAt(index) { - const this$ = this; - ArcTables__RemoveTableAt_Z524259A4(ArcTables_$ctor_Z68BECB99(this$.Tables), index); - } - static removeTableAt(index) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.RemoveTableAt(index); - return newAssay; - }; - } - RemoveTable(name) { - const this$ = this; - ArcTables__RemoveTable_Z721C83C5(ArcTables_$ctor_Z68BECB99(this$.Tables), name); - } - static removeTable(name) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.RemoveTable(name); - return newAssay; - }; - } - MapTableAt(index, updateFun) { - const this$ = this; - ArcTables__MapTableAt_61602D68(ArcTables_$ctor_Z68BECB99(this$.Tables), index, updateFun); - } - static mapTableAt(index, updateFun) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.MapTableAt(index, updateFun); - return newAssay; - }; - } - MapTable(name, updateFun) { - const this$ = this; - ArcTables__MapTable_4E415F2F(ArcTables_$ctor_Z68BECB99(this$.Tables), name, updateFun); - } - static updateTable(name, updateFun) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.MapTable(name, updateFun); - return newAssay; - }; - } - RenameTableAt(index, newName) { - const this$ = this; - ArcTables__RenameTableAt_Z176EF219(ArcTables_$ctor_Z68BECB99(this$.Tables), index, newName); - } - static renameTableAt(index, newName) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.RenameTableAt(index, newName); - return newAssay; - }; - } - RenameTable(name, newName) { - const this$ = this; - ArcTables__RenameTable_Z384F8060(ArcTables_$ctor_Z68BECB99(this$.Tables), name, newName); - } - static renameTable(name, newName) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.RenameTable(name, newName); - return newAssay; - }; - } - AddColumnAt(tableIndex, header, cells, columnIndex, forceReplace) { - const this$ = this; - ArcTables__AddColumnAt_6647579B(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - } - static addColumnAt(tableIndex, header, cells, columnIndex, forceReplace) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.AddColumnAt(tableIndex, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - return newAssay; - }; - } - AddColumn(tableName, header, cells, columnIndex, forceReplace) { - const this$ = this; - ArcTables__AddColumn_Z4FC90944(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - } - static addColumn(tableName, header, cells, columnIndex, forceReplace) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.AddColumn(tableName, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - return newAssay; - }; - } - RemoveColumnAt(tableIndex, columnIndex) { - const this$ = this; - ArcTables__RemoveColumnAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex); - } - static removeColumnAt(tableIndex, columnIndex) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.RemoveColumnAt(tableIndex, columnIndex); - return newAssay; - }; - } - RemoveColumn(tableName, columnIndex) { - const this$ = this; - ArcTables__RemoveColumn_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex); - } - static removeColumn(tableName, columnIndex) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.RemoveColumn(tableName, columnIndex); - return newAssay; - }; - } - UpdateColumnAt(tableIndex, columnIndex, header, cells) { - const this$ = this; - ArcTables__UpdateColumnAt_Z155350AF(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex, header, unwrap(cells)); - } - static updateColumnAt(tableIndex, columnIndex, header, cells) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.UpdateColumnAt(tableIndex, columnIndex, header, unwrap(cells)); - return newAssay; - }; - } - UpdateColumn(tableName, columnIndex, header, cells) { - const this$ = this; - ArcTables__UpdateColumn_Z774BF72A(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex, header, unwrap(cells)); - } - static updateColumn(tableName, columnIndex, header, cells) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.UpdateColumn(tableName, columnIndex, header, unwrap(cells)); - return newAssay; - }; - } - GetColumnAt(tableIndex, columnIndex) { - const this$ = this; - return ArcTables__GetColumnAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex); - } - static getColumnAt(tableIndex, columnIndex) { - return (assay) => { - const newAssay = assay.Copy(); - return newAssay.GetColumnAt(tableIndex, columnIndex); - }; - } - GetColumn(tableName, columnIndex) { - const this$ = this; - return ArcTables__GetColumn_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex); - } - static getColumn(tableName, columnIndex) { - return (assay) => { - const newAssay = assay.Copy(); - return newAssay.GetColumn(tableName, columnIndex); - }; - } - AddRowAt(tableIndex, cells, rowIndex) { - const this$ = this; - ArcTables__AddRowAt_Z57F91678(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, unwrap(cells), unwrap(rowIndex)); - } - static addRowAt(tableIndex, cells, rowIndex) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.AddRowAt(tableIndex, unwrap(cells), unwrap(rowIndex)); - return newAssay; - }; - } - AddRow(tableName, cells, rowIndex) { - const this$ = this; - ArcTables__AddRow_1177C4AF(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, unwrap(cells), unwrap(rowIndex)); - } - static addRow(tableName, cells, rowIndex) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.AddRow(tableName, unwrap(cells), unwrap(rowIndex)); - return newAssay; - }; - } - RemoveRowAt(tableIndex, rowIndex) { - const this$ = this; - ArcTables__RemoveRowAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex); - } - static removeRowAt(tableIndex, rowIndex) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.RemoveColumnAt(tableIndex, rowIndex); - return newAssay; - }; - } - RemoveRow(tableName, rowIndex) { - const this$ = this; - ArcTables__RemoveRow_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex); - } - static removeRow(tableName, rowIndex) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.RemoveRow(tableName, rowIndex); - return newAssay; - }; - } - UpdateRowAt(tableIndex, rowIndex, cells) { - const this$ = this; - ArcTables__UpdateRowAt_Z596C2D98(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex, cells); - } - static updateRowAt(tableIndex, rowIndex, cells) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.UpdateRowAt(tableIndex, rowIndex, cells); - return newAssay; - }; - } - UpdateRow(tableName, rowIndex, cells) { - const this$ = this; - ArcTables__UpdateRow_Z5E65B4B1(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex, cells); - } - static updateRow(tableName, rowIndex, cells) { - return (assay) => { - const newAssay = assay.Copy(); - newAssay.UpdateRow(tableName, rowIndex, cells); - return newAssay; - }; - } - GetRowAt(tableIndex, rowIndex) { - const this$ = this; - return ArcTables__GetRowAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex); - } - static getRowAt(tableIndex, rowIndex) { - return (assay) => { - const newAssay = assay.Copy(); - return newAssay.GetRowAt(tableIndex, rowIndex); - }; - } - GetRow(tableName, rowIndex) { - const this$ = this; - return ArcTables__GetRow_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex); - } - static getRow(tableName, rowIndex) { - return (assay) => { - const newAssay = assay.Copy(); - return newAssay.GetRow(tableName, rowIndex); - }; - } - static setPerformers(performers, assay) { - assay.Performers = performers; - return assay; - } - Copy() { - const this$ = this; - const newTables = []; - let enumerator = getEnumerator(this$.Tables); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const table = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const copy = table.Copy(); - void (newTables.push(copy)); - } - } - finally { - disposeSafe(enumerator); - } - return new ArcAssay(this$.Identifier, unwrap(this$.MeasurementType), unwrap(this$.TechnologyType), unwrap(this$.TechnologyPlatform), newTables, this$.Performers, this$.Comments); - } - ToAssay() { - const this$ = this; - const processSeq = ArcTables__GetProcesses(ArcTables_$ctor_Z68BECB99(this$.Tables)); - let assayMaterials; - const v_2 = AssayMaterials_create_1CB3546D(unwrap(fromValueWithDefault(empty(), getSamples(processSeq))), unwrap(fromValueWithDefault(empty(), getMaterials(processSeq)))); - assayMaterials = fromValueWithDefault(AssayMaterials_get_empty(), v_2); - return Assay_create_ABF59A4(void 0, unwrap(isMissingIdentifier(this$.Identifier) ? void 0 : Assay_fileNameFromIdentifier(this$.Identifier)), unwrap(this$.MeasurementType), unwrap(this$.TechnologyType), unwrap(this$.TechnologyPlatform), unwrap(fromValueWithDefault(empty(), getData(processSeq))), unwrap(assayMaterials), unwrap(fromValueWithDefault(empty(), getCharacteristics(processSeq))), unwrap(fromValueWithDefault(empty(), getUnits(processSeq))), unwrap(fromValueWithDefault(empty(), processSeq)), unwrap(fromValueWithDefault(empty(), this$.Comments))); - } - static fromAssay(a) { - const tables = map((arg_1) => ArcTables__get_Tables(ArcTables_fromProcesses_Z31821267(arg_1)), a.ProcessSequence); - let identifer; - const matchValue = a.FileName; - identifer = ((matchValue == null) ? createMissingIdentifier() : Assay_identifierFromFileName(matchValue)); - return ArcAssay.create(identifer, unwrap(a.MeasurementType), unwrap(a.TechnologyType), unwrap(a.TechnologyPlatform), unwrap(tables), void 0, unwrap(a.Comments)); - } -} - -export function ArcAssay_$reflection() { - return class_type("ISA.ArcAssay", void 0, ArcAssay); -} - -export function ArcAssay_$ctor_4D629C41(identifier, measurementType, technologyType, technologyPlatform, tables, performers, comments) { - return new ArcAssay(identifier, measurementType, technologyType, technologyPlatform, tables, performers, comments); -} - diff --git a/js/ISA/ISA/ArcTypes/ArcInvestigation.js b/js/ISA/ISA/ArcTypes/ArcInvestigation.js deleted file mode 100644 index 04ecbbe9..00000000 --- a/js/ISA/ISA/ArcTypes/ArcInvestigation.js +++ /dev/null @@ -1,414 +0,0 @@ -import { map as map_2, defaultArg, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { toList, removeAt, tryFindIndex, map } from "../../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ArcStudy } from "./ArcStudy.js"; -import { tryFind, removeInPlace } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { disposeSafe, getEnumerator, defaultOf, safeHash, equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { ArcAssay } from "./ArcAssay.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { map as map_1, empty } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { Investigation_create_ZB2B0942 } from "../JsonTypes/Investigation.js"; -import { createMissingIdentifier, isMissingIdentifier } from "./Identifier.js"; -import { class_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class ArcInvestigation { - constructor(identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReferences, publications, contacts, studies, comments, remarks) { - const ontologySourceReferences_1 = defaultArg(ontologySourceReferences, empty()); - const publications_1 = defaultArg(publications, empty()); - const contacts_1 = defaultArg(contacts, empty()); - const studies_1 = defaultArg(studies, []); - const comments_1 = defaultArg(comments, empty()); - const remarks_1 = defaultArg(remarks, empty()); - this["identifier@25"] = identifier; - this["Title@"] = title; - this["Description@"] = description; - this["SubmissionDate@"] = submissionDate; - this["PublicReleaseDate@"] = publicReleaseDate; - this["OntologySourceReferences@"] = ontologySourceReferences_1; - this["Publications@"] = publications_1; - this["Contacts@"] = contacts_1; - this["Studies@"] = studies_1; - this["Comments@"] = comments_1; - this["Remarks@"] = remarks_1; - } - get Identifier() { - const this$ = this; - return this$["identifier@25"]; - } - set Identifier(i) { - const this$ = this; - this$["identifier@25"] = i; - } - get Title() { - const __ = this; - return unwrap(__["Title@"]); - } - set Title(v) { - const __ = this; - __["Title@"] = v; - } - get Description() { - const __ = this; - return unwrap(__["Description@"]); - } - set Description(v) { - const __ = this; - __["Description@"] = v; - } - get SubmissionDate() { - const __ = this; - return unwrap(__["SubmissionDate@"]); - } - set SubmissionDate(v) { - const __ = this; - __["SubmissionDate@"] = v; - } - get PublicReleaseDate() { - const __ = this; - return unwrap(__["PublicReleaseDate@"]); - } - set PublicReleaseDate(v) { - const __ = this; - __["PublicReleaseDate@"] = v; - } - get OntologySourceReferences() { - const __ = this; - return __["OntologySourceReferences@"]; - } - set OntologySourceReferences(v) { - const __ = this; - __["OntologySourceReferences@"] = v; - } - get Publications() { - const __ = this; - return __["Publications@"]; - } - set Publications(v) { - const __ = this; - __["Publications@"] = v; - } - get Contacts() { - const __ = this; - return __["Contacts@"]; - } - set Contacts(v) { - const __ = this; - __["Contacts@"] = v; - } - get Studies() { - const __ = this; - return __["Studies@"]; - } - set Studies(v) { - const __ = this; - __["Studies@"] = v; - } - get Comments() { - const __ = this; - return __["Comments@"]; - } - set Comments(v) { - const __ = this; - __["Comments@"] = v; - } - get Remarks() { - const __ = this; - return __["Remarks@"]; - } - set Remarks(v) { - const __ = this; - __["Remarks@"] = v; - } - static get FileName() { - return "isa.investigation.xlsx"; - } - static init(identifier) { - return new ArcInvestigation(identifier); - } - static create(identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReferences, publications, contacts, studies, comments, remarks) { - return new ArcInvestigation(identifier, unwrap(title), unwrap(description), unwrap(submissionDate), unwrap(publicReleaseDate), unwrap(ontologySourceReferences), unwrap(publications), unwrap(contacts), unwrap(studies), unwrap(comments), unwrap(remarks)); - } - static make(identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReferences, publications, contacts, studies, comments, remarks) { - return new ArcInvestigation(identifier, unwrap(title), unwrap(description), unwrap(submissionDate), unwrap(publicReleaseDate), ontologySourceReferences, publications, contacts, studies, comments, remarks); - } - get StudyCount() { - const this$ = this; - return this$.Studies.length | 0; - } - get StudyIdentifiers() { - const this$ = this; - return map((x) => x.Identifier, this$.Studies); - } - AddStudy(study) { - const this$ = this; - const study_1 = study; - const matchValue = tryFindIndex((x) => (x.Identifier === study_1.Identifier), this$.Studies); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create study with name ${study_1.Identifier}, as study names must be unique and study at index ${matchValue} has the same name.`); - } - void (this$.Studies.push(study)); - } - static addStudy(study) { - return (inv) => { - const copy = inv.Copy(); - copy.AddStudy(study); - return copy; - }; - } - InitStudy(studyName) { - const this$ = this; - const study = ArcStudy.init(studyName); - this$.AddStudy(study); - } - static initStudy(studyName) { - return (inv) => { - const copy = inv.Copy(); - copy.InitStudy(studyName); - return copy; - }; - } - RemoveStudyAt(index) { - const this$ = this; - this$.Studies.splice(index, 1); - } - static removeStudyAt(index) { - return (inv) => { - const newInv = inv.Copy(); - newInv.RemoveStudyAt(index); - return newInv; - }; - } - RemoveStudy(studyIdentifier) { - const this$ = this; - removeInPlace(this$.GetStudy(studyIdentifier), this$.Studies, { - Equals: equals, - GetHashCode: safeHash, - }); - } - static removeStudy(studyIdentifier) { - return (inv) => { - const copy = inv.Copy(); - copy.RemoveStudy(studyIdentifier); - return copy; - }; - } - SetStudyAt(index, study) { - const this$ = this; - const study_1 = study; - const matchValue = tryFindIndex((x) => (x.Identifier === study_1.Identifier), removeAt(index, this$.Studies)); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create study with name ${study_1.Identifier}, as study names must be unique and study at index ${matchValue} has the same name.`); - } - this$.Studies[index] = study; - } - static setStudyAt(index, study) { - return (inv) => { - const newInv = inv.Copy(); - newInv.SetStudyAt(index, study); - return newInv; - }; - } - SetStudy(studyIdentifier, study) { - const this$ = this; - const index = this$.GetStudyIndex(studyIdentifier) | 0; - const study_1 = study; - const matchValue = tryFindIndex((x) => (x.Identifier === study_1.Identifier), removeAt(index, this$.Studies)); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create study with name ${study_1.Identifier}, as study names must be unique and study at index ${matchValue} has the same name.`); - } - this$.Studies[index] = study; - } - static setStudy(studyIdentifier, study) { - return (inv) => { - const newInv = inv.Copy(); - newInv.SetStudy(studyIdentifier, study); - return newInv; - }; - } - GetStudyIndex(studyIdentifier) { - const this$ = this; - const index = this$.Studies.findIndex((s) => (s.Identifier === studyIdentifier)) | 0; - if (index === -1) { - throw new Error(`Unable to find study with specified identifier '${studyIdentifier}'!`); - } - return index | 0; - } - static getStudyIndex(studyIdentifier) { - return (inv) => inv.GetStudyIndex(studyIdentifier); - } - GetStudyAt(index) { - const this$ = this; - return this$.Studies[index]; - } - static getStudyAt(index) { - return (inv) => { - const newInv = inv.Copy(); - return newInv.GetStudyAt(index); - }; - } - GetStudy(studyIdentifier) { - const this$ = this; - return defaultArg(tryFind((s) => (s.Identifier === studyIdentifier), this$.Studies), defaultOf()); - } - static getStudy(studyIdentifier) { - return (inv) => { - const newInv = inv.Copy(); - return newInv.GetStudy(studyIdentifier); - }; - } - AddAssay(studyIdentifier, assay) { - const this$ = this; - const study = this$.GetStudy(studyIdentifier); - const assay_1 = assay; - const matchValue = tryFindIndex((x) => (x.Identifier === assay_1.Identifier), study.Assays); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create assay with name ${assay_1.Identifier}, as assay names must be unique and assay at index ${matchValue} has the same name.`); - } - study.AddAssay(assay); - } - static addAssay(studyIdentifier, assay) { - return (inv) => { - const copy = inv.Copy(); - copy.AddAssay(studyIdentifier, assay); - return copy; - }; - } - AddAssayAt(studyIndex, assay) { - const this$ = this; - const study = this$.GetStudyAt(studyIndex); - const assay_1 = assay; - const matchValue = tryFindIndex((x) => (x.Identifier === assay_1.Identifier), study.Assays); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create assay with name ${assay_1.Identifier}, as assay names must be unique and assay at index ${matchValue} has the same name.`); - } - study.AddAssay(assay); - } - static addAssayAt(studyIndex, assay) { - return (inv) => { - const copy = inv.Copy(); - copy.AddAssayAt(studyIndex, assay); - return copy; - }; - } - InitAssay(studyIdentifier, assayName) { - const this$ = this; - const assay = ArcAssay.init(assayName); - this$.AddAssay(studyIdentifier, assay); - } - static initAssay(studyIdentifier, assayName) { - return (inv) => { - const copy = inv.Copy(); - copy.InitAssay(studyIdentifier, assayName); - return copy; - }; - } - RemoveAssayAt(studyIdentifier, index) { - const this$ = this; - const study = this$.GetStudy(studyIdentifier); - study.Assays.splice(index, 1); - } - static removeAssayAt(studyIdentifier, index) { - return (inv) => { - const newInv = inv.Copy(); - newInv.RemoveAssayAt(studyIdentifier, index); - return newInv; - }; - } - SetAssayAt(studyIdentifier, index, assay) { - const this$ = this; - const study = this$.GetStudy(studyIdentifier); - study.SetAssayAt(index, assay); - this$.Studies[index] = study; - } - static setAssayAt(studyIdentifier, index, assay) { - return (inv) => { - const newInv = inv.Copy(); - newInv.SetAssayAt(studyIdentifier, index, assay); - return newInv; - }; - } - SetAssay(studyIdentifier, assayIdentifier, assay) { - const this$ = this; - const study = this$.GetStudy(studyIdentifier); - const index = study.GetAssayIndex(assayIdentifier) | 0; - study.SetAssayAt(index, assay); - } - static setAssay(studyIdentifier, assayIdentifier, assay) { - return (inv) => { - const newInv = inv.Copy(); - newInv.SetAssay(studyIdentifier, assayIdentifier, assay); - }; - } - GetAssayAt(studyIdentifier, index) { - const this$ = this; - const study = this$.GetStudy(studyIdentifier); - return study.GetAssayAt(index); - } - static getAssayAt(studyIdentifier, index) { - return (inv) => { - const newInv = inv.Copy(); - return newInv.GetAssayAt(studyIdentifier, index); - }; - } - GetAssay(studyIdentifier, assayIdentifier) { - const this$ = this; - const study = this$.GetStudy(studyIdentifier); - const index = study.GetAssayIndex(assayIdentifier) | 0; - return study.GetAssayAt(index); - } - static getAssay(studyIdentifier, assayIdentifier) { - return (inv) => { - const newInv = inv.Copy(); - return newInv.GetAssay(studyIdentifier, assayIdentifier); - }; - } - Copy() { - const this$ = this; - const newStudies = []; - let enumerator = getEnumerator(this$.Studies); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const study = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const copy = study.Copy(); - void (newStudies.push(copy)); - } - } - finally { - disposeSafe(enumerator); - } - return new ArcInvestigation(this$.Identifier, unwrap(this$.Title), unwrap(this$.Description), unwrap(this$.SubmissionDate), unwrap(this$.PublicReleaseDate), this$.OntologySourceReferences, this$.Publications, this$.Contacts, newStudies, this$.Comments, this$.Remarks); - } - ToInvestigation() { - const this$ = this; - const studies = fromValueWithDefault(empty(), map_1((a) => a.ToStudy(), toList(this$.Studies))); - return Investigation_create_ZB2B0942(void 0, "isa.investigation.xlsx", isMissingIdentifier(this$.Identifier) ? void 0 : this$.Identifier, this$.Title, this$.Description, this$.SubmissionDate, this$.PublicReleaseDate, void 0, fromValueWithDefault(empty(), this$.Publications), fromValueWithDefault(empty(), this$.Contacts), studies, fromValueWithDefault(empty(), this$.Comments)); - } - static fromInvestigation(i) { - let identifer; - const matchValue = i.Identifier; - identifer = ((matchValue == null) ? createMissingIdentifier() : matchValue); - const studies = map_2((arg_2) => { - const arg_1 = map_1((arg) => ArcStudy.fromStudy(arg), arg_2); - return Array.from(arg_1); - }, i.Studies); - return ArcInvestigation.create(identifer, i.Title, i.Description, i.SubmissionDate, i.PublicReleaseDate, void 0, i.Publications, i.Contacts, studies, i.Comments); - } -} - -export function ArcInvestigation_$reflection() { - return class_type("ISA.ArcInvestigation", void 0, ArcInvestigation); -} - -export function ArcInvestigation_$ctor_Z8BBFD6A(identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReferences, publications, contacts, studies, comments, remarks) { - return new ArcInvestigation(identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReferences, publications, contacts, studies, comments, remarks); -} - diff --git a/js/ISA/ISA/ArcTypes/ArcStudy.js b/js/ISA/ISA/ArcTypes/ArcStudy.js deleted file mode 100644 index 087397c4..00000000 --- a/js/ISA/ISA/ArcTypes/ArcStudy.js +++ /dev/null @@ -1,651 +0,0 @@ -import { defaultArg, map as map_2, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { disposeSafe, getEnumerator, equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map as map_1, empty } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { toList, removeAt, tryFindIndex, map } from "../../../fable_modules/fable-library.4.1.4/Seq.js"; -import { ArcAssay } from "./ArcAssay.js"; -import { ArcTables_fromProcesses_Z31821267, ArcTables__get_Tables, ArcTables__GetProcesses, ArcTables__GetRow_Z18115A39, ArcTables__GetRowAt_Z37302880, ArcTables__UpdateRow_Z5E65B4B1, ArcTables__UpdateRowAt_Z596C2D98, ArcTables__RemoveRow_Z18115A39, ArcTables__RemoveRowAt_Z37302880, ArcTables__AddRow_1177C4AF, ArcTables__AddRowAt_Z57F91678, ArcTables__GetColumn_Z18115A39, ArcTables__GetColumnAt_Z37302880, ArcTables__UpdateColumn_Z774BF72A, ArcTables__UpdateColumnAt_Z155350AF, ArcTables__RemoveColumn_Z18115A39, ArcTables__RemoveColumnAt_Z37302880, ArcTables__AddColumn_Z4FC90944, ArcTables__AddColumnAt_6647579B, ArcTables__RenameTable_Z384F8060, ArcTables__RenameTableAt_Z176EF219, ArcTables__MapTable_4E415F2F, ArcTables__MapTableAt_61602D68, ArcTables__RemoveTable_Z721C83C5, ArcTables__RemoveTableAt_Z524259A4, ArcTables__UpdateTable_4976F045, ArcTables__UpdateTableAt_66578202, ArcTables__GetTable_Z721C83C5, ArcTables__GetTableAt_Z524259A4, ArcTables__InitTables_7B28792B, ArcTables__InitTable_3B406CA4, ArcTables__AddTables_3601F24E, ArcTables__AddTable_16F700A1, ArcTables__get_TableNames, ArcTables_$ctor_Z68BECB99, ArcTables__get_Count } from "./ArcTables.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { getUnits, getCharacteristics, getMaterials, getSamples, getSources, getProtocols } from "../JsonTypes/ProcessSequence.js"; -import { StudyMaterials_get_empty, StudyMaterials_create_Z460D555F } from "../JsonTypes/StudyMaterials.js"; -import { Study_identifierFromFileName, createMissingIdentifier, Study_fileNameFromIdentifier, isMissingIdentifier } from "./Identifier.js"; -import { Study_create_Z6C8AB268 } from "../JsonTypes/Study.js"; -import { class_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class ArcStudy { - constructor(identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, tables, assays, factors, comments) { - this.submissionDate = submissionDate; - const publications_1 = defaultArg(publications, empty()); - const contacts_1 = defaultArg(contacts, empty()); - const studyDesignDescriptors_1 = defaultArg(studyDesignDescriptors, empty()); - const tables_1 = defaultArg(tables, []); - const assays_1 = defaultArg(assays, []); - const factors_1 = defaultArg(factors, empty()); - const comments_1 = defaultArg(comments, empty()); - this["identifier@25"] = identifier; - this["Title@"] = title; - this["Description@"] = description; - this["SubmissionDate@"] = this.submissionDate; - this["PublicReleaseDate@"] = publicReleaseDate; - this["Publications@"] = publications_1; - this["Contacts@"] = contacts_1; - this["StudyDesignDescriptors@"] = studyDesignDescriptors_1; - this["Tables@"] = tables_1; - this["Assays@"] = assays_1; - this["Factors@"] = factors_1; - this["Comments@"] = comments_1; - } - get Identifier() { - const this$ = this; - return this$["identifier@25"]; - } - set Identifier(i) { - const this$ = this; - this$["identifier@25"] = i; - } - get Title() { - const __ = this; - return unwrap(__["Title@"]); - } - set Title(v) { - const __ = this; - __["Title@"] = v; - } - get Description() { - const __ = this; - return unwrap(__["Description@"]); - } - set Description(v) { - const __ = this; - __["Description@"] = v; - } - get SubmissionDate() { - const __ = this; - return unwrap(__["SubmissionDate@"]); - } - set SubmissionDate(v) { - const __ = this; - __["SubmissionDate@"] = v; - } - get PublicReleaseDate() { - const __ = this; - return unwrap(__["PublicReleaseDate@"]); - } - set PublicReleaseDate(v) { - const __ = this; - __["PublicReleaseDate@"] = v; - } - get Publications() { - const __ = this; - return __["Publications@"]; - } - set Publications(v) { - const __ = this; - __["Publications@"] = v; - } - get Contacts() { - const __ = this; - return __["Contacts@"]; - } - set Contacts(v) { - const __ = this; - __["Contacts@"] = v; - } - get StudyDesignDescriptors() { - const __ = this; - return __["StudyDesignDescriptors@"]; - } - set StudyDesignDescriptors(v) { - const __ = this; - __["StudyDesignDescriptors@"] = v; - } - get Tables() { - const __ = this; - return __["Tables@"]; - } - set Tables(v) { - const __ = this; - __["Tables@"] = v; - } - get Assays() { - const __ = this; - return __["Assays@"]; - } - set Assays(v) { - const __ = this; - __["Assays@"] = v; - } - get Factors() { - const __ = this; - return __["Factors@"]; - } - set Factors(v) { - const __ = this; - __["Factors@"] = v; - } - get Comments() { - const __ = this; - return __["Comments@"]; - } - set Comments(v) { - const __ = this; - __["Comments@"] = v; - } - static init(identifier) { - return new ArcStudy(identifier); - } - static create(identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, tables, assays, factors, comments) { - return new ArcStudy(identifier, unwrap(title), unwrap(description), unwrap(submissionDate), unwrap(publicReleaseDate), unwrap(publications), unwrap(contacts), unwrap(studyDesignDescriptors), unwrap(tables), unwrap(assays), unwrap(factors), unwrap(comments)); - } - static make(identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, tables, assays, factors, comments) { - return new ArcStudy(identifier, unwrap(title), unwrap(description), unwrap(submissionDate), unwrap(publicReleaseDate), publications, contacts, studyDesignDescriptors, tables, assays, factors, comments); - } - get isEmpty() { - const this$ = this; - return (((((((((equals(this$.Title, void 0) && equals(this$.Description, void 0)) && equals(this$.SubmissionDate, void 0)) && equals(this$.PublicReleaseDate, void 0)) && equals(this$.Publications, empty())) && equals(this$.Contacts, empty())) && equals(this$.StudyDesignDescriptors, empty())) && (this$.Tables.length === 0)) && (this$.Assays.length === 0)) && equals(this$.Factors, empty())) && equals(this$.Comments, empty()); - } - static get FileName() { - return "isa.study.xlsx"; - } - get AssayCount() { - const this$ = this; - return this$.Assays.length | 0; - } - get AssayIdentifiers() { - const this$ = this; - return map((x) => x.Identifier, this$.Assays); - } - AddAssay(assay) { - const this$ = this; - const assay_1 = assay; - const matchValue = tryFindIndex((x) => (x.Identifier === assay_1.Identifier), this$.Assays); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create assay with name ${assay_1.Identifier}, as assay names must be unique and assay at index ${matchValue} has the same name.`); - } - void (this$.Assays.push(assay)); - } - static addAssay(assay) { - return (study) => { - const newStudy = study.Copy(); - newStudy.AddAssay(assay); - return newStudy; - }; - } - InitAssay(assayName) { - const this$ = this; - const assay = new ArcAssay(assayName); - this$.AddAssay(assay); - } - static initAssay(assayName) { - return (study) => { - const newStudy = study.Copy(); - newStudy.InitAssay(assayName); - return newStudy; - }; - } - RemoveAssayAt(index) { - const this$ = this; - this$.Assays.splice(index, 1); - } - static removeAssayAt(index) { - return (study) => { - const newStudy = study.Copy(); - newStudy.RemoveAssayAt(index); - return newStudy; - }; - } - SetAssayAt(index, assay) { - const this$ = this; - const assay_1 = assay; - const matchValue = tryFindIndex((x) => (x.Identifier === assay_1.Identifier), removeAt(index, this$.Assays)); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create assay with name ${assay_1.Identifier}, as assay names must be unique and assay at index ${matchValue} has the same name.`); - } - this$.Assays[index] = assay; - } - static setAssayAt(index, assay) { - return (study) => { - const newStudy = study.Copy(); - newStudy.SetAssayAt(index, assay); - return newStudy; - }; - } - SetAssay(assayIdentifier, assay) { - const this$ = this; - const index = this$.GetAssayIndex(assayIdentifier) | 0; - this$.Assays[index] = assay; - } - static setAssay(assayIdentifier, assay) { - return (study) => { - const newStudy = study.Copy(); - newStudy.SetAssay(assayIdentifier, assay); - return newStudy; - }; - } - GetAssayIndex(assayIdentifier) { - const this$ = this; - const index = this$.Assays.findIndex((a) => (a.Identifier === assayIdentifier)) | 0; - if (index === -1) { - throw new Error(`Unable to find assay with specified identifier '${assayIdentifier}'!`); - } - return index | 0; - } - static GetAssayIndex(assayIdentifier) { - return (study) => study.GetAssayIndex(assayIdentifier); - } - GetAssayAt(index) { - const this$ = this; - return this$.Assays[index]; - } - static getAssayAt(index) { - return (study) => { - const newStudy = study.Copy(); - return newStudy.GetAssayAt(index); - }; - } - GetAssay(assayIdentifier) { - const this$ = this; - const index = this$.GetAssayIndex(assayIdentifier) | 0; - return this$.GetAssayAt(index); - } - static getAssay(assayIdentifier) { - return (study) => { - const newStudy = study.Copy(); - return newStudy.GetAssay(assayIdentifier); - }; - } - get TableCount() { - const this$ = this; - return ArcTables__get_Count(ArcTables_$ctor_Z68BECB99(this$.Tables)) | 0; - } - get TableNames() { - const this$ = this; - return ArcTables__get_TableNames(ArcTables_$ctor_Z68BECB99(this$.Tables)); - } - AddTable(table, index) { - const this$ = this; - ArcTables__AddTable_16F700A1(ArcTables_$ctor_Z68BECB99(this$.Tables), table, unwrap(index)); - } - static addTable(table, index) { - return (study) => { - const c = study.Copy(); - c.AddTable(table, unwrap(index)); - return c; - }; - } - AddTables(tables, index) { - const this$ = this; - ArcTables__AddTables_3601F24E(ArcTables_$ctor_Z68BECB99(this$.Tables), tables, unwrap(index)); - } - static addTables(tables, index) { - return (study) => { - const c = study.Copy(); - c.AddTables(tables, unwrap(index)); - return c; - }; - } - InitTable(tableName, index) { - const this$ = this; - ArcTables__InitTable_3B406CA4(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, unwrap(index)); - } - static initTable(tableName, index) { - return (study) => { - const c = study.Copy(); - c.InitTable(tableName, unwrap(index)); - return c; - }; - } - InitTables(tableNames, index) { - const this$ = this; - ArcTables__InitTables_7B28792B(ArcTables_$ctor_Z68BECB99(this$.Tables), tableNames, unwrap(index)); - } - static initTables(tableNames, index) { - return (study) => { - const c = study.Copy(); - c.InitTables(tableNames, unwrap(index)); - return c; - }; - } - GetTableAt(index) { - const this$ = this; - return ArcTables__GetTableAt_Z524259A4(ArcTables_$ctor_Z68BECB99(this$.Tables), index); - } - static getTableAt(index) { - return (study) => { - const newAssay = study.Copy(); - return newAssay.GetTableAt(index); - }; - } - GetTable(name) { - const this$ = this; - return ArcTables__GetTable_Z721C83C5(ArcTables_$ctor_Z68BECB99(this$.Tables), name); - } - static getTable(name) { - return (study) => { - const newAssay = study.Copy(); - return newAssay.GetTable(name); - }; - } - UpdateTableAt(index, table) { - const this$ = this; - ArcTables__UpdateTableAt_66578202(ArcTables_$ctor_Z68BECB99(this$.Tables), index, table); - } - static updateTableAt(index, table) { - return (study) => { - const newAssay = study.Copy(); - newAssay.UpdateTableAt(index, table); - return newAssay; - }; - } - UpdateTable(name, table) { - const this$ = this; - ArcTables__UpdateTable_4976F045(ArcTables_$ctor_Z68BECB99(this$.Tables), name, table); - } - static updateTable(name, table) { - return (study) => { - const newAssay = study.Copy(); - newAssay.UpdateTable(name, table); - return newAssay; - }; - } - RemoveTableAt(index) { - const this$ = this; - ArcTables__RemoveTableAt_Z524259A4(ArcTables_$ctor_Z68BECB99(this$.Tables), index); - } - static removeTableAt(index) { - return (study) => { - const newAssay = study.Copy(); - newAssay.RemoveTableAt(index); - return newAssay; - }; - } - RemoveTable(name) { - const this$ = this; - ArcTables__RemoveTable_Z721C83C5(ArcTables_$ctor_Z68BECB99(this$.Tables), name); - } - static removeTable(name) { - return (study) => { - const newAssay = study.Copy(); - newAssay.RemoveTable(name); - return newAssay; - }; - } - MapTableAt(index, updateFun) { - const this$ = this; - ArcTables__MapTableAt_61602D68(ArcTables_$ctor_Z68BECB99(this$.Tables), index, updateFun); - } - static mapTableAt(index, updateFun) { - return (study) => { - const newAssay = study.Copy(); - newAssay.MapTableAt(index, updateFun); - return newAssay; - }; - } - MapTable(name, updateFun) { - const this$ = this; - ArcTables__MapTable_4E415F2F(ArcTables_$ctor_Z68BECB99(this$.Tables), name, updateFun); - } - static mapTable(name, updateFun) { - return (study) => { - const newAssay = study.Copy(); - newAssay.MapTable(name, updateFun); - return newAssay; - }; - } - RenameTableAt(index, newName) { - const this$ = this; - ArcTables__RenameTableAt_Z176EF219(ArcTables_$ctor_Z68BECB99(this$.Tables), index, newName); - } - static renameTableAt(index, newName) { - return (study) => { - const newAssay = study.Copy(); - newAssay.RenameTableAt(index, newName); - return newAssay; - }; - } - RenameTable(name, newName) { - const this$ = this; - ArcTables__RenameTable_Z384F8060(ArcTables_$ctor_Z68BECB99(this$.Tables), name, newName); - } - static renameTable(name, newName) { - return (study) => { - const newAssay = study.Copy(); - newAssay.RenameTable(name, newName); - return newAssay; - }; - } - AddColumnAt(tableIndex, header, cells, columnIndex, forceReplace) { - const this$ = this; - ArcTables__AddColumnAt_6647579B(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - } - static addColumnAt(tableIndex, header, cells, columnIndex, forceReplace) { - return (study) => { - const newAssay = study.Copy(); - newAssay.AddColumnAt(tableIndex, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - return newAssay; - }; - } - AddColumn(tableName, header, cells, columnIndex, forceReplace) { - const this$ = this; - ArcTables__AddColumn_Z4FC90944(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - } - static addColumn(tableName, header, cells, columnIndex, forceReplace) { - return (study) => { - const newAssay = study.Copy(); - newAssay.AddColumn(tableName, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - return newAssay; - }; - } - RemoveColumnAt(tableIndex, columnIndex) { - const this$ = this; - ArcTables__RemoveColumnAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex); - } - static removeColumnAt(tableIndex, columnIndex) { - return (study) => { - const newAssay = study.Copy(); - newAssay.RemoveColumnAt(tableIndex, columnIndex); - return newAssay; - }; - } - RemoveColumn(tableName, columnIndex) { - const this$ = this; - ArcTables__RemoveColumn_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex); - } - static removeColumn(tableName, columnIndex) { - return (study) => { - const newAssay = study.Copy(); - newAssay.RemoveColumn(tableName, columnIndex); - return newAssay; - }; - } - UpdateColumnAt(tableIndex, columnIndex, header, cells) { - const this$ = this; - ArcTables__UpdateColumnAt_Z155350AF(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex, header, unwrap(cells)); - } - static updateColumnAt(tableIndex, columnIndex, header, cells) { - return (study) => { - const newAssay = study.Copy(); - newAssay.UpdateColumnAt(tableIndex, columnIndex, header, unwrap(cells)); - return newAssay; - }; - } - UpdateColumn(tableName, columnIndex, header, cells) { - const this$ = this; - ArcTables__UpdateColumn_Z774BF72A(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex, header, unwrap(cells)); - } - static updateColumn(tableName, columnIndex, header, cells) { - return (study) => { - const newAssay = study.Copy(); - newAssay.UpdateColumn(tableName, columnIndex, header, unwrap(cells)); - return newAssay; - }; - } - GetColumnAt(tableIndex, columnIndex) { - const this$ = this; - return ArcTables__GetColumnAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex); - } - static getColumnAt(tableIndex, columnIndex) { - return (study) => { - const newAssay = study.Copy(); - return newAssay.GetColumnAt(tableIndex, columnIndex); - }; - } - GetColumn(tableName, columnIndex) { - const this$ = this; - return ArcTables__GetColumn_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex); - } - static getColumn(tableName, columnIndex) { - return (study) => { - const newAssay = study.Copy(); - return newAssay.GetColumn(tableName, columnIndex); - }; - } - AddRowAt(tableIndex, cells, rowIndex) { - const this$ = this; - ArcTables__AddRowAt_Z57F91678(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, unwrap(cells), unwrap(rowIndex)); - } - static addRowAt(tableIndex, cells, rowIndex) { - return (study) => { - const newAssay = study.Copy(); - newAssay.AddRowAt(tableIndex, unwrap(cells), unwrap(rowIndex)); - return newAssay; - }; - } - AddRow(tableName, cells, rowIndex) { - const this$ = this; - ArcTables__AddRow_1177C4AF(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, unwrap(cells), unwrap(rowIndex)); - } - static addRow(tableName, cells, rowIndex) { - return (study) => { - const newAssay = study.Copy(); - newAssay.AddRow(tableName, unwrap(cells), unwrap(rowIndex)); - return newAssay; - }; - } - RemoveRowAt(tableIndex, rowIndex) { - const this$ = this; - ArcTables__RemoveRowAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex); - } - static removeRowAt(tableIndex, rowIndex) { - return (study) => { - const newAssay = study.Copy(); - newAssay.RemoveColumnAt(tableIndex, rowIndex); - return newAssay; - }; - } - RemoveRow(tableName, rowIndex) { - const this$ = this; - ArcTables__RemoveRow_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex); - } - static removeRow(tableName, rowIndex) { - return (study) => { - const newAssay = study.Copy(); - newAssay.RemoveRow(tableName, rowIndex); - return newAssay; - }; - } - UpdateRowAt(tableIndex, rowIndex, cells) { - const this$ = this; - ArcTables__UpdateRowAt_Z596C2D98(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex, cells); - } - static updateRowAt(tableIndex, rowIndex, cells) { - return (study) => { - const newAssay = study.Copy(); - newAssay.UpdateRowAt(tableIndex, rowIndex, cells); - return newAssay; - }; - } - UpdateRow(tableName, rowIndex, cells) { - const this$ = this; - ArcTables__UpdateRow_Z5E65B4B1(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex, cells); - } - static updateRow(tableName, rowIndex, cells) { - return (study) => { - const newAssay = study.Copy(); - newAssay.UpdateRow(tableName, rowIndex, cells); - return newAssay; - }; - } - GetRowAt(tableIndex, rowIndex) { - const this$ = this; - return ArcTables__GetRowAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex); - } - static getRowAt(tableIndex, rowIndex) { - return (study) => { - const newAssay = study.Copy(); - return newAssay.GetRowAt(tableIndex, rowIndex); - }; - } - GetRow(tableName, rowIndex) { - const this$ = this; - return ArcTables__GetRow_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex); - } - static getRow(tableName, rowIndex) { - return (study) => { - const newAssay = study.Copy(); - return newAssay.GetRow(tableName, rowIndex); - }; - } - Copy() { - const this$ = this; - const newTables = []; - const newAssays = []; - let enumerator = getEnumerator(this$.Tables); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const table = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const copy = table.Copy(); - void (newTables.push(copy)); - } - } - finally { - disposeSafe(enumerator); - } - let enumerator_1 = getEnumerator(this$.Assays); - try { - while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) { - const study = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"](); - const copy_1 = study.Copy(); - void (newAssays.push(copy_1)); - } - } - finally { - disposeSafe(enumerator_1); - } - return new ArcStudy(this$.Identifier, unwrap(this$.Title), unwrap(this$.Description), unwrap(this$.submissionDate), unwrap(this$.PublicReleaseDate), this$.Publications, this$.Contacts, this$.StudyDesignDescriptors, newTables, newAssays, this$.Factors, this$.Comments); - } - ToStudy() { - const this$ = this; - const processSeq = ArcTables__GetProcesses(ArcTables_$ctor_Z68BECB99(this$.Tables)); - const protocols = fromValueWithDefault(empty(), getProtocols(processSeq)); - const assays = fromValueWithDefault(empty(), map_1((a) => a.ToAssay(), toList(this$.Assays))); - let studyMaterials; - const v_5 = StudyMaterials_create_Z460D555F(unwrap(fromValueWithDefault(empty(), getSources(processSeq))), unwrap(fromValueWithDefault(empty(), getSamples(processSeq))), unwrap(fromValueWithDefault(empty(), getMaterials(processSeq)))); - studyMaterials = fromValueWithDefault(StudyMaterials_get_empty(), v_5); - const patternInput = isMissingIdentifier(this$.Identifier) ? [void 0, void 0] : [this$.Identifier, Study_fileNameFromIdentifier(this$.Identifier)]; - return Study_create_Z6C8AB268(void 0, unwrap(patternInput[1]), unwrap(patternInput[0]), unwrap(this$.Title), unwrap(this$.Description), unwrap(this$.SubmissionDate), unwrap(this$.PublicReleaseDate), unwrap(fromValueWithDefault(empty(), this$.Publications)), unwrap(fromValueWithDefault(empty(), this$.Contacts)), unwrap(fromValueWithDefault(empty(), this$.StudyDesignDescriptors)), unwrap(protocols), unwrap(studyMaterials), unwrap(fromValueWithDefault(empty(), processSeq)), unwrap(assays), unwrap(fromValueWithDefault(empty(), this$.Factors)), unwrap(fromValueWithDefault(empty(), getCharacteristics(processSeq))), unwrap(fromValueWithDefault(empty(), getUnits(processSeq))), unwrap(fromValueWithDefault(empty(), this$.Comments))); - } - static fromStudy(s) { - const tables = map_2((arg_1) => ArcTables__get_Tables(ArcTables_fromProcesses_Z31821267(arg_1)), s.ProcessSequence); - let identifer; - const matchValue = s.FileName; - identifer = ((matchValue == null) ? createMissingIdentifier() : Study_identifierFromFileName(matchValue)); - const assays = map_2((arg_4) => { - const arg_3 = map_1((arg_2) => ArcAssay.fromAssay(arg_2), arg_4); - return Array.from(arg_3); - }, s.Assays); - return ArcStudy.create(identifer, unwrap(s.Title), unwrap(s.Description), unwrap(s.SubmissionDate), unwrap(s.PublicReleaseDate), unwrap(s.Publications), unwrap(s.Contacts), unwrap(s.StudyDesignDescriptors), unwrap(tables), unwrap(assays), unwrap(s.Factors), unwrap(s.Comments)); - } -} - -export function ArcStudy_$reflection() { - return class_type("ISA.ArcStudy", void 0, ArcStudy); -} - -export function ArcStudy_$ctor_Z337E69A6(identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, tables, assays, factors, comments) { - return new ArcStudy(identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, tables, assays, factors, comments); -} - diff --git a/js/ISA/ISA/ArcTypes/ArcTable.js b/js/ISA/ISA/ArcTypes/ArcTable.js deleted file mode 100644 index b903764b..00000000 --- a/js/ISA/ISA/ArcTypes/ArcTable.js +++ /dev/null @@ -1,594 +0,0 @@ -import { Dictionary } from "../../../fable_modules/fable-library.4.1.4/MutableMap.js"; -import { stringHash, compareArrays, safeHash, disposeSafe, getEnumerator, equals, comparePrimitives, arrayHash, equalArrays } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map as map_2, value as value_9, defaultArg, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { ProcessParsing_processToRows, ProcessParsing_alignByHeaders, ProcessParsing_getProcessGetter, Unchecked_removeRowCells_withIndexChange, Unchecked_addRow, Unchecked_getEmptyCellForHeader, Unchecked_removeColumnCells_withIndexChange, tryFindDuplicateUniqueInArray, Unchecked_removeColumnCells, Unchecked_removeHeader, Unchecked_fillMissingCells, Unchecked_addColumn, tryFindDuplicateUnique, Unchecked_setCellAt, SanityChecks_validateColumn, SanityChecks_validateRowIndex, SanityChecks_validateColumnIndex, Unchecked_tryGetCellAt, getRowCount, getColumnCount } from "./ArcTableAux.js"; -import { sortBy, forAll2, append, zip, fold, filter, length, singleton, collect, findIndex, toArray, removeAt, map, delay, toList } from "../../../fable_modules/fable-library.4.1.4/Seq.js"; -import { rangeDouble } from "../../../fable_modules/fable-library.4.1.4/Range.js"; -import { CompositeColumn } from "./CompositeColumn.js"; -import { singleton as singleton_1, initialize, sortDescending, iterateIndexed, map as map_1 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { collect as collect_1, initialize as initialize_1, singleton as singleton_2, empty, iterate, isEmpty } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { StringBuilder__AppendLine_Z721C83C5, StringBuilder_$ctor } from "../../../fable_modules/fable-library.4.1.4/System.Text.js"; -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { CompositeCell_$reflection, CompositeCell } from "./CompositeCell.js"; -import { CompositeHeader_$reflection, CompositeHeader } from "./CompositeHeader.js"; -import { ISA_Component__Component_TryGetColumnIndex, ISA_ProtocolParameter__ProtocolParameter_TryGetColumnIndex } from "../JsonTypes/ColumnIndex.js"; -import { Protocol_get_empty, Protocol_addComponent, Protocol_addParameter, Protocol_setName, Protocol_setDescription, Protocol_setUri, Protocol_setVersion, Protocol_setProtocolType } from "../JsonTypes/Protocol.js"; -import { OntologyAnnotation_get_empty } from "../JsonTypes/OntologyAnnotation.js"; -import { ProtocolParameter_create_2769312B } from "../JsonTypes/ProtocolParameter.js"; -import { Component_create_Z33AADEE0 } from "../JsonTypes/Component.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { toProtocol } from "./CompositeRow.js"; -import { join } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { record_type, class_type, tuple_type, int32_type, array_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class ArcTable extends Record { - constructor(Name, Headers, Values) { - super(); - this.Name = Name; - this.Headers = Headers; - this.Values = Values; - } - static create(name, headers, values) { - return new ArcTable(name, headers, values); - } - static init(name) { - return new ArcTable(name, [], new Dictionary([], { - Equals: equalArrays, - GetHashCode: arrayHash, - })); - } - Validate(raiseException) { - const this$ = this; - let isValid = true; - for (let columnIndex = 0; columnIndex <= (this$.ColumnCount - 1); columnIndex++) { - const column = this$.GetColumn(columnIndex); - isValid = column.validate(unwrap(raiseException)); - } - return isValid; - } - static validate(raiseException) { - return (table) => table.Validate(unwrap(raiseException)); - } - get ColumnCount() { - const this$ = this; - return getColumnCount(this$.Headers) | 0; - } - get RowCount() { - const this$ = this; - return getRowCount(this$.Values) | 0; - } - get Columns() { - const this$ = this; - return toList(delay(() => map((i) => this$.GetColumn(i), rangeDouble(0, 1, this$.ColumnCount - 1)))); - } - Copy() { - const this$ = this; - return ArcTable.create(this$.Name, Array.from(this$.Headers), new Dictionary(this$.Values, { - Equals: equalArrays, - GetHashCode: arrayHash, - })); - } - TryGetCellAt(column, row) { - const this$ = this; - return Unchecked_tryGetCellAt(column, row, this$.Values); - } - static tryGetCellAt(column, row) { - return (table) => table.TryGetCellAt(column, row); - } - UpdateCellAt(columnIndex, rowIndex, c) { - const this$ = this; - SanityChecks_validateColumnIndex(columnIndex, this$.ColumnCount, false); - SanityChecks_validateRowIndex(rowIndex, this$.RowCount, false); - SanityChecks_validateColumn(CompositeColumn.create(this$.Headers[columnIndex], [c])); - Unchecked_setCellAt(columnIndex, rowIndex, c, this$.Values); - } - static updateCellAt(columnIndex, rowIndex, cell) { - return (table) => { - const newTable = table.Copy(); - newTable.UpdateCellAt(columnIndex, rowIndex, cell); - return newTable; - }; - } - UpdateHeader(index, newHeader, forceConvertCells) { - const this$ = this; - const forceConvertCells_1 = defaultArg(forceConvertCells, false); - SanityChecks_validateColumnIndex(index, this$.ColumnCount, false); - const header = newHeader; - const matchValue = tryFindDuplicateUnique(header, removeAt(index, this$.Headers)); - if (matchValue != null) { - throw new Error(`Invalid input. Tried setting unique header \`${header}\`, but header of same type already exists at index ${matchValue}.`); - } - const c = new CompositeColumn(newHeader, this$.GetColumn(index).Cells); - if (c.validate()) { - let setHeader; - setHeader = (this$.Headers[index] = newHeader); - } - else if (forceConvertCells_1) { - const convertedCells = newHeader.IsTermColumn ? map_1((c_1) => c_1.ToTermCell(), c.Cells) : map_1((c_2) => c_2.ToFreeTextCell(), c.Cells); - this$.UpdateColumn(index, newHeader, convertedCells); - } - else { - throw new Error("Tried setting header for column with invalid type of cells. Set `forceConvertCells` flag to automatically convert cells into valid CompositeCell type."); - } - } - static updateHeader(index, header) { - return (table) => { - const newTable = table.Copy(); - newTable.UpdateHeader(index, header); - return newTable; - }; - } - AddColumn(header, cells, index, forceReplace) { - const this$ = this; - const index_1 = defaultArg(index, this$.ColumnCount) | 0; - const cells_1 = defaultArg(cells, []); - const forceReplace_1 = defaultArg(forceReplace, false); - SanityChecks_validateColumnIndex(index_1, this$.ColumnCount, true); - SanityChecks_validateColumn(CompositeColumn.create(header, cells_1)); - Unchecked_addColumn(header, cells_1, index_1, forceReplace_1, this$.Headers, this$.Values); - Unchecked_fillMissingCells(this$.Headers, this$.Values); - } - static addColumn(header, cells, index, forceReplace) { - return (table) => { - const newTable = table.Copy(); - newTable.AddColumn(header, unwrap(cells), unwrap(index), unwrap(forceReplace)); - return newTable; - }; - } - UpdateColumn(columnIndex, header, cells) { - const this$ = this; - SanityChecks_validateColumnIndex(columnIndex, this$.ColumnCount, false); - const column = CompositeColumn.create(header, unwrap(cells)); - SanityChecks_validateColumn(column); - const header_1 = column.Header; - const matchValue = tryFindDuplicateUnique(header_1, removeAt(columnIndex, this$.Headers)); - if (matchValue != null) { - throw new Error(`Invalid input. Tried setting unique header \`${header_1}\`, but header of same type already exists at index ${matchValue}.`); - } - Unchecked_removeHeader(columnIndex, this$.Headers); - Unchecked_removeColumnCells(columnIndex, this$.Values); - this$.Headers.splice(columnIndex, 0, column.Header); - iterateIndexed((rowIndex, v) => { - Unchecked_setCellAt(columnIndex, rowIndex, v, this$.Values); - }, column.Cells); - Unchecked_fillMissingCells(this$.Headers, this$.Values); - } - static updatetColumn(columnIndex, header, cells) { - return (table) => { - const newTable = table.Copy(); - newTable.UpdateColumn(columnIndex, header, unwrap(cells)); - return newTable; - }; - } - InsertColumn(header, index, cells) { - const this$ = this; - this$.AddColumn(header, unwrap(cells), index, false); - } - static insertColumn(header, index, cells) { - return (table) => { - const newTable = table.Copy(); - newTable.InsertColumn(header, index, unwrap(cells)); - return newTable; - }; - } - AppendColumn(header, cells) { - const this$ = this; - this$.AddColumn(header, unwrap(cells), this$.ColumnCount, false); - } - static appendColumn(header, cells) { - return (table) => { - const newTable = table.Copy(); - newTable.AppendColumn(header, unwrap(cells)); - return newTable; - }; - } - AddColumns(columns, index, forceReplace) { - const this$ = this; - let index_1 = defaultArg(index, this$.ColumnCount); - const forceReplace_1 = defaultArg(forceReplace, false); - SanityChecks_validateColumnIndex(index_1, this$.ColumnCount, true); - const duplicates = tryFindDuplicateUniqueInArray(map((x) => x.Header, columns)); - if (!isEmpty(duplicates)) { - const sb = StringBuilder_$ctor(); - StringBuilder__AppendLine_Z721C83C5(sb, "Found duplicate unique columns in `columns`."); - iterate((x_1) => { - StringBuilder__AppendLine_Z721C83C5(sb, `Duplicate \`${x_1.HeaderType}\` at index ${x_1.Index1} and ${x_1.Index2}.`); - }, duplicates); - throw new Error(toString(sb)); - } - columns.forEach((x_2) => { - SanityChecks_validateColumn(x_2); - }); - columns.forEach((col) => { - const prevHeadersCount = this$.Headers.length | 0; - Unchecked_addColumn(col.Header, col.Cells, index_1, forceReplace_1, this$.Headers, this$.Values); - if (this$.Headers.length > prevHeadersCount) { - index_1 = ((index_1 + 1) | 0); - } - }); - Unchecked_fillMissingCells(this$.Headers, this$.Values); - } - static addColumns(columns, index) { - return (table) => { - const newTable = table.Copy(); - newTable.AddColumns(columns, index); - return newTable; - }; - } - RemoveColumn(index) { - const this$ = this; - SanityChecks_validateColumnIndex(index, this$.ColumnCount, false); - const columnCount = this$.ColumnCount | 0; - Unchecked_removeHeader(index, this$.Headers); - Unchecked_removeColumnCells_withIndexChange(index, columnCount, this$.RowCount, this$.Values); - } - static removeColumn(index) { - return (table) => { - const newTable = table.Copy(); - newTable.RemoveColumn(index); - return newTable; - }; - } - RemoveColumns(indexArr) { - const this$ = this; - indexArr.forEach((index) => { - SanityChecks_validateColumnIndex(index, this$.ColumnCount, false); - }); - const indexArr_1 = sortDescending(indexArr, { - Compare: comparePrimitives, - }); - indexArr_1.forEach((index_1) => { - this$.RemoveColumn(index_1); - }); - } - static removeColumns(indexArr) { - return (table) => { - const newTable = table.Copy(); - newTable.RemoveColumns(indexArr); - return newTable; - }; - } - GetColumn(columnIndex) { - const this$ = this; - SanityChecks_validateColumnIndex(columnIndex, this$.ColumnCount, false); - const h = this$.Headers[columnIndex]; - const cells = toArray(delay(() => map((i) => value_9(this$.TryGetCellAt(columnIndex, i)), rangeDouble(0, 1, this$.RowCount - 1)))); - return CompositeColumn.create(h, cells); - } - static getColumn(index) { - return (table) => table.GetColumn(index); - } - GetColumnByHeader(header) { - const this$ = this; - const index = findIndex((x) => equals(x, header), this$.Headers) | 0; - return this$.GetColumn(index); - } - AddRow(cells, index) { - const this$ = this; - const index_1 = defaultArg(index, this$.RowCount) | 0; - const cells_1 = (cells == null) ? toArray(delay(() => collect((columnIndex) => singleton(Unchecked_getEmptyCellForHeader(this$.Headers[columnIndex], Unchecked_tryGetCellAt(columnIndex, 0, this$.Values))), rangeDouble(0, 1, this$.ColumnCount - 1)))) : value_9(cells); - SanityChecks_validateRowIndex(index_1, this$.RowCount, true); - const columnCount = this$.ColumnCount | 0; - const newCellsCount = length(cells_1) | 0; - if (columnCount === 0) { - throw new Error("Table contains no columns! Cannot add row to empty table!"); - } - else if (newCellsCount !== columnCount) { - throw new Error(`Cannot add a new row with ${newCellsCount} cells, as the table has ${columnCount} columns.`); - } - for (let columnIndex_1 = 0; columnIndex_1 <= (this$.ColumnCount - 1); columnIndex_1++) { - const h_1 = this$.Headers[columnIndex_1]; - SanityChecks_validateColumn(CompositeColumn.create(h_1, [cells_1[columnIndex_1]])); - } - Unchecked_addRow(index_1, cells_1, this$.Headers, this$.Values); - } - static addRow(cells, index) { - return (table) => { - const newTable = table.Copy(); - newTable.AddRow(unwrap(cells), unwrap(index)); - return newTable; - }; - } - UpdateRow(rowIndex, cells) { - const this$ = this; - SanityChecks_validateRowIndex(rowIndex, this$.RowCount, false); - const columnCount = this$.RowCount | 0; - const newCellsCount = length(cells) | 0; - if (columnCount === 0) { - throw new Error("Table contains no columns! Cannot add row to empty table!"); - } - else if (newCellsCount !== columnCount) { - throw new Error(`Cannot add a new row with ${newCellsCount} cells, as the table has ${columnCount} columns.`); - } - iterateIndexed((i, cell) => { - const h = this$.Headers[i]; - SanityChecks_validateColumn(CompositeColumn.create(h, [cell])); - }, cells); - iterateIndexed((columnIndex, cell_1) => { - Unchecked_setCellAt(columnIndex, rowIndex, cell_1, this$.Values); - }, cells); - } - static updateRow(rowIndex, cells) { - return (table) => { - const newTable = table.Copy(); - newTable.UpdateRow(rowIndex, cells); - return newTable; - }; - } - AppendRow(cells) { - const this$ = this; - this$.AddRow(unwrap(cells), this$.RowCount); - } - static appendRow(cells) { - return (table) => { - const newTable = table.Copy(); - newTable.AppendRow(unwrap(cells)); - return newTable; - }; - } - InsertRow(index, cells) { - const this$ = this; - this$.AddRow(unwrap(cells), index); - } - static insertRow(index, cells) { - return (table) => { - const newTable = table.Copy(); - newTable.AddRow(unwrap(cells), index); - return newTable; - }; - } - AddRows(rows, index) { - const this$ = this; - let index_1 = defaultArg(index, this$.RowCount); - SanityChecks_validateRowIndex(index_1, this$.RowCount, true); - rows.forEach((row) => { - const columnCount = this$.ColumnCount | 0; - const newCellsCount = length(row) | 0; - if (columnCount === 0) { - throw new Error("Table contains no columns! Cannot add row to empty table!"); - } - else if (newCellsCount !== columnCount) { - throw new Error(`Cannot add a new row with ${newCellsCount} cells, as the table has ${columnCount} columns.`); - } - }); - for (let idx = 0; idx <= (rows.length - 1); idx++) { - const row_1 = rows[idx]; - for (let columnIndex = 0; columnIndex <= (this$.ColumnCount - 1); columnIndex++) { - const h = this$.Headers[columnIndex]; - SanityChecks_validateColumn(CompositeColumn.create(h, [row_1[columnIndex]])); - } - } - rows.forEach((row_2) => { - Unchecked_addRow(index_1, row_2, this$.Headers, this$.Values); - index_1 = ((index_1 + 1) | 0); - }); - } - static addRows(rows, index) { - return (table) => { - const newTable = table.Copy(); - newTable.AddRows(rows, unwrap(index)); - return newTable; - }; - } - AddRowsEmpty(rowCount, index) { - const this$ = this; - const row = toArray(delay(() => collect((columnIndex) => singleton(Unchecked_getEmptyCellForHeader(this$.Headers[columnIndex], Unchecked_tryGetCellAt(columnIndex, 0, this$.Values))), rangeDouble(0, 1, this$.ColumnCount - 1)))); - const rows = initialize(rowCount, (_arg) => row); - this$.AddRows(rows, unwrap(index)); - } - static addRowsEmpty(rowCount, index) { - return (table) => { - const newTable = table.Copy(); - newTable.AddRowsEmpty(rowCount, unwrap(index)); - return newTable; - }; - } - RemoveRow(index) { - const this$ = this; - SanityChecks_validateRowIndex(index, this$.RowCount, false); - const removeCells = Unchecked_removeRowCells_withIndexChange(index, this$.ColumnCount, this$.RowCount, this$.Values); - } - static removeRow(index) { - return (table) => { - const newTable = table.Copy(); - newTable.RemoveRow(index); - return newTable; - }; - } - RemoveRows(indexArr) { - const this$ = this; - indexArr.forEach((index) => { - SanityChecks_validateRowIndex(index, this$.RowCount, false); - }); - const indexArr_1 = sortDescending(indexArr, { - Compare: comparePrimitives, - }); - indexArr_1.forEach((index_1) => { - this$.RemoveRow(index_1); - }); - } - static removeRows(indexArr) { - return (table) => { - const newTable = table.Copy(); - newTable.RemoveColumns(indexArr); - return newTable; - }; - } - GetRow(rowIndex) { - const this$ = this; - SanityChecks_validateRowIndex(rowIndex, this$.RowCount, false); - return toArray(delay(() => map((columnIndex) => value_9(this$.TryGetCellAt(columnIndex, rowIndex)), rangeDouble(0, 1, this$.ColumnCount - 1)))); - } - static getRow(index) { - return (table) => table.GetRow(index); - } - static insertParameterValue(t, p) { - throw new Error(); - } - static getParameterValues(t) { - throw new Error(); - } - AddProtocolTypeColumn(types, index) { - const this$ = this; - const cells = map_2((array) => map_1((arg) => (new CompositeCell(0, [arg])), array), types); - this$.AddColumn(new CompositeHeader(4, []), cells, index); - } - AddProtocolVersionColumn(versions, index) { - const this$ = this; - const cells = map_2((array) => map_1((arg) => (new CompositeCell(1, [arg])), array), versions); - this$.AddColumn(new CompositeHeader(7, []), cells, index); - } - AddProtocolUriColumn(uris, index) { - const this$ = this; - const cells = map_2((array) => map_1((arg) => (new CompositeCell(1, [arg])), array), uris); - this$.AddColumn(new CompositeHeader(6, []), cells, index); - } - AddProtocolDescriptionColumn(descriptions, index) { - const this$ = this; - const cells = map_2((array) => map_1((arg) => (new CompositeCell(1, [arg])), array), descriptions); - this$.AddColumn(new CompositeHeader(5, []), cells, index); - } - AddProtocolNameColumn(names, index) { - const this$ = this; - const cells = map_2((array) => map_1((arg) => (new CompositeCell(1, [arg])), array), names); - this$.AddColumn(new CompositeHeader(8, []), cells, index); - } - GetProtocolTypeColumn() { - const this$ = this; - return this$.GetColumnByHeader(new CompositeHeader(4, [])); - } - GetProtocolVersionColumn() { - const this$ = this; - return this$.GetColumnByHeader(new CompositeHeader(7, [])); - } - GetProtocolUriColumn() { - const this$ = this; - return this$.GetColumnByHeader(new CompositeHeader(6, [])); - } - GetProtocolDescriptionColumn() { - const this$ = this; - return this$.GetColumnByHeader(new CompositeHeader(5, [])); - } - GetProtocolNameColumn() { - const this$ = this; - return this$.GetColumnByHeader(new CompositeHeader(8, [])); - } - GetComponentColumns() { - const this$ = this; - return map_1((h_1) => this$.GetColumnByHeader(h_1), toArray(filter((h) => h.isComponent, this$.Headers))); - } - static fromProtocol(p) { - const t = ArcTable.init(defaultArg(p.Name, "")); - const enumerator = getEnumerator(defaultArg(p.Parameters, empty())); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const pp = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - t.AddColumn(new CompositeHeader(3, [value_9(pp.ParameterName)]), void 0, ISA_ProtocolParameter__ProtocolParameter_TryGetColumnIndex(pp)); - } - } - finally { - disposeSafe(enumerator); - } - const enumerator_1 = getEnumerator(defaultArg(p.Components, empty())); - try { - while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) { - const c = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"](); - const v_1 = map_2((arg) => singleton_1(CompositeCell.fromValue(arg, unwrap(c.ComponentUnit))), c.ComponentValue); - t.AddColumn(new CompositeHeader(3, [value_9(c.ComponentType)]), v_1, ISA_Component__Component_TryGetColumnIndex(c)); - } - } - finally { - disposeSafe(enumerator_1); - } - map_2((d) => { - t.AddProtocolDescriptionColumn([d]); - }, p.Description); - map_2((d_1) => { - t.AddProtocolVersionColumn([d_1]); - }, p.Version); - map_2((d_2) => { - t.AddProtocolTypeColumn([d_2]); - }, p.ProtocolType); - map_2((d_3) => { - t.AddProtocolUriColumn([d_3]); - }, p.Uri); - map_2((d_4) => { - t.AddProtocolNameColumn([d_4]); - }, p.Name); - return t; - } - GetProtocols() { - const this$ = this; - return (this$.RowCount === 0) ? singleton_2(fold((p, h) => { - switch (h.tag) { - case 4: - return Protocol_setProtocolType(p, OntologyAnnotation_get_empty()); - case 7: - return Protocol_setVersion(p, ""); - case 6: - return Protocol_setUri(p, ""); - case 5: - return Protocol_setDescription(p, ""); - case 8: - return Protocol_setName(p, ""); - case 3: - return Protocol_addParameter(ProtocolParameter_create_2769312B(void 0, h.fields[0]), p); - case 0: - return Protocol_addComponent(Component_create_Z33AADEE0(void 0, void 0, void 0, h.fields[0]), p); - default: - return p; - } - }, Protocol_get_empty(), this$.Headers)) : List_distinct(initialize_1(this$.RowCount, (i) => toProtocol(zip(this$.Headers, this$.GetRow(i)))), { - Equals: equals, - GetHashCode: safeHash, - }); - } - GetProcesses() { - const this$ = this; - let getter; - const clo = ProcessParsing_getProcessGetter(this$.Name, this$.Headers); - getter = ((arg) => { - const clo_1 = clo(arg); - return clo_1; - }); - return toList(delay(() => map((i) => getter(this$.Values)(i), rangeDouble(0, 1, this$.RowCount - 1)))); - } - static fromProcesses(name, ps) { - const tupledArg = ProcessParsing_alignByHeaders(collect_1(ProcessParsing_processToRows, ps)); - return ArcTable.create(name, tupledArg[0], tupledArg[1]); - } - toString() { - const this$ = this; - return join("\n", toList(delay(() => append(singleton(`Table: ${this$.Name}`), delay(() => append(singleton("-------------"), delay(() => append(singleton(join("\t|\t", map(toString, this$.Headers))), delay(() => map((rowI) => join("\t|\t", map(toString, this$.GetRow(rowI))), rangeDouble(0, 1, this$.RowCount - 1))))))))))); - } - Equals(other) { - const this$ = this; - if (other instanceof ArcTable) { - const table = other; - const sameName = this$.Name === table.Name; - const h1 = this$.Headers; - const h2 = table.Headers; - const sameHeaderLength = h1.length === h2.length; - const sameHeaders = forAll2(equals, h1, h2); - const b1 = sortBy((kv) => kv[0], this$.Values, { - Compare: compareArrays, - }); - const b2 = sortBy((kv_1) => kv_1[0], table.Values, { - Compare: compareArrays, - }); - return (((sameName && sameHeaderLength) && sameHeaders) && (length(b1) === length(b2))) && forAll2(equals, b1, b2); - } - else { - return false; - } - } - GetHashCode() { - const this$ = this; - return ((stringHash(this$.Name) + fold((state, ele) => (state + safeHash(ele)), 0, this$.Headers)) + fold((state_2, ele_1) => (state_2 + safeHash(ele_1)), 0, this$.Values)) | 0; - } -} - -export function ArcTable_$reflection() { - return record_type("ISA.ArcTable", [], ArcTable, () => [["Name", string_type], ["Headers", array_type(CompositeHeader_$reflection())], ["Values", class_type("System.Collections.Generic.Dictionary`2", [tuple_type(int32_type, int32_type), CompositeCell_$reflection()])]]); -} - diff --git a/js/ISA/ISA/ArcTypes/ArcTableAux.js b/js/ISA/ISA/ArcTypes/ArcTableAux.js deleted file mode 100644 index 3e917432..00000000 --- a/js/ISA/ISA/ArcTypes/ArcTableAux.js +++ /dev/null @@ -1,1033 +0,0 @@ -import { getItemFromDict, addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { map as map_2, defaultArg, unwrap, value as value_8, some } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { empty as empty_2, singleton as singleton_1, append, delay, map, tryPick, toList, indexed, initialize, filter, tryFindIndex, maxBy } from "../../../fable_modules/fable-library.4.1.4/Seq.js"; -import { arrayHash, equalArrays, stringHash, int32ToString, compareArrays, disposeSafe, getEnumerator, compare, equals, comparePrimitives } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { mapIndexed, pick, exists, zip, append as append_1, sortBy, tryPick as tryPick_1, item, length, map as map_1, ofArray, singleton, choose, ofSeq, empty as empty_1, head, tail as tail_1, isEmpty, cons } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { CompositeCell } from "./CompositeCell.js"; -import { max } from "../../../fable_modules/fable-library.4.1.4/Double.js"; -import { iterateIndexed } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { FSharpSet__get_MinimumElement, FSharpSet__get_IsEmpty, difference, ofSeq as ofSeq_1 } from "../../../fable_modules/fable-library.4.1.4/Set.js"; -import { Value_fromString_Z721C83C5, Value } from "../JsonTypes/Value.js"; -import { Component_fromOptions } from "../JsonTypes/Component.js"; -import { ProcessParameterValue_create_2A3A2A47 } from "../JsonTypes/ProcessParameterValue.js"; -import { ProtocolParameter_create_2769312B } from "../JsonTypes/ProtocolParameter.js"; -import { FactorValue_create_Z54E26173 } from "../JsonTypes/FactorValue.js"; -import { Factor_create_Z3D2B374F } from "../JsonTypes/Factor.js"; -import { toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { MaterialAttributeValue_create_163BDE77 } from "../JsonTypes/MaterialAttributeValue.js"; -import { MaterialAttribute_create_2769312B } from "../JsonTypes/MaterialAttribute.js"; -import { ProcessInput_getCharacteristicValues_Z38E7E853, ProcessInput__isMaterial, ProcessInput__isData, ProcessInput_setCharacteristicValues, ProcessInput__get_Name, ProcessInput__isSource, ProcessInput__isSample, ProcessInput, ProcessInput_createDerivedData_Z721C83C5, ProcessInput_createRawData_Z721C83C5, ProcessInput_createImageFile_Z721C83C5, ProcessInput_createMaterial_ZEED0B34, ProcessInput_createSample_Z445EF6B3, ProcessInput_createSource_Z3083890A } from "../JsonTypes/ProcessInput.js"; -import { remove, printf, toFail } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { ProcessOutput_getFactorValues_Z4A02997C, ProcessOutput__isMaterial, ProcessOutput__isData, ProcessOutput_setFactorValues, ProcessOutput__get_Name, ProcessOutput__isSample, ProcessOutput, ProcessOutput_createDerivedData_Z721C83C5, ProcessOutput_createRawData_Z721C83C5, ProcessOutput_createImageFile_Z721C83C5, ProcessOutput_createMaterial_ZEED0B34, ProcessOutput_createSample_Z445EF6B3 } from "../JsonTypes/ProcessOutput.js"; -import { IOType, CompositeHeader } from "./CompositeHeader.js"; -import { tryGetFactorColumnIndex, tryGetCharacteristicColumnIndex, tryGetComponentIndex, tryGetParameterColumnIndex, ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4 } from "../JsonTypes/ColumnIndex.js"; -import { Source_create_Z32235993 } from "../JsonTypes/Source.js"; -import { Sample_create_3A6378D6 } from "../JsonTypes/Sample.js"; -import { mapOrDefault, fromValueWithDefault } from "../OptionExtensions.js"; -import { Protocol_make } from "../JsonTypes/Protocol.js"; -import { Process_decomposeName_Z721C83C5, Process_make } from "../JsonTypes/Process.js"; -import { List_groupBy } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { createMissingIdentifier } from "./Identifier.js"; -import { Dictionary } from "../../../fable_modules/fable-library.4.1.4/MutableMap.js"; - -/** - * Returns the dictionary with the binding added to the given dictionary. - * If a binding with the given key already exists in the input dictionary, the existing binding is replaced by the new binding in the result dictionary. - */ -export function Dictionary_addOrUpdateInPlace(key, value, table) { - if (table.has(key)) { - table.set(key, value); - } - else { - addToDict(table, key, value); - } - return table; -} - -/** - * Lookup an element in the dictionary, returning a Some value if the element is in the domain - * of the dictionary and None if not. - */ -export function Dictionary_tryFind(key, table) { - if (table.has(key)) { - return some(getItemFromDict(table, key)); - } - else { - return void 0; - } -} - -export function getColumnCount(headers) { - return headers.length; -} - -export function getRowCount(values) { - if (values.size === 0) { - return 0; - } - else { - return (1 + maxBy((tuple) => tuple[1], values.keys(), { - Compare: comparePrimitives, - })[1]) | 0; - } -} - -export function $007CIsUniqueExistingHeader$007C_$007C(existingHeaders, input) { - switch (input.tag) { - case 3: - case 2: - case 1: - case 0: - case 13: - return void 0; - case 12: - return tryFindIndex((h) => (h.tag === 12), existingHeaders); - case 11: - return tryFindIndex((h_1) => (h_1.tag === 11), existingHeaders); - default: - return tryFindIndex((h_2) => equals(h_2, input), existingHeaders); - } -} - -/** - * Returns the column index of the duplicate unique column in `existingHeaders`. - */ -export function tryFindDuplicateUnique(newHeader, existingHeaders) { - const activePatternResult = $007CIsUniqueExistingHeader$007C_$007C(existingHeaders, newHeader); - if (activePatternResult != null) { - const index = activePatternResult | 0; - return index; - } - else { - return void 0; - } -} - -/** - * Returns the column index of the duplicate unique column in `existingHeaders`. - */ -export function tryFindDuplicateUniqueInArray(existingHeaders) { - const loop = (i_mut, duplicateList_mut, headerList_mut) => { - loop: - while (true) { - const i = i_mut, duplicateList = duplicateList_mut, headerList = headerList_mut; - let matchResult, header, tail; - if (isEmpty(headerList)) { - matchResult = 0; - } - else if (isEmpty(tail_1(headerList))) { - matchResult = 0; - } - else { - matchResult = 1; - header = head(headerList); - tail = tail_1(headerList); - } - switch (matchResult) { - case 0: - return duplicateList; - default: { - const hasDuplicate = tryFindDuplicateUnique(header, tail); - i_mut = (i + 1); - duplicateList_mut = ((hasDuplicate != null) ? cons({ - HeaderType: header, - Index1: i, - Index2: value_8(hasDuplicate), - }, duplicateList) : duplicateList); - headerList_mut = tail; - continue loop; - } - } - break; - } - }; - return loop(0, empty_1(), ofSeq(filter((x) => !x.IsTermColumn, existingHeaders))); -} - -/** - * Checks if given column index is valid for given number of columns. - * - * if `allowAppend` = true => `0 < index <= columnCount` - * - * if `allowAppend` = false => `0 < index < columnCount` - */ -export function SanityChecks_validateColumnIndex(index, columnCount, allowAppend) { - let x, y; - if (index < 0) { - throw new Error("Cannot insert CompositeColumn at index < 0."); - } - if ((x = (index | 0), (y = (columnCount | 0), allowAppend ? (compare(x, y) > 0) : (compare(x, y) >= 0)))) { - throw new Error(`Specified index is out of table range! Table contains only ${columnCount} columns.`); - } -} - -/** - * Checks if given index is valid for given number of rows. - * - * if `allowAppend` = true => `0 < index <= rowCount` - * - * if `allowAppend` = false => `0 < index < rowCount` - */ -export function SanityChecks_validateRowIndex(index, rowCount, allowAppend) { - let x, y; - if (index < 0) { - throw new Error("Cannot insert CompositeColumn at index < 0."); - } - if ((x = (index | 0), (y = (rowCount | 0), allowAppend ? (compare(x, y) > 0) : (compare(x, y) >= 0)))) { - throw new Error(`Specified index is out of table range! Table contains only ${rowCount} rows.`); - } -} - -export function SanityChecks_validateColumn(column) { - column.validate(true); -} - -export function Unchecked_tryGetCellAt(column, row, cells) { - return Dictionary_tryFind([column, row], cells); -} - -export function Unchecked_setCellAt(columnIndex, rowIndex, c, cells) { - Dictionary_addOrUpdateInPlace([columnIndex, rowIndex], c, cells); -} - -export function Unchecked_moveCellTo(fromCol, fromRow, toCol, toRow, cells) { - const matchValue = Dictionary_tryFind([fromCol, fromRow], cells); - if (matchValue == null) { - } - else { - const c = matchValue; - cells.delete([fromCol, fromRow]); - const value_1 = Unchecked_setCellAt(toCol, toRow, c, cells); - } -} - -export function Unchecked_removeHeader(index, headers) { - headers.splice(index, 1); -} - -/** - * Remove cells of one Column, change index of cells with higher index to index - 1 - */ -export function Unchecked_removeColumnCells(index, cells) { - let enumerator = getEnumerator(cells); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const activePatternResult = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const c = activePatternResult[0][0] | 0; - if (c === index) { - cells.delete([c, activePatternResult[0][1]]); - } - } - } - finally { - disposeSafe(enumerator); - } -} - -/** - * Remove cells of one Column, change index of cells with higher index to index - 1 - */ -export function Unchecked_removeColumnCells_withIndexChange(index, columnCount, rowCount, cells) { - for (let col = index; col <= (columnCount - 1); col++) { - for (let row = 0; row <= (rowCount - 1); row++) { - if (col === index) { - cells.delete([col, row]); - } - else if (col > index) { - Unchecked_moveCellTo(col, row, col - 1, row, cells); - } - } - } -} - -export function Unchecked_removeRowCells(rowIndex, cells) { - let enumerator = getEnumerator(cells); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const activePatternResult = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const r = activePatternResult[0][1] | 0; - if (r === rowIndex) { - cells.delete([activePatternResult[0][0], r]); - } - } - } - finally { - disposeSafe(enumerator); - } -} - -/** - * Remove cells of one Row, change index of cells with higher index to index - 1 - */ -export function Unchecked_removeRowCells_withIndexChange(rowIndex, columnCount, rowCount, cells) { - for (let row = rowIndex; row <= (rowCount - 1); row++) { - for (let col = 0; col <= (columnCount - 1); col++) { - if (row === rowIndex) { - cells.delete([col, row]); - } - else if (row > rowIndex) { - Unchecked_moveCellTo(col, row, col, row - 1, cells); - } - } - } -} - -/** - * Get an empty cell fitting for related column header. - * - * `columCellOption` is used to decide between `CompositeCell.Term` or `CompositeCell.Unitized`. `columCellOption` can be any other cell in the same column, preferably the first one. - */ -export function Unchecked_getEmptyCellForHeader(header, columCellOption) { - const matchValue = header.IsTermColumn; - if (matchValue) { - let matchResult; - if (columCellOption == null) { - matchResult = 0; - } - else { - switch (columCellOption.tag) { - case 0: { - matchResult = 0; - break; - } - case 2: { - matchResult = 1; - break; - } - default: - matchResult = 2; - } - } - switch (matchResult) { - case 0: - return CompositeCell.emptyTerm; - case 1: - return CompositeCell.emptyUnitized; - default: - throw new Error("[extendBodyCells] This should never happen, IsTermColumn header must be paired with either term or unitized cell."); - } - } - else { - return CompositeCell.emptyFreeText; - } -} - -export function Unchecked_addColumn(newHeader, newCells, index, forceReplace, headers, values) { - let numberOfNewColumns = 1; - let index_1 = index; - const hasDuplicateUnique = tryFindDuplicateUnique(newHeader, headers); - if (!forceReplace && (hasDuplicateUnique != null)) { - throw new Error(`Invalid new column \`${newHeader}\`. Table already contains header of the same type on index \`${value_8(hasDuplicateUnique)}\``); - } - if (hasDuplicateUnique != null) { - numberOfNewColumns = 0; - index_1 = (value_8(hasDuplicateUnique) | 0); - } - const matchValue = getColumnCount(headers) | 0; - const matchValue_1 = getRowCount(values) | 0; - const startColCount = matchValue | 0; - let setNewHeader; - if (hasDuplicateUnique != null) { - Unchecked_removeHeader(index_1, headers); - } - setNewHeader = headers.splice(index_1, 0, newHeader); - let increaseColumnIndices; - if ((index_1 < startColCount) && (hasDuplicateUnique == null)) { - const lastColumnIndex = max(startColCount - 1, 0) | 0; - for (let columnIndex = lastColumnIndex; columnIndex >= index_1; columnIndex--) { - for (let rowIndex = 0; rowIndex <= matchValue_1; rowIndex++) { - Unchecked_moveCellTo(columnIndex, rowIndex, columnIndex + numberOfNewColumns, rowIndex, values); - } - } - } - else { - increaseColumnIndices = void 0; - } - let setNewCells; - if (hasDuplicateUnique != null) { - Unchecked_removeColumnCells(index_1, values); - } - setNewCells = iterateIndexed((rowIndex_1, cell) => { - Unchecked_setCellAt(index_1, rowIndex_1, cell, values); - }, newCells); -} - -export function Unchecked_fillMissingCells(headers, values) { - const rowCount = getRowCount(values) | 0; - const lastColumnIndex = (getColumnCount(headers) - 1) | 0; - const keys = values.keys(); - for (let columnIndex = 0; columnIndex <= lastColumnIndex; columnIndex++) { - const colKeys = ofSeq_1(filter((tupledArg) => (tupledArg[0] === columnIndex), keys), { - Compare: compareArrays, - }); - const missingKeys = difference(ofSeq_1(initialize(rowCount, (i) => [columnIndex, i]), { - Compare: compareArrays, - }), colKeys); - if (!FSharpSet__get_IsEmpty(missingKeys)) { - const empty = Unchecked_getEmptyCellForHeader(headers[columnIndex], FSharpSet__get_IsEmpty(colKeys) ? void 0 : getItemFromDict(values, FSharpSet__get_MinimumElement(colKeys))); - const enumerator = getEnumerator(missingKeys); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const forLoopVar = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - Unchecked_setCellAt(forLoopVar[0], forLoopVar[1], empty, values); - } - } - finally { - disposeSafe(enumerator); - } - } - } -} - -export function Unchecked_addRow(index, newCells, headers, values) { - const rowCount = getRowCount(values) | 0; - const columnCount = getColumnCount(headers) | 0; - let increaseRowIndices; - if (index < rowCount) { - const lastRowIndex = max(rowCount - 1, 0) | 0; - for (let rowIndex = lastRowIndex; rowIndex >= index; rowIndex--) { - for (let columnIndex = 0; columnIndex <= (columnCount - 1); columnIndex++) { - Unchecked_moveCellTo(columnIndex, rowIndex, columnIndex, rowIndex + 1, values); - } - } - } - else { - increaseRowIndices = void 0; - } - const setNewCells = iterateIndexed((columnIndex_1, cell) => { - Unchecked_setCellAt(columnIndex_1, index, cell, values); - }, newCells); -} - -/** - * Convert a CompositeCell to a ISA Value and Unit tuple. - */ -export function JsonTypes_valueOfCell(value) { - switch (value.tag) { - case 0: - return [new Value(0, [value.fields[0]]), void 0]; - case 2: - return [Value_fromString_Z721C83C5(value.fields[0]), value.fields[1]]; - default: - return [Value_fromString_Z721C83C5(value.fields[0]), void 0]; - } -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA Component - */ -export function JsonTypes_composeComponent(header, value) { - const patternInput = JsonTypes_valueOfCell(value); - return Component_fromOptions(patternInput[0], patternInput[1], header.ToTerm()); -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA ProcessParameterValue - */ -export function JsonTypes_composeParameterValue(header, value) { - const patternInput = JsonTypes_valueOfCell(value); - return ProcessParameterValue_create_2A3A2A47(ProtocolParameter_create_2769312B(void 0, header.ToTerm()), patternInput[0], unwrap(patternInput[1])); -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA FactorValue - */ -export function JsonTypes_composeFactorValue(header, value) { - const patternInput = JsonTypes_valueOfCell(value); - return FactorValue_create_Z54E26173(void 0, Factor_create_Z3D2B374F(void 0, toString(header), header.ToTerm()), patternInput[0], unwrap(patternInput[1])); -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA MaterialAttributeValue - */ -export function JsonTypes_composeCharacteristicValue(header, value) { - const patternInput = JsonTypes_valueOfCell(value); - return MaterialAttributeValue_create_163BDE77(void 0, MaterialAttribute_create_2769312B(void 0, header.ToTerm()), patternInput[0], unwrap(patternInput[1])); -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA ProcessInput - */ -export function JsonTypes_composeProcessInput(header, value) { - let matchResult; - if (header.tag === 11) { - switch (header.fields[0].tag) { - case 0: { - matchResult = 0; - break; - } - case 1: { - matchResult = 1; - break; - } - case 5: { - matchResult = 2; - break; - } - case 4: { - matchResult = 3; - break; - } - case 2: { - matchResult = 4; - break; - } - case 3: { - matchResult = 5; - break; - } - default: - matchResult = 6; - } - } - else { - matchResult = 6; - } - switch (matchResult) { - case 0: - return ProcessInput_createSource_Z3083890A(toString(value)); - case 1: - return ProcessInput_createSample_Z445EF6B3(toString(value)); - case 2: - return ProcessInput_createMaterial_ZEED0B34(toString(value)); - case 3: - return ProcessInput_createImageFile_Z721C83C5(toString(value)); - case 4: - return ProcessInput_createRawData_Z721C83C5(toString(value)); - case 5: - return ProcessInput_createDerivedData_Z721C83C5(toString(value)); - default: - return toFail(printf("Could not parse input header %O"))(header); - } -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA ProcessOutput - */ -export function JsonTypes_composeProcessOutput(header, value) { - let matchResult; - if (header.tag === 12) { - switch (header.fields[0].tag) { - case 1: { - matchResult = 0; - break; - } - case 5: { - matchResult = 1; - break; - } - case 4: { - matchResult = 2; - break; - } - case 2: { - matchResult = 3; - break; - } - case 3: { - matchResult = 4; - break; - } - default: - matchResult = 5; - } - } - else { - matchResult = 5; - } - switch (matchResult) { - case 0: - return ProcessOutput_createSample_Z445EF6B3(toString(value)); - case 1: - return ProcessOutput_createMaterial_ZEED0B34(toString(value)); - case 2: - return ProcessOutput_createImageFile_Z721C83C5(toString(value)); - case 3: - return ProcessOutput_createRawData_Z721C83C5(toString(value)); - case 4: - return ProcessOutput_createDerivedData_Z721C83C5(toString(value)); - default: - return toFail(printf("Could not parse output header %O"))(header); - } -} - -/** - * Convert an ISA Value and Unit tuple to a CompositeCell - */ -export function JsonTypes_cellOfValue(value, unit) { - const value_2 = defaultArg(value, new Value(3, [""])); - let matchResult, oa, text, u, f, u_1, f_1, i, u_2, i_1; - switch (value_2.tag) { - case 3: { - if (unit != null) { - if (value_2.fields[0] === "") { - matchResult = 2; - u = unit; - } - else { - matchResult = 7; - } - } - else { - matchResult = 1; - text = value_2.fields[0]; - } - break; - } - case 2: { - if (unit == null) { - matchResult = 4; - f_1 = value_2.fields[0]; - } - else { - matchResult = 3; - f = value_2.fields[0]; - u_1 = unit; - } - break; - } - case 1: { - if (unit == null) { - matchResult = 6; - i_1 = value_2.fields[0]; - } - else { - matchResult = 5; - i = value_2.fields[0]; - u_2 = unit; - } - break; - } - default: - if (unit == null) { - matchResult = 0; - oa = value_2.fields[0]; - } - else { - matchResult = 7; - } - } - switch (matchResult) { - case 0: - return new CompositeCell(0, [oa]); - case 1: - return new CompositeCell(1, [text]); - case 2: - return new CompositeCell(2, ["", u]); - case 3: - return new CompositeCell(2, [f.toString(), u_1]); - case 4: - return new CompositeCell(1, [f_1.toString()]); - case 5: - return new CompositeCell(2, [int32ToString(i), u_2]); - case 6: - return new CompositeCell(1, [int32ToString(i_1)]); - default: - return toFail(printf("Could not parse value %O with unit %O"))(value_2)(unit); - } -} - -/** - * Convert an ISA Component to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeComponent(c) { - return [new CompositeHeader(0, [value_8(c.ComponentType)]), JsonTypes_cellOfValue(c.ComponentValue, c.ComponentUnit)]; -} - -/** - * Convert an ISA ProcessParameterValue to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeParameterValue(ppv) { - return [new CompositeHeader(3, [value_8(value_8(ppv.Category).ParameterName)]), JsonTypes_cellOfValue(ppv.Value, ppv.Unit)]; -} - -/** - * Convert an ISA FactorValue to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeFactorValue(fv) { - return [new CompositeHeader(2, [value_8(value_8(fv.Category).FactorType)]), JsonTypes_cellOfValue(fv.Value, fv.Unit)]; -} - -/** - * Convert an ISA MaterialAttributeValue to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeCharacteristicValue(cv) { - return [new CompositeHeader(1, [value_8(value_8(cv.Category).CharacteristicType)]), JsonTypes_cellOfValue(cv.Value, cv.Unit)]; -} - -/** - * Convert an ISA ProcessOutput to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeProcessInput(pi) { - switch (pi.tag) { - case 1: - return [new CompositeHeader(11, [new IOType(1, [])]), new CompositeCell(1, [defaultArg(pi.fields[0].Name, "")])]; - case 3: - return [new CompositeHeader(11, [new IOType(5, [])]), new CompositeCell(1, [defaultArg(pi.fields[0].Name, "")])]; - case 2: { - const d = pi.fields[0]; - const dataType = value_8(d.DataType); - switch (dataType.tag) { - case 0: - return [new CompositeHeader(11, [new IOType(2, [])]), new CompositeCell(1, [defaultArg(d.Name, "")])]; - case 1: - return [new CompositeHeader(11, [new IOType(3, [])]), new CompositeCell(1, [defaultArg(d.Name, "")])]; - default: - return [new CompositeHeader(11, [new IOType(4, [])]), new CompositeCell(1, [defaultArg(d.Name, "")])]; - } - } - default: - return [new CompositeHeader(11, [new IOType(0, [])]), new CompositeCell(1, [defaultArg(pi.fields[0].Name, "")])]; - } -} - -/** - * Convert an ISA ProcessOutput to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeProcessOutput(po) { - switch (po.tag) { - case 2: - return [new CompositeHeader(12, [new IOType(5, [])]), new CompositeCell(1, [defaultArg(po.fields[0].Name, "")])]; - case 1: { - const d = po.fields[0]; - const dataType = value_8(d.DataType); - switch (dataType.tag) { - case 0: - return [new CompositeHeader(12, [new IOType(2, [])]), new CompositeCell(1, [defaultArg(d.Name, "")])]; - case 1: - return [new CompositeHeader(12, [new IOType(3, [])]), new CompositeCell(1, [defaultArg(d.Name, "")])]; - default: - return [new CompositeHeader(12, [new IOType(4, [])]), new CompositeCell(1, [defaultArg(d.Name, "")])]; - } - } - default: - return [new CompositeHeader(12, [new IOType(1, [])]), new CompositeCell(1, [defaultArg(po.fields[0].Name, "")])]; - } -} - -/** - * If the headers of a node depict a component, returns a function for parsing the values of the matrix to the values of this component - */ -export function ProcessParsing_tryComponentGetter(generalI, valueI, valueHeader) { - if (valueHeader.tag === 0) { - const cat = new CompositeHeader(0, [ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(valueHeader.fields[0], valueI)]); - return (matrix) => ((i) => JsonTypes_composeComponent(cat, getItemFromDict(matrix, [generalI, i]))); - } - else { - return void 0; - } -} - -/** - * If the headers of a node depict a protocolType, returns a function for parsing the values of the matrix to the values of this type - */ -export function ProcessParsing_tryParameterGetter(generalI, valueI, valueHeader) { - if (valueHeader.tag === 3) { - const cat = new CompositeHeader(3, [ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(valueHeader.fields[0], valueI)]); - return (matrix) => ((i) => JsonTypes_composeParameterValue(cat, getItemFromDict(matrix, [generalI, i]))); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryFactorGetter(generalI, valueI, valueHeader) { - if (valueHeader.tag === 2) { - const cat = new CompositeHeader(2, [ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(valueHeader.fields[0], valueI)]); - return (matrix) => ((i) => JsonTypes_composeFactorValue(cat, getItemFromDict(matrix, [generalI, i]))); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryCharacteristicGetter(generalI, valueI, valueHeader) { - if (valueHeader.tag === 1) { - const cat = new CompositeHeader(1, [ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(valueHeader.fields[0], valueI)]); - return (matrix) => ((i) => JsonTypes_composeCharacteristicValue(cat, getItemFromDict(matrix, [generalI, i]))); - } - else { - return void 0; - } -} - -/** - * If the headers of a node depict a protocolType, returns a function for parsing the values of the matrix to the values of this type - */ -export function ProcessParsing_tryGetProtocolTypeGetter(generalI, header) { - if (header.tag === 4) { - return (matrix) => ((i) => getItemFromDict(matrix, [generalI, i]).AsTerm); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetProtocolREFGetter(generalI, header) { - if (header.tag === 8) { - return (matrix) => ((i) => getItemFromDict(matrix, [generalI, i]).AsFreeText); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetProtocolDescriptionGetter(generalI, header) { - if (header.tag === 5) { - return (matrix) => ((i) => getItemFromDict(matrix, [generalI, i]).AsFreeText); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetProtocolURIGetter(generalI, header) { - if (header.tag === 6) { - return (matrix) => ((i) => getItemFromDict(matrix, [generalI, i]).AsFreeText); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetProtocolVersionGetter(generalI, header) { - if (header.tag === 7) { - return (matrix) => ((i) => getItemFromDict(matrix, [generalI, i]).AsFreeText); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetInputGetter(generalI, header) { - if (header.tag === 11) { - return (matrix) => ((i) => JsonTypes_composeProcessInput(header, getItemFromDict(matrix, [generalI, i]))); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetOutputGetter(generalI, header) { - if (header.tag === 12) { - return (matrix) => ((i) => JsonTypes_composeProcessOutput(header, getItemFromDict(matrix, [generalI, i]))); - } - else { - return void 0; - } -} - -/** - * Given the header sequence of an ArcTable, returns a function for parsing each row of the table to a process - */ -export function ProcessParsing_getProcessGetter(processNameRoot, headers) { - const headers_1 = indexed(headers); - const valueHeaders = toList(indexed(filter((arg) => arg[1].IsCvParamColumn, headers_1))); - const charGetters = choose((tupledArg) => { - const _arg = tupledArg[1]; - return ProcessParsing_tryCharacteristicGetter(_arg[0], tupledArg[0], _arg[1]); - }, valueHeaders); - const factorValueGetters = choose((tupledArg_1) => { - const _arg_1 = tupledArg_1[1]; - return ProcessParsing_tryFactorGetter(_arg_1[0], tupledArg_1[0], _arg_1[1]); - }, valueHeaders); - const parameterValueGetters = choose((tupledArg_2) => { - const _arg_2 = tupledArg_2[1]; - return ProcessParsing_tryParameterGetter(_arg_2[0], tupledArg_2[0], _arg_2[1]); - }, valueHeaders); - const componentGetters = choose((tupledArg_3) => { - const _arg_3 = tupledArg_3[1]; - return ProcessParsing_tryComponentGetter(_arg_3[0], tupledArg_3[0], _arg_3[1]); - }, valueHeaders); - const protocolTypeGetter = tryPick((tupledArg_4) => ProcessParsing_tryGetProtocolTypeGetter(tupledArg_4[0], tupledArg_4[1]), headers_1); - const protocolREFGetter = tryPick((tupledArg_5) => ProcessParsing_tryGetProtocolREFGetter(tupledArg_5[0], tupledArg_5[1]), headers_1); - const protocolDescriptionGetter = tryPick((tupledArg_6) => ProcessParsing_tryGetProtocolDescriptionGetter(tupledArg_6[0], tupledArg_6[1]), headers_1); - const protocolURIGetter = tryPick((tupledArg_7) => ProcessParsing_tryGetProtocolURIGetter(tupledArg_7[0], tupledArg_7[1]), headers_1); - const protocolVersionGetter = tryPick((tupledArg_8) => ProcessParsing_tryGetProtocolVersionGetter(tupledArg_8[0], tupledArg_8[1]), headers_1); - let inputGetter_1; - const matchValue = tryPick((tupledArg_9) => ProcessParsing_tryGetInputGetter(tupledArg_9[0], tupledArg_9[1]), headers_1); - if (matchValue == null) { - inputGetter_1 = ((matrix_1) => ((i_1) => singleton(new ProcessInput(0, [Source_create_Z32235993(void 0, `${processNameRoot}_Input_${i_1}`, toList(map((f_1) => f_1(matrix_1)(i_1), charGetters)))])))); - } - else { - const inputGetter = matchValue; - inputGetter_1 = ((matrix) => ((i) => { - const chars = toList(map((f) => f(matrix)(i), charGetters)); - const input = inputGetter(matrix)(i); - return (!(ProcessInput__isSample(input) ? true : ProcessInput__isSource(input)) && !isEmpty(chars)) ? ofArray([input, ProcessInput_createSample_Z445EF6B3(ProcessInput__get_Name(input), chars)]) : singleton(ProcessInput_setCharacteristicValues(chars, input)); - })); - } - let outputGetter_1; - const matchValue_1 = tryPick((tupledArg_10) => ProcessParsing_tryGetOutputGetter(tupledArg_10[0], tupledArg_10[1]), headers_1); - if (matchValue_1 == null) { - outputGetter_1 = ((matrix_3) => ((i_3) => singleton(new ProcessOutput(0, [Sample_create_3A6378D6(void 0, `${processNameRoot}_Output_${i_3}`, void 0, toList(map((f_3) => f_3(matrix_3)(i_3), factorValueGetters)))])))); - } - else { - const outputGetter = matchValue_1; - outputGetter_1 = ((matrix_2) => ((i_2) => { - const factors = toList(map((f_2) => f_2(matrix_2)(i_2), factorValueGetters)); - const output = outputGetter(matrix_2)(i_2); - return (!ProcessOutput__isSample(output) && !isEmpty(factors)) ? ofArray([output, ProcessOutput_createSample_Z445EF6B3(ProcessOutput__get_Name(output), void 0, factors)]) : singleton(ProcessOutput_setFactorValues(factors, output)); - })); - } - return (matrix_4) => ((i_4) => { - const pn = fromValueWithDefault("", processNameRoot); - const paramvalues = fromValueWithDefault(empty_1(), map_1((f_4) => f_4(matrix_4)(i_4), parameterValueGetters)); - const parameters = map_2((list_5) => map_1((pv) => value_8(pv.Category), list_5), paramvalues); - const protocol = Protocol_make(void 0, mapOrDefault(pn, (f_5) => f_5(matrix_4)(i_4), protocolREFGetter), map_2((f_7) => f_7(matrix_4)(i_4), protocolTypeGetter), map_2((f_8) => f_8(matrix_4)(i_4), protocolDescriptionGetter), map_2((f_9) => f_9(matrix_4)(i_4), protocolURIGetter), map_2((f_10) => f_10(matrix_4)(i_4), protocolVersionGetter), parameters, fromValueWithDefault(empty_1(), map_1((f_11) => f_11(matrix_4)(i_4), componentGetters)), void 0); - let patternInput; - const inputs = inputGetter_1(matrix_4)(i_4); - const outputs = outputGetter_1(matrix_4)(i_4); - patternInput = (((length(inputs) === 1) && (length(outputs) === 2)) ? [ofArray([item(0, inputs), item(0, inputs)]), outputs] : (((length(inputs) === 2) && (length(outputs) === 1)) ? [inputs, ofArray([item(0, outputs), item(0, outputs)])] : [inputs, outputs])); - return Process_make(void 0, pn, protocol, paramvalues, void 0, void 0, void 0, void 0, patternInput[0], patternInput[1], void 0); - }); -} - -/** - * Groups processes by their name, or by the name of the protocol they execute - * - * Process names are taken from the Worksheet name and numbered: SheetName_1, SheetName_2, etc. - * - * This function decomposes this name into a root name and a number, and groups processes by root name. - */ -export function ProcessParsing_groupProcesses(ps) { - return List_groupBy((x) => { - if ((x.Name != null) && (Process_decomposeName_Z721C83C5(value_8(x.Name))[1] != null)) { - return Process_decomposeName_Z721C83C5(value_8(x.Name))[0]; - } - else if ((x.ExecutesProtocol != null) && (value_8(x.ExecutesProtocol).Name != null)) { - return value_8(value_8(x.ExecutesProtocol).Name); - } - else if ((x.Name != null) && (value_8(x.Name).indexOf("_") >= 0)) { - const lastUnderScoreIndex = value_8(x.Name).lastIndexOf("_") | 0; - return remove(value_8(x.Name), lastUnderScoreIndex); - } - else if ((x.ExecutesProtocol != null) && (value_8(x.ExecutesProtocol).ID != null)) { - return value_8(value_8(x.ExecutesProtocol).ID); - } - else { - return createMissingIdentifier(); - } - }, ps, { - Equals: (x_1, y) => (x_1 === y), - GetHashCode: stringHash, - }); -} - -export function ProcessParsing_processToRows(p) { - let list_3; - const pvs = map_1((ppv) => [JsonTypes_decomposeParameterValue(ppv), tryGetParameterColumnIndex(ppv)], defaultArg(p.ParameterValues, empty_1())); - let components; - const matchValue = p.ExecutesProtocol; - components = ((matchValue == null) ? empty_1() : map_1((ppv_1) => [JsonTypes_decomposeComponent(ppv_1), tryGetComponentIndex(ppv_1)], defaultArg(matchValue.Components, empty_1()))); - let protVals; - const matchValue_1 = p.ExecutesProtocol; - if (matchValue_1 == null) { - protVals = empty_1(); - } - else { - const prot_1 = matchValue_1; - protVals = toList(delay(() => append((prot_1.Name != null) ? singleton_1([new CompositeHeader(8, []), new CompositeCell(1, [value_8(prot_1.Name)])]) : empty_2(), delay(() => append((prot_1.ProtocolType != null) ? singleton_1([new CompositeHeader(4, []), new CompositeCell(0, [value_8(prot_1.ProtocolType)])]) : empty_2(), delay(() => append((prot_1.Description != null) ? singleton_1([new CompositeHeader(5, []), new CompositeCell(1, [value_8(prot_1.Description)])]) : empty_2(), delay(() => append((prot_1.Uri != null) ? singleton_1([new CompositeHeader(6, []), new CompositeCell(1, [value_8(prot_1.Uri)])]) : empty_2(), delay(() => ((prot_1.Version != null) ? singleton_1([new CompositeHeader(7, []), new CompositeCell(1, [value_8(prot_1.Version)])]) : empty_2()))))))))))); - } - return map_1((tupledArg_1) => { - const ios = tupledArg_1[1]; - const inputForCharas = defaultArg(tryPick_1((tupledArg_2) => { - const i_2 = tupledArg_2[0]; - if (ProcessInput__isSource(i_2) ? true : ProcessInput__isSample(i_2)) { - return i_2; - } - else { - return void 0; - } - }, ios), head(ios)[0]); - const inputForType = defaultArg(tryPick_1((tupledArg_3) => { - const i_3 = tupledArg_3[0]; - if (ProcessInput__isData(i_3) ? true : ProcessInput__isMaterial(i_3)) { - return i_3; - } - else { - return void 0; - } - }, ios), head(ios)[0]); - const chars = map_1((cv) => [JsonTypes_decomposeCharacteristicValue(cv), tryGetCharacteristicColumnIndex(cv)], ProcessInput_getCharacteristicValues_Z38E7E853(inputForCharas)); - const outputForFactors = defaultArg(tryPick_1((tupledArg_4) => { - const o_4 = tupledArg_4[1]; - if (ProcessOutput__isSample(o_4)) { - return o_4; - } - else { - return void 0; - } - }, ios), head(ios)[1]); - const outputForType = defaultArg(tryPick_1((tupledArg_5) => { - const o_5 = tupledArg_5[1]; - if (ProcessOutput__isData(o_5) ? true : ProcessOutput__isMaterial(o_5)) { - return o_5; - } - else { - return void 0; - } - }, ios), head(ios)[1]); - const vals = map_1((tuple_5) => tuple_5[0], sortBy((arg_2) => defaultArg(arg_2[1], 10000), append_1(chars, append_1(components, append_1(pvs, map_1((fv) => [JsonTypes_decomposeFactorValue(fv), tryGetFactorColumnIndex(fv)], ProcessOutput_getFactorValues_Z4A02997C(outputForFactors))))), { - Compare: comparePrimitives, - })); - return toList(delay(() => append(singleton_1(JsonTypes_decomposeProcessInput(inputForType)), delay(() => append(protVals, delay(() => append(vals, delay(() => singleton_1(JsonTypes_decomposeProcessOutput(outputForType)))))))))); - }, List_groupBy((tupledArg) => [ProcessInput__get_Name(tupledArg[0]), ProcessOutput__get_Name(tupledArg[1])], (list_3 = value_8(p.Outputs), zip(value_8(p.Inputs), list_3)), { - Equals: equalArrays, - GetHashCode: arrayHash, - })); -} - -/** - * Returns true, if two composite headers share the same main header string - */ -export function ProcessParsing_compositeHeaderEqual(ch1, ch2) { - return toString(ch1) === toString(ch2); -} - -/** - * From a list of rows consisting of headers and values, creates a list of combined headers and the values as a sparse matrix - * - * The values cant be directly taken as they are, as there is no guarantee that the headers are aligned - * - * This function aligns the headers and values by the main header string - */ -export function ProcessParsing_alignByHeaders(rows) { - const headers = []; - const values = new Dictionary([], { - Equals: equalArrays, - GetHashCode: arrayHash, - }); - const loop = (colI_mut, rows_2_mut) => { - loop: - while (true) { - const colI = colI_mut, rows_2 = rows_2_mut; - if (!exists((arg_1) => !isEmpty(arg_1), rows_2)) { - return [headers, values]; - } - else { - const firstElem = pick((l) => (isEmpty(l) ? void 0 : head(l)), rows_2)[0]; - void (headers.push(firstElem)); - colI_mut = (colI + 1); - rows_2_mut = mapIndexed((rowI, l_1) => { - if (!isEmpty(l_1)) { - if (ProcessParsing_compositeHeaderEqual(head(l_1)[0], firstElem)) { - addToDict(values, [colI, rowI], head(l_1)[1]); - return tail_1(l_1); - } - else { - return l_1; - } - } - else { - return empty_1(); - } - }, rows_2); - continue loop; - } - break; - } - }; - return loop(0, rows); -} - diff --git a/js/ISA/ISA/ArcTypes/ArcTables.js b/js/ISA/ISA/ArcTypes/ArcTables.js deleted file mode 100644 index d128b41d..00000000 --- a/js/ISA/ISA/ArcTypes/ArcTables.js +++ /dev/null @@ -1,277 +0,0 @@ -import { map, delay, toList, length, tryFindIndex } from "../../../fable_modules/fable-library.4.1.4/Seq.js"; -import { comparePrimitives, stringHash, compare } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { FSharpSet__get_IsEmpty, ofSeq, intersect } from "../../../fable_modules/fable-library.4.1.4/Set.js"; -import { class_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { unwrap, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { insertRangeInPlace } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { ArcTable } from "./ArcTable.js"; -import { map as map_1, collect } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { ProcessParsing_groupProcesses, ProcessParsing_processToRows, ProcessParsing_alignByHeaders } from "./ArcTableAux.js"; - -export function ArcTablesAux_indexByTableName(name, tables) { - const matchValue = tryFindIndex((t) => (t.Name === name), tables); - if (matchValue == null) { - throw new Error(`Unable to find table with name '${name}'!`); - } - else { - return matchValue | 0; - } -} - -export function ArcTablesAux_SanityChecks_validateSheetIndex(index, allowAppend, sheets) { - let x, y; - if (index < 0) { - throw new Error("Cannot insert ArcTable at index < 0."); - } - if ((x = (index | 0), (y = (sheets.length | 0), allowAppend ? (compare(x, y) > 0) : (compare(x, y) >= 0)))) { - throw new Error(`Specified index is out of range! Assay contains only ${sheets.length} tables.`); - } -} - -export function ArcTablesAux_SanityChecks_validateNamesUnique(names) { - if (!(length(names) === length(distinct(names, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })))) { - throw new Error("Cannot add multiple tables with the same name! Table names inside one assay must be unqiue"); - } -} - -export function ArcTablesAux_SanityChecks_validateNewNameUnique(newName, existingNames) { - const matchValue = tryFindIndex((x) => (x === newName), existingNames); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create table with name ${newName}, as table names must be unique and table at index ${matchValue} has the same name.`); - } -} - -export function ArcTablesAux_SanityChecks_validateNewNamesUnique(newNames, existingNames) { - ArcTablesAux_SanityChecks_validateNamesUnique(newNames); - const same = intersect(ofSeq(newNames, { - Compare: comparePrimitives, - }), ofSeq(existingNames, { - Compare: comparePrimitives, - })); - if (!FSharpSet__get_IsEmpty(same)) { - throw new Error(`Cannot create tables with the names ${same}, as table names must be unique.`); - } -} - -export class ArcTables { - constructor(thisTables) { - this.thisTables = thisTables; - } -} - -export function ArcTables_$reflection() { - return class_type("ISA.ArcTables", void 0, ArcTables); -} - -export function ArcTables_$ctor_Z68BECB99(thisTables) { - return new ArcTables(thisTables); -} - -export function ArcTables__get_Count(this$) { - return this$.thisTables.length; -} - -export function ArcTables__get_TableNames(this$) { - return toList(delay(() => map((s) => s.Name, this$.thisTables))); -} - -export function ArcTables__get_Tables(this$) { - return this$.thisTables; -} - -export function ArcTables__get_Item_Z524259A4(this$, index) { - return this$.thisTables[index]; -} - -export function ArcTables__AddTable_16F700A1(this$, table, index) { - const index_1 = defaultArg(index, ArcTables__get_Count(this$)) | 0; - ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNameUnique(table.Name, ArcTables__get_TableNames(this$)); - this$.thisTables.splice(index_1, 0, table); -} - -export function ArcTables__AddTables_3601F24E(this$, tables, index) { - const index_1 = defaultArg(index, ArcTables__get_Count(this$)) | 0; - ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNamesUnique(map((x) => x.Name, tables), ArcTables__get_TableNames(this$)); - insertRangeInPlace(index_1, tables, this$.thisTables); -} - -export function ArcTables__InitTable_3B406CA4(this$, tableName, index) { - const index_1 = defaultArg(index, ArcTables__get_Count(this$)) | 0; - const table = ArcTable.init(tableName); - ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNameUnique(table.Name, ArcTables__get_TableNames(this$)); - this$.thisTables.splice(index_1, 0, table); -} - -export function ArcTables__InitTables_7B28792B(this$, tableNames, index) { - const index_1 = defaultArg(index, ArcTables__get_Count(this$)) | 0; - const tables = map((x) => ArcTable.init(x), tableNames); - ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNamesUnique(map((x_1) => x_1.Name, tables), ArcTables__get_TableNames(this$)); - insertRangeInPlace(index_1, tables, this$.thisTables); -} - -export function ArcTables__GetTableAt_Z524259A4(this$, index) { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - return this$.thisTables[index]; -} - -export function ArcTables__GetTable_Z721C83C5(this$, name) { - return ArcTables__GetTableAt_Z524259A4(this$, ArcTablesAux_indexByTableName(name, this$.thisTables)); -} - -export function ArcTables__UpdateTableAt_66578202(this$, index, table) { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNameUnique(table.Name, ArcTables__get_TableNames(this$)); - this$.thisTables[index] = table; -} - -export function ArcTables__UpdateTable_4976F045(this$, name, table) { - const tupledArg = [ArcTablesAux_indexByTableName(name, this$.thisTables), table]; - ArcTables__UpdateTableAt_66578202(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__RemoveTableAt_Z524259A4(this$, index) { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - this$.thisTables.splice(index, 1); -} - -export function ArcTables__RemoveTable_Z721C83C5(this$, name) { - ArcTables__RemoveTableAt_Z524259A4(this$, ArcTablesAux_indexByTableName(name, this$.thisTables)); -} - -export function ArcTables__MapTableAt_61602D68(this$, index, updateFun) { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - updateFun(this$.thisTables[index]); -} - -export function ArcTables__MapTable_4E415F2F(this$, name, updateFun) { - const tupledArg = [ArcTablesAux_indexByTableName(name, this$.thisTables), updateFun]; - ArcTables__MapTableAt_61602D68(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__RenameTableAt_Z176EF219(this$, index, newName) { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNameUnique(newName, ArcTables__get_TableNames(this$)); - const table = ArcTables__GetTableAt_Z524259A4(this$, index); - ArcTables__UpdateTableAt_66578202(this$, index, new ArcTable(newName, table.Headers, table.Values)); -} - -export function ArcTables__RenameTable_Z384F8060(this$, name, newName) { - const tupledArg = [ArcTablesAux_indexByTableName(name, this$.thisTables), newName]; - ArcTables__RenameTableAt_Z176EF219(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__AddColumnAt_6647579B(this$, tableIndex, header, cells, columnIndex, forceReplace) { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table) => { - table.AddColumn(header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - }); -} - -export function ArcTables__AddColumn_Z4FC90944(this$, tableName, header, cells, columnIndex, forceReplace) { - ArcTables__AddColumnAt_6647579B(this$, ArcTablesAux_indexByTableName(tableName, this$.thisTables), header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); -} - -export function ArcTables__RemoveColumnAt_Z37302880(this$, tableIndex, columnIndex) { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table) => { - table.RemoveColumn(columnIndex); - }); -} - -export function ArcTables__RemoveColumn_Z18115A39(this$, tableName, columnIndex) { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), columnIndex]; - ArcTables__RemoveColumnAt_Z37302880(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__UpdateColumnAt_Z155350AF(this$, tableIndex, columnIndex, header, cells) { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table) => { - table.UpdateColumn(columnIndex, header, unwrap(cells)); - }); -} - -export function ArcTables__UpdateColumn_Z774BF72A(this$, tableName, columnIndex, header, cells) { - ArcTables__UpdateColumnAt_Z155350AF(this$, ArcTablesAux_indexByTableName(tableName, this$.thisTables), columnIndex, header, unwrap(cells)); -} - -export function ArcTables__GetColumnAt_Z37302880(this$, tableIndex, columnIndex) { - const table = ArcTables__GetTableAt_Z524259A4(this$, tableIndex); - return table.GetColumn(columnIndex); -} - -export function ArcTables__GetColumn_Z18115A39(this$, tableName, columnIndex) { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), columnIndex]; - return ArcTables__GetColumnAt_Z37302880(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__AddRowAt_Z57F91678(this$, tableIndex, cells, rowIndex) { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table) => { - table.AddRow(unwrap(cells), unwrap(rowIndex)); - }); -} - -export function ArcTables__AddRow_1177C4AF(this$, tableName, cells, rowIndex) { - ArcTables__AddRowAt_Z57F91678(this$, ArcTablesAux_indexByTableName(tableName, this$.thisTables), unwrap(cells), unwrap(rowIndex)); -} - -export function ArcTables__RemoveRowAt_Z37302880(this$, tableIndex, rowIndex) { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table) => { - table.RemoveRow(rowIndex); - }); -} - -export function ArcTables__RemoveRow_Z18115A39(this$, tableName, rowIndex) { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), rowIndex]; - ArcTables__RemoveRowAt_Z37302880(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__UpdateRowAt_Z596C2D98(this$, tableIndex, rowIndex, cells) { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table) => { - table.UpdateRow(rowIndex, cells); - }); -} - -export function ArcTables__UpdateRow_Z5E65B4B1(this$, tableName, rowIndex, cells) { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), rowIndex, cells]; - ArcTables__UpdateRowAt_Z596C2D98(this$, tupledArg[0], tupledArg[1], tupledArg[2]); -} - -export function ArcTables__GetRowAt_Z37302880(this$, tableIndex, rowIndex) { - const table = ArcTables__GetTableAt_Z524259A4(this$, tableIndex); - return table.GetRow(rowIndex); -} - -export function ArcTables__GetRow_Z18115A39(this$, tableName, rowIndex) { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), rowIndex]; - return ArcTables__GetRowAt_Z37302880(this$, tupledArg[0], tupledArg[1]); -} - -/** - * Return a list of all the processes in all the tables. - */ -export function ArcTables__GetProcesses(this$) { - return collect((t) => t.GetProcesses(), toList(ArcTables__get_Tables(this$))); -} - -/** - * Create a collection of tables from a list of processes. - * - * For this, the processes are grouped by nameroot ("nameroot_1", "nameroot_2" ...) or exectued protocol if no name exists - * - * Then each group is converted to a table with this nameroot as sheetname - */ -export function ArcTables_fromProcesses_Z31821267(ps) { - let arg; - return ArcTables_$ctor_Z68BECB99((arg = map_1((tupledArg) => { - const tupledArg_1 = ProcessParsing_alignByHeaders(collect(ProcessParsing_processToRows, tupledArg[1])); - return ArcTable.create(tupledArg[0], tupledArg_1[0], tupledArg_1[1]); - }, ProcessParsing_groupProcesses(ps)), Array.from(arg))); -} - diff --git a/js/ISA/ISA/ArcTypes/CompositeCell.js b/js/ISA/ISA/ArcTypes/CompositeCell.js deleted file mode 100644 index b2658a69..00000000 --- a/js/ISA/ISA/ArcTypes/CompositeCell.js +++ /dev/null @@ -1,165 +0,0 @@ -import { int32ToString } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation__get_NameText, OntologyAnnotation_create_131C8C9D } from "../JsonTypes/OntologyAnnotation.js"; -import { AnnotationValue } from "../JsonTypes/AnnotationValue.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { Union } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { union_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class CompositeCell extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Term", "FreeText", "Unitized"]; - } - static fromValue(value, unit) { - let matchResult, t, i, i_1, u, f, f_1, u_1, s; - switch (value.tag) { - case 1: { - if (unit != null) { - matchResult = 2; - i_1 = value.fields[0]; - u = unit; - } - else { - matchResult = 1; - i = value.fields[0]; - } - break; - } - case 2: { - if (unit != null) { - matchResult = 4; - f_1 = value.fields[0]; - u_1 = unit; - } - else { - matchResult = 3; - f = value.fields[0]; - } - break; - } - case 3: { - if (unit == null) { - matchResult = 5; - s = value.fields[0]; - } - else { - matchResult = 6; - } - break; - } - default: - if (unit == null) { - matchResult = 0; - t = value.fields[0]; - } - else { - matchResult = 6; - } - } - switch (matchResult) { - case 0: - return new CompositeCell(0, [t]); - case 1: - return new CompositeCell(1, [int32ToString(i)]); - case 2: - return new CompositeCell(2, [int32ToString(i_1), u]); - case 3: - return new CompositeCell(1, [f.toString()]); - case 4: - return new CompositeCell(2, [f_1.toString(), u_1]); - case 5: - return new CompositeCell(1, [s]); - default: - throw new Error("could not convert value to cell, invalid combination of value and unit"); - } - } - get isUnitized() { - const this$ = this; - return this$.tag === 2; - } - get isTerm() { - const this$ = this; - return this$.tag === 0; - } - get isFreeText() { - const this$ = this; - return this$.tag === 1; - } - ToUnitizedCell() { - const this$ = this; - return (this$.tag === 1) ? (new CompositeCell(2, ["", OntologyAnnotation_create_131C8C9D(void 0, new AnnotationValue(0, [this$.fields[0]]))])) : ((this$.tag === 0) ? (new CompositeCell(2, ["", this$.fields[0]])) : this$); - } - ToTermCell() { - const this$ = this; - return (this$.tag === 2) ? (new CompositeCell(0, [this$.fields[1]])) : ((this$.tag === 1) ? (new CompositeCell(0, [OntologyAnnotation_create_131C8C9D(void 0, new AnnotationValue(0, [this$.fields[0]]))])) : this$); - } - ToFreeTextCell() { - const this$ = this; - return (this$.tag === 0) ? (new CompositeCell(1, [OntologyAnnotation__get_NameText(this$.fields[0])])) : ((this$.tag === 2) ? (new CompositeCell(1, [OntologyAnnotation__get_NameText(this$.fields[1])])) : this$); - } - get AsUnitized() { - const this$ = this; - if (this$.tag === 2) { - return [this$.fields[0], this$.fields[1]]; - } - else { - throw new Error("Not a Unitized cell."); - } - } - get AsTerm() { - const this$ = this; - if (this$.tag === 0) { - return this$.fields[0]; - } - else { - throw new Error("Not a Swate TermCell."); - } - } - get AsFreeText() { - const this$ = this; - if (this$.tag === 1) { - return this$.fields[0]; - } - else { - throw new Error("Not a Swate TermCell."); - } - } - static createTerm(oa) { - return new CompositeCell(0, [oa]); - } - static createTermFromString(name, tsr, tan) { - return new CompositeCell(0, [OntologyAnnotation_fromString_Z7D8EB286(name, tsr, tan)]); - } - static createUnitized(value, oa) { - return new CompositeCell(2, [value, defaultArg(oa, OntologyAnnotation_get_empty())]); - } - static createUnitizedFromString(value, name, tsr, tan) { - const tupledArg = [value, OntologyAnnotation_fromString_Z7D8EB286(name, tsr, tan)]; - return new CompositeCell(2, [tupledArg[0], tupledArg[1]]); - } - static createFreeText(value) { - return new CompositeCell(1, [value]); - } - static get emptyTerm() { - return new CompositeCell(0, [OntologyAnnotation_get_empty()]); - } - static get emptyFreeText() { - return new CompositeCell(1, [""]); - } - static get emptyUnitized() { - return new CompositeCell(2, ["", OntologyAnnotation_get_empty()]); - } - toString() { - const this$ = this; - return (this$.tag === 1) ? this$.fields[0] : ((this$.tag === 2) ? (`${this$.fields[0]} ${OntologyAnnotation__get_NameText(this$.fields[1])}`) : (`Term${OntologyAnnotation__get_NameText(this$.fields[0])}`)); - } -} - -export function CompositeCell_$reflection() { - return union_type("ISA.CompositeCell", [], CompositeCell, () => [[["Item", OntologyAnnotation_$reflection()]], [["Item", string_type]], [["Item1", string_type], ["Item2", OntologyAnnotation_$reflection()]]]); -} - diff --git a/js/ISA/ISA/ArcTypes/CompositeColumn.js b/js/ISA/ISA/ArcTypes/CompositeColumn.js deleted file mode 100644 index 79853b25..00000000 --- a/js/ISA/ISA/ArcTypes/CompositeColumn.js +++ /dev/null @@ -1,44 +0,0 @@ -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { min } from "../../../fable_modules/fable-library.4.1.4/Double.js"; -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { CompositeHeader_$reflection } from "./CompositeHeader.js"; -import { CompositeCell_$reflection } from "./CompositeCell.js"; -import { record_type, array_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class CompositeColumn extends Record { - constructor(Header, Cells) { - super(); - this.Header = Header; - this.Cells = Cells; - } - static create(header, cells) { - return new CompositeColumn(header, defaultArg(cells, [])); - } - validate(raiseException) { - const this$ = this; - const raiseExeption = defaultArg(raiseException, false); - const header = this$.Header; - const cells = this$.Cells; - if (cells.length === 0) { - return true; - } - else if (header.IsTermColumn && (cells[0].isTerm ? true : cells[0].isUnitized)) { - return true; - } - else if (!header.IsTermColumn && cells[0].isFreeText) { - return true; - } - else { - const c = cells; - if (raiseExeption) { - throw new Error(`Invalid combination of header \`${header}\` and cells \`${c[min(c.length, 3)]}\``); - } - return false; - } - } -} - -export function CompositeColumn_$reflection() { - return record_type("ISA.CompositeColumn", [], CompositeColumn, () => [["Header", CompositeHeader_$reflection()], ["Cells", array_type(CompositeCell_$reflection())]]); -} - diff --git a/js/ISA/ISA/ArcTypes/CompositeHeader.js b/js/ISA/ISA/ArcTypes/CompositeHeader.js deleted file mode 100644 index 512f351c..00000000 --- a/js/ISA/ISA/ArcTypes/CompositeHeader.js +++ /dev/null @@ -1,334 +0,0 @@ -import { Union, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { ActivePatterns_$007CTermColumn$007C_$007C, ActivePatterns_$007CRegex$007C_$007C, tryParseIOTypeHeader } from "../Regex.js"; -import { union_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation__get_TermAccessionShort, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation__get_NameText } from "../JsonTypes/OntologyAnnotation.js"; -import { ProtocolParameter_create_2769312B } from "../JsonTypes/ProtocolParameter.js"; -import { Factor_create_Z3D2B374F } from "../JsonTypes/Factor.js"; -import { MaterialAttribute_create_2769312B } from "../JsonTypes/MaterialAttribute.js"; -import { Component_create_Z33AADEE0 } from "../JsonTypes/Component.js"; - -export class IOType extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Source", "Sample", "RawDataFile", "DerivedDataFile", "ImageFile", "Material", "FreeText"]; - } - static get All() { - return [new IOType(0, []), new IOType(1, []), new IOType(2, []), new IOType(3, []), new IOType(4, []), new IOType(5, [])]; - } - get asInput() { - const this$ = this; - const stringCreate = (x) => { - let copyOfStruct; - return `Input [${(copyOfStruct = x, toString(copyOfStruct))}]`; - }; - return (this$.tag === 6) ? stringCreate(this$.fields[0]) : stringCreate(this$); - } - get asOutput() { - const this$ = this; - const stringCreate = (x) => { - let copyOfStruct; - return `Output [${(copyOfStruct = x, toString(copyOfStruct))}]`; - }; - return (this$.tag === 6) ? stringCreate(this$.fields[0]) : stringCreate(this$); - } - toString() { - const this$ = this; - return (this$.tag === 1) ? "Sample Name" : ((this$.tag === 2) ? "Raw Data File" : ((this$.tag === 3) ? "Derived Data File" : ((this$.tag === 4) ? "Image File" : ((this$.tag === 5) ? "Material" : ((this$.tag === 6) ? this$.fields[0] : "Source Name"))))); - } - static ofString(str) { - return (str === "Source") ? (new IOType(0, [])) : ((str === "Source Name") ? (new IOType(0, [])) : ((str === "Sample") ? (new IOType(1, [])) : ((str === "Sample Name") ? (new IOType(1, [])) : ((str === "RawDataFile") ? (new IOType(2, [])) : ((str === "Raw Data File") ? (new IOType(2, [])) : ((str === "DerivedDataFile") ? (new IOType(3, [])) : ((str === "Derived Data File") ? (new IOType(3, [])) : ((str === "ImageFile") ? (new IOType(4, [])) : ((str === "Image File") ? (new IOType(4, [])) : ((str === "Material") ? (new IOType(5, [])) : (new IOType(6, [str])))))))))))); - } - static tryOfHeaderString(str) { - const matchValue = tryParseIOTypeHeader(str); - if (matchValue == null) { - return void 0; - } - else { - const s = matchValue; - return IOType.ofString(s); - } - } -} - -export function IOType_$reflection() { - return union_type("ISA.IOType", [], IOType, () => [[], [], [], [], [], [], [["Item", string_type]]]); -} - -export class CompositeHeader extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Component", "Characteristic", "Factor", "Parameter", "ProtocolType", "ProtocolDescription", "ProtocolUri", "ProtocolVersion", "ProtocolREF", "Performer", "Date", "Input", "Output", "FreeText"]; - } - toString() { - const this$ = this; - return (this$.tag === 2) ? (`Factor [${OntologyAnnotation__get_NameText(this$.fields[0])}]`) : ((this$.tag === 1) ? (`Characteristic [${OntologyAnnotation__get_NameText(this$.fields[0])}]`) : ((this$.tag === 0) ? (`Component [${OntologyAnnotation__get_NameText(this$.fields[0])}]`) : ((this$.tag === 4) ? "Protocol Type" : ((this$.tag === 8) ? "Protocol REF" : ((this$.tag === 5) ? "Protocol Description" : ((this$.tag === 6) ? "Protocol Uri" : ((this$.tag === 7) ? "Protocol Version" : ((this$.tag === 9) ? "Performer" : ((this$.tag === 10) ? "Date" : ((this$.tag === 11) ? this$.fields[0].asInput : ((this$.tag === 12) ? this$.fields[0].asOutput : ((this$.tag === 13) ? this$.fields[0] : (`Parameter [${OntologyAnnotation__get_NameText(this$.fields[0])}]`))))))))))))); - } - ToTerm() { - const this$ = this; - return (this$.tag === 2) ? this$.fields[0] : ((this$.tag === 1) ? this$.fields[0] : ((this$.tag === 0) ? this$.fields[0] : ((this$.tag === 4) ? OntologyAnnotation_fromString_Z7D8EB286("Protocol Type") : ((this$.tag === 8) ? OntologyAnnotation_fromString_Z7D8EB286("Protocol REF") : ((this$.tag === 5) ? OntologyAnnotation_fromString_Z7D8EB286("Protocol Description") : ((this$.tag === 6) ? OntologyAnnotation_fromString_Z7D8EB286("Protocol Uri") : ((this$.tag === 7) ? OntologyAnnotation_fromString_Z7D8EB286("Protocol Version") : ((this$.tag === 9) ? OntologyAnnotation_fromString_Z7D8EB286("Performer") : ((this$.tag === 10) ? OntologyAnnotation_fromString_Z7D8EB286("Date") : ((this$.tag === 11) ? OntologyAnnotation_fromString_Z7D8EB286(this$.fields[0].asInput) : ((this$.tag === 12) ? OntologyAnnotation_fromString_Z7D8EB286(this$.fields[0].asOutput) : ((this$.tag === 13) ? OntologyAnnotation_fromString_Z7D8EB286(this$.fields[0]) : this$.fields[0])))))))))))); - } - static OfHeaderString(str) { - const matchValue = str.trim(); - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("Input\\s\\[(?.+)\\]", matchValue); - if (activePatternResult != null) { - const r = activePatternResult; - const iotype = (r.groups && r.groups.iotype) || ""; - return new CompositeHeader(11, [IOType.ofString(iotype)]); - } - else { - const activePatternResult_1 = ActivePatterns_$007CRegex$007C_$007C("Output\\s\\[(?.+)\\]", matchValue); - if (activePatternResult_1 != null) { - const r_1 = activePatternResult_1; - const iotype_1 = (r_1.groups && r_1.groups.iotype) || ""; - return new CompositeHeader(12, [IOType.ofString(iotype_1)]); - } - else { - const activePatternResult_2 = ActivePatterns_$007CTermColumn$007C_$007C(matchValue); - if (activePatternResult_2 != null) { - const r_2 = activePatternResult_2; - const matchValue_1 = r_2.TermColumnType; - switch (matchValue_1) { - case "Parameter": - case "Parameter Value": - return new CompositeHeader(3, [OntologyAnnotation_fromString_Z7D8EB286(r_2.TermName)]); - case "Factor": - case "Factor Value": - return new CompositeHeader(2, [OntologyAnnotation_fromString_Z7D8EB286(r_2.TermName)]); - case "Characteristic": - case "Characteristics": - case "Characteristics Value": - return new CompositeHeader(1, [OntologyAnnotation_fromString_Z7D8EB286(r_2.TermName)]); - case "Component": - return new CompositeHeader(0, [OntologyAnnotation_fromString_Z7D8EB286(r_2.TermName)]); - default: - return new CompositeHeader(13, [str]); - } - } - else { - return (matchValue === "Date") ? (new CompositeHeader(10, [])) : ((matchValue === "Performer") ? (new CompositeHeader(9, [])) : ((matchValue === "Protocol Description") ? (new CompositeHeader(5, [])) : ((matchValue === "Protocol Uri") ? (new CompositeHeader(6, [])) : ((matchValue === "Protocol Version") ? (new CompositeHeader(7, [])) : ((matchValue === "Protocol Type") ? (new CompositeHeader(4, [])) : ((matchValue === "Protocol REF") ? (new CompositeHeader(8, [])) : (new CompositeHeader(13, [matchValue])))))))); - } - } - } - } - get IsDeprecated() { - const this$ = this; - let matchResult, s_4, s_5, s_6, s_7; - if (this$.tag === 13) { - if (this$.fields[0].toLocaleLowerCase() === "sample name") { - matchResult = 0; - s_4 = this$.fields[0]; - } - else if (this$.fields[0].toLocaleLowerCase() === "source name") { - matchResult = 1; - s_5 = this$.fields[0]; - } - else if (this$.fields[0].toLocaleLowerCase() === "data file name") { - matchResult = 2; - s_6 = this$.fields[0]; - } - else if (this$.fields[0].toLocaleLowerCase() === "derived data file") { - matchResult = 3; - s_7 = this$.fields[0]; - } - else { - matchResult = 4; - } - } - else { - matchResult = 4; - } - switch (matchResult) { - case 0: - return true; - case 1: - return true; - case 2: - return true; - case 3: - return true; - default: - return false; - } - } - get IsCvParamColumn() { - const this$ = this; - switch (this$.tag) { - case 3: - case 2: - case 1: - case 0: - return true; - default: - return false; - } - } - get IsTermColumn() { - const this$ = this; - switch (this$.tag) { - case 3: - case 2: - case 1: - case 0: - case 4: - return true; - default: - return false; - } - } - get IsFeaturedColumn() { - const this$ = this; - return this$.tag === 4; - } - get GetFeaturedColumnAccession() { - const this$ = this; - if (this$.tag === 4) { - return "DPBO:1000161"; - } - else { - throw new Error(`Tried matching ${this$} in getFeaturedColumnAccession, but is not a featured column.`); - } - } - get GetColumnAccessionShort() { - const this$ = this; - switch (this$.tag) { - case 4: - return this$.GetFeaturedColumnAccession; - case 3: - return OntologyAnnotation__get_TermAccessionShort(this$.fields[0]); - case 2: - return OntologyAnnotation__get_TermAccessionShort(this$.fields[0]); - case 1: - return OntologyAnnotation__get_TermAccessionShort(this$.fields[0]); - case 0: - return OntologyAnnotation__get_TermAccessionShort(this$.fields[0]); - default: - throw new Error(`Tried matching ${this$}, but is not a column with an accession.`); - } - } - get IsSingleColumn() { - const this$ = this; - switch (this$.tag) { - case 13: - case 11: - case 12: - case 8: - case 5: - case 6: - case 7: - case 9: - case 10: - return true; - default: - return false; - } - } - get IsIOType() { - const this$ = this; - let matchResult, io; - switch (this$.tag) { - case 11: { - matchResult = 0; - io = this$.fields[0]; - break; - } - case 12: { - matchResult = 0; - io = this$.fields[0]; - break; - } - default: - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } - } - get isInput() { - const this$ = this; - return this$.tag === 11; - } - get isOutput() { - const this$ = this; - return this$.tag === 11; - } - get isParameter() { - const this$ = this; - return this$.tag === 3; - } - get isFactor() { - const this$ = this; - return this$.tag === 2; - } - get isCharacteristic() { - const this$ = this; - return this$.tag === 1; - } - get isComponent() { - const this$ = this; - return this$.tag === 0; - } - get isProtocolType() { - const this$ = this; - return this$.tag === 4; - } - get isProtocolREF() { - const this$ = this; - return this$.tag === 8; - } - get isProtocolDescription() { - const this$ = this; - return this$.tag === 5; - } - get isProtocolUri() { - const this$ = this; - return this$.tag === 6; - } - get isProtocolVersion() { - const this$ = this; - return this$.tag === 7; - } - get isPerformer() { - const this$ = this; - return this$.tag === 9; - } - get isDate() { - const this$ = this; - return this$.tag === 10; - } - get isFreeText() { - const this$ = this; - return this$.tag === 13; - } - TryParameter() { - const this$ = this; - return (this$.tag === 3) ? ProtocolParameter_create_2769312B(void 0, this$.fields[0]) : void 0; - } - TryFactor() { - const this$ = this; - return (this$.tag === 2) ? Factor_create_Z3D2B374F(void 0, void 0, this$.fields[0]) : void 0; - } - TryCharacteristic() { - const this$ = this; - return (this$.tag === 1) ? MaterialAttribute_create_2769312B(void 0, this$.fields[0]) : void 0; - } - TryComponent() { - const this$ = this; - return (this$.tag === 0) ? Component_create_Z33AADEE0(void 0, void 0, void 0, this$.fields[0]) : void 0; - } -} - -export function CompositeHeader_$reflection() { - return union_type("ISA.CompositeHeader", [], CompositeHeader, () => [[["Item", OntologyAnnotation_$reflection()]], [["Item", OntologyAnnotation_$reflection()]], [["Item", OntologyAnnotation_$reflection()]], [["Item", OntologyAnnotation_$reflection()]], [], [], [], [], [], [], [], [["Item", IOType_$reflection()]], [["Item", IOType_$reflection()]], [["Item", string_type]]]); -} - diff --git a/js/ISA/ISA/ArcTypes/CompositeRow.js b/js/ISA/ISA/ArcTypes/CompositeRow.js deleted file mode 100644 index 8edd5bb3..00000000 --- a/js/ISA/ISA/ArcTypes/CompositeRow.js +++ /dev/null @@ -1,111 +0,0 @@ -import { fold } from "../../../fable_modules/fable-library.4.1.4/Seq.js"; -import { Protocol_get_empty, Protocol_addComponent, Protocol_addParameter, Protocol_setName, Protocol_setDescription, Protocol_setUri, Protocol_setVersion, Protocol_setProtocolType } from "../JsonTypes/Protocol.js"; -import { ProtocolParameter_create_2769312B } from "../JsonTypes/ProtocolParameter.js"; -import { Component_create_Z33AADEE0 } from "../JsonTypes/Component.js"; -import { Value, Value_fromString_Z721C83C5 } from "../JsonTypes/Value.js"; - -export function toProtocol(row) { - return fold((p, hc) => { - let matchResult, oa, v, v_1, v_2, v_3, oa_1, oa_2, unit, v_4, oa_3, t; - switch (hc[0].tag) { - case 4: { - if (hc[1].tag === 0) { - matchResult = 0; - oa = hc[1].fields[0]; - } - else { - matchResult = 8; - } - break; - } - case 7: { - if (hc[1].tag === 1) { - matchResult = 1; - v = hc[1].fields[0]; - } - else { - matchResult = 8; - } - break; - } - case 6: { - if (hc[1].tag === 1) { - matchResult = 2; - v_1 = hc[1].fields[0]; - } - else { - matchResult = 8; - } - break; - } - case 5: { - if (hc[1].tag === 1) { - matchResult = 3; - v_2 = hc[1].fields[0]; - } - else { - matchResult = 8; - } - break; - } - case 8: { - if (hc[1].tag === 1) { - matchResult = 4; - v_3 = hc[1].fields[0]; - } - else { - matchResult = 8; - } - break; - } - case 3: { - matchResult = 5; - oa_1 = hc[0].fields[0]; - break; - } - case 0: { - switch (hc[1].tag) { - case 2: { - matchResult = 6; - oa_2 = hc[0].fields[0]; - unit = hc[1].fields[1]; - v_4 = hc[1].fields[0]; - break; - } - case 0: { - matchResult = 7; - oa_3 = hc[0].fields[0]; - t = hc[1].fields[0]; - break; - } - default: - matchResult = 8; - } - break; - } - default: - matchResult = 8; - } - switch (matchResult) { - case 0: - return Protocol_setProtocolType(p, oa); - case 1: - return Protocol_setVersion(p, v); - case 2: - return Protocol_setUri(p, v_1); - case 3: - return Protocol_setDescription(p, v_2); - case 4: - return Protocol_setName(p, v_3); - case 5: - return Protocol_addParameter(ProtocolParameter_create_2769312B(void 0, oa_1), p); - case 6: - return Protocol_addComponent(Component_create_Z33AADEE0(void 0, Value_fromString_Z721C83C5(v_4), unit, oa_2), p); - case 7: - return Protocol_addComponent(Component_create_Z33AADEE0(void 0, new Value(0, [t]), void 0, oa_3), p); - default: - return p; - } - }, Protocol_get_empty(), row); -} - diff --git a/js/ISA/ISA/ArcTypes/Identifier.js b/js/ISA/ISA/ArcTypes/Identifier.js deleted file mode 100644 index 24b09786..00000000 --- a/js/ISA/ISA/ArcTypes/Identifier.js +++ /dev/null @@ -1,76 +0,0 @@ -import { match, isMatch } from "../../../fable_modules/fable-library.4.1.4/RegExp.js"; -import { newGuid } from "../../../fable_modules/fable-library.4.1.4/Guid.js"; -import { combineMany } from "../../../FileSystem/Path.js"; - -export function checkValidCharacters(identifier) { - if (!isMatch(/^[a-zA-Z0-9_\- ]+$/gu, identifier)) { - throw new Error("New identifier contains forbidden characters! Allowed characters are: letters, digits, underscore (_), dash (-) and whitespace ( )."); - } -} - -export function createMissingIdentifier() { - let copyOfStruct; - return "MISSING_IDENTIFIER_" + ((copyOfStruct = newGuid(), copyOfStruct)); -} - -export function isMissingIdentifier(str) { - return str.indexOf("MISSING_IDENTIFIER_") === 0; -} - -export function removeMissingIdentifier(str) { - if (str.indexOf("MISSING_IDENTIFIER_") === 0) { - return ""; - } - else { - return str; - } -} - -/** - * On read-in the FileName can be any combination of "assays" (assay folder name), assayIdentifier and "isa.assay.xlsx" (the actual file name). - * - * This functions extracts assayIdentifier from any of these combinations and returns it. - */ -export function Assay_identifierFromFileName(fileName) { - const m = match(/^(assays(\/|\\))?(?[a-zA-Z0-9_\- ]+)((\/|\\)isa.assay.xlsx)?$/gu, fileName); - const matchValue = m != null; - if (matchValue) { - return (m.groups && m.groups.identifier) || ""; - } - else { - throw new Error(`Cannot parse identifier from FileName \`${fileName}\``); - } -} - -/** - * On writing a xlsx file we unify our output to a relative path to ARC root. So: `assays/assayIdentifier/isa.assay.xlsx`. - */ -export function Assay_fileNameFromIdentifier(identifier) { - checkValidCharacters(identifier); - return combineMany(["assays", identifier, "isa.assay.xlsx"]); -} - -/** - * On read-in the FileName can be any combination of "studies" (study folder name), studyIdentifier and "isa.study.xlsx" (the actual file name). - * - * This functions extracts studyIdentifier from any of these combinations and returns it. - */ -export function Study_identifierFromFileName(fileName) { - const m = match(/^(studies(\/|\\))?(?[a-zA-Z0-9_\- ]+)((\/|\\)isa.study.xlsx)?$/gu, fileName); - const matchValue = m != null; - if (matchValue) { - return (m.groups && m.groups.identifier) || ""; - } - else { - throw new Error(`Cannot parse identifier from FileName \`${fileName}\``); - } -} - -/** - * On writing a xlsx file we unify our output to a relative path to ARC root. So: `studies/studyIdentifier/isa.study.xlsx`. - */ -export function Study_fileNameFromIdentifier(identifier) { - checkValidCharacters(identifier); - return combineMany(["studies", identifier, "isa.study.xlsx"]); -} - diff --git a/js/ISA/ISA/ArcTypes/IdentifierSetters.js b/js/ISA/ISA/ArcTypes/IdentifierSetters.js deleted file mode 100644 index fa90dfdc..00000000 --- a/js/ISA/ISA/ArcTypes/IdentifierSetters.js +++ /dev/null @@ -1,20 +0,0 @@ -import { checkValidCharacters } from "./Identifier.js"; - -export function setAssayIdentifier(newIdentifier, assay) { - checkValidCharacters(newIdentifier); - assay.Identifier = newIdentifier; - return assay; -} - -export function setStudyIdentifier(newIdentifier, study) { - checkValidCharacters(newIdentifier); - study.Identifier = newIdentifier; - return study; -} - -export function setInvestigationIdentifier(newIdentifier, investigation) { - checkValidCharacters(newIdentifier); - investigation.Identifier = newIdentifier; - return investigation; -} - diff --git a/js/ISA/ISA/Builder/Types.js b/js/ISA/ISA/Builder/Types.js deleted file mode 100644 index b6eee44a..00000000 --- a/js/ISA/ISA/Builder/Types.js +++ /dev/null @@ -1,243 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { list_type, union_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation_$reflection } from "../JsonTypes/OntologyAnnotation.js"; -import { Protocol_get_empty, Protocol } from "../JsonTypes/Protocol.js"; -import { ProcessParameterValue_$reflection } from "../JsonTypes/ProcessParameterValue.js"; -import { MaterialAttributeValue_$reflection } from "../JsonTypes/MaterialAttributeValue.js"; -import { FactorValue_$reflection } from "../JsonTypes/FactorValue.js"; -import { map as map_1, exists, fold, singleton, empty, append } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { map, value as value_4, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { Process_get_empty, Process } from "../JsonTypes/Process.js"; -import { Assay_get_empty, Assay } from "../JsonTypes/Assay.js"; -import { printf, toFail } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { Study } from "../JsonTypes/Study.js"; - -export class ProtocolTransformation extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["AddName", "AddProtocolType", "AddDescription"]; - } -} - -export function ProtocolTransformation_$reflection() { - return union_type("ISA.Builder.ProtocolTransformation", [], ProtocolTransformation, () => [[["Item", string_type]], [["Item", OntologyAnnotation_$reflection()]], [["Item", string_type]]]); -} - -export function ProtocolTransformation__Transform_4D8AC666(this$, p) { - switch (this$.tag) { - case 1: - return new Protocol(p.ID, p.Name, this$.fields[0], p.Description, p.Uri, p.Version, p.Parameters, p.Components, p.Comments); - case 2: - return new Protocol(p.ID, p.Name, p.ProtocolType, this$.fields[0], p.Uri, p.Version, p.Parameters, p.Components, p.Comments); - default: - return new Protocol(p.ID, this$.fields[0], p.ProtocolType, p.Description, p.Uri, p.Version, p.Parameters, p.Components, p.Comments); - } -} - -export function ProtocolTransformation__Equals_4D8AC666(this$, p) { - const matchValue = p.Name; - let matchResult, n_1, n$0027_1; - if (this$.tag === 0) { - if (matchValue != null) { - if (this$.fields[0] === matchValue) { - matchResult = 0; - n_1 = this$.fields[0]; - n$0027_1 = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } -} - -export class ProcessTransformation extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["AddName", "AddParameter", "AddCharacteristic", "AddFactor", "AddProtocol"]; - } -} - -export function ProcessTransformation_$reflection() { - return union_type("ISA.Builder.ProcessTransformation", [], ProcessTransformation, () => [[["Item", string_type]], [["Item", ProcessParameterValue_$reflection()]], [["Item", MaterialAttributeValue_$reflection()]], [["Item", FactorValue_$reflection()]], [["Item", list_type(ProtocolTransformation_$reflection())]]]); -} - -export function ProcessTransformation__Transform_30EF9E7B(this$, p) { - let pro; - switch (this$.tag) { - case 1: { - const pv = this$.fields[0]; - const parameterValues = append(defaultArg(p.ParameterValues, empty()), singleton(pv)); - return new Process(p.ID, p.Name, (pro = defaultArg(p.ExecutesProtocol, Protocol_get_empty()), new Protocol(pro.ID, pro.Name, pro.ProtocolType, pro.Description, pro.Uri, pro.Version, append(defaultArg(pro.Parameters, empty()), singleton(value_4(pv.Category))), pro.Components, pro.Comments)), parameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, p.Outputs, p.Comments); - } - case 2: - return new Process(p.ID, p.Name, p.ExecutesProtocol, p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, map((i) => i, p.Inputs), p.Outputs, p.Comments); - case 3: - return new Process(p.ID, p.Name, p.ExecutesProtocol, p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, map((i_1) => i_1, p.Outputs), p.Comments); - case 4: - return new Process(p.ID, p.Name, fold((pro_2, trans) => ProtocolTransformation__Transform_4D8AC666(trans, pro_2), defaultArg(p.ExecutesProtocol, Protocol_get_empty()), this$.fields[0]), p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, p.Outputs, p.Comments); - default: - return new Process(p.ID, this$.fields[0], p.ExecutesProtocol, p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, p.Outputs, p.Comments); - } -} - -export function ProcessTransformation__Equals_30EF9E7B(this$, p) { - const matchValue = p.Name; - let matchResult, n_1, n$0027_1; - if (this$.tag === 0) { - if (matchValue != null) { - if (this$.fields[0] === matchValue) { - matchResult = 0; - n_1 = this$.fields[0]; - n$0027_1 = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } -} - -export class AssayTransformation extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["AddFileName", "AddParameter", "AddCharacteristic", "AddFactor", "AddProcess"]; - } -} - -export function AssayTransformation_$reflection() { - return union_type("ISA.Builder.AssayTransformation", [], AssayTransformation, () => [[["Item", string_type]], [["Item", ProcessParameterValue_$reflection()]], [["Item", MaterialAttributeValue_$reflection()]], [["Item", FactorValue_$reflection()]], [["Item", list_type(ProcessTransformation_$reflection())]]]); -} - -export function AssayTransformation__Transform_Z269B5B97(this$, a) { - switch (this$.tag) { - case 4: { - const pts = this$.fields[0]; - const processes = defaultArg(a.ProcessSequence, empty()); - return new Assay(a.ID, a.FileName, a.MeasurementType, a.TechnologyType, a.TechnologyPlatform, a.DataFiles, a.Materials, a.CharacteristicCategories, a.UnitCategories, exists((p) => exists((trans) => ProcessTransformation__Equals_30EF9E7B(trans, p), pts), processes) ? map_1((p_1) => { - if (exists((trans_1) => ProcessTransformation__Equals_30EF9E7B(trans_1, p_1), pts)) { - return fold((p_2, trans_2) => ProcessTransformation__Transform_30EF9E7B(trans_2, p_2), p_1, pts); - } - else { - return p_1; - } - }, processes) : append(processes, singleton(fold((p_3, trans_3) => ProcessTransformation__Transform_30EF9E7B(trans_3, p_3), Process_get_empty(), pts))), a.Comments); - } - case 0: - return new Assay(a.ID, this$.fields[0], a.MeasurementType, a.TechnologyType, a.TechnologyPlatform, a.DataFiles, a.Materials, a.CharacteristicCategories, a.UnitCategories, a.ProcessSequence, a.Comments); - default: - return toFail(printf("Builder failed: Case %O Not implemented"))(this$); - } -} - -export function AssayTransformation__Equals_Z269B5B97(this$, a) { - const matchValue = a.FileName; - let matchResult, n_1, n$0027_1; - if (this$.tag === 0) { - if (matchValue != null) { - if (this$.fields[0] === matchValue) { - matchResult = 0; - n_1 = this$.fields[0]; - n$0027_1 = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } -} - -export class StudyTransformation extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["AddParameter", "AddCharacteristic", "AddFactor", "AddProcess", "AddAssay"]; - } -} - -export function StudyTransformation_$reflection() { - return union_type("ISA.Builder.StudyTransformation", [], StudyTransformation, () => [[["Item", ProcessParameterValue_$reflection()]], [["Item", MaterialAttributeValue_$reflection()]], [["Item", FactorValue_$reflection()]], [["Item", list_type(ProcessTransformation_$reflection())]], [["Item", list_type(AssayTransformation_$reflection())]]]); -} - -export function StudyTransformation__Transform_Z27CB2981(this$, s) { - switch (this$.tag) { - case 3: { - const pts = this$.fields[0]; - const processes = defaultArg(s.ProcessSequence, empty()); - return new Study(s.ID, s.FileName, s.Identifier, s.Title, s.Description, s.SubmissionDate, s.PublicReleaseDate, s.Publications, s.Contacts, s.StudyDesignDescriptors, s.Protocols, s.Materials, exists((p) => exists((trans) => ProcessTransformation__Equals_30EF9E7B(trans, p), pts), processes) ? map_1((p_1) => { - if (exists((trans_1) => ProcessTransformation__Equals_30EF9E7B(trans_1, p_1), pts)) { - return fold((p_2, trans_2) => ProcessTransformation__Transform_30EF9E7B(trans_2, p_2), p_1, pts); - } - else { - return p_1; - } - }, processes) : append(processes, singleton(fold((p_3, trans_3) => ProcessTransformation__Transform_30EF9E7B(trans_3, p_3), Process_get_empty(), pts))), s.Assays, s.Factors, s.CharacteristicCategories, s.UnitCategories, s.Comments); - } - case 4: { - const ats = this$.fields[0]; - const assays = defaultArg(s.Assays, empty()); - return new Study(s.ID, s.FileName, s.Identifier, s.Title, s.Description, s.SubmissionDate, s.PublicReleaseDate, s.Publications, s.Contacts, s.StudyDesignDescriptors, s.Protocols, s.Materials, s.ProcessSequence, exists((a) => exists((trans_4) => AssayTransformation__Equals_Z269B5B97(trans_4, a), ats), assays) ? map_1((a_1) => { - if (exists((trans_5) => AssayTransformation__Equals_Z269B5B97(trans_5, a_1), ats)) { - return fold((a_2, trans_6) => AssayTransformation__Transform_Z269B5B97(trans_6, a_2), a_1, ats); - } - else { - return a_1; - } - }, assays) : append(assays, singleton(fold((a_3, trans_7) => AssayTransformation__Transform_Z269B5B97(trans_7, a_3), Assay_get_empty(), ats))), s.Factors, s.CharacteristicCategories, s.UnitCategories, s.Comments); - } - default: - return toFail(printf("Builder failed: Case %O Not implemented"))(this$); - } -} - diff --git a/js/ISA/ISA/Fable.js b/js/ISA/ISA/Fable.js deleted file mode 100644 index 634fe13a..00000000 --- a/js/ISA/ISA/Fable.js +++ /dev/null @@ -1,50 +0,0 @@ -import { toString } from "../../fable_modules/fable-library.4.1.4/Types.js"; -import { append } from "../../fable_modules/fable-library.4.1.4/List.js"; -import { append as append_1 } from "../../fable_modules/fable-library.4.1.4/Array.js"; -import { Array_distinct, List_distinct } from "../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { structuralHash, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; - -export function isMap_generic(l1) { - let copyOfStruct; - return ((copyOfStruct = l1, toString(copyOfStruct))).indexOf("map [") === 0; -} - -export function isList_generic(l1) { - let s; - let copyOfStruct = l1; - s = toString(copyOfStruct); - if (s.indexOf("[") === 0) { - return !(s.indexOf("seq [") === 0); - } - else { - return false; - } -} - -export function append_generic(l1, l2) { - if (l2 == null) { - return l1; - } - else if (isList_generic(l1)) { - return append(l1, l2); - } - else { - return append_1(l1, l2); - } -} - -export function distinct_generic(l1) { - if (isList_generic(l1)) { - return List_distinct(l1, { - Equals: equals, - GetHashCode: structuralHash, - }); - } - else { - return Array_distinct(l1, { - Equals: equals, - GetHashCode: structuralHash, - }); - } -} - diff --git a/js/ISA/ISA/JsonTypes/AnnotationValue.js b/js/ISA/ISA/JsonTypes/AnnotationValue.js deleted file mode 100644 index 70cfba9a..00000000 --- a/js/ISA/ISA/JsonTypes/AnnotationValue.js +++ /dev/null @@ -1,56 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { union_type, int32_type, float64_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { parse } from "../../../fable_modules/fable-library.4.1.4/Double.js"; -import { parse as parse_1 } from "../../../fable_modules/fable-library.4.1.4/Int32.js"; -import { int32ToString } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -export class AnnotationValue extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Text", "Float", "Int"]; - } -} - -export function AnnotationValue_$reflection() { - return union_type("ISA.AnnotationValue", [], AnnotationValue, () => [[["Item", string_type]], [["Item", float64_type]], [["Item", int32_type]]]); -} - -export function AnnotationValue_get_empty() { - return new AnnotationValue(0, [""]); -} - -/** - * Create a ISAJson Annotation value from a ISATab string entry - */ -export function AnnotationValue_fromString_Z721C83C5(s) { - try { - return new AnnotationValue(2, [parse_1(s, 511, false, 32)]); - } - catch (matchValue) { - try { - return new AnnotationValue(1, [parse(s)]); - } - catch (matchValue_1) { - return new AnnotationValue(0, [s]); - } - } -} - -/** - * Get a ISATab string Annotation Name from a ISAJson object - */ -export function AnnotationValue_toString_Z3C00A204(v) { - switch (v.tag) { - case 2: - return int32ToString(v.fields[0]); - case 1: - return v.fields[0].toString(); - default: - return v.fields[0]; - } -} - diff --git a/js/ISA/ISA/JsonTypes/Assay.js b/js/ISA/ISA/JsonTypes/Assay.js deleted file mode 100644 index 3fc62189..00000000 --- a/js/ISA/ISA/JsonTypes/Assay.js +++ /dev/null @@ -1,621 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { Data_$reflection } from "./Data.js"; -import { AssayMaterials_get_empty, AssayMaterials_make, AssayMaterials_$reflection } from "./AssayMaterials.js"; -import { MaterialAttribute_$reflection } from "./MaterialAttribute.js"; -import { Process_$reflection } from "./Process.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { empty, filter, map, singleton, append, exists, tryFind } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { safeHash, structuralHash, equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map2 as map2_2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Dict_tryFind, Dict_ofSeqWithMerge, Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { fromValueWithDefault, mapDefault } from "../OptionExtensions.js"; -import { updateProtocols, getProtocols, getFactors, getOutputsWithFactorBy, getOutputsWithCharacteristicBy, getInputsWithCharacteristicBy, getParameters, getOutputsWithParameterBy, getInputsWithParameterBy, getMaterials, getSamples, getSources, getCharacteristics, getUnits, getData } from "./ProcessSequence.js"; -import { map as map_1, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { Update_UpdateOptions } from "../Update.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { Sample_$reflection } from "./Sample.js"; -import { Material_$reflection } from "./Material.js"; -import { toFail } from "../../../fable_modules/fable-library.4.1.4/String.js"; - -export class Assay extends Record { - constructor(ID, FileName, MeasurementType, TechnologyType, TechnologyPlatform, DataFiles, Materials, CharacteristicCategories, UnitCategories, ProcessSequence, Comments) { - super(); - this.ID = ID; - this.FileName = FileName; - this.MeasurementType = MeasurementType; - this.TechnologyType = TechnologyType; - this.TechnologyPlatform = TechnologyPlatform; - this.DataFiles = DataFiles; - this.Materials = Materials; - this.CharacteristicCategories = CharacteristicCategories; - this.UnitCategories = UnitCategories; - this.ProcessSequence = ProcessSequence; - this.Comments = Comments; - } -} - -export function Assay_$reflection() { - return record_type("ISA.Assay", [], Assay, () => [["ID", option_type(string_type)], ["FileName", option_type(string_type)], ["MeasurementType", option_type(OntologyAnnotation_$reflection())], ["TechnologyType", option_type(OntologyAnnotation_$reflection())], ["TechnologyPlatform", option_type(string_type)], ["DataFiles", option_type(list_type(Data_$reflection()))], ["Materials", option_type(AssayMaterials_$reflection())], ["CharacteristicCategories", option_type(list_type(MaterialAttribute_$reflection()))], ["UnitCategories", option_type(list_type(OntologyAnnotation_$reflection()))], ["ProcessSequence", option_type(list_type(Process_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Assay_make(id, fileName, measurementType, technologyType, technologyPlatform, dataFiles, materials, characteristicCategories, unitCategories, processSequence, comments) { - return new Assay(id, fileName, measurementType, technologyType, technologyPlatform, dataFiles, materials, characteristicCategories, unitCategories, processSequence, comments); -} - -export function Assay_create_ABF59A4(Id, FileName, MeasurementType, TechnologyType, TechnologyPlatform, DataFiles, Materials, CharacteristicCategories, UnitCategories, ProcessSequence, Comments) { - return Assay_make(Id, FileName, MeasurementType, TechnologyType, TechnologyPlatform, DataFiles, Materials, CharacteristicCategories, UnitCategories, ProcessSequence, Comments); -} - -export function Assay_get_empty() { - return Assay_create_ABF59A4(); -} - -/** - * If an assay with the given identfier exists in the list, returns it - */ -export function Assay_tryGetByFileName(fileName, assays) { - return tryFind((a) => equals(a.FileName, fileName), assays); -} - -/** - * If an assay with the given identfier exists in the list, returns true - */ -export function Assay_existsByFileName(fileName, assays) { - return exists((a) => equals(a.FileName, fileName), assays); -} - -/** - * Adds the given assay to the assays - */ -export function Assay_add(assays, assay) { - return append(assays, singleton(assay)); -} - -/** - * Updates all assays for which the predicate returns true with the given assays values - */ -export function Assay_updateBy(predicate, updateOption, assay, assays) { - if (exists(predicate, assays)) { - return map((a) => { - if (predicate(a)) { - const this$ = updateOption; - const recordType_1 = a; - const recordType_2 = assay; - switch (this$.tag) { - case 2: - return makeRecord(Assay_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Assay_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Assay_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - } - else { - return a; - } - }, assays); - } - else { - return assays; - } -} - -/** - * If an assay with the same fileName as the given assay exists in the study exists, updates it with the given assay values - */ -export function Assay_updateByFileName(updateOption, assay, assays) { - return Assay_updateBy((a) => equals(a.FileName, assay.FileName), updateOption, assay, assays); -} - -/** - * Updates all assays with the same name as the given assay with its values - */ -export function Assay_removeByFileName(fileName, assays) { - return filter((a) => !equals(a.FileName, fileName), assays); -} - -/** - * Returns comments of an assay - */ -export function Assay_getComments_Z269B5B97(assay) { - return assay.Comments; -} - -/** - * Applies function f on comments of an assay - */ -export function Assay_mapComments(f, assay) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, mapDefault(empty(), f, assay.Comments)); -} - -/** - * Replaces comments of an assay by given comment list - */ -export function Assay_setComments(assay, comments) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, comments); -} - -/** - * Returns data files of an assay - */ -export function Assay_getData_Z269B5B97(assay) { - const processSequenceData = getData(defaultArg(assay.ProcessSequence, empty())); - const updateOptions = new Update_UpdateOptions(3, []); - const mapping = (d) => d.Name; - const list1 = defaultArg(assay.DataFiles, empty()); - const list2 = processSequenceData; - try { - const map1 = Dict_ofSeqWithMerge((arg, arg_1) => { - const this$ = updateOptions; - const recordType_1 = arg; - const recordType_2 = arg_1; - switch (this$.tag) { - case 2: - return makeRecord(Data_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - }, map((v) => [mapping(v), v], list1)); - const map2 = Dict_ofSeqWithMerge((arg_2, arg_3) => { - const this$_1 = updateOptions; - const recordType_1_1 = arg_2; - const recordType_2_1 = arg_3; - switch (this$_1.tag) { - case 2: - return makeRecord(Data_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 1: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 3: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - default: - return recordType_2_1; - } - }, map((v_1) => [mapping(v_1), v_1], list2)); - return map((k) => { - const matchValue = Dict_tryFind(k, map1); - const matchValue_1 = Dict_tryFind(k, map2); - if (matchValue == null) { - if (matchValue_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1 = matchValue_1; - return v2_1; - } - } - else if (matchValue_1 == null) { - const v1_1 = matchValue; - return v1_1; - } - else { - const v1 = matchValue; - const v2 = matchValue_1; - const this$_2 = updateOptions; - const recordType_1_2 = v1; - const recordType_2_2 = v2; - switch (this$_2.tag) { - case 2: - return makeRecord(Data_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 1: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 3: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - default: - return recordType_2_2; - } - } - }, List_distinct(append(map(mapping, list1), map(mapping, list2)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err) { - throw new Error(`Could not mergeUpdate ${"Data"} list: -${err.message}`); - } -} - -/** - * Applies function f on data files of an assay - */ -export function Assay_mapData(f, assay) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, mapDefault(empty(), f, assay.DataFiles), assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces data files of an assay by given data file list - */ -export function Assay_setData(assay, dataFiles) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, dataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns unit categories of an assay - */ -export function Assay_getUnitCategories_Z269B5B97(assay) { - return List_distinct(append(getUnits(defaultArg(assay.ProcessSequence, empty())), defaultArg(assay.UnitCategories, empty())), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Applies function f on unit categories of an assay - */ -export function Assay_mapUnitCategories(f, assay) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, mapDefault(empty(), f, assay.UnitCategories), assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces unit categories of an assay by given unit categorie list - */ -export function Assay_setUnitCategories(assay, unitCategories) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, unitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns characteristic categories of an assay - */ -export function Assay_getCharacteristics_Z269B5B97(assay) { - return List_distinct(append(getCharacteristics(defaultArg(assay.ProcessSequence, empty())), defaultArg(assay.CharacteristicCategories, empty())), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Applies function f on characteristic categories of an assay - */ -export function Assay_mapCharacteristics(f, assay) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, mapDefault(empty(), f, assay.CharacteristicCategories), assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces characteristic categories of an assay by given characteristic categorie list - */ -export function Assay_setCharacteristics(assay, characteristics) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, characteristics, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns measurement type of an assay - */ -export function Assay_getMeasurementType_Z269B5B97(assay) { - return assay.MeasurementType; -} - -/** - * Applies function f on measurement type of an assay - */ -export function Assay_mapMeasurementType(f, assay) { - return new Assay(assay.ID, assay.FileName, map_1(f, assay.MeasurementType), assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces measurement type of an assay by given measurement type - */ -export function Assay_setMeasurementType(assay, measurementType) { - return new Assay(assay.ID, assay.FileName, measurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns technology type of an assay - */ -export function Assay_getTechnologyType_Z269B5B97(assay) { - return assay.TechnologyType; -} - -/** - * Applies function f on technology type of an assay - */ -export function Assay_mapTechnologyType(f, assay) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, map_1(f, assay.TechnologyType), assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces technology type of an assay by given technology type - */ -export function Assay_setTechnologyType(assay, technologyType) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, technologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns processes of an assay - */ -export function Assay_getProcesses_Z269B5B97(assay) { - return defaultArg(assay.ProcessSequence, empty()); -} - -/** - * Applies function f on processes of an assay - */ -export function Assay_mapProcesses(f, assay) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, mapDefault(empty(), f, assay.ProcessSequence), assay.Comments); -} - -/** - * Replaces processes of an assay by given processe list - */ -export function Assay_setProcesses(assay, processes) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, processes, assay.Comments); -} - -export function Assay_getSources_Z269B5B97(assay) { - return getSources(Assay_getProcesses_Z269B5B97(assay)); -} - -export function Assay_getSamples_Z269B5B97(assay) { - return getSamples(Assay_getProcesses_Z269B5B97(assay)); -} - -/** - * Returns materials of an assay - */ -export function Assay_getMaterials_Z269B5B97(assay) { - const processSequenceMaterials = getMaterials(defaultArg(assay.ProcessSequence, empty())); - const processSequenceSamples = getSamples(defaultArg(assay.ProcessSequence, empty())); - const matchValue = assay.Materials; - if (matchValue == null) { - return AssayMaterials_make(fromValueWithDefault(empty(), processSequenceSamples), fromValueWithDefault(empty(), processSequenceMaterials)); - } - else { - const mat = matchValue; - let samples; - const updateOptions = new Update_UpdateOptions(3, []); - const mapping = (s) => s.Name; - const list1 = defaultArg(mat.Samples, empty()); - const list2 = processSequenceSamples; - try { - const map1 = Dict_ofSeqWithMerge((arg, arg_1) => { - const this$ = updateOptions; - const recordType_1 = arg; - const recordType_2 = arg_1; - switch (this$.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - }, map((v) => [mapping(v), v], list1)); - const map2 = Dict_ofSeqWithMerge((arg_2, arg_3) => { - const this$_1 = updateOptions; - const recordType_1_1 = arg_2; - const recordType_2_1 = arg_3; - switch (this$_1.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - default: - return recordType_2_1; - } - }, map((v_1) => [mapping(v_1), v_1], list2)); - samples = map((k) => { - const matchValue_1 = Dict_tryFind(k, map1); - const matchValue_1_1 = Dict_tryFind(k, map2); - if (matchValue_1 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1 = matchValue_1_1; - return v2_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1 = matchValue_1; - return v1_1; - } - else { - const v1 = matchValue_1; - const v2 = matchValue_1_1; - const this$_2 = updateOptions; - const recordType_1_2 = v1; - const recordType_2_2 = v2; - switch (this$_2.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - default: - return recordType_2_2; - } - } - }, List_distinct(append(map(mapping, list1), map(mapping, list2)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err) { - throw new Error(`Could not mergeUpdate ${"Sample"} list: -${err.message}`); - } - let materials; - const updateOptions_1 = new Update_UpdateOptions(3, []); - const mapping_5 = (m) => m.Name; - const list1_1 = defaultArg(mat.OtherMaterials, empty()); - const list2_1 = processSequenceMaterials; - try { - const map1_1 = Dict_ofSeqWithMerge((arg_6, arg_1_1) => { - const this$_3 = updateOptions_1; - const recordType_1_3 = arg_6; - const recordType_2_3 = arg_1_1; - switch (this$_3.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - default: - return recordType_2_3; - } - }, map((v_2) => [mapping_5(v_2), v_2], list1_1)); - const map2_1 = Dict_ofSeqWithMerge((arg_2_1, arg_3_1) => { - const this$_4 = updateOptions_1; - const recordType_1_4 = arg_2_1; - const recordType_2_4 = arg_3_1; - switch (this$_4.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - default: - return recordType_2_4; - } - }, map((v_1_1) => [mapping_5(v_1_1), v_1_1], list2_1)); - materials = map((k_1) => { - const matchValue_3 = Dict_tryFind(k_1, map1_1); - const matchValue_1_2 = Dict_tryFind(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_2 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1 = matchValue_1_2; - return v2_1_1; - } - } - else if (matchValue_1_2 == null) { - const v1_1_1 = matchValue_3; - return v1_1_1; - } - else { - const v1_2 = matchValue_3; - const v2_2 = matchValue_1_2; - const this$_5 = updateOptions_1; - const recordType_1_5 = v1_2; - const recordType_2_5 = v2_2; - switch (this$_5.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - default: - return recordType_2_5; - } - } - }, List_distinct(append(map(mapping_5, list1_1), map(mapping_5, list2_1)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err_1) { - throw new Error(`Could not mergeUpdate ${"Material"} list: -${err_1.message}`); - } - return AssayMaterials_make(fromValueWithDefault(empty(), samples), fromValueWithDefault(empty(), materials)); - } -} - -/** - * Applies function f on materials of an assay - */ -export function Assay_mapMaterials(f, assay) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, map_1(f, assay.Materials), assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces materials of an assay by given assay materials - */ -export function Assay_setMaterials(assay, materials) { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * If the assay contains a process implementing the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function Assay_getInputsWithParameterBy(predicate, assay) { - return map_1((processSequence) => getInputsWithParameterBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * If the assay contains a process implementing the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function Assay_getOutputsWithParameterBy(predicate, assay) { - return map_1((processSequence) => getOutputsWithParameterBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * Returns the parameters implemented by the processes contained in this assay - */ -export function Assay_getParameters_Z269B5B97(assay) { - return map_1(getParameters, assay.ProcessSequence); -} - -/** - * If the assay contains a process implementing the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function Assay_getInputsWithCharacteristicBy(predicate, assay) { - return map_1((processSequence) => getInputsWithCharacteristicBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * If the assay contains a process implementing the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function Assay_getOutputsWithCharacteristicBy(predicate, assay) { - return map_1((processSequence) => getOutputsWithCharacteristicBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * If the assay contains a process implementing the given factor, return the list of output files together with their according factor values of this factor - */ -export function Assay_getOutputsWithFactorBy(predicate, assay) { - return map_1((processSequence) => getOutputsWithFactorBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * Returns the factors implemented by the processes contained in this assay - */ -export function Assay_getFactors_Z269B5B97(assay) { - return getFactors(defaultArg(assay.ProcessSequence, empty())); -} - -/** - * Returns the protocols implemented by the processes contained in this assay - */ -export function Assay_getProtocols_Z269B5B97(assay) { - return getProtocols(defaultArg(assay.ProcessSequence, empty())); -} - -export function Assay_update_Z269B5B97(assay) { - let v_1; - try { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, fromValueWithDefault(empty(), Assay_getData_Z269B5B97(assay)), (v_1 = Assay_getMaterials_Z269B5B97(assay), fromValueWithDefault(AssayMaterials_get_empty(), v_1)), fromValueWithDefault(empty(), Assay_getCharacteristics_Z269B5B97(assay)), fromValueWithDefault(empty(), Assay_getUnitCategories_Z269B5B97(assay)), assay.ProcessSequence, assay.Comments); - } - catch (err) { - return toFail(`Could not update assay ${assay.FileName}: -${err.message}`); - } -} - -export function Assay_updateProtocols(protocols, assay) { - try { - return Assay_mapProcesses((processSequence) => updateProtocols(protocols, processSequence), assay); - } - catch (err) { - return toFail(`Could not update assay protocols ${assay.FileName}: -${err.message}`); - } -} - diff --git a/js/ISA/ISA/JsonTypes/AssayMaterials.js b/js/ISA/ISA/JsonTypes/AssayMaterials.js deleted file mode 100644 index d75808c9..00000000 --- a/js/ISA/ISA/JsonTypes/AssayMaterials.js +++ /dev/null @@ -1,39 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { Sample_$reflection } from "./Sample.js"; -import { record_type, option_type, list_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Material_$reflection } from "./Material.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { empty } from "../../../fable_modules/fable-library.4.1.4/List.js"; - -export class AssayMaterials extends Record { - constructor(Samples, OtherMaterials) { - super(); - this.Samples = Samples; - this.OtherMaterials = OtherMaterials; - } -} - -export function AssayMaterials_$reflection() { - return record_type("ISA.AssayMaterials", [], AssayMaterials, () => [["Samples", option_type(list_type(Sample_$reflection()))], ["OtherMaterials", option_type(list_type(Material_$reflection()))]]); -} - -export function AssayMaterials_make(samples, otherMaterials) { - return new AssayMaterials(samples, otherMaterials); -} - -export function AssayMaterials_create_1CB3546D(Samples, OtherMaterials) { - return AssayMaterials_make(Samples, OtherMaterials); -} - -export function AssayMaterials_get_empty() { - return AssayMaterials_create_1CB3546D(); -} - -export function AssayMaterials_getMaterials_E3447B1(am) { - return defaultArg(am.OtherMaterials, empty()); -} - -export function AssayMaterials_getSamples_E3447B1(am) { - return defaultArg(am.Samples, empty()); -} - diff --git a/js/ISA/ISA/JsonTypes/ColumnIndex.js b/js/ISA/ISA/JsonTypes/ColumnIndex.js deleted file mode 100644 index 5747441b..00000000 --- a/js/ISA/ISA/JsonTypes/ColumnIndex.js +++ /dev/null @@ -1,245 +0,0 @@ -import { tryParse } from "../../../fable_modules/fable-library.4.1.4/Int32.js"; -import { FSharpRef } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { Comment_fromString } from "./Comment.js"; -import { int32ToString } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { value, bind } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { tryItem } from "./CommentList.js"; -import { cons, singleton } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; -import { Factor_fromString_Z5D76503E } from "./Factor.js"; -import { MaterialAttribute_fromString_703AFBF9 } from "./MaterialAttribute.js"; -import { ProtocolParameter_fromString_703AFBF9 } from "./ProtocolParameter.js"; -import { Component_fromString_55205B02 } from "./Component.js"; - -function tryInt(str) { - let matchValue; - let outArg = 0; - matchValue = [tryParse(str, 511, false, 32, new FSharpRef(() => outArg, (v) => { - outArg = (v | 0); - })), outArg]; - if (matchValue[0]) { - return matchValue[1]; - } - else { - return void 0; - } -} - -export const orderName = "ColumnIndex"; - -export function createOrderComment(index) { - return Comment_fromString(orderName, int32ToString(index)); -} - -export function tryGetIndex(comments) { - return bind(tryInt, tryItem(orderName, comments)); -} - -export function setOntologyAnnotationIndex(i, oa) { - let matchValue, cs; - return new OntologyAnnotation(oa.ID, oa.Name, oa.TermSourceREF, oa.LocalID, oa.TermAccessionNumber, (matchValue = oa.Comments, (matchValue == null) ? singleton(createOrderComment(i)) : ((cs = matchValue, cons(createOrderComment(i), cs))))); -} - -export function tryGetOntologyAnnotationIndex(oa) { - return bind(tryGetIndex, oa.Comments); -} - -export function tryGetParameterIndex(param) { - return bind((oa) => bind(tryGetIndex, oa.Comments), param.ParameterName); -} - -export function tryGetParameterColumnIndex(paramValue) { - return bind(tryGetParameterIndex, paramValue.Category); -} - -export function tryGetFactorIndex(factor) { - return bind((oa) => bind(tryGetIndex, oa.Comments), factor.FactorType); -} - -export function tryGetFactorColumnIndex(factorValue) { - return bind(tryGetFactorIndex, factorValue.Category); -} - -export function tryGetCharacteristicIndex(characteristic) { - return bind((oa) => bind(tryGetIndex, oa.Comments), characteristic.CharacteristicType); -} - -export function tryGetCharacteristicColumnIndex(characteristicValue) { - return bind(tryGetCharacteristicIndex, characteristicValue.Category); -} - -export function tryGetComponentIndex(comp) { - return bind((oa) => bind(tryGetIndex, oa.Comments), comp.ComponentType); -} - -/** - * Create a ISAJson Factor from ISATab string entries - */ -export function ISA_OntologyAnnotation__OntologyAnnotation_fromStringWithColumnIndex_Static(name, term, source, accession, valueIndex) { - return Factor_fromString_Z5D76503E(name, term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_getColumnIndex_Static_2FC95D30(f) { - return value(tryGetOntologyAnnotationIndex(f)); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_GetColumnIndex(this$) { - return value(tryGetOntologyAnnotationIndex(this$)); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_tryGetColumnIndex_Static_2FC95D30(f) { - return tryGetOntologyAnnotationIndex(f); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_TryGetColumnIndex(this$) { - return tryGetOntologyAnnotationIndex(this$); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_setColumnIndex_Static(i, oa) { - return setOntologyAnnotationIndex(i, oa); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(this$, i) { - return setOntologyAnnotationIndex(i, this$); -} - -/** - * Create a ISAJson Factor from ISATab string entries - */ -export function ISA_Factor__Factor_fromStringWithColumnIndex_Static(name, term, source, accession, valueIndex) { - return Factor_fromString_Z5D76503E(name, term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_Factor__Factor_getColumnIndex_Static_E353FDD(f) { - return value(tryGetFactorIndex(f)); -} - -export function ISA_Factor__Factor_GetColumnIndex(this$) { - return value(tryGetFactorIndex(this$)); -} - -export function ISA_Factor__Factor_tryGetColumnIndex_Static_E353FDD(f) { - return tryGetFactorIndex(f); -} - -export function ISA_Factor__Factor_TryGetColumnIndex(this$) { - return tryGetFactorIndex(this$); -} - -export function ISA_FactorValue__FactorValue_getColumnIndex_Static_2A4175B6(f) { - return value(tryGetFactorColumnIndex(f)); -} - -export function ISA_FactorValue__FactorValue_GetColumnIndex(this$) { - return value(tryGetFactorColumnIndex(this$)); -} - -export function ISA_FactorValue__FactorValue_tryGetColumnIndex_Static_2A4175B6(f) { - return tryGetFactorColumnIndex(f); -} - -export function ISA_FactorValue__FactorValue_TryGetColumnIndex(this$) { - return tryGetFactorColumnIndex(this$); -} - -/** - * Create a ISAJson characteristic from ISATab string entries - */ -export function ISA_MaterialAttribute__MaterialAttribute_fromStringWithColumnIndex_Static(term, source, accession, valueIndex) { - return MaterialAttribute_fromString_703AFBF9(term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_MaterialAttribute__MaterialAttribute_getColumnIndex_Static_Z6476E859(m) { - return value(tryGetCharacteristicIndex(m)); -} - -export function ISA_MaterialAttribute__MaterialAttribute_GetColumnIndex(this$) { - return value(tryGetCharacteristicIndex(this$)); -} - -export function ISA_MaterialAttribute__MaterialAttribute_tryGetColumnIndex_Static_Z6476E859(m) { - return tryGetCharacteristicIndex(m); -} - -export function ISA_MaterialAttribute__MaterialAttribute_TryGetColumnIndex(this$) { - return tryGetCharacteristicIndex(this$); -} - -export function ISA_MaterialAttributeValue__MaterialAttributeValue_getColumnIndex_Static_6A64994C(m) { - return value(tryGetCharacteristicColumnIndex(m)); -} - -export function ISA_MaterialAttributeValue__MaterialAttributeValue_GetColumnIndex(this$) { - return value(tryGetCharacteristicColumnIndex(this$)); -} - -export function ISA_MaterialAttributeValue__MaterialAttributeValue_tryGetColumnIndex_Static_6A64994C(m) { - return tryGetCharacteristicColumnIndex(m); -} - -export function ISA_MaterialAttributeValue__MaterialAttributeValue_TryGetColumnIndex(this$) { - return tryGetCharacteristicColumnIndex(this$); -} - -/** - * Create a ISAJson parameter from ISATab string entries - */ -export function ISA_ProtocolParameter__ProtocolParameter_fromStringWithColumnIndex_Static(term, source, accession, valueIndex) { - return ProtocolParameter_fromString_703AFBF9(term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_ProtocolParameter__ProtocolParameter_getColumnIndex_Static_2762A46F(p) { - return value(tryGetParameterIndex(p)); -} - -export function ISA_ProtocolParameter__ProtocolParameter_GetColumnIndex(this$) { - return value(tryGetParameterIndex(this$)); -} - -export function ISA_ProtocolParameter__ProtocolParameter_tryGetColumnIndex_Static_2762A46F(p) { - return tryGetParameterIndex(p); -} - -export function ISA_ProtocolParameter__ProtocolParameter_TryGetColumnIndex(this$) { - return tryGetParameterIndex(this$); -} - -export function ISA_ProcessParameterValue__ProcessParameterValue_getColumnIndex_Static_39585819(p) { - return value(tryGetParameterColumnIndex(p)); -} - -export function ISA_ProcessParameterValue__ProcessParameterValue_GetColumnIndex(this$) { - return value(tryGetParameterColumnIndex(this$)); -} - -export function ISA_ProcessParameterValue__ProcessParameterValue_tryGetColumnIndex_Static_39585819(p) { - return tryGetParameterColumnIndex(p); -} - -export function ISA_ProcessParameterValue__ProcessParameterValue_TryGetColumnIndex(this$) { - return tryGetParameterColumnIndex(this$); -} - -/** - * Create a ISAJson Factor from ISATab string entries - */ -export function ISA_Component__Component_fromStringWithColumnIndex_Static(name, term, source, accession, valueIndex) { - return Component_fromString_55205B02(name, term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_Component__Component_getColumnIndex_Static_Z7E9B32A1(f) { - return value(tryGetComponentIndex(f)); -} - -export function ISA_Component__Component_GetColumnIndex(this$) { - return value(tryGetComponentIndex(this$)); -} - -export function ISA_Component__Component_tryGetColumnIndex_Static_Z7E9B32A1(f) { - return tryGetComponentIndex(f); -} - -export function ISA_Component__Component_TryGetColumnIndex(this$) { - return tryGetComponentIndex(this$); -} - diff --git a/js/ISA/ISA/JsonTypes/Comment.js b/js/ISA/ISA/JsonTypes/Comment.js deleted file mode 100644 index a14a944c..00000000 --- a/js/ISA/ISA/JsonTypes/Comment.js +++ /dev/null @@ -1,57 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { int32_type, record_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; - -export class Comment$ extends Record { - constructor(ID, Name, Value) { - super(); - this.ID = ID; - this.Name = Name; - this.Value = Value; - } -} - -export function Comment$_$reflection() { - return record_type("ISA.Comment", [], Comment$, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["Value", option_type(string_type)]]); -} - -export function Comment_make(id, name, value) { - return new Comment$(id, name, value); -} - -export function Comment_create_250E0578(Id, Name, Value) { - return Comment_make(Id, Name, Value); -} - -export function Comment_fromString(name, value) { - return Comment_create_250E0578(void 0, name, value); -} - -export function Comment_toString_6AAB8F23(comment) { - return [defaultArg(comment.Name, ""), defaultArg(comment.Value, "")]; -} - -export class Remark extends Record { - constructor(Line, Value) { - super(); - this.Line = (Line | 0); - this.Value = Value; - } -} - -export function Remark_$reflection() { - return record_type("ISA.Remark", [], Remark, () => [["Line", int32_type], ["Value", string_type]]); -} - -export function Remark_make(line, value) { - return new Remark(line, value); -} - -export function Remark_create_Z176EF219(line, value) { - return Remark_make(line, value); -} - -export function Remark_toTuple_Z2023CF4E(remark) { - return [remark.Line, remark.Value]; -} - diff --git a/js/ISA/ISA/JsonTypes/CommentList.js b/js/ISA/ISA/JsonTypes/CommentList.js deleted file mode 100644 index 8ddda26b..00000000 --- a/js/ISA/ISA/JsonTypes/CommentList.js +++ /dev/null @@ -1,139 +0,0 @@ -import { filter, map, singleton, append, choose, exists, tryPick } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { value } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { ofList } from "../../../fable_modules/fable-library.4.1.4/Map.js"; -import { equals, comparePrimitives } from "../../../fable_modules/fable-library.4.1.4/Util.js"; - -/** - * If a comment with the given key exists in the list, return its value, else return None - */ -export function tryItem(key, comments) { - return tryPick((c) => { - const matchValue = c.Name; - let matchResult, n_1; - if (matchValue != null) { - if (matchValue === key) { - matchResult = 0; - n_1 = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return c.Value; - default: - return void 0; - } - }, comments); -} - -/** - * Returns true, if the key exists in the list - */ -export function containsKey(key, comments) { - return exists((c) => { - const matchValue = c.Name; - let matchResult, n_1; - if (matchValue != null) { - if (matchValue === key) { - matchResult = 0; - n_1 = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } - }, comments); -} - -/** - * If a comment with the given key exists in the list, return its value - */ -export function item(key, comments) { - return value(tryItem(key, comments)); -} - -/** - * Create a map of comment keys to comment values - */ -export function toMap(comments) { - return ofList(choose((c) => { - const matchValue = c.Name; - if (matchValue != null) { - return [matchValue, c.Value]; - } - else { - return void 0; - } - }, comments), { - Compare: comparePrimitives, - }); -} - -/** - * Adds the given comment to the comment list - */ -export function add(comment, comments) { - return append(comments, singleton(comment)); -} - -/** - * Add the given comment to the comment list if it doesnt exist, else replace it - */ -export function set$(comment, comments) { - if (containsKey(value(comment.Name), comments)) { - return map((c) => { - if (equals(c.Name, comment.Name)) { - return comment; - } - else { - return c; - } - }, comments); - } - else { - return append(comments, singleton(comment)); - } -} - -/** - * Returns a new comment list where comments with the given key are filtered out - */ -export function dropByKey(key, comments) { - return filter((c) => { - const matchValue = c.Name; - let matchResult, n_1; - if (matchValue != null) { - if (matchValue === key) { - matchResult = 0; - n_1 = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return false; - default: - return true; - } - }, comments); -} - diff --git a/js/ISA/ISA/JsonTypes/Component.js b/js/ISA/ISA/JsonTypes/Component.js deleted file mode 100644 index f7daaca5..00000000 --- a/js/ISA/ISA/JsonTypes/Component.js +++ /dev/null @@ -1,154 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { record_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Value as Value_1, Value_fromString_Z721C83C5, Value__get_Text, Value_$reflection } from "./Value.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation, OntologyAnnotation_fromTermAnnotation_Z721C83C5, OntologyAnnotation__get_TermAccessionShort, OntologyAnnotation__get_NameText, OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { create, match } from "../../../fable_modules/fable-library.4.1.4/RegExp.js"; -import { AnnotationValue } from "./AnnotationValue.js"; -import { map, defaultArg, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; - -export class Component extends Record { - constructor(ComponentName, ComponentValue, ComponentUnit, ComponentType) { - super(); - this.ComponentName = ComponentName; - this.ComponentValue = ComponentValue; - this.ComponentUnit = ComponentUnit; - this.ComponentType = ComponentType; - } -} - -export function Component_$reflection() { - return record_type("ISA.Component", [], Component, () => [["ComponentName", option_type(string_type)], ["ComponentValue", option_type(Value_$reflection())], ["ComponentUnit", option_type(OntologyAnnotation_$reflection())], ["ComponentType", option_type(OntologyAnnotation_$reflection())]]); -} - -export function Component_make(name, value, unit, componentType) { - return new Component(name, value, unit, componentType); -} - -export function Component_create_Z33AADEE0(Name, Value, Unit, ComponentType) { - return Component_make(Name, Value, Unit, ComponentType); -} - -export function Component_get_empty() { - return Component_create_Z33AADEE0(); -} - -/** - * This function creates a string containing full isa term triplet information about the component - * - * Components do not have enough fields in ISA-JSON to include all existing ontology term information. - * This function allows us, to add the same information as `Parameter`, `Characteristics`.., to `Component`. - * Without this string composition we loose the ontology information for the header value. - */ -export function Component_composeName(value, unit) { - if (value == null) { - return ""; - } - else if (value.tag === 0) { - const oa = value.fields[0]; - return `${OntologyAnnotation__get_NameText(oa)} (${OntologyAnnotation__get_TermAccessionShort(oa)})`; - } - else if (unit != null) { - const u = unit; - const v_1 = value; - return `${Value__get_Text(v_1)} ${OntologyAnnotation__get_NameText(u)} (${OntologyAnnotation__get_TermAccessionShort(u)})`; - } - else { - const v = value; - return `${Value__get_Text(v)}`; - } -} - -/** - * This function parses the given Component header string format into the ISA-JSON Component type - * - * Components do not have enough fields in ISA-JSON to include all existing ontology term information. - * This function allows us, to add the same information as `Parameter`, `Characteristics`.., to `Component`. - * Without this string composition we loose the ontology information for the header value. - */ -export function Component_decomposeName_Z721C83C5(name) { - const r = match(create("(?[^\\(]+) \\((?[^(]*:[^)]*)\\)"), name); - const unitr = match(create("(?[\\d\\.]+) (?.+) \\((?[^(]*:[^)]*)\\)"), name); - if (unitr != null) { - const oa = OntologyAnnotation_fromTermAnnotation_Z721C83C5((unitr.groups && unitr.groups.ontology) || ""); - return [Value_fromString_Z721C83C5((unitr.groups && unitr.groups.value) || ""), new OntologyAnnotation(oa.ID, new AnnotationValue(0, [(unitr.groups && unitr.groups.unit) || ""]), oa.TermSourceREF, oa.LocalID, oa.TermAccessionNumber, oa.Comments)]; - } - else if (r != null) { - const oa_1 = OntologyAnnotation_fromTermAnnotation_Z721C83C5((r.groups && r.groups.ontology) || ""); - return [new Value_1(0, [new OntologyAnnotation(oa_1.ID, new AnnotationValue(0, [Value__get_Text(Value_fromString_Z721C83C5((r.groups && r.groups.value) || ""))]), oa_1.TermSourceREF, oa_1.LocalID, oa_1.TermAccessionNumber, oa_1.Comments)]), void 0]; - } - else { - return [new Value_1(3, [name]), void 0]; - } -} - -/** - * Create a ISAJson Component from ISATab string entries - */ -export function Component_fromString_55205B02(name, term, source, accession, comments) { - let cType; - const v = OntologyAnnotation_fromString_Z7D8EB286(unwrap(term), unwrap(source), unwrap(accession), unwrap(comments)); - cType = fromValueWithDefault(OntologyAnnotation_get_empty(), v); - if (name == null) { - return Component_make(void 0, void 0, void 0, cType); - } - else { - const patternInput = Component_decomposeName_Z721C83C5(name); - return Component_make(name, fromValueWithDefault(new Value_1(3, [""]), patternInput[0]), patternInput[1], cType); - } -} - -export function Component_fromOptions(value, unit, header) { - return Component_make(fromValueWithDefault("", Component_composeName(value, unit)), value, unit, header); -} - -/** - * Get ISATab string entries from an ISAJson Component object - */ -export function Component_toString_Z7E9B32A1(c) { - let oa; - const value = { - TermAccessionNumber: "", - TermName: "", - TermSourceREF: "", - }; - oa = defaultArg(map(OntologyAnnotation_toString_473B9D79, c.ComponentType), value); - return [defaultArg(c.ComponentName, ""), oa]; -} - -export function Component__get_NameText(this$) { - return defaultArg(map(OntologyAnnotation__get_NameText, this$.ComponentType), ""); -} - -/** - * Returns the ontology of the category of the Value as string - */ -export function Component__get_UnitText(this$) { - return defaultArg(map(OntologyAnnotation__get_NameText, this$.ComponentUnit), ""); -} - -export function Component__get_ValueText(this$) { - return defaultArg(map(Value__get_Text, this$.ComponentValue), ""); -} - -export function Component__get_ValueWithUnitText(this$) { - const unit = map(OntologyAnnotation__get_NameText, this$.ComponentUnit); - const v = Component__get_ValueText(this$); - if (unit == null) { - return v; - } - else { - const u = unit; - return toText(printf("%s %s"))(v)(u); - } -} - -export function Component__MapCategory_65D42856(this$, f) { - return new Component(this$.ComponentName, this$.ComponentValue, this$.ComponentUnit, map(f, this$.ComponentType)); -} - -export function Component__SetCategory_2FC95D30(this$, c) { - return new Component(this$.ComponentName, this$.ComponentValue, this$.ComponentUnit, c); -} - diff --git a/js/ISA/ISA/JsonTypes/Data.js b/js/ISA/ISA/JsonTypes/Data.js deleted file mode 100644 index 079a450b..00000000 --- a/js/ISA/ISA/JsonTypes/Data.js +++ /dev/null @@ -1,55 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { DataFile_$reflection, DataFile__get_AsString } from "./DataFile.js"; -import { record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; - -export class Data extends Record { - constructor(ID, Name, DataType, Comments) { - super(); - this.ID = ID; - this.Name = Name; - this.DataType = DataType; - this.Comments = Comments; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - const matchValue = this$.DataType; - if (matchValue == null) { - const arg_2 = Data__get_NameAsString(this$); - return toText(printf("%s"))(arg_2); - } - else { - const t = matchValue; - const arg = Data__get_NameAsString(this$); - const arg_1 = DataFile__get_AsString(t); - return toText(printf("%s [%s]"))(arg)(arg_1); - } - } -} - -export function Data_$reflection() { - return record_type("ISA.Data", [], Data, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["DataType", option_type(DataFile_$reflection())], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Data_make(id, name, dataType, comments) { - return new Data(id, name, dataType, comments); -} - -export function Data_create_Z748D099(Id, Name, DataType, Comments) { - return Data_make(Id, Name, DataType, Comments); -} - -export function Data_get_empty() { - return Data_create_Z748D099(); -} - -export function Data__get_NameAsString(this$) { - return defaultArg(this$.Name, ""); -} - diff --git a/js/ISA/ISA/JsonTypes/DataFile.js b/js/ISA/ISA/JsonTypes/DataFile.js deleted file mode 100644 index 4c94ed02..00000000 --- a/js/ISA/ISA/JsonTypes/DataFile.js +++ /dev/null @@ -1,68 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { union_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class DataFile extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["RawDataFile", "DerivedDataFile", "ImageFile"]; - } -} - -export function DataFile_$reflection() { - return union_type("ISA.DataFile", [], DataFile, () => [[], [], []]); -} - -export function DataFile_get_RawDataFileJson() { - return "Raw Data File"; -} - -export function DataFile_get_DerivedDataFileJson() { - return "Derived Data File"; -} - -export function DataFile_get_ImageFileJson() { - return "Image File"; -} - -export function DataFile__get_AsString(this$) { - switch (this$.tag) { - case 1: - return "DerivedDataFileJson"; - case 2: - return "ImageFileJson"; - default: - return "RawDataFileJson"; - } -} - -export function DataFile__get_IsDerivedData(this$) { - if (this$.tag === 1) { - return true; - } - else { - return false; - } -} - -export function DataFile__get_IsRawData(this$) { - if (this$.tag === 0) { - return true; - } - else { - return false; - } -} - -export function DataFile__get_IsImage(this$) { - if (this$.tag === 2) { - return true; - } - else { - return false; - } -} - diff --git a/js/ISA/ISA/JsonTypes/Factor.js b/js/ISA/ISA/JsonTypes/Factor.js deleted file mode 100644 index 200ce9da..00000000 --- a/js/ISA/ISA/JsonTypes/Factor.js +++ /dev/null @@ -1,197 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { map, defaultArg, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { filter, map as map_1, singleton, append, exists, tryFind } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; - -export class Factor extends Record { - constructor(ID, Name, FactorType, Comments) { - super(); - this.ID = ID; - this.Name = Name; - this.FactorType = FactorType; - this.Comments = Comments; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - return "OA " + Factor__get_NameText(this$); - } -} - -export function Factor_$reflection() { - return record_type("ISA.Factor", [], Factor, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["FactorType", option_type(OntologyAnnotation_$reflection())], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Factor_make(id, name, factorType, comments) { - return new Factor(id, name, factorType, comments); -} - -export function Factor_create_Z3D2B374F(Id, Name, FactorType, Comments) { - return Factor_make(Id, Name, FactorType, Comments); -} - -export function Factor_get_empty() { - return Factor_create_Z3D2B374F(); -} - -/** - * Create a ISAJson Factor from ISATab string entries - */ -export function Factor_fromString_Z5D76503E(name, term, source, accession, comments) { - const oa = OntologyAnnotation_fromString_Z7D8EB286(term, source, accession, unwrap(comments)); - return Factor_make(void 0, fromValueWithDefault("", name), fromValueWithDefault(OntologyAnnotation_get_empty(), oa), void 0); -} - -/** - * Get ISATab string entries from an ISAJson Factor object - */ -export function Factor_toString_E353FDD(factor) { - const value = { - TermAccessionNumber: "", - TermName: "", - TermSourceREF: "", - }; - return defaultArg(map(OntologyAnnotation_toString_473B9D79, factor.FactorType), value); -} - -export function Factor__get_NameText(this$) { - return defaultArg(this$.Name, ""); -} - -export function Factor__MapCategory_65D42856(this$, f) { - return new Factor(this$.ID, this$.Name, map(f, this$.FactorType), this$.Comments); -} - -export function Factor__SetCategory_2FC95D30(this$, c) { - return new Factor(this$.ID, this$.Name, c, this$.Comments); -} - -/** - * If a factor with the given name exists in the list, returns it - */ -export function Factor_tryGetByName(name, factors) { - return tryFind((f) => equals(f.Name, name), factors); -} - -/** - * If a factor with the given name exists in the list exists, returns true - */ -export function Factor_existsByName(name, factors) { - return exists((f) => equals(f.Name, name), factors); -} - -/** - * adds the given factor to the factors - */ -export function Factor_add(factors, factor) { - return append(factors, singleton(factor)); -} - -/** - * Updates all factors for which the predicate returns true with the given factor values - */ -export function Factor_updateBy(predicate, updateOption, factor, factors) { - if (exists(predicate, factors)) { - return map_1((f) => { - if (predicate(f)) { - const this$ = updateOption; - const recordType_1 = f; - const recordType_2 = factor; - return (this$.tag === 2) ? makeRecord(Factor_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) : ((this$.tag === 1) ? makeRecord(Factor_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) : ((this$.tag === 3) ? makeRecord(Factor_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) : recordType_2)); - } - else { - return f; - } - }, factors); - } - else { - return factors; - } -} - -/** - * Updates all factors with the same name as the given factor with its values - */ -export function Factor_updateByName(updateOption, factor, factors) { - return Factor_updateBy((f) => equals(f.Name, factor.Name), updateOption, factor, factors); -} - -/** - * If a factor with the given name exists in the list, removes it - */ -export function Factor_removeByName(name, factors) { - return filter((f) => !equals(f.Name, name), factors); -} - -/** - * Returns comments of a factor - */ -export function Factor_getComments_E353FDD(factor) { - return factor.Comments; -} - -/** - * Applies function f on comments of a factor - */ -export function Factor_mapComments(f, factor) { - return new Factor(factor.ID, factor.Name, factor.FactorType, map(f, factor.Comments)); -} - -/** - * Replaces comments of a factor by given comment list - */ -export function Factor_setComments(factor, comments) { - return new Factor(factor.ID, factor.Name, factor.FactorType, comments); -} - -/** - * Returns factor type of a factor - */ -export function Factor_getFactorType_E353FDD(factor) { - return factor.FactorType; -} - -/** - * Applies function f on factor type of a factor - */ -export function Factor_mapFactorType(f, factor) { - return new Factor(factor.ID, factor.Name, map(f, factor.FactorType), factor.Comments); -} - -/** - * Replaces factor type of a factor by given factor type - */ -export function Factor_setFactorType(factor, factorType) { - return new Factor(factor.ID, factor.Name, factorType, factor.Comments); -} - -/** - * Returns the name of the factor as string if it exists - */ -export function Factor_tryGetName_E353FDD(f) { - return f.Name; -} - -/** - * Returns the name of the factor as string - */ -export function Factor_getNameAsString_E353FDD(f) { - return Factor__get_NameText(f); -} - -/** - * Returns true if the given name matches the name of the factor - */ -export function Factor_nameEqualsString(name, f) { - return Factor__get_NameText(f) === name; -} - diff --git a/js/ISA/ISA/JsonTypes/FactorValue.js b/js/ISA/ISA/JsonTypes/FactorValue.js deleted file mode 100644 index 0e44dcf5..00000000 --- a/js/ISA/ISA/JsonTypes/FactorValue.js +++ /dev/null @@ -1,109 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { defaultArg, map } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { Factor__SetCategory_2FC95D30, Factor_create_Z3D2B374F, Factor__MapCategory_65D42856, Factor_$reflection, Factor__get_NameText } from "./Factor.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation__get_NameText } from "./OntologyAnnotation.js"; -import { record_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Value_$reflection } from "./Value.js"; -import { int32ToString } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; - -export class FactorValue extends Record { - constructor(ID, Category, Value, Unit) { - super(); - this.ID = ID; - this.Category = Category; - this.Value = Value; - this.Unit = Unit; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - let value_2, category_2, category_1, value_1; - const this$ = this; - const category = map(Factor__get_NameText, this$.Category); - const unit = map(OntologyAnnotation__get_NameText, this$.Unit); - const value = map((v) => { - const s = v.PrintCompact(); - if (unit == null) { - return s; - } - else { - return (s + " ") + unit; - } - }, this$.Value); - return (category == null) ? ((value == null) ? "" : ((value_2 = value, value_2))) : ((value == null) ? ((category_2 = category, (category_2 + ":") + "No Value")) : ((category_1 = category, (value_1 = value, (category_1 + ":") + value_1)))); - } -} - -export function FactorValue_$reflection() { - return record_type("ISA.FactorValue", [], FactorValue, () => [["ID", option_type(string_type)], ["Category", option_type(Factor_$reflection())], ["Value", option_type(Value_$reflection())], ["Unit", option_type(OntologyAnnotation_$reflection())]]); -} - -export function FactorValue_make(id, category, value, unit) { - return new FactorValue(id, category, value, unit); -} - -export function FactorValue_create_Z54E26173(Id, Category, Value, Unit) { - return FactorValue_make(Id, Category, Value, Unit); -} - -export function FactorValue_get_empty() { - return FactorValue_create_Z54E26173(); -} - -export function FactorValue__get_ValueText(this$) { - return defaultArg(map((oa) => { - switch (oa.tag) { - case 2: - return oa.fields[0].toString(); - case 1: - return int32ToString(oa.fields[0]); - case 3: - return oa.fields[0]; - default: - return OntologyAnnotation__get_NameText(oa.fields[0]); - } - }, this$.Value), ""); -} - -export function FactorValue__get_ValueWithUnitText(this$) { - const unit = map(OntologyAnnotation__get_NameText, this$.Unit); - const v = FactorValue__get_ValueText(this$); - if (unit == null) { - return v; - } - else { - const u = unit; - return toText(printf("%s %s"))(v)(u); - } -} - -export function FactorValue__get_NameText(this$) { - return defaultArg(map(Factor__get_NameText, this$.Category), ""); -} - -export function FactorValue__MapCategory_65D42856(this$, f) { - return new FactorValue(this$.ID, map((p) => Factor__MapCategory_65D42856(p, f), this$.Category), this$.Value, this$.Unit); -} - -export function FactorValue__SetCategory_2FC95D30(this$, c) { - let matchValue; - return new FactorValue(this$.ID, (matchValue = this$.Category, (matchValue == null) ? Factor_create_Z3D2B374F(void 0, void 0, c) : Factor__SetCategory_2FC95D30(matchValue, c)), this$.Value, this$.Unit); -} - -/** - * Returns the name of the factor value as string - */ -export function FactorValue_getNameAsString_2A4175B6(fv) { - return FactorValue__get_NameText(fv); -} - -/** - * Returns true if the given name matches the name of the factor value - */ -export function FactorValue_nameEqualsString(name, fv) { - return FactorValue__get_NameText(fv) === name; -} - diff --git a/js/ISA/ISA/JsonTypes/Investigation.js b/js/ISA/ISA/JsonTypes/Investigation.js deleted file mode 100644 index ff926cc6..00000000 --- a/js/ISA/ISA/JsonTypes/Investigation.js +++ /dev/null @@ -1,204 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologySourceReference_$reflection } from "./OntologySourceReference.js"; -import { Publication_$reflection } from "./Publication.js"; -import { Person_$reflection } from "./Person.js"; -import { Study_update_Z27CB2981, Study_$reflection } from "./Study.js"; -import { Remark_$reflection, Comment$_$reflection } from "./Comment.js"; -import { map, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { map as map_1, empty } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { mapDefault } from "../OptionExtensions.js"; -import { map2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { toFail } from "../../../fable_modules/fable-library.4.1.4/String.js"; - -export class Investigation extends Record { - constructor(ID, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, OntologySourceReferences, Publications, Contacts, Studies, Comments, Remarks) { - super(); - this.ID = ID; - this.FileName = FileName; - this.Identifier = Identifier; - this.Title = Title; - this.Description = Description; - this.SubmissionDate = SubmissionDate; - this.PublicReleaseDate = PublicReleaseDate; - this.OntologySourceReferences = OntologySourceReferences; - this.Publications = Publications; - this.Contacts = Contacts; - this.Studies = Studies; - this.Comments = Comments; - this.Remarks = Remarks; - } -} - -export function Investigation_$reflection() { - return record_type("ISA.Investigation", [], Investigation, () => [["ID", option_type(string_type)], ["FileName", option_type(string_type)], ["Identifier", option_type(string_type)], ["Title", option_type(string_type)], ["Description", option_type(string_type)], ["SubmissionDate", option_type(string_type)], ["PublicReleaseDate", option_type(string_type)], ["OntologySourceReferences", option_type(list_type(OntologySourceReference_$reflection()))], ["Publications", option_type(list_type(Publication_$reflection()))], ["Contacts", option_type(list_type(Person_$reflection()))], ["Studies", option_type(list_type(Study_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))], ["Remarks", list_type(Remark_$reflection())]]); -} - -export function Investigation_make(id, filename, identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReference, publications, contacts, studies, comments, remarks) { - return new Investigation(id, filename, identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReference, publications, contacts, studies, comments, remarks); -} - -export function Investigation_create_ZB2B0942(Id, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, OntologySourceReferences, Publications, Contacts, Studies, Comments, Remarks) { - return Investigation_make(Id, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, OntologySourceReferences, Publications, Contacts, Studies, Comments, defaultArg(Remarks, empty())); -} - -export function Investigation_get_empty() { - return Investigation_create_ZB2B0942(); -} - -/** - * Returns contacts of an investigation - */ -export function Investigation_getContacts_5997CE50(investigation) { - return investigation.Contacts; -} - -/** - * Applies function f on person of an investigation - */ -export function Investigation_mapContacts(f, investigation) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, mapDefault(empty(), f, investigation.Contacts), investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Replaces persons of an investigation with the given person list - */ -export function Investigation_setContacts(investigation, persons) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, persons, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Returns publications of an investigation - */ -export function Investigation_getPublications_5997CE50(investigation) { - return investigation.Publications; -} - -/** - * Applies function f on publications of an investigation - */ -export function Investigation_mapPublications(f, investigation) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, mapDefault(empty(), f, investigation.Publications), investigation.Contacts, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Replaces publications of an investigation with the given publication list - */ -export function Investigation_setPublications(investigation, publications) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, publications, investigation.Contacts, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Returns ontology source ref of an investigation - */ -export function Investigation_getOntologies_5997CE50(investigation) { - return investigation.OntologySourceReferences; -} - -/** - * Applies function f on ontology source ref of an investigation - */ -export function Investigation_mapOntologies(f, investigation) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, mapDefault(empty(), f, investigation.OntologySourceReferences), investigation.Publications, investigation.Contacts, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Replaces ontology source ref of an investigation with the given ontology source ref list - */ -export function Investigation_setOntologies(investigation, ontologies) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, ontologies, investigation.Publications, investigation.Contacts, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Returns studies of an investigation - */ -export function Investigation_getStudies_5997CE50(investigation) { - return defaultArg(investigation.Studies, empty()); -} - -/** - * Applies function f on studies of an investigation - */ -export function Investigation_mapStudies(f, investigation) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, mapDefault(empty(), f, investigation.Studies), investigation.Comments, investigation.Remarks); -} - -/** - * Replaces studies of an investigation with the given study list - */ -export function Investigation_setStudies(investigation, studies) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, studies, investigation.Comments, investigation.Remarks); -} - -/** - * Returns comments of an investigation - */ -export function Investigation_getComments_5997CE50(investigation) { - return investigation.Comments; -} - -/** - * Applies function f on comments of an investigation - */ -export function Investigation_mapComments(f, investigation) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, investigation.Studies, mapDefault(empty(), f, investigation.Comments), investigation.Remarks); -} - -/** - * Replaces comments of an investigation with the given comment list - */ -export function Investigation_setComments(investigation, comments) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, investigation.Studies, comments, investigation.Remarks); -} - -/** - * Returns remarks of an investigation - */ -export function Investigation_getRemarks_5997CE50(investigation) { - return investigation.Remarks; -} - -/** - * Applies function f on remarks of an investigation - */ -export function Investigation_mapRemarks(f, investigation) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, investigation.Studies, investigation.Comments, f(investigation.Remarks)); -} - -/** - * Replaces remarks of an investigation with the given remark list - */ -export function Investigation_setRemarks(investigation, remarks) { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, investigation.Studies, investigation.Comments, remarks); -} - -/** - * Update the investigation with the values of the given newInvestigation - */ -export function Investigation_updateBy(updateOption, investigation, newInvestigation) { - const this$ = updateOption; - const recordType_1 = investigation; - const recordType_2 = newInvestigation; - switch (this$.tag) { - case 2: - return makeRecord(Investigation_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Investigation_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Investigation_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } -} - -export function Investigation_update_5997CE50(investigation) { - try { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, map((list) => map_1(Study_update_Z27CB2981, list), investigation.Studies), investigation.Comments, investigation.Remarks); - } - catch (err) { - return toFail(`Could not update investigation ${investigation.Identifier}: -${err.message}`); - } -} - diff --git a/js/ISA/ISA/JsonTypes/Material.js b/js/ISA/ISA/JsonTypes/Material.js deleted file mode 100644 index db931f23..00000000 --- a/js/ISA/ISA/JsonTypes/Material.js +++ /dev/null @@ -1,66 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { choose, empty, length } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { MaterialType_$reflection, MaterialType__get_AsString } from "./MaterialType.js"; -import { record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { MaterialAttributeValue_$reflection } from "./MaterialAttributeValue.js"; - -export class Material extends Record { - constructor(ID, Name, MaterialType, Characteristics, DerivesFrom) { - super(); - this.ID = ID; - this.Name = Name; - this.MaterialType = MaterialType; - this.Characteristics = Characteristics; - this.DerivesFrom = DerivesFrom; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - const chars = length(defaultArg(this$.Characteristics, empty())) | 0; - const matchValue = this$.MaterialType; - if (matchValue == null) { - const arg_3 = Material__get_NameText(this$); - return toText(printf("%s [%i characteristics]"))(arg_3)(chars); - } - else { - const t = matchValue; - const arg = Material__get_NameText(this$); - const arg_1 = MaterialType__get_AsString(t); - return toText(printf("%s [%s; %i characteristics]"))(arg)(arg_1)(chars); - } - } -} - -export function Material_$reflection() { - return record_type("ISA.Material", [], Material, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["MaterialType", option_type(MaterialType_$reflection())], ["Characteristics", option_type(list_type(MaterialAttributeValue_$reflection()))], ["DerivesFrom", option_type(list_type(Material_$reflection()))]]); -} - -export function Material_make(id, name, materialType, characteristics, derivesFrom) { - return new Material(id, name, materialType, characteristics, derivesFrom); -} - -export function Material_create_76090C97(Id, Name, MaterialType, Characteristics, DerivesFrom) { - return Material_make(Id, Name, MaterialType, Characteristics, DerivesFrom); -} - -export function Material_get_empty() { - return Material_create_76090C97(); -} - -export function Material__get_NameText(this$) { - return defaultArg(this$.Name, ""); -} - -export function Material_getUnits_43A4149B(m) { - return choose((c) => c.Unit, defaultArg(m.Characteristics, empty())); -} - -export function Material_setCharacteristicValues(values, m) { - return new Material(m.ID, m.Name, m.MaterialType, values, m.DerivesFrom); -} - diff --git a/js/ISA/ISA/JsonTypes/MaterialAttribute.js b/js/ISA/ISA/JsonTypes/MaterialAttribute.js deleted file mode 100644 index 599f51d2..00000000 --- a/js/ISA/ISA/JsonTypes/MaterialAttribute.js +++ /dev/null @@ -1,101 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { record_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation__get_TryNameText, OntologyAnnotation__get_NameText, OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { bind, map, defaultArg, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; - -export class MaterialAttribute extends Record { - constructor(ID, CharacteristicType) { - super(); - this.ID = ID; - this.CharacteristicType = CharacteristicType; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - return "OA " + MaterialAttribute__get_NameText(this$); - } -} - -export function MaterialAttribute_$reflection() { - return record_type("ISA.MaterialAttribute", [], MaterialAttribute, () => [["ID", option_type(string_type)], ["CharacteristicType", option_type(OntologyAnnotation_$reflection())]]); -} - -export function MaterialAttribute_make(id, characteristicType) { - return new MaterialAttribute(id, characteristicType); -} - -export function MaterialAttribute_create_2769312B(Id, CharacteristicType) { - return MaterialAttribute_make(Id, CharacteristicType); -} - -export function MaterialAttribute_get_empty() { - return MaterialAttribute_create_2769312B(); -} - -/** - * Create a ISAJson MaterialAttribute from ISATab string entries - */ -export function MaterialAttribute_fromString_703AFBF9(term, source, accession, comments) { - const oa = OntologyAnnotation_fromString_Z7D8EB286(term, source, accession, unwrap(comments)); - return MaterialAttribute_make(void 0, fromValueWithDefault(OntologyAnnotation_get_empty(), oa)); -} - -/** - * Get ISATab string entries from an ISAJson MaterialAttribute object - */ -export function MaterialAttribute_toString_Z6476E859(ma) { - const value = { - TermAccessionNumber: "", - TermName: "", - TermSourceREF: "", - }; - return defaultArg(map(OntologyAnnotation_toString_473B9D79, ma.CharacteristicType), value); -} - -/** - * Returns the name of the characteristic as string - */ -export function MaterialAttribute__get_NameText(this$) { - return defaultArg(map(OntologyAnnotation__get_NameText, this$.CharacteristicType), ""); -} - -/** - * Returns the name of the characteristic as string - */ -export function MaterialAttribute__get_TryNameText(this$) { - return bind(OntologyAnnotation__get_TryNameText, this$.CharacteristicType); -} - -export function MaterialAttribute__MapCategory_65D42856(this$, f) { - return new MaterialAttribute(this$.ID, map(f, this$.CharacteristicType)); -} - -export function MaterialAttribute__SetCategory_2FC95D30(this$, c) { - return new MaterialAttribute(this$.ID, c); -} - -/** - * Returns the name of the characteristic as string if it exists - */ -export function MaterialAttribute_tryGetNameText_Z6476E859(ma) { - return MaterialAttribute__get_NameText(ma); -} - -/** - * Returns the name of the characteristic as string - */ -export function MaterialAttribute_getNameText_Z6476E859(ma) { - return MaterialAttribute__get_TryNameText(ma); -} - -/** - * Returns true if the given name matches the name of the characteristic - */ -export function MaterialAttribute_nameEqualsString(name, ma) { - return MaterialAttribute__get_NameText(ma) === name; -} - diff --git a/js/ISA/ISA/JsonTypes/MaterialAttributeValue.js b/js/ISA/ISA/JsonTypes/MaterialAttributeValue.js deleted file mode 100644 index 9dc3b14d..00000000 --- a/js/ISA/ISA/JsonTypes/MaterialAttributeValue.js +++ /dev/null @@ -1,126 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { bind, defaultArg, map } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { MaterialAttribute__SetCategory_2FC95D30, MaterialAttribute_create_2769312B, MaterialAttribute__MapCategory_65D42856, MaterialAttribute__get_TryNameText, MaterialAttribute_$reflection, MaterialAttribute__get_NameText } from "./MaterialAttribute.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation__get_NameText } from "./OntologyAnnotation.js"; -import { record_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Value_$reflection } from "./Value.js"; -import { int32ToString } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; - -export class MaterialAttributeValue extends Record { - constructor(ID, Category, Value, Unit) { - super(); - this.ID = ID; - this.Category = Category; - this.Value = Value; - this.Unit = Unit; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - let value_2, category_2, category_1, value_1; - const this$ = this; - const category = map(MaterialAttribute__get_NameText, this$.Category); - const unit = map(OntologyAnnotation__get_NameText, this$.Unit); - const value = map((v) => { - const s = v.PrintCompact(); - if (unit == null) { - return s; - } - else { - return (s + " ") + unit; - } - }, this$.Value); - return (category == null) ? ((value == null) ? "" : ((value_2 = value, value_2))) : ((value == null) ? ((category_2 = category, (category_2 + ":") + "No Value")) : ((category_1 = category, (value_1 = value, (category_1 + ":") + value_1)))); - } -} - -export function MaterialAttributeValue_$reflection() { - return record_type("ISA.MaterialAttributeValue", [], MaterialAttributeValue, () => [["ID", option_type(string_type)], ["Category", option_type(MaterialAttribute_$reflection())], ["Value", option_type(Value_$reflection())], ["Unit", option_type(OntologyAnnotation_$reflection())]]); -} - -export function MaterialAttributeValue_make(id, category, value, unit) { - return new MaterialAttributeValue(id, category, value, unit); -} - -export function MaterialAttributeValue_create_163BDE77(Id, Category, Value, Unit) { - return MaterialAttributeValue_make(Id, Category, Value, Unit); -} - -export function MaterialAttributeValue_get_empty() { - return MaterialAttributeValue_create_163BDE77(); -} - -/** - * Returns the name of the category as string - */ -export function MaterialAttributeValue__get_NameText(this$) { - return defaultArg(map(MaterialAttribute__get_NameText, this$.Category), ""); -} - -/** - * Returns the name of the category as string - */ -export function MaterialAttributeValue__get_TryNameText(this$) { - return bind(MaterialAttribute__get_TryNameText, this$.Category); -} - -export function MaterialAttributeValue__get_ValueText(this$) { - return defaultArg(map((oa) => { - switch (oa.tag) { - case 2: - return oa.fields[0].toString(); - case 1: - return int32ToString(oa.fields[0]); - case 3: - return oa.fields[0]; - default: - return OntologyAnnotation__get_NameText(oa.fields[0]); - } - }, this$.Value), ""); -} - -export function MaterialAttributeValue__get_ValueWithUnitText(this$) { - const unit = map(OntologyAnnotation__get_NameText, this$.Unit); - const v = MaterialAttributeValue__get_ValueText(this$); - if (unit == null) { - return v; - } - else { - const u = unit; - return toText(printf("%s %s"))(v)(u); - } -} - -export function MaterialAttributeValue__MapCategory_65D42856(this$, f) { - return new MaterialAttributeValue(this$.ID, map((p) => MaterialAttribute__MapCategory_65D42856(p, f), this$.Category), this$.Value, this$.Unit); -} - -export function MaterialAttributeValue__SetCategory_2FC95D30(this$, c) { - let matchValue; - return new MaterialAttributeValue(this$.ID, (matchValue = this$.Category, (matchValue == null) ? MaterialAttribute_create_2769312B(void 0, c) : MaterialAttribute__SetCategory_2FC95D30(matchValue, c)), this$.Value, this$.Unit); -} - -/** - * Returns the name of the characteristic value as string if it exists - */ -export function MaterialAttributeValue_tryGetNameText_6A64994C(mv) { - return MaterialAttributeValue__get_TryNameText(mv); -} - -/** - * Returns the name of the characteristic value as string - */ -export function MaterialAttributeValue_getNameAsString_6A64994C(mv) { - return MaterialAttributeValue__get_TryNameText(mv); -} - -/** - * Returns true if the given name matches the name of the characteristic value - */ -export function MaterialAttributeValue_nameEqualsString(name, mv) { - return MaterialAttributeValue__get_NameText(mv) === name; -} - diff --git a/js/ISA/ISA/JsonTypes/MaterialType.js b/js/ISA/ISA/JsonTypes/MaterialType.js deleted file mode 100644 index aec8704d..00000000 --- a/js/ISA/ISA/JsonTypes/MaterialType.js +++ /dev/null @@ -1,41 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { union_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; - -export class MaterialType extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["ExtractName", "LabeledExtractName"]; - } -} - -export function MaterialType_$reflection() { - return union_type("ISA.MaterialType", [], MaterialType, () => [[], []]); -} - -export function MaterialType_create_Z721C83C5(t) { - switch (t) { - case "Extract Name": - return new MaterialType(0, []); - case "Labeled Extract Name": - return new MaterialType(1, []); - default: - throw new Error("No other value than \"Extract Name\" or \"Labeled Extract Name\" allowed for materialtype"); - } -} - -/** - * Returns the type of the MaterialType - */ -export function MaterialType__get_AsString(this$) { - if (this$.tag === 1) { - return "Labeled Extract"; - } - else { - return "Extract"; - } -} - diff --git a/js/ISA/ISA/JsonTypes/OntologyAnnotation.js b/js/ISA/ISA/JsonTypes/OntologyAnnotation.js deleted file mode 100644 index 916b8b6a..00000000 --- a/js/ISA/ISA/JsonTypes/OntologyAnnotation.js +++ /dev/null @@ -1,340 +0,0 @@ -import { equals, int32ToString, stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { AnnotationValue_toString_Z3C00A204, AnnotationValue_fromString_Z721C83C5, AnnotationValue_$reflection } from "./AnnotationValue.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { value as value_4, map, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { ActivePatterns_$007CRegex$007C_$007C, tryParseTermAnnotation, ActivePatterns_$007CTermAnnotation$007C_$007C } from "../Regex.js"; -import { empty, filter, map as map_1, singleton, append, exists, tryFind } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { map2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { mapDefault } from "../OptionExtensions.js"; - -export class OntologyAnnotation extends Record { - constructor(ID, Name, TermSourceREF, LocalID, TermAccessionNumber, Comments) { - super(); - this.ID = ID; - this.Name = Name; - this.TermSourceREF = TermSourceREF; - this.LocalID = LocalID; - this.TermAccessionNumber = TermAccessionNumber; - this.Comments = Comments; - } - Equals(other) { - const this$ = this; - if (other instanceof OntologyAnnotation) { - return this$["System.IEquatable`1.Equals2B595"](other); - } - else if (typeof other === "string") { - const s = other; - return ((OntologyAnnotation__get_NameText(this$) === s) ? true : (OntologyAnnotation__get_TermAccessionShort(this$) === s)) ? true : (OntologyAnnotation__get_TermAccessionOntobeeUrl(this$) === s); - } - else { - return false; - } - } - GetHashCode() { - const this$ = this; - return stringHash(OntologyAnnotation__get_NameText(this$) + OntologyAnnotation__get_TermAccessionShort(this$)) | 0; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - return "OA " + OntologyAnnotation__get_NameText(this$); - } - "System.IEquatable`1.Equals2B595"(other) { - const this$ = this; - return ((this$.TermAccessionNumber != null) && (other.TermAccessionNumber != null)) ? ((OntologyAnnotation__get_TermAccessionShort(other) === OntologyAnnotation__get_TermAccessionShort(this$)) ? true : (OntologyAnnotation__get_TermAccessionOntobeeUrl(other) === OntologyAnnotation__get_TermAccessionOntobeeUrl(this$))) : (((this$.Name != null) && (other.Name != null)) ? (OntologyAnnotation__get_NameText(other) === OntologyAnnotation__get_NameText(this$)) : ((((this$.TermAccessionNumber == null) && (other.TermAccessionNumber == null)) && (this$.Name == null)) && (other.Name == null))); - } -} - -export function OntologyAnnotation_$reflection() { - return record_type("ISA.OntologyAnnotation", [], OntologyAnnotation, () => [["ID", option_type(string_type)], ["Name", option_type(AnnotationValue_$reflection())], ["TermSourceREF", option_type(string_type)], ["LocalID", option_type(string_type)], ["TermAccessionNumber", option_type(string_type)], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function OntologyAnnotation_make(id, name, termSourceREF, localID, termAccessionNumber, comments) { - return new OntologyAnnotation(id, name, termSourceREF, localID, termAccessionNumber, comments); -} - -/** - * This function creates the type exactly as given. If you want a more streamlined approach use `OntologyAnnotation.fromString`. - */ -export function OntologyAnnotation_create_131C8C9D(Id, Name, TermSourceREF, LocalID, TermAccessionNumber, Comments) { - return OntologyAnnotation_make(Id, Name, TermSourceREF, LocalID, TermAccessionNumber, Comments); -} - -export function OntologyAnnotation_get_empty() { - return OntologyAnnotation_create_131C8C9D(); -} - -/** - * Returns the name of the ontology as string - */ -export function OntologyAnnotation__get_NameText(this$) { - return defaultArg(map((av) => { - switch (av.tag) { - case 1: - return av.fields[0].toString(); - case 2: - return int32ToString(av.fields[0]); - default: - return av.fields[0]; - } - }, this$.Name), ""); -} - -/** - * Returns the name of the ontology as string - */ -export function OntologyAnnotation__get_TryNameText(this$) { - return map((av) => { - switch (av.tag) { - case 1: - return av.fields[0].toString(); - case 2: - return int32ToString(av.fields[0]); - default: - return av.fields[0]; - } - }, this$.Name); -} - -/** - * Returns the term source of the ontology as string - */ -export function OntologyAnnotation__get_TermSourceREFString(this$) { - return defaultArg(this$.TermSourceREF, ""); -} - -/** - * Returns the term accession number of the ontology as string - */ -export function OntologyAnnotation__get_TermAccessionString(this$) { - return defaultArg(this$.TermAccessionNumber, ""); -} - -/** - * Create a path in form of `http://purl.obolibrary.org/obo/MS_1000121` from it's Term Accession Source `MS` and Local Term Accession Number `1000121`. - */ -export function OntologyAnnotation_createUriAnnotation(termSourceRef, localTAN) { - return `${"http://purl.obolibrary.org/obo/"}${termSourceRef}_${localTAN}`; -} - -/** - * Create a ISAJson Ontology Annotation value from ISATab string entries, will try to reduce `termAccessionNumber` with regex matching. - * - * Exmp. 1: http://purl.obolibrary.org/obo/GO_000001 --> GO:000001 - */ -export function OntologyAnnotation_fromString_Z7D8EB286(term, tsr, tan, comments) { - let activePatternResult, tan_1; - const patternInput = (tan != null) ? ((activePatternResult = ActivePatterns_$007CTermAnnotation$007C_$007C(tan), (activePatternResult != null) ? ((tan_1 = activePatternResult, [(tsr != null) ? tsr : tan_1.TermSourceREF, tan_1.LocalTAN])) : [tsr, void 0])) : [tsr, void 0]; - return OntologyAnnotation_make(void 0, map(AnnotationValue_fromString_Z721C83C5, term), patternInput[0], patternInput[1], tan, comments); -} - -/** - * Will always be created without `OntologyAnnotion.Name` - */ -export function OntologyAnnotation_fromTermAnnotation_Z721C83C5(termAnnotation) { - const r = value_4(tryParseTermAnnotation(termAnnotation)); - return OntologyAnnotation_fromString_Z7D8EB286("", r.TermSourceREF, (r.TermSourceREF + ":") + r.LocalTAN); -} - -/** - * Parses any value in `TermAccessionString` to term accession format "termsourceref:localtan". Exmp.: "MS:000001". - * - * If `TermAccessionString` cannot be parsed to this format, returns empty string! - */ -export function OntologyAnnotation__get_TermAccessionShort(this$) { - const matchValue = this$.TermSourceREF; - const matchValue_1 = this$.LocalID; - let matchResult, id, tsr; - if (matchValue != null) { - if (matchValue_1 != null) { - matchResult = 0; - id = matchValue_1; - tsr = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return `${tsr}:${id}`; - default: - return ""; - } -} - -export function OntologyAnnotation__get_TermAccessionOntobeeUrl(this$) { - const matchValue = this$.TermSourceREF; - const matchValue_1 = this$.LocalID; - let matchResult, id, tsr; - if (matchValue != null) { - if (matchValue_1 != null) { - matchResult = 0; - id = matchValue_1; - tsr = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return OntologyAnnotation_createUriAnnotation(tsr, id); - default: - return ""; - } -} - -export function OntologyAnnotation__get_TermAccessionAndOntobeeUrlIfShort(this$) { - const matchValue = this$.TermAccessionNumber; - if (matchValue != null) { - const tan = matchValue; - if (ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", tan) != null) { - return OntologyAnnotation__get_TermAccessionOntobeeUrl(this$); - } - else { - return tan; - } - } - else { - return ""; - } -} - -/** - * Get a ISATab string entries from an ISAJson Ontology Annotation object (name,source,accession) - * - * `asOntobeePurlUrl`: option to return term accession in Ontobee purl-url format (`http://purl.obolibrary.org/obo/MS_1000121`) - */ -export function OntologyAnnotation_toString_473B9D79(oa, asOntobeePurlUrlIfShort) { - let url; - const asOntobeePurlUrlIfShort_1 = defaultArg(asOntobeePurlUrlIfShort, false); - const TermName = defaultArg(map(AnnotationValue_toString_Z3C00A204, oa.Name), ""); - const TermSourceREF = defaultArg(oa.TermSourceREF, ""); - return { - TermAccessionNumber: asOntobeePurlUrlIfShort_1 ? ((url = OntologyAnnotation__get_TermAccessionAndOntobeeUrlIfShort(oa), (url === "") ? defaultArg(oa.TermAccessionNumber, "") : url)) : defaultArg(oa.TermAccessionNumber, ""), - TermName: TermName, - TermSourceREF: TermSourceREF, - }; -} - -/** - * Returns the name of the ontology as string if it has a name - */ -export function OntologyAnnotation_tryGetNameText_2FC95D30(oa) { - return OntologyAnnotation__get_TryNameText(oa); -} - -/** - * Returns the name of the ontology as string if it has a name - */ -export function OntologyAnnotation_getNameText_2FC95D30(oa) { - return OntologyAnnotation__get_NameText(oa); -} - -/** - * Returns true if the given name matches the name of the ontology annotation - */ -export function OntologyAnnotation_nameEqualsString(name, oa) { - return OntologyAnnotation__get_NameText(oa) === name; -} - -/** - * If an ontology annotation with the given annotation value exists in the list, returns it - */ -export function OntologyAnnotation_tryGetByName(name, annotations) { - return tryFind((d) => equals(d.Name, name), annotations); -} - -/** - * If a ontology annotation with the given annotation value exists in the list, returns true - */ -export function OntologyAnnotation_existsByName(name, annotations) { - return exists((d) => equals(d.Name, name), annotations); -} - -/** - * Adds the given ontology annotation to the Study.StudyDesignDescriptors - */ -export function OntologyAnnotation_add(onotolgyAnnotations, onotolgyAnnotation) { - return append(onotolgyAnnotations, singleton(onotolgyAnnotation)); -} - -/** - * Updates all ontology annotations for which the predicate returns true with the given ontology annotations values - */ -export function OntologyAnnotation_updateBy(predicate, updateOption, design, annotations) { - if (exists(predicate, annotations)) { - return map_1((d) => { - if (predicate(d)) { - const this$ = updateOption; - const recordType_1 = d; - const recordType_2 = design; - switch (this$.tag) { - case 2: - return makeRecord(OntologyAnnotation_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(OntologyAnnotation_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(OntologyAnnotation_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - } - else { - return d; - } - }, annotations); - } - else { - return annotations; - } -} - -/** - * If an ontology annotation with the same annotation value as the given annotation value exists in the list, updates it with the given ontology annotation - */ -export function OntologyAnnotation_updateByName(updateOption, design, annotations) { - return OntologyAnnotation_updateBy((f) => equals(f.Name, design.Name), updateOption, design, annotations); -} - -/** - * If a ontology annotation with the annotation value exists in the list, removes it - */ -export function OntologyAnnotation_removeByName(name, annotations) { - return filter((d) => !equals(d.Name, name), annotations); -} - -/** - * Returns comments of a ontology annotation - */ -export function OntologyAnnotation_getComments_2FC95D30(annotation) { - return annotation.Comments; -} - -/** - * Applies function f on comments of a ontology annotation - */ -export function OntologyAnnotation_mapComments(f, annotation) { - return new OntologyAnnotation(annotation.ID, annotation.Name, annotation.TermSourceREF, annotation.LocalID, annotation.TermAccessionNumber, mapDefault(empty(), f, annotation.Comments)); -} - -/** - * Replaces comments of a ontology annotation by given comment list - */ -export function OntologyAnnotation_setComments(annotation, comments) { - return new OntologyAnnotation(annotation.ID, annotation.Name, annotation.TermSourceREF, annotation.LocalID, annotation.TermAccessionNumber, comments); -} - diff --git a/js/ISA/ISA/JsonTypes/OntologySourceReference.js b/js/ISA/ISA/JsonTypes/OntologySourceReference.js deleted file mode 100644 index 6fd63977..00000000 --- a/js/ISA/ISA/JsonTypes/OntologySourceReference.js +++ /dev/null @@ -1,123 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { empty, filter, map, singleton, append, exists, tryFind } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { mapDefault } from "../OptionExtensions.js"; - -export class OntologySourceReference extends Record { - constructor(Description, File, Name, Version, Comments) { - super(); - this.Description = Description; - this.File = File; - this.Name = Name; - this.Version = Version; - this.Comments = Comments; - } -} - -export function OntologySourceReference_$reflection() { - return record_type("ISA.OntologySourceReference", [], OntologySourceReference, () => [["Description", option_type(string_type)], ["File", option_type(string_type)], ["Name", option_type(string_type)], ["Version", option_type(string_type)], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function OntologySourceReference_make(description, file, name, version, comments) { - return new OntologySourceReference(description, file, name, version, comments); -} - -export function OntologySourceReference_create_55205B02(Description, File, Name, Version, Comments) { - return OntologySourceReference_make(Description, File, Name, Version, Comments); -} - -export function OntologySourceReference_get_empty() { - return OntologySourceReference_create_55205B02(); -} - -/** - * If an ontology source reference with the given name exists in the list, returns it - */ -export function OntologySourceReference_tryGetByName(name, ontologies) { - return tryFind((t) => equals(t.Name, name), ontologies); -} - -/** - * If an ontology source reference with the given name exists in the list, returns true - */ -export function OntologySourceReference_existsByName(name, ontologies) { - return exists((t) => equals(t.Name, name), ontologies); -} - -/** - * Adds the given ontology source reference to the investigation - */ -export function OntologySourceReference_add(ontologySourceReference, ontologies) { - return append(ontologies, singleton(ontologySourceReference)); -} - -/** - * Updates all ontology source references for which the predicate returns true with the given ontology source reference values - */ -export function OntologySourceReference_updateBy(predicate, updateOption, ontologySourceReference, ontologies) { - if (exists(predicate, ontologies)) { - return map((t) => { - if (predicate(t)) { - const this$ = updateOption; - const recordType_1 = t; - const recordType_2 = ontologySourceReference; - switch (this$.tag) { - case 2: - return makeRecord(OntologySourceReference_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(OntologySourceReference_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(OntologySourceReference_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - } - else { - return t; - } - }, ontologies); - } - else { - return ontologies; - } -} - -/** - * If an ontology source reference with the same name as the given name exists in the investigation, updates it with the given ontology source reference - */ -export function OntologySourceReference_updateByName(updateOption, ontologySourceReference, ontologies) { - return OntologySourceReference_updateBy((t) => equals(t.Name, ontologySourceReference.Name), updateOption, ontologySourceReference, ontologies); -} - -/** - * If a ontology source reference with the given name exists in the list, removes it - */ -export function OntologySourceReference_removeByName(name, ontologies) { - return filter((t) => !equals(t.Name, name), ontologies); -} - -/** - * Returns comments of ontology source ref - */ -export function OntologySourceReference_getComments_Z68D7813F(ontology) { - return ontology.Comments; -} - -/** - * Applies function f on comments in ontology source ref - */ -export function OntologySourceReference_mapComments(f, ontology) { - return new OntologySourceReference(ontology.Description, ontology.File, ontology.Name, ontology.Version, mapDefault(empty(), f, ontology.Comments)); -} - -/** - * Replaces comments in ontology source ref by given comment list - */ -export function OntologySourceReference_setComments(ontology, comments) { - return new OntologySourceReference(ontology.Description, ontology.File, ontology.Name, ontology.Version, comments); -} - diff --git a/js/ISA/ISA/JsonTypes/Person.js b/js/ISA/ISA/JsonTypes/Person.js deleted file mode 100644 index 929c7784..00000000 --- a/js/ISA/ISA/JsonTypes/Person.js +++ /dev/null @@ -1,155 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { empty, filter, map, singleton, append, exists, tryFind } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { mapDefault } from "../OptionExtensions.js"; - -export class Person extends Record { - constructor(ID, LastName, FirstName, MidInitials, EMail, Phone, Fax, Address, Affiliation, Roles, Comments) { - super(); - this.ID = ID; - this.LastName = LastName; - this.FirstName = FirstName; - this.MidInitials = MidInitials; - this.EMail = EMail; - this.Phone = Phone; - this.Fax = Fax; - this.Address = Address; - this.Affiliation = Affiliation; - this.Roles = Roles; - this.Comments = Comments; - } -} - -export function Person_$reflection() { - return record_type("ISA.Person", [], Person, () => [["ID", option_type(string_type)], ["LastName", option_type(string_type)], ["FirstName", option_type(string_type)], ["MidInitials", option_type(string_type)], ["EMail", option_type(string_type)], ["Phone", option_type(string_type)], ["Fax", option_type(string_type)], ["Address", option_type(string_type)], ["Affiliation", option_type(string_type)], ["Roles", option_type(list_type(OntologyAnnotation_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Person_make(id, lastName, firstName, midInitials, email, phone, fax, address, affiliation, roles, comments) { - return new Person(id, lastName, firstName, midInitials, email, phone, fax, address, affiliation, roles, comments); -} - -export function Person_create_28E835CB(Id, LastName, FirstName, MidInitials, Email, Phone, Fax, Address, Affiliation, Roles, Comments) { - return Person_make(Id, LastName, FirstName, MidInitials, Email, Phone, Fax, Address, Affiliation, Roles, Comments); -} - -export function Person_get_empty() { - return Person_create_28E835CB(); -} - -export function Person_tryGetByFullName(firstName, midInitials, lastName, persons) { - return tryFind((p) => ((midInitials === "") ? (equals(p.FirstName, firstName) && equals(p.LastName, lastName)) : ((equals(p.FirstName, firstName) && equals(p.MidInitials, midInitials)) && equals(p.LastName, lastName))), persons); -} - -/** - * If an person with the given FirstName, MidInitials and LastName exists in the list, returns true - */ -export function Person_existsByFullName(firstName, midInitials, lastName, persons) { - return exists((p) => ((midInitials === "") ? (equals(p.FirstName, firstName) && equals(p.LastName, lastName)) : ((equals(p.FirstName, firstName) && equals(p.MidInitials, midInitials)) && equals(p.LastName, lastName))), persons); -} - -/** - * adds the given person to the persons - */ -export function Person_add(persons, person) { - return append(persons, singleton(person)); -} - -/** - * Updates all persons for which the predicate returns true with the given person values - */ -export function Person_updateBy(predicate, updateOption, person, persons) { - if (exists(predicate, persons)) { - return map((p) => { - if (predicate(p)) { - const this$ = updateOption; - const recordType_1 = p; - const recordType_2 = person; - switch (this$.tag) { - case 2: - return makeRecord(Person_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Person_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Person_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - } - else { - return p; - } - }, persons); - } - else { - return persons; - } -} - -/** - * Updates all persons with the same FirstName, MidInitials and LastName as the given person with its values - */ -export function Person_updateByFullName(updateOption, person, persons) { - return Person_updateBy((p) => { - if (equals(p.FirstName, person.FirstName) && equals(p.MidInitials, person.MidInitials)) { - return equals(p.LastName, person.LastName); - } - else { - return false; - } - }, updateOption, person, persons); -} - -/** - * If a person with the given FirstName, MidInitials and LastName exists in the list, removes it - */ -export function Person_removeByFullName(firstName, midInitials, lastName, persons) { - return filter((p) => ((midInitials === "") ? !(equals(p.FirstName, firstName) && equals(p.LastName, lastName)) : !((equals(p.FirstName, firstName) && equals(p.MidInitials, midInitials)) && equals(p.LastName, lastName))), persons); -} - -/** - * Returns roles of a person - */ -export function Person_getRoles_Z2DD38D1B(person) { - return person.Roles; -} - -/** - * Applies function f on roles of a person - */ -export function Person_mapRoles(f, person) { - return new Person(person.ID, person.LastName, person.FirstName, person.MidInitials, person.EMail, person.Phone, person.Fax, person.Address, person.Affiliation, mapDefault(empty(), f, person.Roles), person.Comments); -} - -/** - * Replaces roles of a person with the given roles - */ -export function Person_setRoles(person, roles) { - return new Person(person.ID, person.LastName, person.FirstName, person.MidInitials, person.EMail, person.Phone, person.Fax, person.Address, person.Affiliation, roles, person.Comments); -} - -/** - * Returns comments of a person - */ -export function Person_getComments_Z2DD38D1B(person) { - return person.Comments; -} - -/** - * Applies function f on comments of a person - */ -export function Person_mapComments(f, person) { - return new Person(person.ID, person.LastName, person.FirstName, person.MidInitials, person.EMail, person.Phone, person.Fax, person.Address, person.Affiliation, person.Roles, mapDefault(empty(), f, person.Comments)); -} - -/** - * Replaces comments of a person by given comment list - */ -export function Person_setComments(person, comments) { - return new Person(person.ID, person.LastName, person.FirstName, person.MidInitials, person.EMail, person.Phone, person.Fax, person.Address, person.Affiliation, person.Roles, comments); -} - diff --git a/js/ISA/ISA/JsonTypes/Process.js b/js/ISA/ISA/JsonTypes/Process.js deleted file mode 100644 index def7d426..00000000 --- a/js/ISA/ISA/JsonTypes/Process.js +++ /dev/null @@ -1,402 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { zip, tryPick, map as map_1, tryFind, append, collect, choose, empty, length } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { map, value as value_4, bind, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Protocol_$reflection } from "./Protocol.js"; -import { ProcessParameterValue_$reflection } from "./ProcessParameterValue.js"; -import { ProcessInput_tryMaterial_Z38E7E853, ProcessInput_trySample_Z38E7E853, ProcessInput_tryData_Z38E7E853, ProcessInput_trySource_Z38E7E853, ProcessInput_tryGetCharacteristicValues_Z38E7E853, ProcessInput_$reflection } from "./ProcessInput.js"; -import { ProcessOutput_tryGetFactorValues_Z4A02997C, ProcessOutput_tryGetCharacteristicValues_Z4A02997C, ProcessOutput_$reflection } from "./ProcessOutput.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { create, match } from "../../../fable_modules/fable-library.4.1.4/RegExp.js"; -import { parse } from "../../../fable_modules/fable-library.4.1.4/Int32.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { safeHash, equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { ProtocolParameter_get_empty } from "./ProtocolParameter.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { Update_UpdateOptions } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; - -export class Process extends Record { - constructor(ID, Name, ExecutesProtocol, ParameterValues, Performer, Date$, PreviousProcess, NextProcess, Inputs, Outputs, Comments) { - super(); - this.ID = ID; - this.Name = Name; - this.ExecutesProtocol = ExecutesProtocol; - this.ParameterValues = ParameterValues; - this.Performer = Performer; - this.Date = Date$; - this.PreviousProcess = PreviousProcess; - this.NextProcess = NextProcess; - this.Inputs = Inputs; - this.Outputs = Outputs; - this.Comments = Comments; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - const inputCount = length(defaultArg(this$.Inputs, empty())) | 0; - const outputCount = length(defaultArg(this$.Outputs, empty())) | 0; - const paramCount = length(defaultArg(this$.ParameterValues, empty())) | 0; - const name = defaultArg(this$.Name, "Unnamed Process"); - return toText(printf("%s [%i Inputs -> %i Params -> %i Outputs]"))(name)(inputCount)(paramCount)(outputCount); - } -} - -export function Process_$reflection() { - return record_type("ISA.Process", [], Process, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["ExecutesProtocol", option_type(Protocol_$reflection())], ["ParameterValues", option_type(list_type(ProcessParameterValue_$reflection()))], ["Performer", option_type(string_type)], ["Date", option_type(string_type)], ["PreviousProcess", option_type(Process_$reflection())], ["NextProcess", option_type(Process_$reflection())], ["Inputs", option_type(list_type(ProcessInput_$reflection()))], ["Outputs", option_type(list_type(ProcessOutput_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Process_make(id, name, executesProtocol, parameterValues, performer, date, previousProcess, nextProcess, inputs, outputs, comments) { - return new Process(id, name, executesProtocol, parameterValues, performer, date, previousProcess, nextProcess, inputs, outputs, comments); -} - -export function Process_create_236DF576(Id, Name, ExecutesProtocol, ParameterValues, Performer, Date$, PreviousProcess, NextProcess, Inputs, Outputs, Comments) { - return Process_make(Id, Name, ExecutesProtocol, ParameterValues, Performer, Date$, PreviousProcess, NextProcess, Inputs, Outputs, Comments); -} - -export function Process_get_empty() { - return Process_create_236DF576(); -} - -export function Process_composeName(processNameRoot, i) { - return `${processNameRoot}_${i}`; -} - -export function Process_decomposeName_Z721C83C5(name) { - const r = match(create("(?.+)_(?\\d+)"), name); - if (r != null) { - return [(r.groups && r.groups.name) || "", parse((r.groups && r.groups.num) || "", 511, false, 32)]; - } - else { - return [name, void 0]; - } -} - -/** - * Returns the name of the protocol the given process executes - */ -export function Process_tryGetProtocolName_30EF9E7B(p) { - return bind((p_1) => p_1.Name, p.ExecutesProtocol); -} - -/** - * Returns the name of the protocol the given process executes - */ -export function Process_getProtocolName_30EF9E7B(p) { - return value_4(bind((p_1) => p_1.Name, p.ExecutesProtocol)); -} - -/** - * Returns the parameter values describing the process - */ -export function Process_getParameterValues_30EF9E7B(p) { - return defaultArg(p.ParameterValues, empty()); -} - -/** - * Returns the parameters describing the process - */ -export function Process_getParameters_30EF9E7B(p) { - return choose((pv) => pv.Category, Process_getParameterValues_30EF9E7B(p)); -} - -/** - * Returns the characteristics describing the inputs of the process - */ -export function Process_getInputCharacteristicValues_30EF9E7B(p) { - const matchValue = p.Inputs; - if (matchValue == null) { - return empty(); - } - else { - return List_distinct(collect((inp) => defaultArg(ProcessInput_tryGetCharacteristicValues_Z38E7E853(inp), empty()), matchValue), { - Equals: equals, - GetHashCode: safeHash, - }); - } -} - -/** - * Returns the characteristics describing the outputs of the process - */ -export function Process_getOutputCharacteristicValues_30EF9E7B(p) { - const matchValue = p.Outputs; - if (matchValue == null) { - return empty(); - } - else { - return List_distinct(collect((out) => defaultArg(ProcessOutput_tryGetCharacteristicValues_Z4A02997C(out), empty()), matchValue), { - Equals: equals, - GetHashCode: safeHash, - }); - } -} - -/** - * Returns the characteristic values describing the inputs and outputs of the process - */ -export function Process_getCharacteristicValues_30EF9E7B(p) { - return List_distinct(append(Process_getInputCharacteristicValues_30EF9E7B(p), Process_getOutputCharacteristicValues_30EF9E7B(p)), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the characteristics describing the inputs and outputs of the process - */ -export function Process_getCharacteristics_30EF9E7B(p) { - return List_distinct(choose((cv) => cv.Category, Process_getCharacteristicValues_30EF9E7B(p)), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the factor values of the samples of the process - */ -export function Process_getFactorValues_30EF9E7B(p) { - return List_distinct(collect((arg_1) => defaultArg(ProcessOutput_tryGetFactorValues_Z4A02997C(arg_1), empty()), defaultArg(p.Outputs, empty())), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the factors of the samples of the process - */ -export function Process_getFactors_30EF9E7B(p) { - return List_distinct(choose((fv) => fv.Category, Process_getFactorValues_30EF9E7B(p)), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the units of the process - */ -export function Process_getUnits_30EF9E7B(p) { - return append(choose((cv) => cv.Unit, Process_getCharacteristicValues_30EF9E7B(p)), append(choose((pv) => pv.Unit, Process_getParameterValues_30EF9E7B(p)), choose((fv) => fv.Unit, Process_getFactorValues_30EF9E7B(p)))); -} - -/** - * If the process implements the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function Process_tryGetInputsWithParameterBy(predicate, p) { - const matchValue = p.ParameterValues; - if (matchValue == null) { - return void 0; - } - else { - const matchValue_1 = tryFind((pv) => predicate(defaultArg(pv.Category, ProtocolParameter_get_empty())), matchValue); - if (matchValue_1 == null) { - return void 0; - } - else { - const paramValue = matchValue_1; - return map((list_1) => map_1((i) => [i, paramValue], list_1), p.Inputs); - } - } -} - -/** - * If the process implements the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function Process_tryGetOutputsWithParameterBy(predicate, p) { - const matchValue = p.ParameterValues; - if (matchValue == null) { - return void 0; - } - else { - const matchValue_1 = tryFind((pv) => predicate(defaultArg(pv.Category, ProtocolParameter_get_empty())), matchValue); - if (matchValue_1 == null) { - return void 0; - } - else { - const paramValue = matchValue_1; - return map((list_1) => map_1((i) => [i, paramValue], list_1), p.Outputs); - } - } -} - -/** - * If the process implements the given characteristic, return the list of input files together with their according characteristic values of this characteristic - */ -export function Process_tryGetInputsWithCharacteristicBy(predicate, p) { - const matchValue = p.Inputs; - if (matchValue == null) { - return void 0; - } - else { - return fromValueWithDefault(empty(), choose((i) => tryPick((mv) => { - const matchValue_1 = mv.Category; - let matchResult, m_1; - if (matchValue_1 != null) { - if (predicate(matchValue_1)) { - matchResult = 0; - m_1 = matchValue_1; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return [i, mv]; - default: - return void 0; - } - }, defaultArg(ProcessInput_tryGetCharacteristicValues_Z38E7E853(i), empty())), matchValue)); - } -} - -/** - * If the process implements the given characteristic, return the list of output files together with their according characteristic values of this characteristic - */ -export function Process_tryGetOutputsWithCharacteristicBy(predicate, p) { - const matchValue = p.Inputs; - const matchValue_1 = p.Outputs; - let matchResult, is, os; - if (matchValue != null) { - if (matchValue_1 != null) { - matchResult = 0; - is = matchValue; - os = matchValue_1; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return fromValueWithDefault(empty(), choose((tupledArg) => tryPick((mv) => { - const matchValue_3 = mv.Category; - let matchResult_1, m_1; - if (matchValue_3 != null) { - if (predicate(matchValue_3)) { - matchResult_1 = 0; - m_1 = matchValue_3; - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - switch (matchResult_1) { - case 0: - return [tupledArg[1], mv]; - default: - return void 0; - } - }, defaultArg(ProcessInput_tryGetCharacteristicValues_Z38E7E853(tupledArg[0]), empty())), zip(is, os))); - default: - return void 0; - } -} - -/** - * If the process implements the given factor, return the list of output files together with their according factor values of this factor - */ -export function Process_tryGetOutputsWithFactorBy(predicate, p) { - const matchValue = p.Outputs; - if (matchValue == null) { - return void 0; - } - else { - return fromValueWithDefault(empty(), choose((o) => tryPick((mv) => { - const matchValue_1 = mv.Category; - let matchResult, m_1; - if (matchValue_1 != null) { - if (predicate(matchValue_1)) { - matchResult = 0; - m_1 = matchValue_1; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return [o, mv]; - default: - return void 0; - } - }, defaultArg(ProcessOutput_tryGetFactorValues_Z4A02997C(o), empty())), matchValue)); - } -} - -export function Process_getSources_30EF9E7B(p) { - return List_distinct(choose(ProcessInput_trySource_Z38E7E853, defaultArg(p.Inputs, empty())), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function Process_getData_30EF9E7B(p) { - return List_distinct(append(choose(ProcessInput_tryData_Z38E7E853, defaultArg(p.Inputs, empty())), choose(ProcessInput_tryData_Z38E7E853, defaultArg(p.Inputs, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function Process_getSamples_30EF9E7B(p) { - return List_distinct(append(choose(ProcessInput_trySample_Z38E7E853, defaultArg(p.Inputs, empty())), choose(ProcessInput_trySample_Z38E7E853, defaultArg(p.Inputs, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function Process_getMaterials_30EF9E7B(p) { - return List_distinct(append(choose(ProcessInput_tryMaterial_Z38E7E853, defaultArg(p.Inputs, empty())), choose(ProcessInput_tryMaterial_Z38E7E853, defaultArg(p.Inputs, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function Process_updateProtocol(referenceProtocols, p) { - let this$, recordType_1, recordType_2; - const matchValue = p.ExecutesProtocol; - let matchResult, protocol_1; - if (matchValue != null) { - if (matchValue.Name != null) { - matchResult = 0; - protocol_1 = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: { - const matchValue_1 = tryFind((prot) => (value_4(prot.Name) === defaultArg(protocol_1.Name, "")), referenceProtocols); - if (matchValue_1 != null) { - return new Process(p.ID, p.Name, (this$ = (new Update_UpdateOptions(3, [])), (recordType_1 = protocol_1, (recordType_2 = matchValue_1, (this$.tag === 2) ? makeRecord(Protocol_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) : ((this$.tag === 1) ? makeRecord(Protocol_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) : ((this$.tag === 3) ? makeRecord(Protocol_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) : recordType_2))))), p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, p.Outputs, p.Comments); - } - else { - return p; - } - } - default: - return p; - } -} - diff --git a/js/ISA/ISA/JsonTypes/ProcessInput.js b/js/ISA/ISA/JsonTypes/ProcessInput.js deleted file mode 100644 index 2bce6c8b..00000000 --- a/js/ISA/ISA/JsonTypes/ProcessInput.js +++ /dev/null @@ -1,297 +0,0 @@ -import { Union, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { Source_create_Z32235993, Source_getUnits_Z220A6393, Source_setCharacteristicValues, Source_get_empty, Source_$reflection } from "./Source.js"; -import { Sample_create_3A6378D6, Sample_getUnits_Z23050B6A, Sample_setCharacteristicValues, Sample_$reflection } from "./Sample.js"; -import { Data_create_Z748D099, Data_$reflection } from "./Data.js"; -import { Material_create_76090C97, Material_getUnits_43A4149B, Material_setCharacteristicValues, Material_$reflection } from "./Material.js"; -import { union_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { unwrap, map, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { empty, choose } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { DataFile } from "./DataFile.js"; - -export class ProcessInput extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Source", "Sample", "Data", "Material"]; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - switch (this$.tag) { - case 0: { - const arg_1 = this$.fields[0].PrintCompact(); - return toText(printf("Source {%s}"))(arg_1); - } - case 3: { - const arg_2 = this$.fields[0].PrintCompact(); - return toText(printf("Material {%s}"))(arg_2); - } - case 2: { - const arg_3 = this$.fields[0].PrintCompact(); - return toText(printf("Data {%s}"))(arg_3); - } - default: { - const arg = this$.fields[0].PrintCompact(); - return toText(printf("Sample {%s}"))(arg); - } - } - } -} - -export function ProcessInput_$reflection() { - return union_type("ISA.ProcessInput", [], ProcessInput, () => [[["Item", Source_$reflection()]], [["Item", Sample_$reflection()]], [["Item", Data_$reflection()]], [["Item", Material_$reflection()]]]); -} - -export function ProcessInput__get_TryName(this$) { - switch (this$.tag) { - case 0: - return this$.fields[0].Name; - case 3: - return this$.fields[0].Name; - case 2: - return this$.fields[0].Name; - default: - return this$.fields[0].Name; - } -} - -export function ProcessInput__get_Name(this$) { - return defaultArg(ProcessInput__get_TryName(this$), ""); -} - -export function ProcessInput_get_Default() { - return new ProcessInput(0, [Source_get_empty()]); -} - -/** - * Returns name of processInput - */ -export function ProcessInput_tryGetName_Z38E7E853(pi) { - return ProcessInput__get_TryName(pi); -} - -/** - * Returns name of processInput - */ -export function ProcessInput_getName_Z38E7E853(pi) { - return ProcessInput__get_Name(pi); -} - -/** - * Returns true, if given name equals name of processInput - */ -export function ProcessInput_nameEquals(name, pi) { - return ProcessInput__get_Name(pi) === name; -} - -/** - * Returns true, if Process Input is Sample - */ -export function ProcessInput_isSample_Z38E7E853(pi) { - if (pi.tag === 1) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Input is Source - */ -export function ProcessInput_isSource_Z38E7E853(pi) { - if (pi.tag === 0) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Input is Data - */ -export function ProcessInput_isData_Z38E7E853(pi) { - if (pi.tag === 2) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Input is Material - */ -export function ProcessInput_isMaterial_Z38E7E853(pi) { - if (pi.tag === 3) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Input is Source - */ -export function ProcessInput__isSource(this$) { - return ProcessInput_isSource_Z38E7E853(this$); -} - -/** - * Returns true, if Process Input is Sample - */ -export function ProcessInput__isSample(this$) { - return ProcessInput_isSample_Z38E7E853(this$); -} - -/** - * Returns true, if Process Input is Data - */ -export function ProcessInput__isData(this$) { - return ProcessInput_isData_Z38E7E853(this$); -} - -/** - * Returns true, if Process Input is Material - */ -export function ProcessInput__isMaterial(this$) { - return ProcessInput_isMaterial_Z38E7E853(this$); -} - -/** - * If given process input is a sample, returns it, else returns None - */ -export function ProcessInput_trySample_Z38E7E853(pi) { - if (pi.tag === 1) { - return pi.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process input is a source, returns it, else returns None - */ -export function ProcessInput_trySource_Z38E7E853(pi) { - if (pi.tag === 0) { - return pi.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process input is a data, returns it, else returns None - */ -export function ProcessInput_tryData_Z38E7E853(pi) { - if (pi.tag === 2) { - return pi.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process input is a material, returns it, else returns None - */ -export function ProcessInput_tryMaterial_Z38E7E853(pi) { - if (pi.tag === 3) { - return pi.fields[0]; - } - else { - return void 0; - } -} - -export function ProcessInput_setCharacteristicValues(characteristics, pi) { - switch (pi.tag) { - case 0: - return new ProcessInput(0, [Source_setCharacteristicValues(characteristics, pi.fields[0])]); - case 3: - return new ProcessInput(3, [Material_setCharacteristicValues(characteristics, pi.fields[0])]); - case 2: - return pi; - default: - return new ProcessInput(1, [Sample_setCharacteristicValues(characteristics, pi.fields[0])]); - } -} - -/** - * If given process input contains characteristics, returns them - */ -export function ProcessInput_tryGetCharacteristicValues_Z38E7E853(pi) { - switch (pi.tag) { - case 0: - return pi.fields[0].Characteristics; - case 3: - return pi.fields[0].Characteristics; - case 2: - return void 0; - default: - return pi.fields[0].Characteristics; - } -} - -/** - * If given process input contains characteristics, returns them - */ -export function ProcessInput_tryGetCharacteristics_Z38E7E853(pi) { - return map((list) => choose((c) => c.Category, list), ProcessInput_tryGetCharacteristicValues_Z38E7E853(pi)); -} - -export function ProcessInput_getCharacteristicValues_Z38E7E853(pi) { - return defaultArg(ProcessInput_tryGetCharacteristicValues_Z38E7E853(pi), empty()); -} - -/** - * If given process output contains units, returns them - */ -export function ProcessInput_getUnits_Z38E7E853(pi) { - switch (pi.tag) { - case 1: - return Sample_getUnits_Z23050B6A(pi.fields[0]); - case 3: - return Material_getUnits_43A4149B(pi.fields[0]); - case 2: - return empty(); - default: - return Source_getUnits_Z220A6393(pi.fields[0]); - } -} - -export function ProcessInput_createSource_Z3083890A(name, characteristics) { - return new ProcessInput(0, [Source_create_Z32235993(void 0, name, unwrap(characteristics))]); -} - -export function ProcessInput_createSample_Z445EF6B3(name, characteristics, factors, derivesFrom) { - return new ProcessInput(1, [Sample_create_3A6378D6(void 0, name, unwrap(characteristics), unwrap(factors), unwrap(derivesFrom))]); -} - -export function ProcessInput_createMaterial_ZEED0B34(name, characteristics, derivesFrom) { - return new ProcessInput(3, [Material_create_76090C97(void 0, name, void 0, unwrap(characteristics), unwrap(derivesFrom))]); -} - -export function ProcessInput_createImageFile_Z721C83C5(name) { - return new ProcessInput(2, [Data_create_Z748D099(void 0, name, new DataFile(2, []))]); -} - -export function ProcessInput_createRawData_Z721C83C5(name) { - return new ProcessInput(2, [Data_create_Z748D099(void 0, name, new DataFile(0, []))]); -} - -export function ProcessInput_createDerivedData_Z721C83C5(name) { - return new ProcessInput(2, [Data_create_Z748D099(void 0, name, new DataFile(1, []))]); -} - diff --git a/js/ISA/ISA/JsonTypes/ProcessOutput.js b/js/ISA/ISA/JsonTypes/ProcessOutput.js deleted file mode 100644 index 4787bab5..00000000 --- a/js/ISA/ISA/JsonTypes/ProcessOutput.js +++ /dev/null @@ -1,263 +0,0 @@ -import { Union, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { Sample_create_3A6378D6, Sample_getUnits_Z23050B6A, Sample_setFactorValues, Sample_get_empty, Sample_$reflection } from "./Sample.js"; -import { Data_create_Z748D099, Data_$reflection } from "./Data.js"; -import { Material_create_76090C97, Material_getUnits_43A4149B, Material_$reflection } from "./Material.js"; -import { union_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { unwrap, map, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { empty, choose } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { DataFile } from "./DataFile.js"; - -export class ProcessOutput extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Sample", "Data", "Material"]; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - switch (this$.tag) { - case 2: { - const arg_1 = this$.fields[0].PrintCompact(); - return toText(printf("Material {%s}"))(arg_1); - } - case 1: { - const arg_2 = this$.fields[0].PrintCompact(); - return toText(printf("Data {%s}"))(arg_2); - } - default: { - const arg = this$.fields[0].PrintCompact(); - return toText(printf("Sample {%s}"))(arg); - } - } - } -} - -export function ProcessOutput_$reflection() { - return union_type("ISA.ProcessOutput", [], ProcessOutput, () => [[["Item", Sample_$reflection()]], [["Item", Data_$reflection()]], [["Item", Material_$reflection()]]]); -} - -export function ProcessOutput__get_TryName(this$) { - switch (this$.tag) { - case 2: - return this$.fields[0].Name; - case 1: - return this$.fields[0].Name; - default: - return this$.fields[0].Name; - } -} - -export function ProcessOutput__get_Name(this$) { - return defaultArg(ProcessOutput__get_TryName(this$), ""); -} - -export function ProcessOutput_get_Default() { - return new ProcessOutput(0, [Sample_get_empty()]); -} - -/** - * Returns name of processOutput - */ -export function ProcessOutput_tryGetName_Z4A02997C(po) { - return ProcessOutput__get_TryName(po); -} - -/** - * Returns name of processInput - */ -export function ProcessOutput_getName_Z4A02997C(po) { - return ProcessOutput__get_Name(po); -} - -/** - * Returns true, if given name equals name of processOutput - */ -export function ProcessOutput_nameEquals(name, po) { - return ProcessOutput__get_Name(po) === name; -} - -/** - * Returns true, if Process Output is Sample - */ -export function ProcessOutput_isSample_Z4A02997C(po) { - if (po.tag === 0) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Output is Data - */ -export function ProcessOutput_isData_Z4A02997C(po) { - if (po.tag === 1) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Output is Material - */ -export function ProcessOutput_isMaterial_Z4A02997C(po) { - if (po.tag === 2) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Output is Sample - */ -export function ProcessOutput__isSample(this$) { - return ProcessOutput_isSample_Z4A02997C(this$); -} - -/** - * Returns true, if Process Output is Data - */ -export function ProcessOutput__isData(this$) { - return ProcessOutput_isData_Z4A02997C(this$); -} - -/** - * Returns true, if Process Output is Material - */ -export function ProcessOutput__isMaterial(this$) { - return ProcessOutput_isMaterial_Z4A02997C(this$); -} - -/** - * If given process output is a sample, returns it, else returns None - */ -export function ProcessOutput_trySample_Z4A02997C(po) { - if (po.tag === 0) { - return po.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process output is a data, returns it, else returns None - */ -export function ProcessOutput_tryData_Z4A02997C(po) { - if (po.tag === 1) { - return po.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process output is a material, returns it, else returns None - */ -export function ProcessOutput_tryMaterial_Z4A02997C(po) { - if (po.tag === 2) { - return po.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process output contains characteristics, returns them - */ -export function ProcessOutput_tryGetCharacteristicValues_Z4A02997C(po) { - switch (po.tag) { - case 2: - return po.fields[0].Characteristics; - case 1: - return void 0; - default: - return po.fields[0].Characteristics; - } -} - -/** - * If given process output contains characteristics, returns them - */ -export function ProcessOutput_tryGetCharacteristics_Z4A02997C(po) { - return map((list) => choose((c) => c.Category, list), ProcessOutput_tryGetCharacteristicValues_Z4A02997C(po)); -} - -/** - * If given process output contains factors, returns them - */ -export function ProcessOutput_tryGetFactorValues_Z4A02997C(po) { - switch (po.tag) { - case 2: - return void 0; - case 1: - return void 0; - default: - return po.fields[0].FactorValues; - } -} - -export function ProcessOutput_setFactorValues(values, po) { - switch (po.tag) { - case 2: - return po; - case 1: - return po; - default: - return new ProcessOutput(0, [Sample_setFactorValues(values, po.fields[0])]); - } -} - -export function ProcessOutput_getFactorValues_Z4A02997C(po) { - return defaultArg(ProcessOutput_tryGetFactorValues_Z4A02997C(po), empty()); -} - -/** - * If given process output contains units, returns them - */ -export function ProcessOutput_getUnits_Z4A02997C(po) { - switch (po.tag) { - case 2: - return Material_getUnits_43A4149B(po.fields[0]); - case 1: - return empty(); - default: - return Sample_getUnits_Z23050B6A(po.fields[0]); - } -} - -export function ProcessOutput_createSample_Z445EF6B3(name, characteristics, factors, derivesFrom) { - return new ProcessOutput(0, [Sample_create_3A6378D6(void 0, name, unwrap(characteristics), unwrap(factors), unwrap(derivesFrom))]); -} - -export function ProcessOutput_createMaterial_ZEED0B34(name, characteristics, derivesFrom) { - return new ProcessOutput(2, [Material_create_76090C97(void 0, name, void 0, unwrap(characteristics), unwrap(derivesFrom))]); -} - -export function ProcessOutput_createImageFile_Z721C83C5(name) { - return new ProcessOutput(1, [Data_create_Z748D099(void 0, name, new DataFile(2, []))]); -} - -export function ProcessOutput_createRawData_Z721C83C5(name) { - return new ProcessOutput(1, [Data_create_Z748D099(void 0, name, new DataFile(0, []))]); -} - -export function ProcessOutput_createDerivedData_Z721C83C5(name) { - return new ProcessOutput(1, [Data_create_Z748D099(void 0, name, new DataFile(1, []))]); -} - diff --git a/js/ISA/ISA/JsonTypes/ProcessParameterValue.js b/js/ISA/ISA/JsonTypes/ProcessParameterValue.js deleted file mode 100644 index b941b050..00000000 --- a/js/ISA/ISA/JsonTypes/ProcessParameterValue.js +++ /dev/null @@ -1,129 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { bind, defaultArg, map } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { ProtocolParameter__SetCategory_2FC95D30, ProtocolParameter_create_2769312B, ProtocolParameter__MapCategory_65D42856, ProtocolParameter__get_TryNameText, ProtocolParameter_$reflection, ProtocolParameter__get_NameText } from "./ProtocolParameter.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation__get_NameText } from "./OntologyAnnotation.js"; -import { record_type, option_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Value_$reflection } from "./Value.js"; -import { int32ToString } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; - -export class ProcessParameterValue extends Record { - constructor(Category, Value, Unit) { - super(); - this.Category = Category; - this.Value = Value; - this.Unit = Unit; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - let value_2, category_2, category_1, value_1; - const this$ = this; - const category = map(ProtocolParameter__get_NameText, this$.Category); - const unit = map(OntologyAnnotation__get_NameText, this$.Unit); - const value = map((v) => { - const s = v.PrintCompact(); - if (unit == null) { - return s; - } - else { - return (s + " ") + unit; - } - }, this$.Value); - return (category == null) ? ((value == null) ? "" : ((value_2 = value, value_2))) : ((value == null) ? ((category_2 = category, (category_2 + ":") + "No Value")) : ((category_1 = category, (value_1 = value, (category_1 + ":") + value_1)))); - } -} - -export function ProcessParameterValue_$reflection() { - return record_type("ISA.ProcessParameterValue", [], ProcessParameterValue, () => [["Category", option_type(ProtocolParameter_$reflection())], ["Value", option_type(Value_$reflection())], ["Unit", option_type(OntologyAnnotation_$reflection())]]); -} - -export function ProcessParameterValue_make(category, value, unit) { - return new ProcessParameterValue(category, value, unit); -} - -export function ProcessParameterValue_create_2A3A2A47(Category, Value, Unit) { - return ProcessParameterValue_make(Category, Value, Unit); -} - -export function ProcessParameterValue_get_empty() { - return ProcessParameterValue_create_2A3A2A47(); -} - -/** - * Returns the name of the category as string - */ -export function ProcessParameterValue__get_NameText(this$) { - return defaultArg(map(ProtocolParameter__get_NameText, this$.Category), ""); -} - -/** - * Returns the name of the category as string - */ -export function ProcessParameterValue__get_TryNameText(this$) { - return bind(ProtocolParameter__get_TryNameText, this$.Category); -} - -export function ProcessParameterValue__get_ValueText(this$) { - return defaultArg(map((oa) => { - switch (oa.tag) { - case 2: - return oa.fields[0].toString(); - case 1: - return int32ToString(oa.fields[0]); - case 3: - return oa.fields[0]; - default: - return OntologyAnnotation__get_NameText(oa.fields[0]); - } - }, this$.Value), ""); -} - -export function ProcessParameterValue__get_ValueWithUnitText(this$) { - const unit = map(OntologyAnnotation__get_NameText, this$.Unit); - const v = ProcessParameterValue__get_ValueText(this$); - if (unit == null) { - return v; - } - else { - const u = unit; - return toText(printf("%s %s"))(v)(u); - } -} - -export function ProcessParameterValue__MapCategory_65D42856(this$, f) { - return new ProcessParameterValue(map((p) => ProtocolParameter__MapCategory_65D42856(p, f), this$.Category), this$.Value, this$.Unit); -} - -export function ProcessParameterValue__SetCategory_2FC95D30(this$, c) { - let matchValue; - return new ProcessParameterValue((matchValue = this$.Category, (matchValue == null) ? ProtocolParameter_create_2769312B(void 0, c) : ProtocolParameter__SetCategory_2FC95D30(matchValue, c)), this$.Value, this$.Unit); -} - -/** - * Returns the name of the paramater value as string if it exists - */ -export function ProcessParameterValue_tryGetNameText_39585819(pv) { - return ProcessParameterValue__get_TryNameText(pv); -} - -/** - * Returns the name of the paramater value as string - */ -export function ProcessParameterValue_getNameText_39585819(pv) { - return ProcessParameterValue__get_NameText(pv); -} - -/** - * Returns true if the given name matches the name of the parameter value - */ -export function ProcessParameterValue_nameEqualsString(name, pv) { - return ProcessParameterValue__get_NameText(pv) === name; -} - -export function ProcessParameterValue_getCategory_39585819(pv) { - return pv.Category; -} - diff --git a/js/ISA/ISA/JsonTypes/ProcessSequence.js b/js/ISA/ISA/JsonTypes/ProcessSequence.js deleted file mode 100644 index f8ea4017..00000000 --- a/js/ISA/ISA/JsonTypes/ProcessSequence.js +++ /dev/null @@ -1,255 +0,0 @@ -import { List_groupBy, List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { singleton, zip, map, empty, collect, concat, filter, choose } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { value as value_3, defaultArg, bind } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { arrayHash, equalArrays, comparePrimitives, safeHash, equals, stringHash } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { Process_updateProtocol, Process_getMaterials_30EF9E7B, Process_getSamples_30EF9E7B, Process_getSources_30EF9E7B, Process_getData_30EF9E7B, Process_getUnits_30EF9E7B, Process_getFactors_30EF9E7B, Process_tryGetOutputsWithFactorBy, Process_tryGetOutputsWithCharacteristicBy, Process_tryGetInputsWithCharacteristicBy, Process_getCharacteristics_30EF9E7B, Process_getParameters_30EF9E7B, Process_tryGetOutputsWithParameterBy, Process_tryGetInputsWithParameterBy } from "./Process.js"; -import { FSharpSet__Contains, ofList } from "../../../fable_modules/fable-library.4.1.4/Set.js"; -import { ProcessOutput__get_Name, ProcessOutput_getName_Z4A02997C } from "./ProcessOutput.js"; -import { ProcessInput__get_Name, ProcessInput_getName_Z38E7E853 } from "./ProcessInput.js"; -import { FSharpMap__TryFind, ofList as ofList_1 } from "../../../fable_modules/fable-library.4.1.4/Map.js"; - -/** - * Returns the names of the protocols the given processes impelement - */ -export function getProtocolNames(processSequence) { - return List_distinct(choose((p) => bind((protocol) => protocol.Name, p.ExecutesProtocol), processSequence), { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - }); -} - -/** - * Returns the protocols the given processes impelement - */ -export function getProtocols(processSequence) { - return List_distinct(choose((p) => p.ExecutesProtocol, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns a list of the processes, containing only the ones executing a protocol for which the predicate returns true - */ -export function filterByProtocolBy(predicate, processSequence) { - return filter((p) => { - const matchValue = p.ExecutesProtocol; - let matchResult, protocol_1; - if (matchValue != null) { - if (predicate(matchValue)) { - matchResult = 0; - protocol_1 = matchValue; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } - }, processSequence); -} - -/** - * Returns a list of the processes, containing only the ones executing a protocol with the given name - */ -export function filterByProtocolName(protocolName, processSequence) { - return filterByProtocolBy((p) => equals(p.Name, protocolName), processSequence); -} - -/** - * If the processes contain a process implementing the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function getInputsWithParameterBy(predicate, processSequence) { - return concat(choose((arg_1) => Process_tryGetInputsWithParameterBy(predicate, arg_1), processSequence)); -} - -/** - * If the processes contain a process implementing the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function getOutputsWithParameterBy(predicate, processSequence) { - return concat(choose((arg_1) => Process_tryGetOutputsWithParameterBy(predicate, arg_1), processSequence)); -} - -/** - * Returns the parameters implemented by the processes contained in these processes - */ -export function getParameters(processSequence) { - return List_distinct(collect(Process_getParameters_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the characteristics describing the inputs and outputs of the processssequence - */ -export function getCharacteristics(processSequence) { - return List_distinct(collect(Process_getCharacteristics_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * If the processes contain a process implementing the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function getInputsWithCharacteristicBy(predicate, processSequence) { - return concat(choose((arg_1) => Process_tryGetInputsWithCharacteristicBy(predicate, arg_1), processSequence)); -} - -/** - * If the processes contain a process implementing the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function getOutputsWithCharacteristicBy(predicate, processSequence) { - return concat(choose((arg_1) => Process_tryGetOutputsWithCharacteristicBy(predicate, arg_1), processSequence)); -} - -/** - * If the processes contain a process implementing the given factor, return the list of output files together with their according factor values of this factor - */ -export function getOutputsWithFactorBy(predicate, processSequence) { - return concat(choose((arg_1) => Process_tryGetOutputsWithFactorBy(predicate, arg_1), processSequence)); -} - -/** - * Returns the factors implemented by the processes contained in these processes - */ -export function getFactors(processSequence) { - return List_distinct(collect(Process_getFactors_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the initial inputs final outputs of the processSequence, to which no processPoints - */ -export function getRootInputs(processSequence) { - const inputs = collect((p) => defaultArg(p.Inputs, empty()), processSequence); - const outputs = ofList(collect((p_1) => map(ProcessOutput_getName_Z4A02997C, defaultArg(p_1.Outputs, empty())), processSequence), { - Compare: comparePrimitives, - }); - return filter((i) => !FSharpSet__Contains(outputs, ProcessInput_getName_Z38E7E853(i)), inputs); -} - -/** - * Returns the final outputs of the processSequence, which point to no further nodes - */ -export function getFinalOutputs(processSequence) { - const inputs = ofList(collect((p) => map(ProcessInput_getName_Z38E7E853, defaultArg(p.Inputs, empty())), processSequence), { - Compare: comparePrimitives, - }); - return filter((o) => !FSharpSet__Contains(inputs, ProcessOutput_getName_Z4A02997C(o)), collect((p_1) => defaultArg(p_1.Outputs, empty()), processSequence)); -} - -/** - * Returns the initial inputs final outputs of the processSequence, to which no processPoints - */ -export function getRootInputOf(processSequence, sample) { - const mappings = ofList_1(map((tupledArg) => [tupledArg[0], map((tuple_1) => tuple_1[1], tupledArg[1])], List_groupBy((tuple) => tuple[0], collect((p) => List_distinct(zip(map(ProcessOutput__get_Name, value_3(p.Outputs)), map(ProcessInput__get_Name, value_3(p.Inputs))), { - Equals: equalArrays, - GetHashCode: arrayHash, - }), processSequence), { - Equals: (x_1, y_1) => (x_1 === y_1), - GetHashCode: stringHash, - })), { - Compare: comparePrimitives, - }); - const loop = (lastState_mut, state_mut) => { - loop: - while (true) { - const lastState = lastState_mut, state = state_mut; - if (equals(lastState, state)) { - return state; - } - else { - lastState_mut = state; - state_mut = collect((s) => defaultArg(FSharpMap__TryFind(mappings, s), singleton(s)), state); - continue loop; - } - break; - } - }; - return loop(empty(), singleton(sample)); -} - -/** - * Returns the final outputs of the processSequence, which point to no further nodes - */ -export function getFinalOutputsOf(processSequence, sample) { - const mappings = ofList_1(map((tupledArg) => [tupledArg[0], map((tuple_1) => tuple_1[1], tupledArg[1])], List_groupBy((tuple) => tuple[0], collect((p) => List_distinct(zip(map(ProcessInput__get_Name, value_3(p.Inputs)), map(ProcessOutput__get_Name, value_3(p.Outputs))), { - Equals: equalArrays, - GetHashCode: arrayHash, - }), processSequence), { - Equals: (x_1, y_1) => (x_1 === y_1), - GetHashCode: stringHash, - })), { - Compare: comparePrimitives, - }); - const loop = (lastState_mut, state_mut) => { - loop: - while (true) { - const lastState = lastState_mut, state = state_mut; - if (equals(lastState, state)) { - return state; - } - else { - lastState_mut = state; - state_mut = collect((s) => defaultArg(FSharpMap__TryFind(mappings, s), singleton(s)), state); - continue loop; - } - break; - } - }; - return loop(empty(), singleton(sample)); -} - -export function getUnits(processSequence) { - return List_distinct(collect(Process_getUnits_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the data the given processes contain - */ -export function getData(processSequence) { - return List_distinct(collect(Process_getData_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function getSources(processSequence) { - return List_distinct(collect(Process_getSources_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function getSamples(processSequence) { - return List_distinct(collect(Process_getSamples_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function getMaterials(processSequence) { - return List_distinct(collect(Process_getMaterials_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function updateProtocols(protocols, processSequence) { - return map((arg_1) => Process_updateProtocol(protocols, arg_1), processSequence); -} - diff --git a/js/ISA/ISA/JsonTypes/Protocol.js b/js/ISA/ISA/JsonTypes/Protocol.js deleted file mode 100644 index 959896cc..00000000 --- a/js/ISA/ISA/JsonTypes/Protocol.js +++ /dev/null @@ -1,277 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { ProtocolParameter_$reflection } from "./ProtocolParameter.js"; -import { Component_$reflection } from "./Component.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { empty, filter, map, singleton, append, exists, tryFind } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { defaultArg, map as map_1 } from "../../../fable_modules/fable-library.4.1.4/Option.js"; - -export class Protocol extends Record { - constructor(ID, Name, ProtocolType, Description, Uri, Version, Parameters, Components, Comments) { - super(); - this.ID = ID; - this.Name = Name; - this.ProtocolType = ProtocolType; - this.Description = Description; - this.Uri = Uri; - this.Version = Version; - this.Parameters = Parameters; - this.Components = Components; - this.Comments = Comments; - } -} - -export function Protocol_$reflection() { - return record_type("ISA.Protocol", [], Protocol, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["ProtocolType", option_type(OntologyAnnotation_$reflection())], ["Description", option_type(string_type)], ["Uri", option_type(string_type)], ["Version", option_type(string_type)], ["Parameters", option_type(list_type(ProtocolParameter_$reflection()))], ["Components", option_type(list_type(Component_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Protocol_make(id, name, protocolType, description, uri, version, parameters, components, comments) { - return new Protocol(id, name, protocolType, description, uri, version, parameters, components, comments); -} - -export function Protocol_create_Z4D717767(Id, Name, ProtocolType, Description, Uri, Version, Parameters, Components, Comments) { - return Protocol_make(Id, Name, ProtocolType, Description, Uri, Version, Parameters, Components, Comments); -} - -export function Protocol_get_empty() { - return Protocol_create_Z4D717767(); -} - -/** - * If a protocol with the given identfier exists in the list, returns it - */ -export function Protocol_tryGetByName(name, protocols) { - return tryFind((p) => equals(p.Name, name), protocols); -} - -/** - * If a protocol with the given name exists in the list exists, returns true - */ -export function Protocol_existsByName(name, protocols) { - return exists((p) => equals(p.Name, name), protocols); -} - -/** - * Adds the given protocol to the protocols - */ -export function Protocol_add(protocols, protocol) { - return append(protocols, singleton(protocol)); -} - -/** - * Updates all protocols for which the predicate returns true with the given protocol values - */ -export function Protocol_updateBy(predicate, updateOption, protocol, protocols) { - if (exists(predicate, protocols)) { - return map((p) => { - if (predicate(p)) { - const this$ = updateOption; - const recordType_1 = p; - const recordType_2 = protocol; - return (this$.tag === 2) ? makeRecord(Protocol_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) : ((this$.tag === 1) ? makeRecord(Protocol_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) : ((this$.tag === 3) ? makeRecord(Protocol_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) : recordType_2)); - } - else { - return p; - } - }, protocols); - } - else { - return protocols; - } -} - -/** - * Updates all protocols with the same name as the given protocol with its values - */ -export function Protocol_updateByName(updateOption, protocol, protocols) { - return Protocol_updateBy((p) => equals(p.Name, protocol.Name), updateOption, protocol, protocols); -} - -/** - * If a protocol with the given name exists in the list, removes it - */ -export function Protocol_removeByName(name, protocols) { - return filter((p) => !equals(p.Name, name), protocols); -} - -/** - * Returns comments of a protocol - */ -export function Protocol_getComments_4D8AC666(protocol) { - return protocol.Comments; -} - -/** - * Applies function f on comments of a protocol - */ -export function Protocol_mapComments(f, protocol) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, map_1(f, protocol.Comments)); -} - -/** - * Replaces comments of a protocol by given comment list - */ -export function Protocol_setComments(protocol, comments) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, comments); -} - -/** - * Returns protocol type of a protocol - */ -export function Protocol_getProtocolType_4D8AC666(protocol) { - return protocol.ProtocolType; -} - -/** - * Applies function f on protocol type of a protocol - */ -export function Protocol_mapProtocolType(f, protocol) { - return new Protocol(protocol.ID, protocol.Name, map_1(f, protocol.ProtocolType), protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol type of a protocol by given protocol type - */ -export function Protocol_setProtocolType(protocol, protocolType) { - return new Protocol(protocol.ID, protocol.Name, protocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Returns protocol version of a protocol - */ -export function Protocol_getVersion_4D8AC666(protocol) { - return protocol.Version; -} - -/** - * Applies function f on protocol version of a protocol - */ -export function Protocol_mapVersion(f, protocol) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, map_1(f, protocol.Version), protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol version of a protocol by given protocol version - */ -export function Protocol_setVersion(protocol, version) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Protocol Name - * Returns protocol name of a protocol - */ -export function Protocol_getName_4D8AC666(protocol) { - return protocol.Name; -} - -/** - * Applies function f on protocol name of a protocol - */ -export function Protocol_mapName(f, protocol) { - return new Protocol(protocol.ID, map_1(f, protocol.Name), protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol name of a protocol by given protocol name - */ -export function Protocol_setName(protocol, name) { - return new Protocol(protocol.ID, name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Returns protocol description of a protocol - */ -export function Protocol_getDescription_4D8AC666(protocol) { - return protocol.Description; -} - -/** - * Applies function f on protocol description of a protocol - */ -export function Protocol_mapDescription(f, protocol) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, map_1(f, protocol.Description), protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol description of a protocol by given protocol description - */ -export function Protocol_setDescription(protocol, description) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Returns protocol URI of a protocol - */ -export function Protocol_getUri_4D8AC666(protocol) { - return protocol.Uri; -} - -/** - * Applies function f on protocol URI of a protocol - */ -export function Protocol_mapUri(f, protocol) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, map_1(f, protocol.Uri), protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol URI of a protocol by given protocol URI - */ -export function Protocol_setUri(protocol, uri) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Returns components of a protocol - */ -export function Protocol_getComponents_4D8AC666(protocol) { - return protocol.Components; -} - -/** - * Applies function f on components of a protocol - */ -export function Protocol_mapComponents(f, protocol) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, map_1(f, protocol.Components), protocol.Comments); -} - -/** - * Replaces components of a protocol by given component list - */ -export function Protocol_setComponents(protocol, components) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, components, protocol.Comments); -} - -export function Protocol_addComponent(comp, protocol) { - return Protocol_setComponents(protocol, append(defaultArg(protocol.Components, empty()), singleton(comp))); -} - -/** - * Returns protocol parameters of a protocol - */ -export function Protocol_getParameters_4D8AC666(protocol) { - return protocol.Parameters; -} - -/** - * Applies function f on protocol parameters of a protocol - */ -export function Protocol_mapParameters(f, protocol) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, map_1(f, protocol.Parameters), protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol parameters of a protocol by given protocol parameter list - */ -export function Protocol_setParameters(protocol, parameters) { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, parameters, protocol.Components, protocol.Comments); -} - -export function Protocol_addParameter(parameter, protocol) { - return Protocol_setParameters(protocol, append(defaultArg(protocol.Parameters, empty()), singleton(parameter))); -} - diff --git a/js/ISA/ISA/JsonTypes/ProtocolParameter.js b/js/ISA/ISA/JsonTypes/ProtocolParameter.js deleted file mode 100644 index 93d8ca12..00000000 --- a/js/ISA/ISA/JsonTypes/ProtocolParameter.js +++ /dev/null @@ -1,101 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { record_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation__get_TryNameText, OntologyAnnotation__get_NameText, OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { bind, map, defaultArg, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; - -export class ProtocolParameter extends Record { - constructor(ID, ParameterName) { - super(); - this.ID = ID; - this.ParameterName = ParameterName; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - return "OA " + ProtocolParameter__get_NameText(this$); - } -} - -export function ProtocolParameter_$reflection() { - return record_type("ISA.ProtocolParameter", [], ProtocolParameter, () => [["ID", option_type(string_type)], ["ParameterName", option_type(OntologyAnnotation_$reflection())]]); -} - -export function ProtocolParameter_make(id, parameterName) { - return new ProtocolParameter(id, parameterName); -} - -export function ProtocolParameter_create_2769312B(Id, ParameterName) { - return ProtocolParameter_make(Id, ParameterName); -} - -export function ProtocolParameter_get_empty() { - return ProtocolParameter_create_2769312B(); -} - -/** - * Create a ISAJson Protocol Parameter from ISATab string entries - */ -export function ProtocolParameter_fromString_703AFBF9(term, source, accession, comments) { - const oa = OntologyAnnotation_fromString_Z7D8EB286(term, source, accession, unwrap(comments)); - return ProtocolParameter_make(void 0, fromValueWithDefault(OntologyAnnotation_get_empty(), oa)); -} - -/** - * Get ISATab string entries from an ISAJson ProtocolParameter object (name,source,accession) - */ -export function ProtocolParameter_toString_2762A46F(pp) { - const value = { - TermAccessionNumber: "", - TermName: "", - TermSourceREF: "", - }; - return defaultArg(map(OntologyAnnotation_toString_473B9D79, pp.ParameterName), value); -} - -/** - * Returns the name of the parameter as string - */ -export function ProtocolParameter__get_NameText(this$) { - return defaultArg(map(OntologyAnnotation__get_NameText, this$.ParameterName), ""); -} - -/** - * Returns the name of the parameter as string - */ -export function ProtocolParameter__get_TryNameText(this$) { - return bind(OntologyAnnotation__get_TryNameText, this$.ParameterName); -} - -export function ProtocolParameter__MapCategory_65D42856(this$, f) { - return new ProtocolParameter(this$.ID, map(f, this$.ParameterName)); -} - -export function ProtocolParameter__SetCategory_2FC95D30(this$, c) { - return new ProtocolParameter(this$.ID, c); -} - -/** - * Returns the name of the paramater as string if it exists - */ -export function ProtocolParameter_tryGetNameText_2762A46F(pp) { - return ProtocolParameter__get_TryNameText(pp); -} - -/** - * Returns the name of the paramater as string - */ -export function ProtocolParameter_getNameText_2762A46F(pp) { - return defaultArg(ProtocolParameter_tryGetNameText_2762A46F(pp), ""); -} - -/** - * Returns true if the given name matches the name of the parameter - */ -export function ProtocolParameter_nameEqualsString(name, pp) { - return ProtocolParameter__get_NameText(pp) === name; -} - diff --git a/js/ISA/ISA/JsonTypes/Publication.js b/js/ISA/ISA/JsonTypes/Publication.js deleted file mode 100644 index 7f90ae5d..00000000 --- a/js/ISA/ISA/JsonTypes/Publication.js +++ /dev/null @@ -1,169 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { empty, filter, map, tryFind, exists, singleton, append } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { map as map_1 } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { mapDefault } from "../OptionExtensions.js"; - -export class Publication extends Record { - constructor(PubMedID, DOI, Authors, Title, Status, Comments) { - super(); - this.PubMedID = PubMedID; - this.DOI = DOI; - this.Authors = Authors; - this.Title = Title; - this.Status = Status; - this.Comments = Comments; - } -} - -export function Publication_$reflection() { - return record_type("ISA.Publication", [], Publication, () => [["PubMedID", option_type(string_type)], ["DOI", option_type(string_type)], ["Authors", option_type(string_type)], ["Title", option_type(string_type)], ["Status", option_type(OntologyAnnotation_$reflection())], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Publication_make(pubMedID, doi, authors, title, status, comments) { - return new Publication(pubMedID, doi, authors, title, status, comments); -} - -export function Publication_create_Z3E55064F(PubMedID, Doi, Authors, Title, Status, Comments) { - return Publication_make(PubMedID, Doi, Authors, Title, Status, Comments); -} - -export function Publication_get_empty() { - return Publication_create_Z3E55064F(); -} - -/** - * Adds the given publication to the publications - */ -export function Publication_add(publications, publication) { - return append(publications, singleton(publication)); -} - -/** - * Returns true, if a publication with the given doi exists in the investigation - */ -export function Publication_existsByDoi(doi, publications) { - return exists((p) => equals(p.DOI, doi), publications); -} - -/** - * Returns true, if a publication with the given pubmedID exists in the investigation - */ -export function Publication_existsByPubMedID(pubMedID, publications) { - return exists((p) => equals(p.PubMedID, pubMedID), publications); -} - -/** - * If a publication with the given doi exists in the investigation, returns it - */ -export function Publication_tryGetByDoi(doi, publications) { - return tryFind((publication) => equals(publication.DOI, doi), publications); -} - -/** - * Updates all publications for which the predicate returns true with the given publication values - */ -export function Publication_updateBy(predicate, updateOption, publication, publications) { - if (exists(predicate, publications)) { - return map((p) => { - if (predicate(p)) { - const this$ = updateOption; - const recordType_1 = p; - const recordType_2 = publication; - switch (this$.tag) { - case 2: - return makeRecord(Publication_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Publication_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Publication_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - } - else { - return p; - } - }, publications); - } - else { - return publications; - } -} - -/** - * Updates all protocols with the same DOI as the given publication with its values - */ -export function Publication_updateByDOI(updateOption, publication, publications) { - return Publication_updateBy((p) => equals(p.DOI, publication.DOI), updateOption, publication, publications); -} - -/** - * Updates all protocols with the same pubMedID as the given publication with its values - */ -export function Publication_updateByPubMedID(updateOption, publication, publications) { - return Publication_updateBy((p) => equals(p.PubMedID, publication.PubMedID), updateOption, publication, publications); -} - -/** - * If a publication with the given doi exists in the investigation, removes it from the investigation - */ -export function Publication_removeByDoi(doi, publications) { - return filter((p) => !equals(p.DOI, doi), publications); -} - -/** - * If a publication with the given pubMedID exists in the investigation, removes it - */ -export function Publication_removeByPubMedID(pubMedID, publications) { - return filter((p) => !equals(p.PubMedID, pubMedID), publications); -} - -/** - * Status - * Returns publication status of a publication - */ -export function Publication_getStatus_Z3C2FFBB4(publication) { - return publication.Status; -} - -/** - * Applies function f on publication status of a publication - */ -export function Publication_mapStatus(f, publication) { - return new Publication(publication.PubMedID, publication.DOI, publication.Authors, publication.Title, map_1(f, publication.Status), publication.Comments); -} - -/** - * Replaces publication status of a publication by given publication status - */ -export function Publication_setStatus(publication, status) { - return new Publication(publication.PubMedID, publication.DOI, publication.Authors, publication.Title, status, publication.Comments); -} - -/** - * Returns comments of a protocol - */ -export function Publication_getComments_Z3C2FFBB4(publication) { - return publication.Comments; -} - -/** - * Applies function f on comments of a protocol - */ -export function Publication_mapComments(f, publication) { - return new Publication(publication.PubMedID, publication.DOI, publication.Authors, publication.Title, publication.Status, mapDefault(empty(), f, publication.Comments)); -} - -/** - * Replaces comments of a protocol by given comment list - */ -export function Publication_setComments(publication, comments) { - return new Publication(publication.PubMedID, publication.DOI, publication.Authors, publication.Title, publication.Status, comments); -} - diff --git a/js/ISA/ISA/JsonTypes/Sample.js b/js/ISA/ISA/JsonTypes/Sample.js deleted file mode 100644 index a6a58ef6..00000000 --- a/js/ISA/ISA/JsonTypes/Sample.js +++ /dev/null @@ -1,71 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { append, choose, empty, length } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { MaterialAttributeValue_$reflection } from "./MaterialAttributeValue.js"; -import { FactorValue_$reflection } from "./FactorValue.js"; -import { Source_$reflection } from "./Source.js"; - -export class Sample extends Record { - constructor(ID, Name, Characteristics, FactorValues, DerivesFrom) { - super(); - this.ID = ID; - this.Name = Name; - this.Characteristics = Characteristics; - this.FactorValues = FactorValues; - this.DerivesFrom = DerivesFrom; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - const chars = length(defaultArg(this$.Characteristics, empty())) | 0; - const facts = length(defaultArg(this$.FactorValues, empty())) | 0; - const arg = Sample__get_NameAsString(this$); - return toText(printf("%s [%i characteristics; %i factors]"))(arg)(chars)(facts); - } -} - -export function Sample_$reflection() { - return record_type("ISA.Sample", [], Sample, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["Characteristics", option_type(list_type(MaterialAttributeValue_$reflection()))], ["FactorValues", option_type(list_type(FactorValue_$reflection()))], ["DerivesFrom", option_type(list_type(Source_$reflection()))]]); -} - -export function Sample_make(id, name, characteristics, factorValues, derivesFrom) { - return new Sample(id, name, characteristics, factorValues, derivesFrom); -} - -export function Sample_create_3A6378D6(Id, Name, Characteristics, FactorValues, DerivesFrom) { - return Sample_make(Id, Name, Characteristics, FactorValues, DerivesFrom); -} - -export function Sample_get_empty() { - return Sample_create_3A6378D6(); -} - -export function Sample__get_NameAsString(this$) { - return defaultArg(this$.Name, ""); -} - -export function Sample_getCharacteristicUnits_Z23050B6A(s) { - return choose((c) => c.Unit, defaultArg(s.Characteristics, empty())); -} - -export function Sample_getFactorUnits_Z23050B6A(s) { - return choose((c) => c.Unit, defaultArg(s.FactorValues, empty())); -} - -export function Sample_getUnits_Z23050B6A(s) { - return append(Sample_getCharacteristicUnits_Z23050B6A(s), Sample_getFactorUnits_Z23050B6A(s)); -} - -export function Sample_setCharacteristicValues(values, s) { - return new Sample(s.ID, s.Name, values, s.FactorValues, s.DerivesFrom); -} - -export function Sample_setFactorValues(values, s) { - return new Sample(s.ID, s.Name, s.Characteristics, values, s.DerivesFrom); -} - diff --git a/js/ISA/ISA/JsonTypes/Source.js b/js/ISA/ISA/JsonTypes/Source.js deleted file mode 100644 index 1d58b02a..00000000 --- a/js/ISA/ISA/JsonTypes/Source.js +++ /dev/null @@ -1,54 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { choose, empty, length } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { MaterialAttributeValue_$reflection } from "./MaterialAttributeValue.js"; - -export class Source extends Record { - constructor(ID, Name, Characteristics) { - super(); - this.ID = ID; - this.Name = Name; - this.Characteristics = Characteristics; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - const l = length(defaultArg(this$.Characteristics, empty())) | 0; - const arg = Source__get_NameAsString(this$); - return toText(printf("%s [%i characteristics]"))(arg)(l); - } -} - -export function Source_$reflection() { - return record_type("ISA.Source", [], Source, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["Characteristics", option_type(list_type(MaterialAttributeValue_$reflection()))]]); -} - -export function Source_make(id, name, characteristics) { - return new Source(id, name, characteristics); -} - -export function Source_create_Z32235993(Id, Name, Characteristics) { - return Source_make(Id, Name, Characteristics); -} - -export function Source_get_empty() { - return Source_create_Z32235993(); -} - -export function Source__get_NameAsString(this$) { - return defaultArg(this$.Name, ""); -} - -export function Source_getUnits_Z220A6393(m) { - return choose((c) => c.Unit, defaultArg(m.Characteristics, empty())); -} - -export function Source_setCharacteristicValues(values, m) { - return new Source(m.ID, m.Name, values); -} - diff --git a/js/ISA/ISA/JsonTypes/Study.js b/js/ISA/ISA/JsonTypes/Study.js deleted file mode 100644 index 857e4aa8..00000000 --- a/js/ISA/ISA/JsonTypes/Study.js +++ /dev/null @@ -1,943 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Publication_$reflection } from "./Publication.js"; -import { Person_$reflection } from "./Person.js"; -import { OntologyAnnotation_$reflection } from "./OntologyAnnotation.js"; -import { Protocol_$reflection } from "./Protocol.js"; -import { StudyMaterials_get_empty, StudyMaterials_make, StudyMaterials_$reflection } from "./StudyMaterials.js"; -import { Process_$reflection } from "./Process.js"; -import { Assay_update_Z269B5B97, Assay_updateProtocols, Assay_getMaterials_Z269B5B97, Assay_getSamples_Z269B5B97, Assay_getSources_Z269B5B97, Assay_getUnitCategories_Z269B5B97, Assay_getFactors_Z269B5B97, Assay_getCharacteristics_Z269B5B97, Assay_getProtocols_Z269B5B97, Assay_$reflection } from "./Assay.js"; -import { Factor_$reflection } from "./Factor.js"; -import { MaterialAttribute_$reflection } from "./MaterialAttribute.js"; -import { Comment$_$reflection } from "./Comment.js"; -import { collect, empty, filter, map, singleton, append, exists } from "../../../fable_modules/fable-library.4.1.4/List.js"; -import { stringHash, safeHash, structuralHash, equals } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { map2 as map2_2 } from "../../../fable_modules/fable-library.4.1.4/Array.js"; -import { Dict_tryFind, Dict_ofSeqWithMerge, Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { map as map_1, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { fromValueWithDefault, mapDefault } from "../OptionExtensions.js"; -import { updateProtocols, getMaterials, getSamples, getSources, getUnits, getFactors, getCharacteristics, getProtocols } from "./ProcessSequence.js"; -import { Update_UpdateOptions } from "../Update.js"; -import { List_distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js"; -import { Source_$reflection } from "./Source.js"; -import { Sample_$reflection } from "./Sample.js"; -import { AssayMaterials_getMaterials_E3447B1 } from "./AssayMaterials.js"; -import { Material_$reflection } from "./Material.js"; -import { toFail } from "../../../fable_modules/fable-library.4.1.4/String.js"; - -export class Study extends Record { - constructor(ID, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, Publications, Contacts, StudyDesignDescriptors, Protocols, Materials, ProcessSequence, Assays, Factors, CharacteristicCategories, UnitCategories, Comments) { - super(); - this.ID = ID; - this.FileName = FileName; - this.Identifier = Identifier; - this.Title = Title; - this.Description = Description; - this.SubmissionDate = SubmissionDate; - this.PublicReleaseDate = PublicReleaseDate; - this.Publications = Publications; - this.Contacts = Contacts; - this.StudyDesignDescriptors = StudyDesignDescriptors; - this.Protocols = Protocols; - this.Materials = Materials; - this.ProcessSequence = ProcessSequence; - this.Assays = Assays; - this.Factors = Factors; - this.CharacteristicCategories = CharacteristicCategories; - this.UnitCategories = UnitCategories; - this.Comments = Comments; - } -} - -export function Study_$reflection() { - return record_type("ISA.Study", [], Study, () => [["ID", option_type(string_type)], ["FileName", option_type(string_type)], ["Identifier", option_type(string_type)], ["Title", option_type(string_type)], ["Description", option_type(string_type)], ["SubmissionDate", option_type(string_type)], ["PublicReleaseDate", option_type(string_type)], ["Publications", option_type(list_type(Publication_$reflection()))], ["Contacts", option_type(list_type(Person_$reflection()))], ["StudyDesignDescriptors", option_type(list_type(OntologyAnnotation_$reflection()))], ["Protocols", option_type(list_type(Protocol_$reflection()))], ["Materials", option_type(StudyMaterials_$reflection())], ["ProcessSequence", option_type(list_type(Process_$reflection()))], ["Assays", option_type(list_type(Assay_$reflection()))], ["Factors", option_type(list_type(Factor_$reflection()))], ["CharacteristicCategories", option_type(list_type(MaterialAttribute_$reflection()))], ["UnitCategories", option_type(list_type(OntologyAnnotation_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Study_make(id, filename, identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, protocols, materials, processSequence, assays, factors, characteristicCategories, unitCategories, comments) { - return new Study(id, filename, identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, protocols, materials, processSequence, assays, factors, characteristicCategories, unitCategories, comments); -} - -export function Study_create_Z6C8AB268(Id, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, Publications, Contacts, StudyDesignDescriptors, Protocols, Materials, ProcessSequence, Assays, Factors, CharacteristicCategories, UnitCategories, Comments) { - return Study_make(Id, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, Publications, Contacts, StudyDesignDescriptors, Protocols, Materials, ProcessSequence, Assays, Factors, CharacteristicCategories, UnitCategories, Comments); -} - -export function Study_get_empty() { - return Study_create_Z6C8AB268(); -} - -/** - * If an study with the given identfier exists in the list, returns true - */ -export function Study_existsByIdentifier(identifier, studies) { - return exists((s) => equals(s.Identifier, identifier), studies); -} - -/** - * Adds the given study to the studies - */ -export function Study_add(studies, study) { - return append(studies, singleton(study)); -} - -/** - * Updates all studies for which the predicate returns true with the given study values - */ -export function Study_updateBy(predicate, updateOption, study, studies) { - if (exists(predicate, studies)) { - return map((a) => { - if (predicate(a)) { - const this$ = updateOption; - const recordType_1 = a; - const recordType_2 = study; - return (this$.tag === 2) ? makeRecord(Study_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) : ((this$.tag === 1) ? makeRecord(Study_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) : ((this$.tag === 3) ? makeRecord(Study_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) : recordType_2)); - } - else { - return a; - } - }, studies); - } - else { - return studies; - } -} - -/** - * Updates all studies with the same identifier as the given study with its values - */ -export function Study_updateByIdentifier(updateOption, study, studies) { - return Study_updateBy((s) => equals(s.Identifier, study.Identifier), updateOption, study, studies); -} - -/** - * If a study with the given identifier exists in the list, removes it - */ -export function Study_removeByIdentifier(identifier, studies) { - return filter((s) => !equals(s.Identifier, identifier), studies); -} - -/** - * Returns assays of a study - */ -export function Study_getAssays_Z27CB2981(study) { - return defaultArg(study.Assays, empty()); -} - -/** - * Applies function f to the assays of a study - */ -export function Study_mapAssays(f, study) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, mapDefault(empty(), f, study.Assays), study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces study assays with the given assay list - */ -export function Study_setAssays(study, assays) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Applies function f to the factors of a study - */ -export function Study_mapFactors(f, study) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, mapDefault(empty(), f, study.Factors), study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces study factors with the given assay list - */ -export function Study_setFactors(study, factors) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Applies function f to the protocols of a study - */ -export function Study_mapProtocols(f, study) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, mapDefault(empty(), f, study.Protocols), study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces study protocols with the given assay list - */ -export function Study_setProtocols(study, protocols) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Returns all contacts of a study - */ -export function Study_getContacts_Z27CB2981(study) { - return defaultArg(study.Contacts, empty()); -} - -/** - * Applies function f to contacts of a study - */ -export function Study_mapContacts(f, study) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, mapDefault(empty(), f, study.Contacts), study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces contacts of a study with the given person list - */ -export function Study_setContacts(study, persons) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, persons, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Returns publications of a study - */ -export function Study_getPublications_Z27CB2981(study) { - return defaultArg(study.Publications, empty()); -} - -/** - * Applies function f to publications of the study - */ -export function Study_mapPublications(f, study) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, mapDefault(empty(), f, study.Publications), study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces publications of a study with the given publication list - */ -export function Study_setPublications(study, publications) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Returns study design descriptors of a study - */ -export function Study_getDescriptors_Z27CB2981(study) { - return defaultArg(study.StudyDesignDescriptors, empty()); -} - -/** - * Applies function f to to study design descriptors of a study - */ -export function Study_mapDescriptors(f, study) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, mapDefault(empty(), f, study.StudyDesignDescriptors), study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces study design descriptors with the given ontology annotation list - */ -export function Study_setDescriptors(study, descriptors) { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, descriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Returns processSequence of study - */ -export function Study_getProcesses_Z27CB2981(study) { - return defaultArg(study.ProcessSequence, empty()); -} - -/** - * Returns protocols of a study - */ -export function Study_getProtocols_Z27CB2981(study) { - const processSequenceProtocols = getProtocols(Study_getProcesses_Z27CB2981(study)); - const assaysProtocols = collect(Assay_getProtocols_Z269B5B97, Study_getAssays_Z27CB2981(study)); - const updateOptions_2 = new Update_UpdateOptions(3, []); - const mapping_6 = (p_1) => p_1.Name; - const list1_1 = defaultArg(study.Protocols, empty()); - let list2_1; - const updateOptions = new Update_UpdateOptions(3, []); - const mapping_1 = (p) => p.Name; - const list1 = assaysProtocols; - const list2 = processSequenceProtocols; - try { - const map1 = Dict_ofSeqWithMerge((arg_1, arg_1_1) => { - const this$ = updateOptions; - const recordType_1 = arg_1; - const recordType_2 = arg_1_1; - switch (this$.tag) { - case 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - }, map((v) => [mapping_1(v), v], list1)); - const map2 = Dict_ofSeqWithMerge((arg_2, arg_3) => { - const this$_1 = updateOptions; - const recordType_1_1 = arg_2; - const recordType_2_1 = arg_3; - switch (this$_1.tag) { - case 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - default: - return recordType_2_1; - } - }, map((v_1) => [mapping_1(v_1), v_1], list2)); - list2_1 = map((k) => { - const matchValue = Dict_tryFind(k, map1); - const matchValue_1 = Dict_tryFind(k, map2); - if (matchValue == null) { - if (matchValue_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1 = matchValue_1; - return v2_1; - } - } - else if (matchValue_1 == null) { - const v1_1 = matchValue; - return v1_1; - } - else { - const v1 = matchValue; - const v2 = matchValue_1; - const this$_2 = updateOptions; - const recordType_1_2 = v1; - const recordType_2_2 = v2; - switch (this$_2.tag) { - case 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - default: - return recordType_2_2; - } - } - }, List_distinct(append(map(mapping_1, list1), map(mapping_1, list2)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err) { - throw new Error(`Could not mergeUpdate ${"Protocol"} list: -${err.message}`); - } - try { - const map1_1 = Dict_ofSeqWithMerge((arg_6, arg_1_2) => { - const this$_3 = updateOptions_2; - const recordType_1_3 = arg_6; - const recordType_2_3 = arg_1_2; - switch (this$_3.tag) { - case 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - default: - return recordType_2_3; - } - }, map((v_2) => [mapping_6(v_2), v_2], list1_1)); - const map2_1 = Dict_ofSeqWithMerge((arg_2_1, arg_3_1) => { - const this$_4 = updateOptions_2; - const recordType_1_4 = arg_2_1; - const recordType_2_4 = arg_3_1; - switch (this$_4.tag) { - case 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - default: - return recordType_2_4; - } - }, map((v_1_1) => [mapping_6(v_1_1), v_1_1], list2_1)); - return map((k_1) => { - const matchValue_3 = Dict_tryFind(k_1, map1_1); - const matchValue_1_1 = Dict_tryFind(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1 = matchValue_1_1; - return v2_1_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1_1 = matchValue_3; - return v1_1_1; - } - else { - const v1_2 = matchValue_3; - const v2_2 = matchValue_1_1; - const this$_5 = updateOptions_2; - const recordType_1_5 = v1_2; - const recordType_2_5 = v2_2; - switch (this$_5.tag) { - case 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - default: - return recordType_2_5; - } - } - }, List_distinct(append(map(mapping_6, list1_1), map(mapping_6, list2_1)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err_1) { - throw new Error(`Could not mergeUpdate ${"Protocol"} list: -${err_1.message}`); - } -} - -/** - * Returns Characteristics of the study - */ -export function Study_getCharacteristics_Z27CB2981(study) { - return List_distinct(append(getCharacteristics(Study_getProcesses_Z27CB2981(study)), append(collect(Assay_getCharacteristics_Z269B5B97, Study_getAssays_Z27CB2981(study)), defaultArg(study.CharacteristicCategories, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns factors of the study - */ -export function Study_getFactors_Z27CB2981(study) { - return List_distinct(append(getFactors(Study_getProcesses_Z27CB2981(study)), append(collect(Assay_getFactors_Z269B5B97, Study_getAssays_Z27CB2981(study)), defaultArg(study.Factors, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns unit categories of the study - */ -export function Study_getUnitCategories_Z27CB2981(study) { - return List_distinct(append(getUnits(Study_getProcesses_Z27CB2981(study)), append(collect(Assay_getUnitCategories_Z269B5B97, Study_getAssays_Z27CB2981(study)), defaultArg(study.UnitCategories, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns sources of the study - */ -export function Study_getSources_Z27CB2981(study) { - const processSequenceSources = getSources(Study_getProcesses_Z27CB2981(study)); - const assaysSources = collect(Assay_getSources_Z269B5B97, Study_getAssays_Z27CB2981(study)); - const updateOptions_2 = new Update_UpdateOptions(3, []); - const mapping_6 = (s_2) => defaultArg(s_2.Name, ""); - let list1_1; - const matchValue = study.Materials; - list1_1 = ((matchValue == null) ? empty() : defaultArg(matchValue.Sources, empty())); - let list2_1; - const updateOptions = new Update_UpdateOptions(3, []); - const mapping_1 = (s) => defaultArg(s.Name, ""); - const list1 = assaysSources; - const list2 = processSequenceSources; - try { - const map1 = Dict_ofSeqWithMerge((arg_1, arg_1_1) => { - const this$ = updateOptions; - const recordType_1 = arg_1; - const recordType_2 = arg_1_1; - switch (this$.tag) { - case 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - }, map((v) => [mapping_1(v), v], list1)); - const map2 = Dict_ofSeqWithMerge((arg_2, arg_3) => { - const this$_1 = updateOptions; - const recordType_1_1 = arg_2; - const recordType_2_1 = arg_3; - switch (this$_1.tag) { - case 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - default: - return recordType_2_1; - } - }, map((v_1) => [mapping_1(v_1), v_1], list2)); - list2_1 = map((k) => { - const matchValue_1 = Dict_tryFind(k, map1); - const matchValue_1_1 = Dict_tryFind(k, map2); - if (matchValue_1 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1 = matchValue_1_1; - return v2_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1 = matchValue_1; - return v1_1; - } - else { - const v1 = matchValue_1; - const v2 = matchValue_1_1; - const this$_2 = updateOptions; - const recordType_1_2 = v1; - const recordType_2_2 = v2; - switch (this$_2.tag) { - case 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - default: - return recordType_2_2; - } - } - }, List_distinct(append(map(mapping_1, list1), map(mapping_1, list2)), { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })); - } - catch (err) { - throw new Error(`Could not mergeUpdate ${"Source"} list: -${err.message}`); - } - try { - const map1_1 = Dict_ofSeqWithMerge((arg_6, arg_1_2) => { - const this$_3 = updateOptions_2; - const recordType_1_3 = arg_6; - const recordType_2_3 = arg_1_2; - switch (this$_3.tag) { - case 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - default: - return recordType_2_3; - } - }, map((v_2) => [mapping_6(v_2), v_2], list1_1)); - const map2_1 = Dict_ofSeqWithMerge((arg_2_1, arg_3_1) => { - const this$_4 = updateOptions_2; - const recordType_1_4 = arg_2_1; - const recordType_2_4 = arg_3_1; - switch (this$_4.tag) { - case 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - default: - return recordType_2_4; - } - }, map((v_1_1) => [mapping_6(v_1_1), v_1_1], list2_1)); - return map((k_1) => { - const matchValue_3 = Dict_tryFind(k_1, map1_1); - const matchValue_1_2 = Dict_tryFind(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_2 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1 = matchValue_1_2; - return v2_1_1; - } - } - else if (matchValue_1_2 == null) { - const v1_1_1 = matchValue_3; - return v1_1_1; - } - else { - const v1_2 = matchValue_3; - const v2_2 = matchValue_1_2; - const this$_5 = updateOptions_2; - const recordType_1_5 = v1_2; - const recordType_2_5 = v2_2; - switch (this$_5.tag) { - case 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - default: - return recordType_2_5; - } - } - }, List_distinct(append(map(mapping_6, list1_1), map(mapping_6, list2_1)), { - Equals: (x_1, y_1) => (x_1 === y_1), - GetHashCode: stringHash, - })); - } - catch (err_1) { - throw new Error(`Could not mergeUpdate ${"Source"} list: -${err_1.message}`); - } -} - -/** - * Returns sources of the study - */ -export function Study_getSamples_Z27CB2981(study) { - const processSequenceSamples = getSamples(Study_getProcesses_Z27CB2981(study)); - const assaysSamples = collect(Assay_getSamples_Z269B5B97, Study_getAssays_Z27CB2981(study)); - const updateOptions_2 = new Update_UpdateOptions(3, []); - const mapping_6 = (s_2) => defaultArg(s_2.Name, ""); - let list1_1; - const matchValue = study.Materials; - list1_1 = ((matchValue == null) ? empty() : defaultArg(matchValue.Samples, empty())); - let list2_1; - const updateOptions = new Update_UpdateOptions(3, []); - const mapping_1 = (s) => defaultArg(s.Name, ""); - const list1 = assaysSamples; - const list2 = processSequenceSamples; - try { - const map1 = Dict_ofSeqWithMerge((arg_1, arg_1_1) => { - const this$ = updateOptions; - const recordType_1 = arg_1; - const recordType_2 = arg_1_1; - switch (this$.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - }, map((v) => [mapping_1(v), v], list1)); - const map2 = Dict_ofSeqWithMerge((arg_2, arg_3) => { - const this$_1 = updateOptions; - const recordType_1_1 = arg_2; - const recordType_2_1 = arg_3; - switch (this$_1.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - default: - return recordType_2_1; - } - }, map((v_1) => [mapping_1(v_1), v_1], list2)); - list2_1 = map((k) => { - const matchValue_1 = Dict_tryFind(k, map1); - const matchValue_1_1 = Dict_tryFind(k, map2); - if (matchValue_1 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1 = matchValue_1_1; - return v2_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1 = matchValue_1; - return v1_1; - } - else { - const v1 = matchValue_1; - const v2 = matchValue_1_1; - const this$_2 = updateOptions; - const recordType_1_2 = v1; - const recordType_2_2 = v2; - switch (this$_2.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - default: - return recordType_2_2; - } - } - }, List_distinct(append(map(mapping_1, list1), map(mapping_1, list2)), { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - })); - } - catch (err) { - throw new Error(`Could not mergeUpdate ${"Sample"} list: -${err.message}`); - } - try { - const map1_1 = Dict_ofSeqWithMerge((arg_6, arg_1_2) => { - const this$_3 = updateOptions_2; - const recordType_1_3 = arg_6; - const recordType_2_3 = arg_1_2; - switch (this$_3.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - default: - return recordType_2_3; - } - }, map((v_2) => [mapping_6(v_2), v_2], list1_1)); - const map2_1 = Dict_ofSeqWithMerge((arg_2_1, arg_3_1) => { - const this$_4 = updateOptions_2; - const recordType_1_4 = arg_2_1; - const recordType_2_4 = arg_3_1; - switch (this$_4.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - default: - return recordType_2_4; - } - }, map((v_1_1) => [mapping_6(v_1_1), v_1_1], list2_1)); - return map((k_1) => { - const matchValue_3 = Dict_tryFind(k_1, map1_1); - const matchValue_1_2 = Dict_tryFind(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_2 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1 = matchValue_1_2; - return v2_1_1; - } - } - else if (matchValue_1_2 == null) { - const v1_1_1 = matchValue_3; - return v1_1_1; - } - else { - const v1_2 = matchValue_3; - const v2_2 = matchValue_1_2; - const this$_5 = updateOptions_2; - const recordType_1_5 = v1_2; - const recordType_2_5 = v2_2; - switch (this$_5.tag) { - case 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - default: - return recordType_2_5; - } - } - }, List_distinct(append(map(mapping_6, list1_1), map(mapping_6, list2_1)), { - Equals: (x_1, y_1) => (x_1 === y_1), - GetHashCode: stringHash, - })); - } - catch (err_1) { - throw new Error(`Could not mergeUpdate ${"Sample"} list: -${err_1.message}`); - } -} - -/** - * Returns materials of the study - */ -export function Study_getMaterials_Z27CB2981(study) { - const processSequenceMaterials = getMaterials(Study_getProcesses_Z27CB2981(study)); - const assaysMaterials = collect((arg_2) => AssayMaterials_getMaterials_E3447B1(Assay_getMaterials_Z269B5B97(arg_2)), Study_getAssays_Z27CB2981(study)); - let materials; - const updateOptions_2 = new Update_UpdateOptions(3, []); - const mapping_6 = (s_2) => s_2.Name; - let list1_1; - const matchValue = study.Materials; - list1_1 = ((matchValue == null) ? empty() : defaultArg(matchValue.OtherMaterials, empty())); - let list2_1; - const updateOptions = new Update_UpdateOptions(3, []); - const mapping_1 = (s) => s.Name; - const list1 = assaysMaterials; - const list2 = processSequenceMaterials; - try { - const map1 = Dict_ofSeqWithMerge((arg_3, arg_1_1) => { - const this$ = updateOptions; - const recordType_1 = arg_3; - const recordType_2 = arg_1_1; - switch (this$.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))); - default: - return recordType_2; - } - }, map((v) => [mapping_1(v), v], list1)); - const map2 = Dict_ofSeqWithMerge((arg_2_1, arg_3_1) => { - const this$_1 = updateOptions; - const recordType_1_1 = arg_2_1; - const recordType_2_1 = arg_3_1; - switch (this$_1.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))); - default: - return recordType_2_1; - } - }, map((v_1) => [mapping_1(v_1), v_1], list2)); - list2_1 = map((k) => { - const matchValue_1 = Dict_tryFind(k, map1); - const matchValue_1_1 = Dict_tryFind(k, map2); - if (matchValue_1 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1 = matchValue_1_1; - return v2_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1 = matchValue_1; - return v1_1; - } - else { - const v1 = matchValue_1; - const v2 = matchValue_1_1; - const this$_2 = updateOptions; - const recordType_1_2 = v1; - const recordType_2_2 = v2; - switch (this$_2.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))); - default: - return recordType_2_2; - } - } - }, List_distinct(append(map(mapping_1, list1), map(mapping_1, list2)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err) { - throw new Error(`Could not mergeUpdate ${"Material"} list: -${err.message}`); - } - try { - const map1_1 = Dict_ofSeqWithMerge((arg_6, arg_1_2) => { - const this$_3 = updateOptions_2; - const recordType_1_3 = arg_6; - const recordType_2_3 = arg_1_2; - switch (this$_3.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))); - default: - return recordType_2_3; - } - }, map((v_2) => [mapping_6(v_2), v_2], list1_1)); - const map2_1 = Dict_ofSeqWithMerge((arg_2_2, arg_3_2) => { - const this$_4 = updateOptions_2; - const recordType_1_4 = arg_2_2; - const recordType_2_4 = arg_3_2; - switch (this$_4.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))); - default: - return recordType_2_4; - } - }, map((v_1_1) => [mapping_6(v_1_1), v_1_1], list2_1)); - materials = map((k_1) => { - const matchValue_3 = Dict_tryFind(k_1, map1_1); - const matchValue_1_2 = Dict_tryFind(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_2 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1 = matchValue_1_2; - return v2_1_1; - } - } - else if (matchValue_1_2 == null) { - const v1_1_1 = matchValue_3; - return v1_1_1; - } - else { - const v1_2 = matchValue_3; - const v2_2 = matchValue_1_2; - const this$_5 = updateOptions_2; - const recordType_1_5 = v1_2; - const recordType_2_5 = v2_2; - switch (this$_5.tag) { - case 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - case 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))); - default: - return recordType_2_5; - } - } - }, List_distinct(append(map(mapping_6, list1_1), map(mapping_6, list2_1)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err_1) { - throw new Error(`Could not mergeUpdate ${"Material"} list: -${err_1.message}`); - } - const sources = Study_getSources_Z27CB2981(study); - const samples = Study_getSamples_Z27CB2981(study); - return StudyMaterials_make(fromValueWithDefault(empty(), sources), fromValueWithDefault(empty(), samples), fromValueWithDefault(empty(), materials)); -} - -export function Study_update_Z27CB2981(study) { - try { - const protocols = Study_getProtocols_Z27CB2981(study); - let Materials; - const v = Study_getMaterials_Z27CB2981(study); - Materials = fromValueWithDefault(StudyMaterials_get_empty(), v); - const Assays = map_1((list) => map((arg_3) => ((arg_2) => Assay_updateProtocols(protocols, arg_2))(Assay_update_Z269B5B97(arg_3)), list), study.Assays); - const Protocols = fromValueWithDefault(empty(), protocols); - const Factors = fromValueWithDefault(empty(), Study_getFactors_Z27CB2981(study)); - const CharacteristicCategories = fromValueWithDefault(empty(), Study_getCharacteristics_Z27CB2981(study)); - const UnitCategories = fromValueWithDefault(empty(), Study_getUnitCategories_Z27CB2981(study)); - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, Protocols, Materials, map_1((processSequence) => updateProtocols(protocols, processSequence), study.ProcessSequence), Assays, Factors, CharacteristicCategories, UnitCategories, study.Comments); - } - catch (err) { - return toFail(`Could not update study ${study.Identifier}: -${err.message}`); - } -} - diff --git a/js/ISA/ISA/JsonTypes/StudyMaterials.js b/js/ISA/ISA/JsonTypes/StudyMaterials.js deleted file mode 100644 index 96b16ed9..00000000 --- a/js/ISA/ISA/JsonTypes/StudyMaterials.js +++ /dev/null @@ -1,45 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { Source_$reflection } from "./Source.js"; -import { record_type, option_type, list_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { Sample_$reflection } from "./Sample.js"; -import { Material_$reflection } from "./Material.js"; -import { defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { empty } from "../../../fable_modules/fable-library.4.1.4/List.js"; - -export class StudyMaterials extends Record { - constructor(Sources, Samples, OtherMaterials) { - super(); - this.Sources = Sources; - this.Samples = Samples; - this.OtherMaterials = OtherMaterials; - } -} - -export function StudyMaterials_$reflection() { - return record_type("ISA.StudyMaterials", [], StudyMaterials, () => [["Sources", option_type(list_type(Source_$reflection()))], ["Samples", option_type(list_type(Sample_$reflection()))], ["OtherMaterials", option_type(list_type(Material_$reflection()))]]); -} - -export function StudyMaterials_make(sources, samples, otherMaterials) { - return new StudyMaterials(sources, samples, otherMaterials); -} - -export function StudyMaterials_create_Z460D555F(Sources, Samples, OtherMaterials) { - return StudyMaterials_make(Sources, Samples, OtherMaterials); -} - -export function StudyMaterials_get_empty() { - return StudyMaterials_create_Z460D555F(); -} - -export function StudyMaterials_getMaterials_6A1922E7(am) { - return defaultArg(am.OtherMaterials, empty()); -} - -export function StudyMaterials_getSamples_6A1922E7(am) { - return defaultArg(am.Samples, empty()); -} - -export function StudyMaterials_getSources_6A1922E7(am) { - return defaultArg(am.Sources, empty()); -} - diff --git a/js/ISA/ISA/JsonTypes/URI.js b/js/ISA/ISA/JsonTypes/URI.js deleted file mode 100644 index 4fac8e00..00000000 --- a/js/ISA/ISA/JsonTypes/URI.js +++ /dev/null @@ -1,19 +0,0 @@ - -/** - * Create a ISAJson URI from a ISATab string entry - * - * This is a placeholder function. It has currently no function, but as soon as it is implemented it will already be placed at all relevant code locations. - */ -export function URIModule_fromString(s) { - return s; -} - -/** - * Create a ISATab string entry from a ISAJson URI - * - * This is a placeholder function. It has currently no function, but as soon as it is implemented it will already be placed at all relevant code locations. - */ -export function URIModule_toString(s) { - return s; -} - diff --git a/js/ISA/ISA/JsonTypes/Value.js b/js/ISA/ISA/JsonTypes/Value.js deleted file mode 100644 index 3b31d717..00000000 --- a/js/ISA/ISA/JsonTypes/Value.js +++ /dev/null @@ -1,210 +0,0 @@ -import { Union, toString } from "../../../fable_modules/fable-library.4.1.4/Types.js"; -import { printf, toText } from "../../../fable_modules/fable-library.4.1.4/String.js"; -import { OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_$reflection, OntologyAnnotation__get_NameText } from "./OntologyAnnotation.js"; -import { union_type, string_type, float64_type, int32_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { parse } from "../../../fable_modules/fable-library.4.1.4/Double.js"; -import { parse as parse_1 } from "../../../fable_modules/fable-library.4.1.4/Int32.js"; -import { map, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js"; -import { int32ToString } from "../../../fable_modules/fable-library.4.1.4/Util.js"; -import { AnnotationValue_toString_Z3C00A204 } from "./AnnotationValue.js"; - -export class Value extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Ontology", "Int", "Float", "Name"]; - } - Print() { - const this$ = this; - return toString(this$); - } - PrintCompact() { - const this$ = this; - return (this$.tag === 1) ? toText(printf("%i"))(this$.fields[0]) : ((this$.tag === 2) ? toText(printf("%f"))(this$.fields[0]) : ((this$.tag === 3) ? this$.fields[0] : OntologyAnnotation__get_NameText(this$.fields[0]))); - } -} - -export function Value_$reflection() { - return union_type("ISA.Value", [], Value, () => [[["Item", OntologyAnnotation_$reflection()]], [["Item", int32_type]], [["Item", float64_type]], [["Item", string_type]]]); -} - -export function Value_fromString_Z721C83C5(value) { - try { - return new Value(1, [parse_1(value, 511, false, 32)]); - } - catch (matchValue) { - try { - return new Value(2, [parse(value)]); - } - catch (matchValue_1) { - return new Value(3, [value]); - } - } -} - -export function Value_fromOptions(value, termSource, termAccesssion) { - let matchResult, value_1; - if (value == null) { - if (termSource == null) { - if (termAccesssion == null) { - matchResult = 1; - } - else { - matchResult = 2; - } - } - else { - matchResult = 2; - } - } - else if (termSource == null) { - if (termAccesssion == null) { - matchResult = 0; - value_1 = value; - } - else { - matchResult = 2; - } - } - else { - matchResult = 2; - } - switch (matchResult) { - case 0: - return (() => { - try { - return new Value(1, [parse_1(value_1, 511, false, 32)]); - } - catch (matchValue_1) { - try { - return new Value(2, [parse(value_1)]); - } - catch (matchValue_2) { - return new Value(3, [value_1]); - } - } - })(); - case 1: - return void 0; - default: - return new Value(0, [OntologyAnnotation_fromString_Z7D8EB286(defaultArg(value, ""), termSource, termAccesssion)]); - } -} - -export function Value_toOptions_Z277CD705(value) { - switch (value.tag) { - case 1: - return [int32ToString(value.fields[0]), void 0, void 0]; - case 2: - return [value.fields[0].toString(), void 0, void 0]; - case 3: - return [value.fields[0], void 0, void 0]; - default: { - const oa = value.fields[0]; - return [map(AnnotationValue_toString_Z3C00A204, oa.Name), oa.TermAccessionNumber, oa.TermSourceREF]; - } - } -} - -export function Value__get_Text(this$) { - switch (this$.tag) { - case 2: - return this$.fields[0].toString(); - case 1: - return int32ToString(this$.fields[0]); - case 3: - return this$.fields[0]; - default: - return OntologyAnnotation__get_NameText(this$.fields[0]); - } -} - -export function Value__AsName(this$) { - if (this$.tag === 3) { - return this$.fields[0]; - } - else { - throw new Error(`Value ${this$} is not of case name`); - } -} - -export function Value__AsInt(this$) { - if (this$.tag === 1) { - return this$.fields[0] | 0; - } - else { - throw new Error(`Value ${this$} is not of case int`); - } -} - -export function Value__AsFloat(this$) { - if (this$.tag === 2) { - return this$.fields[0]; - } - else { - throw new Error(`Value ${this$} is not of case float`); - } -} - -export function Value__AsOntology(this$) { - if (this$.tag === 0) { - return this$.fields[0]; - } - else { - throw new Error(`Value ${this$} is not of case ontology`); - } -} - -export function Value__get_IsAnOntology(this$) { - if (this$.tag === 0) { - return true; - } - else { - return false; - } -} - -export function Value__get_IsNumerical(this$) { - switch (this$.tag) { - case 1: - case 2: - return true; - default: - return false; - } -} - -export function Value__get_IsAnInt(this$) { - if (this$.tag === 1) { - return true; - } - else { - return false; - } -} - -export function Value__get_IsAFloat(this$) { - if (this$.tag === 2) { - return true; - } - else { - return false; - } -} - -export function Value__get_IsAText(this$) { - if (this$.tag === 3) { - return true; - } - else { - return false; - } -} - -export function Value_getText_Z277CD705(v) { - return Value__get_Text(v); -} - diff --git a/js/ISA/ISA/OptionExtensions.js b/js/ISA/ISA/OptionExtensions.js deleted file mode 100644 index ead229fc..00000000 --- a/js/ISA/ISA/OptionExtensions.js +++ /dev/null @@ -1,34 +0,0 @@ -import { equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { value, some } from "../../fable_modules/fable-library.4.1.4/Option.js"; - -/** - * If the value matches the default, a None is returned, else a Some is returned - */ -export function fromValueWithDefault(d, v) { - if (equals(d, v)) { - return void 0; - } - else { - return some(v); - } -} - -/** - * Applies the function f on the value of the option if it exists, else applies it on the default value. If the result value matches the default, a None is returned - */ -export function mapDefault(d, f, o) { - return fromValueWithDefault(d, (o == null) ? f(d) : f(value(o))); -} - -/** - * Applies the function f on the value of the option if it exists, else returns the default value. - */ -export function mapOrDefault(d, f, o) { - if (o == null) { - return d; - } - else { - return some(f(value(o))); - } -} - diff --git a/js/ISA/ISA/Regex.js b/js/ISA/ISA/Regex.js deleted file mode 100644 index 3f97dc73..00000000 --- a/js/ISA/ISA/Regex.js +++ /dev/null @@ -1,512 +0,0 @@ -import { create, match } from "../../fable_modules/fable-library.4.1.4/RegExp.js"; -import { value as value_1, map, some } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { parse } from "../../fable_modules/fable-library.4.1.4/Int32.js"; - -/** - * Matches, if the input string matches the given regex pattern. - */ -export function ActivePatterns_$007CRegex$007C_$007C(pattern, input) { - const m = match(create(pattern), input.trim()); - if (m != null) { - return m; - } - else { - return void 0; - } -} - -/** - * Matches any column header starting with some text, followed by one whitespace and a term name inside squared brackets. - */ -export function ActivePatterns_$007CTermColumn$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("(?.+)\\s\\[(?.+)\\]", input); - if (activePatternResult != null) { - const r = activePatternResult; - return { - TermColumnType: (r.groups && r.groups.termcolumntype) || "", - TermName: (r.groups && r.groups.termname) || "", - }; - } - else { - return void 0; - } -} - -/** - * Matches a "Unit" column header. - */ -export function ActivePatterns_$007CUnitColumnHeader$007C_$007C(input) { - if (ActivePatterns_$007CRegex$007C_$007C("Unit", input) != null) { - return some(void 0); - } - else { - return void 0; - } -} - -/** - * Matches a "Parameter [Term]" or "Parameter Value [Term]" column header and returns the Term string. - */ -export function ActivePatterns_$007CParameterColumnHeader$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CTermColumn$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - const matchValue = r.TermColumnType; - switch (matchValue) { - case "Parameter": - case "Parameter Value": - return r.TermName; - default: - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a "Factor [Term]" or "Factor Value [Term]" column header and returns the Term string. - */ -export function ActivePatterns_$007CFactorColumnHeader$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CTermColumn$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - const matchValue = r.TermColumnType; - switch (matchValue) { - case "Factor": - case "Factor Value": - return r.TermName; - default: - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a "Characteristic [Term]" or "Characteristics [Term]" or "Characteristics Value [Term]" column header and returns the Term string. - */ -export function ActivePatterns_$007CCharacteristicColumnHeader$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CTermColumn$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - const matchValue = r.TermColumnType; - switch (matchValue) { - case "Characteristic": - case "Characteristics": - case "Characteristics Value": - return r.TermName; - default: - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a short term string and returns the term source ref and the annotation number strings. - * - * Example: "MS:1003022" --> term source ref: "MS"; annotation number: "1003022" - */ -export function ActivePatterns_$007CTermAnnotationShort$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", input); - if (activePatternResult != null) { - const value = activePatternResult; - const termsourceref = (value.groups && value.groups.termsourceref) || ""; - return { - LocalTAN: (value.groups && value.groups.localtan) || "", - TermSourceREF: termsourceref, - }; - } - else { - return void 0; - } -} - -/** - * Matches a term string (either short or URI) and returns the term source ref and the annotation number strings. - * - * Example 1: "MS:1003022" --> term source ref: "MS"; annotation number: "1003022" - * - * Example 2: "http://purl.obolibrary.org/obo/MS_1003022" --> term source ref: "MS"; annotation number: "1003022" - */ -export function ActivePatterns_$007CTermAnnotation$007C_$007C(input) { - let matchResult, value; - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", input); - if (activePatternResult != null) { - matchResult = 0; - value = activePatternResult; - } - else { - const activePatternResult_1 = ActivePatterns_$007CRegex$007C_$007C("http://purl.obolibrary.org/obo/(?\\w+?)_(?\\w+)", input); - if (activePatternResult_1 != null) { - matchResult = 0; - value = activePatternResult_1; - } - else { - const activePatternResult_2 = ActivePatterns_$007CRegex$007C_$007C(".*\\/(?\\w+?)[:_](?\\w+)", input); - if (activePatternResult_2 != null) { - matchResult = 0; - value = activePatternResult_2; - } - else { - matchResult = 1; - } - } - } - switch (matchResult) { - case 0: { - const termsourceref = (value.groups && value.groups.termsourceref) || ""; - return { - LocalTAN: (value.groups && value.groups.localtan) || "", - TermAccessionNumber: input, - TermSourceREF: termsourceref, - }; - } - default: - return void 0; - } -} - -/** - * Matches a "Term Source REF (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. - * - * Example: "Term Source REF (MS:1003022)" --> term source ref: "MS"; annotation number: "1003022" - */ -export function ActivePatterns_$007CTSRColumnHeader$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("Term Source REF\\s\\((?.+)\\)", input); - if (activePatternResult != null) { - const r = activePatternResult; - const matchValue = (r.groups && r.groups.id) || ""; - const activePatternResult_1 = ActivePatterns_$007CTermAnnotation$007C_$007C(matchValue); - if (activePatternResult_1 != null) { - const r_1 = activePatternResult_1; - return r_1; - } - else { - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a "Term Accession Number (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. - * - * Example: "Term Accession Number (MS:1003022)" --> term source ref: "MS"; annotation number: "1003022" - */ -export function ActivePatterns_$007CTANColumnHeader$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("Term Accession Number\\s\\((?.+)\\)", input); - if (activePatternResult != null) { - const r = activePatternResult; - const matchValue = (r.groups && r.groups.id) || ""; - const activePatternResult_1 = ActivePatterns_$007CTermAnnotation$007C_$007C(matchValue); - if (activePatternResult_1 != null) { - const r_1 = activePatternResult_1; - return r_1; - } - else { - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a "Input [InputType]" column header and returns the InputType as string. - */ -export function ActivePatterns_$007CInputColumnHeader$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("Input\\s\\[(?.+)\\]", input); - if (activePatternResult != null) { - const r = activePatternResult; - return (r.groups && r.groups.iotype) || ""; - } - else { - return void 0; - } -} - -/** - * Matches a "Output [OutputType]" column header and returns the OutputType as string. - */ -export function ActivePatterns_$007COutputColumnHeader$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("Output\\s\\[(?.+)\\]", input); - if (activePatternResult != null) { - const r = activePatternResult; - return (r.groups && r.groups.iotype) || ""; - } - else { - return void 0; - } -} - -/** - * Matches auto-generated readable table names. Mainly used in ArcAssay.addTable(). Default tables will get such a name. - * - * Will match "New Table 10" and return the number `10`. - */ -export function ActivePatterns_$007CAutoGeneratedTableName$007C_$007C(input) { - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("^New\\sTable\\s(?\\d+)$", input); - if (activePatternResult != null) { - const r = activePatternResult; - return parse((r.groups && r.groups.number) || "", 511, false, 32); - } - else { - return void 0; - } -} - -export function tryParseTermAnnotationShort(str) { - const matchValue = str.trim(); - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", matchValue); - if (activePatternResult != null) { - const value = activePatternResult; - const termsourceref = (value.groups && value.groups.termsourceref) || ""; - return { - LocalTAN: (value.groups && value.groups.localtan) || "", - TermSourceREF: termsourceref, - }; - } - else { - return void 0; - } -} - -/** - * This function can be used to extract `IDSPACE:LOCALID` (or: `Term Accession`) from Swate header strings or obofoundry conform URI strings. - * - * **Example 1:** "http://purl.obolibrary.org/obo/GO_000001" --> "GO:000001" - * - * **Example 2:** "Term Source REF (NFDI4PSO:0000064)" --> "NFDI4PSO:0000064" - */ -export function tryParseTermAnnotation(str) { - const matchValue = str.trim(); - let matchResult, value; - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", matchValue); - if (activePatternResult != null) { - matchResult = 0; - value = activePatternResult; - } - else { - const activePatternResult_1 = ActivePatterns_$007CRegex$007C_$007C("http://purl.obolibrary.org/obo/(?\\w+?)_(?\\w+)", matchValue); - if (activePatternResult_1 != null) { - matchResult = 0; - value = activePatternResult_1; - } - else { - const activePatternResult_2 = ActivePatterns_$007CRegex$007C_$007C(".*\\/(?\\w+?)[:_](?\\w+)", matchValue); - if (activePatternResult_2 != null) { - matchResult = 0; - value = activePatternResult_2; - } - else { - matchResult = 1; - } - } - } - switch (matchResult) { - case 0: { - const termsourceref = (value.groups && value.groups.termsourceref) || ""; - return { - LocalTAN: (value.groups && value.groups.localtan) || "", - TermSourceREF: termsourceref, - }; - } - default: - return void 0; - } -} - -/** - * Tries to parse 'str' to term accession and returns it in the format `Some "termsourceref:localtan"`. Exmp.: `Some "MS:000001"` - */ -export function tryGetTermAnnotationShortString(str) { - return map((r) => ((r.TermSourceREF + ":") + r.LocalTAN), tryParseTermAnnotation(str)); -} - -/** - * Parses 'str' to term accession and returns it in the format "termsourceref:localtan". Exmp.: "MS:000001" - */ -export function getTermAnnotationShortString(str) { - const matchValue = tryGetTermAnnotationShortString(str); - if (matchValue == null) { - throw new Error(`Unable to parse '${str}' to term accession.`); - } - else { - return matchValue; - } -} - -/** - * This function is used to parse Excel numberFormat string to term name. - * - * **Example 1:** "0.00 "degree Celsius"" --> "degree Celsius" - */ -export function tryParseExcelNumberFormat(headerStr) { - const matchValue = headerStr.trim(); - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("\"(?(.*?))\"", matchValue); - if (activePatternResult != null) { - const value = activePatternResult; - return (value.groups && value.groups.numberFormat) || ""; - } - else { - return void 0; - } -} - -/** - * This function is used to match both Input and Output columns and capture the IOType as `iotype` group. - * - * **Example 1:** "Input [Sample]" --> "Sample" - */ -export function tryParseIOTypeHeader(headerStr) { - const matchValue = headerStr.trim(); - const activePatternResult = ActivePatterns_$007CRegex$007C_$007C("(Input|Output)\\s\\[(?.+)\\]", matchValue); - if (activePatternResult != null) { - const value = activePatternResult; - return (value.groups && value.groups.iotype) || ""; - } - else { - return void 0; - } -} - -/** - * Matches any column header starting with some text, followed by one whitespace and a term name inside squared brackets. - */ -export function tryParseTermColumn(input) { - const activePatternResult = ActivePatterns_$007CTermColumn$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Unit" column header. - */ -export function tryParseUnitColumnHeader(input) { - const activePatternResult = ActivePatterns_$007CUnitColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r = value_1(activePatternResult); - return some(void 0); - } - else { - return void 0; - } -} - -/** - * Matches a "Parameter [Term]" or "Parameter Value [Term]" column header and returns the Term string. - */ -export function tryParseParameterColumnHeader(input) { - const activePatternResult = ActivePatterns_$007CParameterColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Factor [Term]" or "Factor Value [Term]" column header and returns the Term string. - */ -export function tryParseFactorColumnHeader(input) { - const activePatternResult = ActivePatterns_$007CFactorColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Characteristic [Term]" or "Characteristics [Term]" or "Characteristics Value [Term]" column header and returns the Term string. - */ -export function tryParseCharacteristicColumnHeader(input) { - const activePatternResult = ActivePatterns_$007CCharacteristicColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Term Source REF (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. - * - * Example: "Term Source REF (MS:1003022)" --> term source ref: "MS"; annotation number: "1003022" - */ -export function tryParseTSRColumnHeader(input) { - const activePatternResult = ActivePatterns_$007CTSRColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Term Accession Number (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. - * - * Example: "Term Accession Number (MS:1003022)" --> term source ref: "MS"; annotation number: "1003022" - */ -export function tryParseTANColumnHeader(input) { - const activePatternResult = ActivePatterns_$007CTANColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Input [InputType]" column header and returns the InputType as string. - */ -export function tryParseInputColumnHeader(input) { - const activePatternResult = ActivePatterns_$007CInputColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Output [OutputType]" column header and returns the OutputType as string. - */ -export function tryParseOutputColumnHeader(input) { - const activePatternResult = ActivePatterns_$007COutputColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r = activePatternResult; - return r; - } - else { - return void 0; - } -} - diff --git a/js/ISA/ISA/Update.js b/js/ISA/ISA/Update.js deleted file mode 100644 index 4dba64d5..00000000 --- a/js/ISA/ISA/Update.js +++ /dev/null @@ -1,267 +0,0 @@ -import { Dictionary } from "../../fable_modules/fable-library.4.1.4/MutableMap.js"; -import { isIterable, defaultOf, structuralHash, equals } from "../../fable_modules/fable-library.4.1.4/Util.js"; -import { isEmpty, iterate } from "../../fable_modules/fable-library.4.1.4/Seq.js"; -import { tryGetValue, addToDict } from "../../fable_modules/fable-library.4.1.4/MapUtil.js"; -import { Union, toString, FSharpRef } from "../../fable_modules/fable-library.4.1.4/Types.js"; -import { value as value_1, some } from "../../fable_modules/fable-library.4.1.4/Option.js"; -import { append_generic, distinct_generic, isList_generic, isMap_generic } from "./Fable.js"; -import { union_type, makeUnion, option_type, makeGenericType, getUnionCases, name, obj_type } from "../../fable_modules/fable-library.4.1.4/Reflection.js"; -import { exactlyOne, partition } from "../../fable_modules/fable-library.4.1.4/Array.js"; - -export function Dict_ofSeq(s) { - const dict = new Dictionary([], { - Equals: equals, - GetHashCode: structuralHash, - }); - iterate((tupledArg) => { - addToDict(dict, tupledArg[0], tupledArg[1]); - }, s); - return dict; -} - -export function Dict_tryFind(key, dict) { - let patternInput; - let outArg = defaultOf(); - patternInput = [tryGetValue(dict, key, new FSharpRef(() => outArg, (v) => { - outArg = v; - })), outArg]; - if (patternInput[0]) { - return some(patternInput[1]); - } - else { - return void 0; - } -} - -export function Dict_ofSeqWithMerge(merge, s) { - const dict = new Dictionary([], { - Equals: equals, - GetHashCode: structuralHash, - }); - iterate((tupledArg) => { - const k = tupledArg[0]; - const v = tupledArg[1]; - const matchValue = Dict_tryFind(k, dict); - if (matchValue == null) { - addToDict(dict, k, v); - } - else { - const v$0027 = value_1(matchValue); - dict.delete(k); - addToDict(dict, k, merge(v$0027, v)); - } - }, s); - return dict; -} - -/** - * Get the type of the IEnumerable elements. E.g. for Array<'T> it would be 'T - */ -export function Update_isMapType(v) { - return isMap_generic(v); -} - -export function Update_isListType(v) { - return isList_generic(v); -} - -/** - * Get the type of the IEnumerable elements. E.g. for Array<'T> it would be 'T - */ -export function Update_enumGetInnerType(v) { - return obj_type; -} - -/** - * updates oldRT with newRT by replacing all values, but appending all lists. - * - * newRTList@oldRTList - */ -export function Update_updateAppend(oldVal, newVal) { - let matchResult, oldInternal, others; - if (typeof oldVal === "string") { - matchResult = 0; - } - else if (isIterable(oldVal)) { - let activePatternResult; - const a = oldVal; - activePatternResult = ((a == null) ? void 0 : (undefined)); - if (activePatternResult != null) { - matchResult = 1; - oldInternal = value_1(activePatternResult); - } - else { - matchResult = 2; - } - } - else { - let activePatternResult_1; - const a_1 = oldVal; - activePatternResult_1 = ((a_1 == null) ? void 0 : (undefined)); - if (activePatternResult_1 != null) { - matchResult = 1; - oldInternal = value_1(activePatternResult_1); - } - else { - matchResult = 3; - others = oldVal; - } - } - switch (matchResult) { - case 0: - return newVal; - case 1: - if (typeof oldInternal === "string") { - return newVal; - } - else if (isIterable(oldInternal)) { - let activePatternResult_2; - const a_2 = newVal; - activePatternResult_2 = ((a_2 == null) ? void 0 : (undefined)); - if (activePatternResult_2 != null) { - const newInternal = value_1(activePatternResult_2); - const v = Update_updateAppend(oldInternal, newInternal); - const cases_1 = partition((x) => (name(x) === "Some"), getUnionCases(makeGenericType(option_type(obj_type), [obj_type]))); - const patternInput = [exactlyOne(cases_1[0]), [v]]; - return makeUnion(patternInput[0], patternInput[1]); - } - else { - return oldVal; - } - } - else { - return newVal; - } - case 2: { - const oldSeq = oldVal; - const newSeq = newVal; - const innerType = Update_enumGetInnerType(oldVal); - if (Update_isMapType(oldVal)) { - return newVal; - } - else { - return distinct_generic(append_generic(oldSeq, newSeq)); - } - } - default: - return newVal; - } -} - -/** - * updates oldRT with newRT by replacing all values, but only if the new value is not empty. - */ -export function Update_updateOnlyByExisting(oldVal, newVal) { - if (equals(newVal, defaultOf())) { - return oldVal; - } - else { - let activePatternResult; - const a = oldVal; - activePatternResult = ((a == null) ? void 0 : (undefined)); - if (activePatternResult != null) { - const oldInternal = value_1(activePatternResult); - let activePatternResult_1; - const a_1 = newVal; - activePatternResult_1 = ((a_1 == null) ? void 0 : (undefined)); - if (activePatternResult_1 != null) { - const newInternal = value_1(activePatternResult_1); - const v = Update_updateOnlyByExisting(oldInternal, newInternal); - const cases_1 = partition((x) => (name(x) === "Some"), getUnionCases(makeGenericType(option_type(obj_type), [obj_type]))); - const patternInput = [exactlyOne(cases_1[0]), [v]]; - return makeUnion(patternInput[0], patternInput[1]); - } - else { - return oldVal; - } - } - else if (typeof oldVal === "string") { - const newStr = newVal; - if (toString(newStr) === "") { - return oldVal; - } - else { - return newStr; - } - } - else if (isIterable(oldVal)) { - const newSeq = newVal; - if (isEmpty(newSeq)) { - return oldVal; - } - else { - return newSeq; - } - } - else { - return newVal; - } - } -} - -/** - * updates oldRT with newRT by replacing all values, but only if the new value is not empty. - */ -export function Update_updateOnlyByExistingAppend(oldVal, newVal) { - if (equals(newVal, defaultOf())) { - return oldVal; - } - else { - let activePatternResult; - const a = oldVal; - activePatternResult = ((a == null) ? void 0 : (undefined)); - if (activePatternResult != null) { - const oldInternal = value_1(activePatternResult); - let activePatternResult_1; - const a_1 = newVal; - activePatternResult_1 = ((a_1 == null) ? void 0 : (undefined)); - if (activePatternResult_1 != null) { - const newInternal = value_1(activePatternResult_1); - const v = Update_updateOnlyByExistingAppend(oldInternal, newInternal); - const cases_1 = partition((x) => (name(x) === "Some"), getUnionCases(makeGenericType(option_type(obj_type), [obj_type]))); - const patternInput = [exactlyOne(cases_1[0]), [v]]; - return makeUnion(patternInput[0], patternInput[1]); - } - else { - return oldVal; - } - } - else if (typeof oldVal === "string") { - const newStr = newVal; - if (toString(newStr) === "") { - return oldVal; - } - else { - return newStr; - } - } - else if (isIterable(oldVal)) { - const innerType = Update_enumGetInnerType(oldVal); - if (Update_isMapType(oldVal)) { - return newVal; - } - else { - return distinct_generic(append_generic(oldVal, newVal)); - } - } - else { - return newVal; - } - } -} - -export class Update_UpdateOptions extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["UpdateAll", "UpdateByExisting", "UpdateAllAppendLists", "UpdateByExistingAppendLists"]; - } -} - -export function Update_UpdateOptions_$reflection() { - return union_type("ISA.Aux.Update.UpdateOptions", [], Update_UpdateOptions, () => [[], [], [], []]); -} - diff --git a/package-lock.json b/package-lock.json index ec12818b..1b559b2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,19 @@ { "name": "arcapi", - "version": "1.0.0", + "version": "1.0.0+4892f43", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "arcapi", - "version": "1.0.0", + "version": "1.0.0+4892f43", "hasInstallScript": true, "license": "ISC", "dependencies": { "fable-library": "^1.1.1" }, "devDependencies": { + "mkdirp": "3.0.1", "mocha": "^10.2.0" } }, @@ -569,6 +570,21 @@ "node": ">=10" } }, + "node_modules/mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true, + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/mocha": { "version": "10.2.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", @@ -1324,6 +1340,12 @@ "brace-expansion": "^2.0.1" } }, + "mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true + }, "mocha": { "version": "10.2.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", diff --git a/package.json b/package.json index b8a8ffa3..6078a9e5 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,27 @@ { "name": "arcapi", - "version": "1.0.0", + "version": "1.0.0+4892f43", "description": "Top level ARC DataModel and API function descriptions.", "type": "module", "scripts": { - "prebundle-js": "dotnet fable clean -o ./js --yes", - "bundle-js": "dotnet fable ./src/ARCtrl -o ./js", - "prebundle-ts": "dotnet fable clean -o ./ts --yes --extension .ts", - "bundle-ts": "dotnet fable ./src/ARCtrl -o ./ts --lang ts", + "prebundlejs": "mkdirp .\\dist/js && dotnet fable clean -o ./dist/js --yes", + "bundlejs": "dotnet fable ./src/ARCtrl -o ./dist/js", + "prebundlets": "mkdirp .\\dist/ts && dotnet fable clean -o ./dist/ts --yes --extension .ts", + "bundlets": "dotnet fable ./src/ARCtrl -o ./dist/ts --lang ts", "pretestJson": "dotnet fable tests/ISA/ISA.Json.Tests -o tests/ISA/ISA.Json.Tests/js", "testJson": "mocha tests/ISA/ISA.Json.Tests/js --timeout 20000", "pretestSpreadsheet": "dotnet fable tests/ISA/ISA.Spreadsheet.Tests -o tests/ISA/ISA.Spreadsheet.Tests/js", "testSpreadsheet": "mocha tests/ISA/ISA.Spreadsheet.Tests/js", "pretest": "dotnet fable tests/ISA/ISA.Tests -o tests/ISA/ISA.Tests/js", "test": "mocha tests/ISA/ISA.Tests/js", - "pretestFS": "dotnet fable tests/FileSystem/FileSystem.Tests -o tests/FileSystem/FileSystem.Tests/js", - "testFS": "mocha tests/FileSystem/FileSystem.Tests/js", + "pretestFS": "dotnet fable tests/FileSystem -o tests/FileSystem/js", + "testFS": "mocha tests/FileSystem/js", "pretestARC": "dotnet fable tests/ARCtrl -o tests/ARCtrl/js", "testARC": "mocha tests/ARCtrl/js", - "pretestJavaScript": "dotnet fable src/ARCtrl -o tests/JavaScript/ARCtrl", - "testJavaScript": "mocha tests/JavaScript", - "pretestPython": "dotnet fable src/ARCtrl -o tests/Python/ARCtrl --lang py ", - "testPython": "", + "pretestjs": "dotnet fable src/ARCtrl -o tests/JavaScript/ARCtrl", + "testjs": "mocha tests/JavaScript", + "pretestpy": "dotnet fable src/ARCtrl -o tests/Python/ARCtrl --lang py ", + "testpy": "", "postinstall": "cd src/ISA & npm install" }, "repository": { @@ -38,6 +38,7 @@ "fable-library": "^1.1.1" }, "devDependencies": { - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "mkdirp": "3.0.1" } } diff --git a/paket.dependencies b/paket.dependencies new file mode 100644 index 00000000..9aa4b79f --- /dev/null +++ b/paket.dependencies @@ -0,0 +1,14 @@ +source https://api.nuget.org/v3/index.json + +storage: none +framework: net6.0, netstandard2.0 + +nuget Fable.Core ~> 4.0.0 +nuget FSharp.Core +nuget FsSpreadsheet 3.3.0 + +// Test NuGet packages +nuget Expecto ~> 9.0.4 +nuget Fable.Mocha ~> 2.16.0 +nuget Microsoft.NET.Test.Sdk ~> 17.4.0 +nuget YoloDev.Expecto.TestSdk ~> 0.13.2 \ No newline at end of file diff --git a/paket.lock b/paket.lock new file mode 100644 index 00000000..c14cceb3 --- /dev/null +++ b/paket.lock @@ -0,0 +1,37 @@ +STORAGE: NONE +RESTRICTION: || (== net6.0) (== netstandard2.0) +NUGET + remote: https://api.nuget.org/v3/index.json + Expecto (9.0.4) + FSharp.Core (>= 4.6) + Mono.Cecil (>= 0.11.3) + Fable.Core (4.0) + Fable.Mocha (2.16) + Fable.Core (>= 3.0) + FSharp.Core (>= 4.7) + FSharp.Core (7.0.300) + FsSpreadsheet (3.3) + Fable.Core (>= 4.0) + FSharp.Core (>= 6.0.7) + Microsoft.CodeCoverage (17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.NET.Test.Sdk (17.4.1) + Microsoft.CodeCoverage (>= 17.4.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.TestPlatform.TestHost (>= 17.4.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.TestPlatform.ObjectModel (17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + NuGet.Frameworks (>= 6.5) + System.Reflection.Metadata (>= 1.6) + Microsoft.TestPlatform.TestHost (17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.TestPlatform.ObjectModel (>= 17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Newtonsoft.Json (>= 13.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Mono.Cecil (0.11.5) + Newtonsoft.Json (13.0.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + NuGet.Frameworks (6.6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + System.Collections.Immutable (7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + System.Runtime.CompilerServices.Unsafe (>= 6.0) + System.Reflection.Metadata (7.0.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + System.Collections.Immutable (>= 7.0) + System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.0) (>= netcoreapp3.1)) + YoloDev.Expecto.TestSdk (0.13.3) + Expecto (>= 9.0 < 10.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + FSharp.Core (>= 4.6.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + System.Collections.Immutable (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) diff --git a/src/ARCtrl/ARCtrl.fs b/src/ARCtrl/ARCtrl.fs index 08fa314a..3c5b96e9 100644 --- a/src/ARCtrl/ARCtrl.fs +++ b/src/ARCtrl/ARCtrl.fs @@ -56,7 +56,6 @@ module ARCAux = [] type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSystem) = - let mutable isa = isa let mutable cwl = cwl let mutable fs = fs @@ -64,8 +63,7 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste |> ARCAux.updateFSByISA isa |> ARCAux.updateFSByCWL cwl - member this.ISA - with get() = isa + member val ISA : ArcInvestigation option = isa with get, set member this.CWL with get() = cwl @@ -166,30 +164,30 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste let studies = ARCAux.getArcStudiesFromContracts contracts /// get assays from xlsx let assays = ARCAux.getArcAssaysFromContracts contracts - /// Necessary, else: System.InvalidOperationException: Collection was modified; enumeration operation may not execute. - let copy = investigation.Copy() - copy.StudyIdentifiers |> Seq.iter (fun studyRegisteredIdent -> + + investigation.Studies |> Seq.iter (fun registeredStudy -> /// Try find registered study in parsed READ contracts - let studyOpt = studies |> Array.tryFind (fun s -> s.Identifier = studyRegisteredIdent) + let studyOpt = studies |> Array.tryFind (fun s -> s.Identifier = registeredStudy.Identifier) match studyOpt with | Some study -> // This study element is parsed from FsWorkbook and has no regsitered assays, yet - if enableLogging then printfn "Found study: %s" studyRegisteredIdent - let registeredAssays = copy.GetStudy(studyRegisteredIdent).AssayIdentifiers - registeredAssays |> Seq.iter (fun assayRegisteredIdent -> + + if enableLogging then printfn "Found study: %s" registeredStudy.Identifier + registeredStudy.Assays |> Seq.iter (fun registeredAssay -> /// Try find registered assay in parsed READ contracts - let assayOpt = assays |> Array.tryFind (fun a -> a.Identifier = assayRegisteredIdent) + let assayOpt = assays |> Array.tryFind (fun a -> a.Identifier = registeredAssay.Identifier) match assayOpt with | Some assay -> - if enableLogging then printfn "Found assay: %s - %s" studyRegisteredIdent assayRegisteredIdent - study.AddAssay(assay) + if enableLogging then printfn "Found assay: %s - %s" registeredStudy.Identifier registeredAssay.Identifier + registeredAssay.AddTables(assay.Tables) | None -> - if enableLogging then printfn "Unable to find registered assay '%s' in fullfilled READ contracts!" assayRegisteredIdent + if enableLogging then printfn "Unable to find registered assay '%s' in fullfilled READ contracts!" registeredAssay.Identifier ) - investigation.SetStudy(studyRegisteredIdent, study) + study.Tables + |> Seq.iter (fun table -> registeredStudy.SetTable(table.Name , table)) | None -> - if enableLogging then printfn "Unable to find registered study '%s' in fullfilled READ contracts!" studyRegisteredIdent + if enableLogging then printfn "Unable to find registered study '%s' in fullfilled READ contracts!" registeredStudy.Identifier ) - isa <- Some investigation + this.ISA <- Some investigation member this.UpdateFileSystem() = @@ -225,7 +223,7 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste workbooks.Add (Path.InvestigationFileName, (DTOType.ISA_Investigation, ISA.Spreadsheet.ArcInvestigation.toFsWorkbook (ArcInvestigation.create(Identifier.MISSING_IDENTIFIER)))) printfn "ARC contains no ISA part." - /// Iterates over filesystem and creates a write contract for every file. If possible, include DTO. + // Iterates over filesystem and creates a write contract for every file. If possible, include DTO. fs.Tree.ToFilePaths(true) |> Array.map (fun fp -> match Dictionary.tryGet fp workbooks with diff --git a/src/ARCtrl/ARCtrl.fsproj b/src/ARCtrl/ARCtrl.fsproj index 27d1f4d2..314d5ec9 100644 --- a/src/ARCtrl/ARCtrl.fsproj +++ b/src/ARCtrl/ARCtrl.fsproj @@ -1,11 +1,11 @@ - - + + netstandard2.0 true - + @@ -15,8 +15,6 @@ - - @@ -25,25 +23,21 @@ - - - + - - nfdi4plants, Lukas Weil, Kevin Frey, Kevin Schneider, Oliver Maus Library for management of Annotated Research Contexts (ARCs) using an in-memory representation and runtimer agnostic contract systems. MIT - https://raw.githubusercontent.com/nfdi4plants/Branding/138420e3b6f9ec9e125c1ca8840874b2be2a1262/logos/DataPLANT_logo_minimal_rounded_bg_transparent.svg + logo.png ARC F# FSharp dotnet .Net bioinformatics biology fable-library datascience dataplant nfdi metadata https://github.com/nfdi4plants/ARCtrl https://github.com/nfdi4plants/ARCtrl git - - + + \ No newline at end of file diff --git a/src/ARCtrl/paket.references b/src/ARCtrl/paket.references new file mode 100644 index 00000000..2387b156 --- /dev/null +++ b/src/ARCtrl/paket.references @@ -0,0 +1,2 @@ +FSharp.Core +Fable.Core \ No newline at end of file diff --git a/src/CWL/ARCtrl.CWL.fsproj b/src/CWL/ARCtrl.CWL.fsproj index 3d557d15..aa13ecc7 100644 --- a/src/CWL/ARCtrl.CWL.fsproj +++ b/src/CWL/ARCtrl.CWL.fsproj @@ -1,32 +1,27 @@ - - + + netstandard2.0 true - + + - - - - - - nfdi4plants ARC helper functions for Common workflow language. MIT - https://raw.githubusercontent.com/nfdi4plants/Branding/138420e3b6f9ec9e125c1ca8840874b2be2a1262/logos/DataPLANT_logo_minimal_rounded_bg_transparent.svg + logo.png ARC F# FSharp dotnet .Net bioinformatics biology fable-library datascience dataplant nfdi metadata https://github.com/nfdi4plants/ARCtrl/tree/main/src/CWL https://github.com/nfdi4plants/ARCtrl git - - + + \ No newline at end of file diff --git a/src/CWL/paket.references b/src/CWL/paket.references new file mode 100644 index 00000000..2387b156 --- /dev/null +++ b/src/CWL/paket.references @@ -0,0 +1,2 @@ +FSharp.Core +Fable.Core \ No newline at end of file diff --git a/src/Contract/ARCtrl.Contract.fsproj b/src/Contract/ARCtrl.Contract.fsproj index 610200e5..ce8cee60 100644 --- a/src/Contract/ARCtrl.Contract.fsproj +++ b/src/Contract/ARCtrl.Contract.fsproj @@ -1,33 +1,27 @@ - - + + netstandard2.0 true - - - - - + + - - nfdi4plants, Kevin Frey, Lukas Weil, Kevin Schneider, Oliver Maus ARC helper functions for contracts management. MIT - https://raw.githubusercontent.com/nfdi4plants/Branding/138420e3b6f9ec9e125c1ca8840874b2be2a1262/logos/DataPLANT_logo_minimal_rounded_bg_transparent.svg + logo.png ARC F# FSharp dotnet .Net bioinformatics biology fable-library datascience dataplant nfdi metadata https://github.com/nfdi4plants/ARCtrl/tree/main/src/Contract https://github.com/nfdi4plants/ARCtrl git - - - + + \ No newline at end of file diff --git a/src/Contract/paket.references b/src/Contract/paket.references new file mode 100644 index 00000000..2387b156 --- /dev/null +++ b/src/Contract/paket.references @@ -0,0 +1,2 @@ +FSharp.Core +Fable.Core \ No newline at end of file diff --git a/src/FileSystem/ARCtrl.FileSystem.fsproj b/src/FileSystem/ARCtrl.FileSystem.fsproj index a92da242..0f4bd397 100644 --- a/src/FileSystem/ARCtrl.FileSystem.fsproj +++ b/src/FileSystem/ARCtrl.FileSystem.fsproj @@ -1,36 +1,31 @@ - - + + netstandard2.0 true - + - - - + - - - nfdi4plants, Kevin Frey, Lukas Weil ARC helper functions for filesystem management. MIT - https://raw.githubusercontent.com/nfdi4plants/Branding/138420e3b6f9ec9e125c1ca8840874b2be2a1262/logos/DataPLANT_logo_minimal_rounded_bg_transparent.svg + logo.png ARC F# FSharp dotnet .Net bioinformatics biology fable-library datascience dataplant nfdi metadata https://github.com/nfdi4plants/ARCtrl/tree/main/src/FileSystem https://github.com/nfdi4plants/ARCtrl git - - + + \ No newline at end of file diff --git a/src/FileSystem/paket.references b/src/FileSystem/paket.references new file mode 100644 index 00000000..2387b156 --- /dev/null +++ b/src/FileSystem/paket.references @@ -0,0 +1,2 @@ +FSharp.Core +Fable.Core \ No newline at end of file diff --git a/src/ISA/ISA.Json/ARCtrl.ISA.Json.fsproj b/src/ISA/ISA.Json/ARCtrl.ISA.Json.fsproj index bc739687..019010c4 100644 --- a/src/ISA/ISA.Json/ARCtrl.ISA.Json.fsproj +++ b/src/ISA/ISA.Json/ARCtrl.ISA.Json.fsproj @@ -1,12 +1,14 @@ - + + netstandard2.0 true + - Always - + Always + @@ -25,45 +27,39 @@ + - + - - - - - - - - + + + + - - - nfdi4plants, Lukas Weil, Florian Wetzels, Kevin Frey ARC and ISA json compliant parser for experimental metadata toolkit in F#. This project is meant as an easy means to open, manipulate and save ISA (Investigation,Study,Assay) metadata files in isa-json format. MIT - https://raw.githubusercontent.com/nfdi4plants/Branding/138420e3b6f9ec9e125c1ca8840874b2be2a1262/logos/DataPLANT_logo_minimal_rounded_bg_transparent.svg + logo.png ARC F# FSharp dotnet .Net bioinformatics biology fable-library datascience dataplant nfdi metadata investigation study assay ISA Json https://github.com/nfdi4plants/ARCtrl/tree/main/src/ISA https://github.com/nfdi4plants/ARCtrl git - + \ No newline at end of file diff --git a/src/ISA/ISA.Json/Ontology.fs b/src/ISA/ISA.Json/Ontology.fs index 74b677fc..2ad7dcce 100644 --- a/src/ISA/ISA.Json/Ontology.fs +++ b/src/ISA/ISA.Json/Ontology.fs @@ -62,7 +62,7 @@ module OntologySourceReference = File = get.Optional.Field "file" Decode.string Name = get.Optional.Field "name" Decode.string Version = get.Optional.Field "version" Decode.string - Comments = get.Optional.Field "comments" (Decode.list (Comment.decoder options)) + Comments = get.Optional.Field "comments" (Decode.array (Comment.decoder options)) } ) @@ -109,27 +109,16 @@ module OntologyAnnotation = |> GEncode.choose |> Encode.object - let localIDDecoder : Decoder = - fun s json -> - match Decode.string s json with - | Ok (Regex.ActivePatterns.TermAnnotation tan) -> - Ok (tan.TermSourceREF) - | _ -> Ok "" - //| Ok s -> Error (DecoderError(s,ErrorReason.FailMessage "Could not parse local ID from string")) - //| Error e -> Error e - let decoder (options : ConverterOptions) : Decoder = Decode.object (fun get -> - { - ID = get.Optional.Field "@id" GDecode.uri - Name = get.Optional.Field "annotationValue" (AnnotationValue.decoder options) - TermSourceREF = get.Optional.Field "termSource" Decode.string - //LocalID = try get.Optional.Field "termAccession" localIDDecoder with | _ -> None - LocalID = get.Optional.Field "termAccession" localIDDecoder |> Option.bind (fun s -> if s = "" then None else Some s) - TermAccessionNumber = get.Optional.Field "termAccession" Decode.string - Comments = get.Optional.Field "comments" (Decode.array (Comment.decoder options)) - } + OntologyAnnotation.create( + ?Id = get.Optional.Field "@id" GDecode.uri, + ?Name = get.Optional.Field "annotationValue" (AnnotationValue.decoder options), + ?TermSourceREF = get.Optional.Field "termSource" Decode.string, + ?TermAccessionNumber = get.Optional.Field "termAccession" Decode.string, + ?Comments = get.Optional.Field "comments" (Decode.array (Comment.decoder options)) + ) ) let fromString (s:string) = diff --git a/src/ISA/ISA.Json/Person.fs b/src/ISA/ISA.Json/Person.fs index fb32bf96..8c479898 100644 --- a/src/ISA/ISA.Json/Person.fs +++ b/src/ISA/ISA.Json/Person.fs @@ -32,8 +32,9 @@ module Person = | _ -> "#EmptyPerson" let rec encoder (options : ConverterOptions) (oa : obj) = + let oa = oa :?> Person |> Person.setCommentFromORCID [ - if options.SetID then "@id", GEncode.string (oa :?> Person |> genID) + if options.SetID then "@id", GEncode.string (oa |> genID) else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") if options.IncludeType then "@type", GEncode.string "Person" GEncode.tryInclude "firstName" GEncode.string (oa |> GEncode.tryGetPropertyValue "FirstName") @@ -54,6 +55,7 @@ module Person = Decode.object (fun get -> { ID = get.Optional.Field "@id" GDecode.uri + ORCID = None FirstName = get.Optional.Field "firstName" Decode.string LastName = get.Optional.Field "lastName" Decode.string MidInitials = get.Optional.Field "midInitials" Decode.string @@ -65,6 +67,7 @@ module Person = Roles = get.Optional.Field "roles" (Decode.array (OntologyAnnotation.decoder options)) Comments = get.Optional.Field "comments" (Decode.array (Comment.decoder options)) } + |> Person.setOrcidFromComments ) diff --git a/src/ISA/ISA.Json/paket.references b/src/ISA/ISA.Json/paket.references new file mode 100644 index 00000000..2387b156 --- /dev/null +++ b/src/ISA/ISA.Json/paket.references @@ -0,0 +1,2 @@ +FSharp.Core +Fable.Core \ No newline at end of file diff --git a/src/ISA/ISA.Spreadsheet/ARCtrl.ISA.Spreadsheet.fsproj b/src/ISA/ISA.Spreadsheet/ARCtrl.ISA.Spreadsheet.fsproj index 2fb9c7cf..a70c4771 100644 --- a/src/ISA/ISA.Spreadsheet/ARCtrl.ISA.Spreadsheet.fsproj +++ b/src/ISA/ISA.Spreadsheet/ARCtrl.ISA.Spreadsheet.fsproj @@ -1,15 +1,14 @@ - - + + netstandard2.0 true - - + @@ -30,31 +29,24 @@ + - - - - - - - - nfdi4plants, Lukas Weil ARC and ISA xlsx compliant parser for experimental metadata toolkit in F#. This project is meant as an easy means to open, manipulate and save ISA (Investigation,Study,Assay) metadata files in isa-xlsx format. MIT - https://raw.githubusercontent.com/nfdi4plants/Branding/138420e3b6f9ec9e125c1ca8840874b2be2a1262/logos/DataPLANT_logo_minimal_rounded_bg_transparent.svg + logo.png ARC F# FSharp dotnet .Net bioinformatics biology fable-library datascience dataplant nfdi metadata investigation study assay ISA Spreadsheet xlsx excel https://github.com/nfdi4plants/ARCtrl/tree/main/src/ISA https://github.com/nfdi4plants/ARCtrl git - - + + \ No newline at end of file diff --git a/src/ISA/ISA.Spreadsheet/CompositeHeader.fs b/src/ISA/ISA.Spreadsheet/CompositeHeader.fs index 8787555f..c0697e83 100644 --- a/src/ISA/ISA.Spreadsheet/CompositeHeader.fs +++ b/src/ISA/ISA.Spreadsheet/CompositeHeader.fs @@ -7,10 +7,10 @@ module ActivePattern = open ARCtrl.ISA.Regex.ActivePatterns - let mergeTerms tsr1 tan1 tsr2 tan2 = - if tsr1 <> tsr2 then failwithf "TermSourceRef %s and %s do not match" tsr1 tsr2 - if tan1 <> tan2 then failwithf "TermAccessionNumber %s and %s do not match" tan1 tan2 - {|TermSourceRef = tsr1; TermAccessionNumber = tan1|} + let mergeIDInfo idSpace1 localID1 idSpace2 localID2 = + if idSpace1 <> idSpace2 then failwithf "TermSourceRef %s and %s do not match" idSpace1 idSpace2 + if localID1 <> localID2 then failwithf "LocalID %s and %s do not match" localID1 localID2 + {|TermSourceRef = idSpace1; TermAccessionNumber = $"{idSpace1}:{localID1}"|} let (|Term|_|) (categoryParser : string -> string option) (f : OntologyAnnotation -> CompositeHeader) (cells : FsCell list) = let (|AC|_|) s = @@ -25,7 +25,7 @@ module ActivePattern = //| [AC name; TermAccessionNumber term1; TermSourceREF term2] //| [AC name; Unit; TermAccessionNumber term1; TermSourceREF term2] | [AC name; UnitColumnHeader; TSRColumnHeader term1; TANColumnHeader term2] -> - let term = mergeTerms term1.TermSourceREF term1.TermAccessionNumber term2.TermSourceREF term2.TermAccessionNumber + let term = mergeIDInfo term1.IDSpace term1.LocalID term2.IDSpace term2.LocalID let ont = OntologyAnnotation.fromString(name, term.TermSourceRef, term.TermAccessionNumber) f ont |> Some diff --git a/src/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.fs b/src/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.fs index 8e0b257f..4385afbb 100644 --- a/src/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.fs +++ b/src/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.fs @@ -25,6 +25,7 @@ module Contacts = let roles = OntologyAnnotation.fromAggregatedStrings ';' role rolesTermSourceREF rolesTermAccessionNumber Person.make None + None (Option.fromValueWithDefault "" lastName ) (Option.fromValueWithDefault "" firstName ) (Option.fromValueWithDefault "" midInitials) @@ -35,6 +36,7 @@ module Contacts = (Option.fromValueWithDefault "" affiliation) (Option.fromValueWithDefault [||] roles ) (Option.fromValueWithDefault [||] comments ) + |> Person.setOrcidFromComments let fromSparseTable (matrix : SparseTable) = if matrix.ColumnCount = 0 && matrix.CommentKeys.Length <> 0 then @@ -67,6 +69,7 @@ module Contacts = let matrix = SparseTable.Create (keys = labels,length=persons.Length + 1) let mutable commentKeys = [] persons + |> List.map Person.setCommentFromORCID |> List.iteri (fun i p -> let i = i + 1 let rAgg = Option.defaultValue [||] p.Roles |> OntologyAnnotation.toAggregatedStrings ';' diff --git a/src/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.fs b/src/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.fs index 1ab4cf3b..651561e1 100644 --- a/src/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.fs +++ b/src/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.fs @@ -21,12 +21,12 @@ module OntologySourceReference = (Option.fromValueWithDefault "" file) (Option.fromValueWithDefault "" name) (Option.fromValueWithDefault "" version) - (Option.fromValueWithDefault [] comments) + (Option.fromValueWithDefault [||] comments) let fromSparseTable (matrix : SparseTable) = if matrix.ColumnCount = 0 && matrix.CommentKeys.Length <> 0 then let comments = SparseTable.GetEmptyComments matrix - OntologySourceReference.create(Comments = List.ofArray comments) + OntologySourceReference.create(Comments = comments) |> List.singleton else List.init matrix.ColumnCount (fun i -> @@ -35,6 +35,7 @@ module OntologySourceReference = matrix.CommentKeys |> List.map (fun k -> Comment.fromString k (matrix.TryGetValueDefault("",(k,i)))) + |> Array.ofList fromString (matrix.TryGetValueDefault("",(descriptionLabel,i))) @@ -59,7 +60,7 @@ module OntologySourceReference = | None -> () | Some c -> c - |> List.iter (fun comment -> + |> Array.iter (fun comment -> let n,v = comment |> Comment.toString commentKeys <- n :: commentKeys matrix.Matrix.Add((n,i),v) diff --git a/src/ISA/ISA.Spreadsheet/SparseTable.fs b/src/ISA/ISA.Spreadsheet/SparseTable.fs index 338793b3..7c72e438 100644 --- a/src/ISA/ISA.Spreadsheet/SparseTable.fs +++ b/src/ISA/ISA.Spreadsheet/SparseTable.fs @@ -48,7 +48,8 @@ module SparseRow = let writeToSheet (rowI : int) (row : SparseRow) (sheet : FsWorksheet) = let fsRow = sheet.Row(rowI) row - |> Seq.iter (fun (colI,v) -> fsRow.[colI + 1].SetValueAs v) + |> Seq.iter (fun (colI,v) -> + if v.Trim() <> "" then fsRow.[colI + 1].SetValueAs v) type SparseTable = diff --git a/src/ISA/ISA.Spreadsheet/paket.references b/src/ISA/ISA.Spreadsheet/paket.references new file mode 100644 index 00000000..d95dfd31 --- /dev/null +++ b/src/ISA/ISA.Spreadsheet/paket.references @@ -0,0 +1,3 @@ +FSharp.Core +Fable.Core +FsSpreadsheet \ No newline at end of file diff --git a/src/ISA/ISA/ARCtrl.ISA.fsproj b/src/ISA/ISA/ARCtrl.ISA.fsproj index 71d03890..eb20bd0d 100644 --- a/src/ISA/ISA/ARCtrl.ISA.fsproj +++ b/src/ISA/ISA/ARCtrl.ISA.fsproj @@ -1,11 +1,11 @@ - - + + netstandard2.0 true - + @@ -62,33 +62,26 @@ + - - - - - - - + - - + - nfdi4plants, Lukas Weil, Kevin Frey, Kevin Schneider, Oliver Muas ARC and ISA compliant experimental metadata toolkit in F#. This project is meant as an easy means to open, manipulate and save ISA (Investigation,Study,Assay) metadata files in the dotnet environment. MIT - https://raw.githubusercontent.com/nfdi4plants/Branding/138420e3b6f9ec9e125c1ca8840874b2be2a1262/logos/DataPLANT_logo_minimal_rounded_bg_transparent.svg + logo.png ARC F# FSharp dotnet .Net bioinformatics biology fable-library datascience dataplant nfdi metadata investigation study assay ISA Json https://github.com/nfdi4plants/ARCtrl/tree/main/src/ISA https://github.com/nfdi4plants/ARCtrl - git + git - - + + \ No newline at end of file diff --git a/src/ISA/ISA/ArcTypes/ArcAssay.fs b/src/ISA/ISA/ArcTypes/ArcAssay.fs index ae5ab9e5..5e6708a8 100644 --- a/src/ISA/ISA/ArcTypes/ArcAssay.fs +++ b/src/ISA/ISA/ArcTypes/ArcAssay.fs @@ -119,6 +119,24 @@ type ArcAssay(identifier: string, ?measurementType : OntologyAnnotation, ?techno newAssay.UpdateTable(name, table) newAssay + // - Table API - // + member this.SetTableAt(index:int, table:ArcTable) = ArcTables(this.Tables).SetTableAt(index, table) + + static member setTableAt(index:int, table:ArcTable) : ArcAssay -> ArcAssay = + fun (assay:ArcAssay) -> + let newAssay = assay.Copy() + newAssay.SetTableAt(index, table) + newAssay + + // - Table API - // + member this.SetTable(name: string, table:ArcTable) : unit = ArcTables(this.Tables).SetTable(name, table) + + static member setTable(name: string, table:ArcTable) : ArcAssay -> ArcAssay = + fun (assay:ArcAssay) -> + let newAssay = assay.Copy() + newAssay.SetTable(name, table) + newAssay + // - Table API - // member this.RemoveTableAt(index:int) : unit = ArcTables(this.Tables).RemoveTableAt(index) @@ -336,18 +354,20 @@ type ArcAssay(identifier: string, ?measurementType : OntologyAnnotation, ?techno assay member this.Copy() : ArcAssay = - let newTables = ResizeArray() + let nextTables = ResizeArray() for table in this.Tables do let copy = table.Copy() - newTables.Add(copy) + nextTables.Add(copy) + let nextComments = this.Comments |> Array.map (fun c -> c.Copy()) + let nextPerformers = this.Performers |> Array.map (fun c -> c.Copy()) ArcAssay( this.Identifier, ?measurementType = this.MeasurementType, ?technologyType = this.TechnologyType, ?technologyPlatform = this.TechnologyPlatform, - tables=newTables, - performers=this.Performers, - comments=this.Comments + tables=nextTables, + performers=nextPerformers, + comments=nextComments ) /// Transform an ArcAssay to an ISA Json Assay. @@ -386,8 +406,8 @@ type ArcAssay(identifier: string, ?measurementType : OntologyAnnotation, ?techno | None -> Identifier.createMissingIdentifier() ArcAssay.create( identifer, - ?measurementType = a.MeasurementType, - ?technologyType = a.TechnologyType, + ?measurementType = (a.MeasurementType |> Option.map (fun x -> x.Copy())), + ?technologyType = (a.TechnologyType |> Option.map (fun x -> x.Copy())), ?technologyPlatform = a.TechnologyPlatform, ?tables = tables, ?comments = (a.Comments |> Option.map Array.ofList) diff --git a/src/ISA/ISA/ArcTypes/ArcInvestigation.fs b/src/ISA/ISA/ArcTypes/ArcInvestigation.fs index 48f08876..37793700 100644 --- a/src/ISA/ISA/ArcTypes/ArcInvestigation.fs +++ b/src/ISA/ISA/ArcTypes/ArcInvestigation.fs @@ -240,29 +240,47 @@ type ArcInvestigation(identifier : string, ?title : string, ?description : strin let newInv = inv.Copy() newInv.GetAssay(studyIdentifier, assayIdentifier) - //member this.TryFindStudyForAssay(assayIdentifier: string) = - // let idents = this.Studies |> Seq.map (fun s -> s.Identifier, s.AssayIdentifiers) - // idents |> Seq.tryFind (fun (s, aArr) -> - // aArr |> Seq.contains assayIdentifier - // ) + member this.TryFindAssay(assayIdentifier: string) : ArcAssay option = + let assays = this.Studies |> Seq.collect (fun s -> s.Assays) |> Array.ofSeq + assays |> Array.tryFind (fun a -> a.Identifier = assayIdentifier) + + member this.FindAssay(assayIdentifier: string) : ArcAssay = + match this.TryFindAssay(assayIdentifier) with + | Some a -> a + | None -> failwith $"Unable to find assay with identifier '{assayIdentifier}'." + + static member tryFindAssay(assayIdentifier: string) : ArcInvestigation -> ArcAssay option = + fun (inv: ArcInvestigation) -> + let newInv = inv.Copy() + newInv.TryFindAssay(assayIdentifier) + + static member findAssay(assayIdentifier: string) : ArcInvestigation -> ArcAssay = + fun (inv: ArcInvestigation) -> + let newInv = inv.Copy() + newInv.FindAssay(assayIdentifier) member this.Copy() : ArcInvestigation = - let newStudies = ResizeArray() + let nextStudies = ResizeArray() for study in this.Studies do let copy = study.Copy() - newStudies.Add(copy) + nextStudies.Add(copy) + let nextComments = this.Comments |> Array.map (fun c -> c.Copy()) + let nextRemarks = this.Remarks |> Array.map (fun c -> c.Copy()) + let nextContacts = this.Contacts |> Array.map (fun c -> c.Copy()) + let nextPublications = this.Publications |> Array.map (fun c -> c.Copy()) + let nextOntologySourceReferences = this.OntologySourceReferences |> Array.map (fun c -> c.Copy()) ArcInvestigation( this.Identifier, ?title = this.Title, ?description = this.Description, ?submissionDate = this.SubmissionDate, ?publicReleaseDate = this.PublicReleaseDate, - ontologySourceReferences = this.OntologySourceReferences, - publications = this.Publications, - contacts = this.Contacts, - studies = newStudies, // correct mutable behaviour is tested on this field - comments = this.Comments, - remarks = this.Remarks + ontologySourceReferences = nextOntologySourceReferences, + publications = nextPublications, + contacts = nextContacts, + studies = nextStudies, // correct mutable behaviour is tested on this field + comments = nextComments, + remarks = nextRemarks ) diff --git a/src/ISA/ISA/ArcTypes/ArcStudy.fs b/src/ISA/ISA/ArcTypes/ArcStudy.fs index cafe313d..33b5d075 100644 --- a/src/ISA/ISA/ArcTypes/ArcStudy.fs +++ b/src/ISA/ISA/ArcTypes/ArcStudy.fs @@ -240,6 +240,25 @@ type ArcStudy(identifier : string, ?title, ?description, ?submissionDate, ?publi newAssay.UpdateTable(name, table) newAssay + + // - Table API - // + member this.SetTableAt(index:int, table:ArcTable) = ArcTables(this.Tables).SetTableAt(index, table) + + static member setTableAt(index:int, table:ArcTable) : ArcStudy -> ArcStudy = + fun (study:ArcStudy) -> + let newAssay = study.Copy() + newAssay.SetTableAt(index, table) + newAssay + + // - Table API - // + member this.SetTable(name: string, table:ArcTable) : unit = ArcTables(this.Tables).SetTable(name, table) + + static member setTable(name: string, table:ArcTable) : ArcStudy -> ArcStudy = + fun (study:ArcStudy) -> + let newAssay = study.Copy() + newAssay.SetTable(name, table) + newAssay + // - Table API - // member this.RemoveTableAt(index:int) : unit = ArcTables(this.Tables).RemoveTableAt(index) @@ -452,27 +471,32 @@ type ArcStudy(identifier : string, ?title, ?description, ?submissionDate, ?publi newAssay.GetRow(tableName, rowIndex) member this.Copy() : ArcStudy = - let newTables = ResizeArray() - let newAssays = ResizeArray() + let nextTables = ResizeArray() + let nextAssays = ResizeArray() for table in this.Tables do let copy = table.Copy() - newTables.Add(copy) + nextTables.Add(copy) for study in this.Assays do let copy = study.Copy() - newAssays.Add(copy) + nextAssays.Add(copy) + let nextComments = this.Comments |> Array.map (fun c -> c.Copy()) + let nextFactors = this.Factors |> Array.map (fun c -> c.Copy()) + let nextContacts = this.Contacts |> Array.map (fun c -> c.Copy()) + let nextPublications = this.Publications |> Array.map (fun c -> c.Copy()) + let nextStudyDesignDescriptors = this.StudyDesignDescriptors |> Array.map (fun c -> c.Copy()) ArcStudy( this.Identifier, ?title = this.Title, ?description = this.Description, - ?submissionDate = submissionDate, + ?submissionDate = this.SubmissionDate, ?publicReleaseDate = this.PublicReleaseDate, - publications = this.Publications, - contacts = this.Contacts, - studyDesignDescriptors = this.StudyDesignDescriptors, - tables = newTables, - assays = newAssays, - factors = this.Factors, - comments = this.Comments + publications = nextPublications, + contacts = nextContacts, + studyDesignDescriptors = nextStudyDesignDescriptors, + tables = nextTables, + assays = nextAssays, + factors = nextFactors, + comments = nextComments ) /// Transform an ArcStudy to an ISA Json Study. diff --git a/src/ISA/ISA/ArcTypes/ArcTables.fs b/src/ISA/ISA/ArcTypes/ArcTables.fs index 6b2b2ca6..3c62fba0 100644 --- a/src/ISA/ISA/ArcTypes/ArcTables.fs +++ b/src/ISA/ISA/ArcTypes/ArcTables.fs @@ -24,23 +24,31 @@ module ArcTablesAux = // |> findNextNumber // ArcTable.init($"New Table {nextNumber}") - let indexByTableName (name: string) (tables: ResizeArray) = + /// If a table with the given name exists in the TableList, returns it, else returns None. + let tryFindIndexByTableName (name: string) (tables: ResizeArray) = + Seq.tryFindIndex (fun t -> t.Name = name) tables + + /// If a table with the given name exists in the TableList, returns it, else fails. + let findIndexByTableName (name: string) (tables: ResizeArray) = match Seq.tryFindIndex (fun t -> t.Name = name) tables with | Some index -> index | None -> failwith $"Unable to find table with name '{name}'!" module SanityChecks = + /// Fails, if the index is out of range of the Tables collection. When allowAppend is set to true, it may be out of range by at most 1. let validateSheetIndex (index: int) (allowAppend: bool) (sheets: ResizeArray) = let eval x y = if allowAppend then x > y else x >= y if index < 0 then failwith "Cannot insert ArcTable at index < 0." if eval index sheets.Count then failwith $"Specified index is out of range! Assay contains only {sheets.Count} tables." + /// Fails, if two tables have the same name. let validateNamesUnique (names:seq) = let isDistinct = (Seq.length names) = (Seq.distinct names |> Seq.length) if not isDistinct then failwith "Cannot add multiple tables with the same name! Table names inside one assay must be unqiue" + /// Fails, if the name is already used by another table. let validateNewNameUnique (newName:string) (existingNames:seq) = match Seq.tryFindIndex (fun x -> x = newName) existingNames with | Some i -> @@ -48,6 +56,17 @@ module ArcTablesAux = | None -> () + /// Fails, if the name is already used by another table at a different position. + /// + /// Does not fail, if the newName is the same as the one in the given position. + let validateNewNameAtUnique (index : int) (newName:string) (existingNames:seq) = + match Seq.tryFindIndex (fun x -> x = newName) existingNames with + | Some i when index = i-> () + | Some i -> + failwith $"Cannot create table with name {newName}, as table names must be unique and table at index {i} has the same name." + | None -> + () + let validateNewNamesUnique (newNames:seq) (existingNames:seq) = validateNamesUnique newNames let setNew = Set.ofSeq newNames @@ -76,7 +95,6 @@ type ArcTables(thisTables:ResizeArray) = thisTables.[index] // - Table API - // - // remark should this return ArcTable? member this.AddTable(table:ArcTable, ?index: int) = let index = defaultArg index this.Count SanityChecks.validateSheetIndex index true thisTables @@ -114,20 +132,31 @@ type ArcTables(thisTables:ResizeArray) = // - Table API - // member this.GetTable(name: string) : ArcTable = - indexByTableName name thisTables + findIndexByTableName name thisTables |> this.GetTableAt // - Table API - // member this.UpdateTableAt(index:int, table:ArcTable) = SanityChecks.validateSheetIndex index false thisTables - SanityChecks.validateNewNameUnique table.Name this.TableNames + SanityChecks.validateNewNameAtUnique index table.Name this.TableNames thisTables.[index] <- table // - Table API - // member this.UpdateTable(name: string, table:ArcTable) : unit = - (indexByTableName name thisTables, table) + (findIndexByTableName name thisTables, table) |> this.UpdateTableAt + // - Table API - // + member this.SetTableAt(index:int, table:ArcTable) = + SanityChecks.validateSheetIndex index true thisTables + SanityChecks.validateNewNameAtUnique index table.Name this.TableNames + thisTables.[index] <- table + + // - Table API - // + member this.SetTable(name: string, table:ArcTable) : unit = + match tryFindIndexByTableName name thisTables with + | Some index -> this.SetTableAt(index, table) + | None -> this.AddTable(table) // - Table API - // member this.RemoveTableAt(index:int) : unit = @@ -136,7 +165,7 @@ type ArcTables(thisTables:ResizeArray) = // - Table API - // member this.RemoveTable(name: string) : unit = - indexByTableName name thisTables + findIndexByTableName name thisTables |> this.RemoveTableAt @@ -149,7 +178,7 @@ type ArcTables(thisTables:ResizeArray) = // - Table API - // member this.MapTable(name: string, updateFun: ArcTable -> unit) : unit = - (indexByTableName name thisTables, updateFun) + (findIndexByTableName name thisTables, updateFun) |> this.MapTableAt // - Table API - // @@ -162,7 +191,7 @@ type ArcTables(thisTables:ResizeArray) = // - Table API - // member this.RenameTable(name: string, newName: string) : unit = - (indexByTableName name thisTables, newName) + (findIndexByTableName name thisTables, newName) |> this.RenameTableAt // - Column CRUD API - // @@ -173,7 +202,7 @@ type ArcTables(thisTables:ResizeArray) = // - Column CRUD API - // member this.AddColumn(tableName: string, header: CompositeHeader, ?cells: CompositeCell [], ?columnIndex: int, ?forceReplace: bool) = - indexByTableName tableName thisTables + findIndexByTableName tableName thisTables |> fun i -> this.AddColumnAt(i, header, ?cells=cells, ?columnIndex=columnIndex, ?forceReplace=forceReplace) // - Column CRUD API - // @@ -184,7 +213,7 @@ type ArcTables(thisTables:ResizeArray) = // - Column CRUD API - // member this.RemoveColumn(tableName: string, columnIndex: int) : unit = - (indexByTableName tableName thisTables, columnIndex) + (findIndexByTableName tableName thisTables, columnIndex) |> this.RemoveColumnAt // - Column CRUD API - // @@ -195,7 +224,7 @@ type ArcTables(thisTables:ResizeArray) = // - Column CRUD API - // member this.UpdateColumn(tableName: string, columnIndex: int, header: CompositeHeader, ?cells: CompositeCell []) = - indexByTableName tableName thisTables + findIndexByTableName tableName thisTables |> fun tableIndex -> this.UpdateColumnAt(tableIndex, columnIndex, header, ?cells=cells) // - Column CRUD API - // @@ -205,7 +234,7 @@ type ArcTables(thisTables:ResizeArray) = // - Column CRUD API - // member this.GetColumn(tableName: string, columnIndex: int) = - (indexByTableName tableName thisTables, columnIndex) + (findIndexByTableName tableName thisTables, columnIndex) |> this.GetColumnAt // - Row CRUD API - // @@ -216,7 +245,7 @@ type ArcTables(thisTables:ResizeArray) = // - Row CRUD API - // member this.AddRow(tableName: string, ?cells: CompositeCell [], ?rowIndex: int) = - indexByTableName tableName thisTables + findIndexByTableName tableName thisTables |> fun i -> this.AddRowAt(i, ?cells=cells, ?rowIndex=rowIndex) // - Row CRUD API - // @@ -227,7 +256,7 @@ type ArcTables(thisTables:ResizeArray) = // - Row CRUD API - // member this.RemoveRow(tableName: string, rowIndex: int) : unit = - (indexByTableName tableName thisTables, rowIndex) + (findIndexByTableName tableName thisTables, rowIndex) |> this.RemoveRowAt // - Row CRUD API - // @@ -238,7 +267,7 @@ type ArcTables(thisTables:ResizeArray) = // - Row CRUD API - // member this.UpdateRow(tableName: string, rowIndex: int, cells: CompositeCell []) = - (indexByTableName tableName thisTables, rowIndex, cells) + (findIndexByTableName tableName thisTables, rowIndex, cells) |> this.UpdateRowAt // - Row CRUD API - // @@ -248,7 +277,7 @@ type ArcTables(thisTables:ResizeArray) = // - Row CRUD API - // member this.GetRow(tableName: string, rowIndex: int) = - (indexByTableName tableName thisTables, rowIndex) + (findIndexByTableName tableName thisTables, rowIndex) |> this.GetRowAt /// Return a list of all the processes in all the tables. diff --git a/src/ISA/ISA/ArcTypes/CompositeCell.fs b/src/ISA/ISA/ArcTypes/CompositeCell.fs index 61d99aa8..c1e8a1a2 100644 --- a/src/ISA/ISA/ArcTypes/CompositeCell.fs +++ b/src/ISA/ISA/ArcTypes/CompositeCell.fs @@ -75,10 +75,10 @@ type CompositeCell = // TODO: i would really love to have an overload here accepting string input static member createTerm (oa:OntologyAnnotation) = Term oa static member createTermFromString (?name: string, ?tsr: string, ?tan: string) = - Term <| OntologyAnnotation.fromString(?term = name, ?tsr = tsr, ?tan = tan) + Term <| OntologyAnnotation.fromString(?termName = name, ?tsr = tsr, ?tan = tan) static member createUnitized (value: string, ?oa:OntologyAnnotation) = Unitized (value, Option.defaultValue (OntologyAnnotation.empty) oa) static member createUnitizedFromString (value: string, ?name: string, ?tsr: string, ?tan: string) = - Unitized <| (value, OntologyAnnotation.fromString(?term = name, ?tsr = tsr, ?tan = tan)) + Unitized <| (value, OntologyAnnotation.fromString(?termName = name, ?tsr = tsr, ?tan = tan)) static member createFreeText (value: string) = FreeText value static member emptyTerm = Term OntologyAnnotation.empty @@ -87,6 +87,6 @@ type CompositeCell = override this.ToString() = match this with - | Term oa -> $"Term{oa.NameText}" + | Term oa -> $"{oa.NameText}" | FreeText s -> s | Unitized (v,oa) -> $"{v} {oa.NameText}" \ No newline at end of file diff --git a/src/ISA/ISA/ArcTypes/CompositeHeader.fs b/src/ISA/ISA/ArcTypes/CompositeHeader.fs index 04c439f2..e1d90f24 100644 --- a/src/ISA/ISA/ArcTypes/CompositeHeader.fs +++ b/src/ISA/ISA/ArcTypes/CompositeHeader.fs @@ -140,10 +140,10 @@ type CompositeHeader = // Input/Output have similiar naming as Term, but are more specific. // So they have to be called first. | Regex.ActivePatterns.Regex Regex.Pattern.InputPattern r -> - let iotype = r.Groups.["iotype"].Value + let iotype = r.Groups.[Regex.Pattern.MatchGroups.iotype].Value Input <| IOType.ofString (iotype) | Regex.ActivePatterns.Regex Regex.Pattern.OutputPattern r -> - let iotype = r.Groups.["iotype"].Value + let iotype = r.Groups.[Regex.Pattern.MatchGroups.iotype].Value Output <| IOType.ofString (iotype) // Is term column | Regex.ActivePatterns.TermColumn r -> diff --git a/src/ISA/ISA/JsonTypes/AnnotationValue.fs b/src/ISA/ISA/JsonTypes/AnnotationValue.fs index d8a7c5dc..dc52e8c8 100644 --- a/src/ISA/ISA/JsonTypes/AnnotationValue.fs +++ b/src/ISA/ISA/JsonTypes/AnnotationValue.fs @@ -1,5 +1,7 @@ namespace ARCtrl.ISA +open Fable.Core + type AnnotationValue = | Text of string | Float of float diff --git a/src/ISA/ISA/JsonTypes/Comment.fs b/src/ISA/ISA/JsonTypes/Comment.fs index 29916e07..69651133 100644 --- a/src/ISA/ISA/JsonTypes/Comment.fs +++ b/src/ISA/ISA/JsonTypes/Comment.fs @@ -2,6 +2,9 @@ namespace ARCtrl.ISA type EMail = string +open Fable.Core + +[] type Comment = { ID : URI option @@ -25,8 +28,11 @@ type Comment = static member toString (comment : Comment) = Option.defaultValue "" comment.Name, Option.defaultValue "" comment.Value + member this.Copy() = + Comment.make this.ID this.Name this.Value +[] type Remark = { Line : int @@ -43,4 +49,7 @@ type Remark = Remark.make line value static member toTuple (remark : Remark ) = - remark.Line, remark.Value \ No newline at end of file + remark.Line, remark.Value + + member this.Copy() = + Remark.make this.Line this.Value \ No newline at end of file diff --git a/src/ISA/ISA/JsonTypes/Component.fs b/src/ISA/ISA/JsonTypes/Component.fs index 3962e69d..f730f30c 100644 --- a/src/ISA/ISA/JsonTypes/Component.fs +++ b/src/ISA/ISA/JsonTypes/Component.fs @@ -69,7 +69,7 @@ type Component = /// Create a ISAJson Component from ISATab string entries static member fromString (?name: string, ?term:string, ?source:string, ?accession:string, ?comments : Comment []) = - let cType = OntologyAnnotation.fromString (?term = term, ?tsr=source, ?tan=accession, ?comments = comments) |> Option.fromValueWithDefault OntologyAnnotation.empty + let cType = OntologyAnnotation.fromString (?termName = term, ?tsr=source, ?tan=accession, ?comments = comments) |> Option.fromValueWithDefault OntologyAnnotation.empty match name with | Some n -> let v,u = Component.decomposeName n diff --git a/src/ISA/ISA/JsonTypes/Factor.fs b/src/ISA/ISA/JsonTypes/Factor.fs index e7b96383..571fd990 100644 --- a/src/ISA/ISA/JsonTypes/Factor.fs +++ b/src/ISA/ISA/JsonTypes/Factor.fs @@ -2,7 +2,9 @@ namespace ARCtrl.ISA open ARCtrl.ISA.Aux open Update +open Fable.Core +[] type Factor = { ID : URI option @@ -113,7 +115,10 @@ type Factor = static member getNameAsString (f : Factor) = f.NameText - /// Returns true if the given name matches the name of the factor static member nameEqualsString (name : string) (f : Factor) = f.NameText = name + + member this.Copy() = + let nextComments = this.Comments |> Option.map (Array.map (fun c -> c.Copy())) + Factor.make this.ID this.Name this.FactorType nextComments diff --git a/src/ISA/ISA/JsonTypes/OntologyAnnotation.fs b/src/ISA/ISA/JsonTypes/OntologyAnnotation.fs index e34e6876..af5387c5 100644 --- a/src/ISA/ISA/JsonTypes/OntologyAnnotation.fs +++ b/src/ISA/ISA/JsonTypes/OntologyAnnotation.fs @@ -2,35 +2,40 @@ namespace ARCtrl.ISA open ARCtrl.ISA.Aux open Update +open Fable.Core [] +[] type OntologyAnnotation = { ID : URI option Name : AnnotationValue option TermSourceREF : string option - LocalID : string option TermAccessionNumber : URI option Comments : Comment [] option } - static member make id name termSourceREF localID termAccessionNumber comments= + static member make id name termSourceREF termAccessionNumber comments= { ID = id Name = name TermSourceREF = termSourceREF - LocalID = localID TermAccessionNumber = termAccessionNumber Comments = comments } - + /// This function creates the type exactly as given. If you want a more streamlined approach use `OntologyAnnotation.fromString`. - static member create(?Id,?Name,?TermSourceREF,?LocalID,?TermAccessionNumber,?Comments) : OntologyAnnotation = - OntologyAnnotation.make Id Name TermSourceREF LocalID TermAccessionNumber Comments + static member create(?Id,?Name,?TermSourceREF,?TermAccessionNumber,?Comments) : OntologyAnnotation = + OntologyAnnotation.make Id Name TermSourceREF TermAccessionNumber Comments static member empty = OntologyAnnotation.create() + + member this.TANInfo = + this.TermAccessionNumber + |> Option.bind Regex.tryParseTermAnnotation + /// Returns the name of the ontology as string // TODO: Why is this called Text, while everything else is called string? member this.NameText = @@ -74,20 +79,12 @@ type OntologyAnnotation = /// ///Term source reference ///Term accession number - static member fromString (?term:string, ?tsr:string, ?tan:string, ?comments : Comment []) = - - let tsr,localID = - match tan with - | Some (Regex.ActivePatterns.TermAnnotation tan) -> - (if tsr.IsSome then tsr else Some tan.TermSourceREF), - Some tan.LocalTAN - | _ -> tsr,None + static member fromString (?termName:string, ?tsr:string, ?tan:string, ?comments : Comment []) = OntologyAnnotation.make None - (term |> Option.map AnnotationValue.fromString) + (termName |> Option.map AnnotationValue.fromString) tsr - localID tan comments @@ -97,20 +94,20 @@ type OntologyAnnotation = |> Regex.tryParseTermAnnotation |> Option.get |> fun r -> - let accession = r.TermSourceREF + ":" + r.LocalTAN - OntologyAnnotation.fromString ("", r.TermSourceREF, accession) + let accession = r.IDSpace + ":" + r.LocalID + OntologyAnnotation.fromString ("", r.IDSpace, accession) /// Parses any value in `TermAccessionString` to term accession format "termsourceref:localtan". Exmp.: "MS:000001". /// /// If `TermAccessionString` cannot be parsed to this format, returns empty string! member this.TermAccessionShort = - match this.TermSourceREF, this.LocalID with - | Some tsr, Some id -> $"{tsr}:{id}" + match this.TANInfo with + | Some id -> $"{id.IDSpace}:{id.LocalID}" | _ -> "" member this.TermAccessionOntobeeUrl = - match this.TermSourceREF, this.LocalID with - | Some tsr, Some id -> OntologyAnnotation.createUriAnnotation tsr id + match this.TANInfo with + | Some id -> OntologyAnnotation.createUriAnnotation id.IDSpace id.LocalID | _ -> "" member this.TermAccessionAndOntobeeUrlIfShort = @@ -228,4 +225,8 @@ type OntologyAnnotation = /// Replaces comments of a ontology annotation by given comment list static member setComments (annotation : OntologyAnnotation) (comments : Comment []) = { annotation with - Comments = Some comments } \ No newline at end of file + Comments = Some comments } + + member this.Copy() = + let nextComments = this.Comments |> Option.map (Array.map (fun c -> c.Copy())) + OntologyAnnotation.make this.ID this.Name this.TermSourceREF this.TermAccessionNumber nextComments \ No newline at end of file diff --git a/src/ISA/ISA/JsonTypes/OntologySourceReference.fs b/src/ISA/ISA/JsonTypes/OntologySourceReference.fs index 3718d098..43f3fc28 100644 --- a/src/ISA/ISA/JsonTypes/OntologySourceReference.fs +++ b/src/ISA/ISA/JsonTypes/OntologySourceReference.fs @@ -2,14 +2,16 @@ open ARCtrl.ISA.Aux open Update +open Fable.Core +[] type OntologySourceReference = { Description : string option File : string option Name : string option Version : string option - Comments : Comment list option + Comments : Comment [] option } static member make description file name version comments = @@ -62,11 +64,15 @@ type OntologySourceReference = ontology.Comments /// Applies function f on comments in ontology source ref - static member mapComments (f : Comment list -> Comment list) (ontology : OntologySourceReference) = + static member mapComments (f : Comment [] -> Comment []) (ontology : OntologySourceReference) = { ontology with - Comments = Option.mapDefault [] f ontology.Comments} + Comments = Option.mapDefault [||] f ontology.Comments} /// Replaces comments in ontology source ref by given comment list - static member setComments (ontology : OntologySourceReference) (comments : Comment list) = + static member setComments (ontology : OntologySourceReference) (comments : Comment []) = { ontology with - Comments = Some comments } \ No newline at end of file + Comments = Some comments } + + member this.Copy() = + let nextComments = this.Comments |> Option.map (Array.map (fun c -> c.Copy())) + OntologySourceReference.make this.Description this.File this.Name this.Version nextComments \ No newline at end of file diff --git a/src/ISA/ISA/JsonTypes/Person.fs b/src/ISA/ISA/JsonTypes/Person.fs index f04019e2..0fa4e77e 100644 --- a/src/ISA/ISA/JsonTypes/Person.fs +++ b/src/ISA/ISA/JsonTypes/Person.fs @@ -2,10 +2,13 @@ namespace ARCtrl.ISA open ARCtrl.ISA.Aux open Update +open Fable.Core +[] type Person = { ID : URI option + ORCID : string option LastName : string option FirstName : string option MidInitials : string option @@ -18,9 +21,10 @@ type Person = Comments : Comment [] option } - static member make id lastName firstName midInitials email phone fax address affiliation roles comments : Person = + static member make id orcid lastName firstName midInitials email phone fax address affiliation roles comments : Person = { ID = id + ORCID = orcid LastName = lastName FirstName = firstName MidInitials = midInitials @@ -33,8 +37,8 @@ type Person = Comments = comments } - static member create (?Id,?LastName,?FirstName,?MidInitials,?Email,?Phone,?Fax,?Address,?Affiliation,?Roles,?Comments) : Person = - Person.make Id LastName FirstName MidInitials Email Phone Fax Address Affiliation Roles Comments + static member create (?Id,?ORCID,?LastName,?FirstName,?MidInitials,?Email,?Phone,?Fax,?Address,?Affiliation,?Roles,?Comments) : Person = + Person.make Id ORCID LastName FirstName MidInitials Email Phone Fax Address Affiliation Roles Comments static member empty = Person.create () @@ -127,3 +131,52 @@ type Person = { person with Comments = Some comments } + static member orcidKey = "ORCID" + + static member setOrcidFromComments (person : Person) = + let isOrcidComment (c : Comment) = + c.Name.IsSome && (c.Name.Value.ToUpper().EndsWith(Person.orcidKey)) + let orcid,comments = + person.Comments + |> Option.map (fun comments -> + let orcid = + comments + |> Array.tryPick (fun c -> if isOrcidComment c then c.Value else None) + let comments = + comments + |> Array.filter (isOrcidComment >> not) + |> Option.fromValueWithDefault [||] + (orcid, comments) + ) + |> Option.defaultValue (None, person.Comments) + {person with ORCID = orcid; Comments = comments} + + static member setCommentFromORCID (person : Person) = + let comments = + match person.ORCID, person.Comments with + | Some orcid, Some comments -> + let comment = Comment.create (Name = Person.orcidKey, Value = orcid) + Array.append comments [|comment|] + |> Some + | Some orcid, None -> + [|Comment.create (Name = Person.orcidKey, Value = orcid)|] + |> Some + | None, comments -> comments + {person with Comments = comments} + + member this.Copy() : Person = + let nextComments = this.Comments |> Option.map (Array.map (fun c -> c.Copy())) + let nextRoles = this.Roles |> Option.map (Array.map (fun c -> c.Copy())) + Person.make + this.ID + this.ORCID + this.LastName + this.FirstName + this.MidInitials + this.EMail + this.Phone + this.Fax + this.Address + this.Affiliation + nextRoles + nextComments diff --git a/src/ISA/ISA/JsonTypes/Publication.fs b/src/ISA/ISA/JsonTypes/Publication.fs index 0745a5ab..9408f2df 100644 --- a/src/ISA/ISA/JsonTypes/Publication.fs +++ b/src/ISA/ISA/JsonTypes/Publication.fs @@ -2,7 +2,9 @@ namespace ARCtrl.ISA open ARCtrl.ISA.Aux open Update +open Fable.Core +[] type Publication = { PubMedID : URI option @@ -101,3 +103,10 @@ type Publication = static member setComments (publication : Publication) (comments : Comment []) = { publication with Comments = Some comments } + + + // + + member this.Copy() = + let nextComments = this.Comments |> Option.map (Array.map (fun c -> c.Copy())) + Publication.make this.PubMedID this.DOI this.Authors this.Title this.Status nextComments \ No newline at end of file diff --git a/src/ISA/ISA/Regex.fs b/src/ISA/ISA/Regex.fs index e06a5f61..0d000c0c 100644 --- a/src/ISA/ISA/Regex.fs +++ b/src/ISA/ISA/Regex.fs @@ -7,6 +7,20 @@ open System module Pattern = + module MatchGroups = + + [] + let numberFormat = "numberFormat" + + [] + let localID = "localid" + + [] + let idspace = "idspace" + + [] + let iotype = "iotype" + /// This pattern is only used to remove any leftover #id attributes from previous Swate version. /// `"Parameter [biological replicate#2]"` This #id is deprecated but the pattern can still be used to remove any from files. /// Was deprecated before 2023. @@ -21,8 +35,7 @@ module Pattern = let SquaredBracketsTermNamePattern = "\[.*\]" // @"(?<= \[)[^#\]]*(?=[\]#])" <- Cannot be used in IE11 /// Used to get unit name from Excel numberFormat: 0.00 "degree Celsius" --> degree Celsius - [] - let ExcelNumberFormat = "\"(?(.*?))\"" + let ExcelNumberFormat = $"\"(?<{MatchGroups.numberFormat}>(.*?))\"" /// Hits Unit column header [] @@ -55,29 +68,23 @@ module Pattern = let TermAccessionNumberColumnPattern = @"Term Accession Number\s\((?.*)\)" /// Hits term accession, without id: ENVO:01001831 - [] - let TermAnnotationShortPattern = @"(?\w+?):(?\w+)" //prev: @"[\w]+?:[\d]+" + let TermAnnotationShortPattern = $@"(?<{MatchGroups.idspace}>\w+?):(?<{MatchGroups.localID}>\w+)" //prev: @"[\w]+?:[\d]+" // https://obofoundry.org/id-policy.html#mapping-of-owl-ids-to-obo-format-ids /// Regex pattern is designed to hit only Foundry-compliant URIs. - [] - let TermAnnotationURIPattern = @"http://purl.obolibrary.org/obo/(?\w+?)_(?\w+)" + let TermAnnotationURIPattern = $@"http://purl.obolibrary.org/obo/(?<{MatchGroups.idspace}>\w+?)_(?<{MatchGroups.localID}>\w+)" /// Watch this closely, this could hit some edge cases we do not want to cover. - [] - let TermAnnotationURIPattern_lessRestrictive = @".*\/(?\w+?)[:_](?\w+)" + let TermAnnotationURIPattern_lessRestrictive = $@".*\/(?<{MatchGroups.idspace}>\w+?)[:_](?<{MatchGroups.localID}>\w+)" /// This pattern is used to match both Input and Output columns and capture the IOType as `iotype` group. - [] - let IOTypePattern = @"(Input|Output)\s\[(?.+)\]" + let IOTypePattern = $@"(Input|Output)\s\[(?<{MatchGroups.iotype}>.+)\]" /// This pattern is used to match Input column and capture the IOType as `iotype` group. - [] - let InputPattern = @"Input\s\[(?.+)\]" + let InputPattern = $@"Input\s\[(?<{MatchGroups.iotype}>.+)\]" /// This pattern is used to match Output column and capture the IOType as `iotype` group. - [] - let OutputPattern = @"Output\s\[(?.+)\]" + let OutputPattern = $@"Output\s\[(?<{MatchGroups.iotype}>.+)\]" /// This pattern matches any column header starting with some text, followed by one whitespace and a term name inside squared brackets. /// @@ -176,9 +183,9 @@ module ActivePatterns = let (|TermAnnotationShort|_|) input = match input with | Regex Pattern.TermAnnotationShortPattern value -> - let termsourceref = value.Groups.["termsourceref"].Value - let localtan = value.Groups.["localtan"].Value - {|TermSourceREF = termsourceref; LocalTAN = localtan|} + let idspace = value.Groups.[Pattern.MatchGroups.idspace].Value + let localID = value.Groups.[Pattern.MatchGroups.localID].Value + {|IDSpace = idspace; LocalID = localID|} |> Some | _ -> None @@ -193,9 +200,9 @@ module ActivePatterns = | Regex Pattern.TermAnnotationShortPattern value | Regex Pattern.TermAnnotationURIPattern value | Regex Pattern.TermAnnotationURIPattern_lessRestrictive value -> - let termsourceref = value.Groups.["termsourceref"].Value - let localtan = value.Groups.["localtan"].Value - {|TermSourceREF = termsourceref; LocalTAN = localtan; TermAccessionNumber = input|} + let idspace = value.Groups.[Pattern.MatchGroups.idspace].Value + let localID = value.Groups.[Pattern.MatchGroups.localID].Value + {|IDSpace = idspace; LocalID = localID|} |> Some | _ -> None @@ -208,7 +215,7 @@ module ActivePatterns = | Regex Pattern.TermSourceREFColumnPattern r -> match r.Groups.["id"].Value with | TermAnnotation r -> Some r - | _ -> Some {|LocalTAN = ""; TermAccessionNumber = ""; TermSourceREF = ""|} + | _ -> Some {|IDSpace = ""; LocalID = ""|} | _ -> None /// Matches a "Term Accession Number (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. @@ -219,21 +226,21 @@ module ActivePatterns = | Regex Pattern.TermAccessionNumberColumnPattern r -> match r.Groups.["id"].Value with | TermAnnotation r -> Some r - | _ -> Some {|LocalTAN = ""; TermAccessionNumber = ""; TermSourceREF = ""|} + | _ -> Some {|IDSpace = ""; LocalID = ""|} | _ -> None /// Matches a "Input [InputType]" column header and returns the InputType as string. let (|InputColumnHeader|_|) input = match input with | Regex Pattern.InputPattern r -> - Some r.Groups.["iotype"].Value + Some r.Groups.[Pattern.MatchGroups.iotype].Value | _ -> None /// Matches a "Output [OutputType]" column header and returns the OutputType as string. let (|OutputColumnHeader|_|) input = match input with | Regex Pattern.OutputPattern r -> - Some r.Groups.["iotype"].Value + Some r.Groups.[Pattern.MatchGroups.iotype].Value | _ -> None @@ -261,9 +268,9 @@ let tryParseReferenceColumnHeader (str : string) = let tryParseTermAnnotationShort (str:string) = match str.Trim() with | Regex TermAnnotationShortPattern value -> - let termsourceref = value.Groups.["termsourceref"].Value - let localtan = value.Groups.["localtan"].Value - {|TermSourceREF = termsourceref; LocalTAN = localtan|} + let idspace = value.Groups.[Pattern.MatchGroups.idspace].Value + let localid = value.Groups.[Pattern.MatchGroups.localID].Value + {|IDSpace = idspace; LocalID = localid|} |> Some | _ -> None @@ -279,9 +286,9 @@ let tryParseTermAnnotation (str:string) = | Regex TermAnnotationShortPattern value | Regex TermAnnotationURIPattern value | Regex TermAnnotationURIPattern_lessRestrictive value -> - let termsourceref = value.Groups.["termsourceref"].Value - let localtan = value.Groups.["localtan"].Value - {|TermSourceREF = termsourceref; LocalTAN = localtan|} + let idspace = value.Groups.[Pattern.MatchGroups.idspace].Value + let localid = value.Groups.[Pattern.MatchGroups.localID].Value + {|IDSpace = idspace; LocalID = localid|} |> Some | _ -> None @@ -289,7 +296,7 @@ let tryParseTermAnnotation (str:string) = /// Tries to parse 'str' to term accession and returns it in the format `Some "termsourceref:localtan"`. Exmp.: `Some "MS:000001"` let tryGetTermAnnotationShortString (str:string) = tryParseTermAnnotation str - |> Option.map (fun r -> r.TermSourceREF + ":" + r.LocalTAN) + |> Option.map (fun r -> r.IDSpace + ":" + r.LocalID) /// Parses 'str' to term accession and returns it in the format "termsourceref:localtan". Exmp.: "MS:000001" let getTermAnnotationShortString (str:string) = @@ -320,7 +327,7 @@ let tryParseIOTypeHeader (headerStr: string) = match headerStr.Trim() with | Regex IOTypePattern value -> // remove quotes at beginning and end of matched string - let numberFormat = value.Groups.["iotype"].Value + let numberFormat = value.Groups.[Pattern.MatchGroups.iotype].Value Some numberFormat | _ -> None diff --git a/src/ISA/ISA/paket.references b/src/ISA/ISA/paket.references new file mode 100644 index 00000000..2387b156 --- /dev/null +++ b/src/ISA/ISA/paket.references @@ -0,0 +1,2 @@ +FSharp.Core +Fable.Core \ No newline at end of file diff --git a/tests/ARCtrl/ARCtrl.Tests.fs b/tests/ARCtrl/ARCtrl.Tests.fs index 3e62eb95..3cbc403f 100644 --- a/tests/ARCtrl/ARCtrl.Tests.fs +++ b/tests/ARCtrl/ARCtrl.Tests.fs @@ -48,6 +48,39 @@ let private test_model = testList "model" [ Expect.equal actualFilePaths input "isSome fs" ] + +let private test_isaFromContracts = testList "read_contracts" [ + testCase "simpleISA" (fun () -> + let iContract = TestObjects.ISAContracts.SimpleISA.investigationReadContract + let sContract = TestObjects.ISAContracts.SimpleISA.studyReadContract + let aContract = TestObjects.ISAContracts.SimpleISA.assayReadContract + let arc = ARC() + arc.SetISAFromContracts([|iContract; sContract; aContract|]) + Expect.isSome arc.ISA "isa should be fille out" + let inv = arc.ISA.Value + Expect.equal inv.Identifier TestObjects.Investigation.investigationIdentifier "investigation identifier should have been read from investigation contract" + + Expect.equal inv.Studies.Count 2 "should have read two studies" + let study1 = inv.Studies.[0] + let study2 = inv.Studies.[1] + Expect.equal study1.Identifier TestObjects.Study.studyIdentifier "study 1 identifier should have been read from study contract" + Expect.equal study1.TableCount 8 "study 1 should have the 7 tables from investigation plus one extra. One table should be overwritten." + Expect.equal study2.TableCount 4 "study 2 should have exactly as many tables as stated in investigation file" + + Expect.equal study1.AssayCount 3 "study 1 should have read three assays" + let assay1 = study1.Assays.[0] + let assay2 = study1.Assays.[1] + let assay3 = study1.Assays.[2] + Expect.equal assay1.Identifier TestObjects.Assay.assayIdentifier "assay 1 identifier should have been read from assay contract" + Expect.equal assay1.TableCount 1 "assay 1 should have read one table" + Expect.equal assay2.TableCount 0 "assay 2 should have read no tables" + Expect.equal assay3.TableCount 0 "assay 3 should have read no tables" + + + ) + +] + let private test_writeContracts = testList "write_contracts" [ testCase "empty" (fun _ -> let arc = ARC() @@ -97,5 +130,6 @@ let private test_writeContracts = testList "write_contracts" [ let main = testList "main" [ test_model + test_isaFromContracts test_writeContracts ] \ No newline at end of file diff --git a/tests/ARCtrl/ARCtrl.Tests.fsproj b/tests/ARCtrl/ARCtrl.Tests.fsproj index ab8b3d65..5bcd1acb 100644 --- a/tests/ARCtrl/ARCtrl.Tests.fsproj +++ b/tests/ARCtrl/ARCtrl.Tests.fsproj @@ -1,26 +1,20 @@ - - + + Exe net6.0 false - + + - - - - - - - - - + - + + \ No newline at end of file diff --git a/tests/ARCtrl/TestObjects/ISAContracts.fs b/tests/ARCtrl/TestObjects/ISAContracts.fs new file mode 100644 index 00000000..d3f8d5c1 --- /dev/null +++ b/tests/ARCtrl/TestObjects/ISAContracts.fs @@ -0,0 +1,76 @@ +module TestObjects.ISAContracts + +open FsSpreadsheet +open ARCtrl.Contract +open ARCtrl +open ARCtrl.ISA + +module SimpleISA = + let assayMetadataWorksheet = TestObjects.Assay.assayMetadata + let assayWsName = "Measurement" + let assayTable = + ArcTable.initWorksheet assayWsName + [ + ArcTable.Protocol.REF.appendLolColumn 4 + ArcTable.Protocol.Type.appendCollectionColumn 2 + ArcTable.Parameter.appendMixedTemperatureColumn 2 2 + ArcTable.Parameter.appendInstrumentColumn 2 + ArcTable.Characteristic.appendOrganismColumn 3 + ArcTable.Factor.appendTimeColumn 0 + ] + let assayWB = + let wb = new FsWorkbook() + wb.AddWorksheet(assayMetadataWorksheet) + wb.AddWorksheet(assayTable) + wb + let assayReadContract = + Contract.create( + Operation.READ, + path = Identifier.Assay.fileNameFromIdentifier Assay.assayIdentifier, + dtoType = DTOType.ISA_Assay, + dto = DTO.Spreadsheet assayWB) + + + let studyMetadataWorksheet = TestObjects.Study.studyMetadata + let studyNewWsName = "preparation" + let studyNewTable = + ArcTable.initWorksheet studyNewWsName + [ + ArcTable.Protocol.REF.appendLolColumn 4 + ArcTable.Protocol.Type.appendCollectionColumn 2 + ArcTable.Parameter.appendMixedTemperatureColumn 2 2 + ArcTable.Parameter.appendInstrumentColumn 2 + ArcTable.Characteristic.appendOrganismColumn 3 + ArcTable.Factor.appendTimeColumn 0 + ] + let studyExistingWSName = "growth protocol" + let studyExistingTable = + ArcTable.initWorksheet studyExistingWSName + [ + ArcTable.Protocol.REF.appendLolColumn 4 + ArcTable.Protocol.Type.appendCollectionColumn 2 + ArcTable.Parameter.appendMixedTemperatureColumn 2 2 + ArcTable.Parameter.appendInstrumentColumn 2 + ArcTable.Characteristic.appendOrganismColumn 3 + ArcTable.Factor.appendTimeColumn 0 + ] + let studyWB = + let wb = new FsWorkbook() + wb.AddWorksheet(studyMetadataWorksheet) + wb.AddWorksheet(studyNewTable) + wb.AddWorksheet(studyExistingTable) + wb + let studyReadContract = + Contract.create( + Operation.READ, + path = Identifier.Study.fileNameFromIdentifier Study.studyIdentifier, + dtoType = DTOType.ISA_Study, + dto = DTO.Spreadsheet studyWB) + + + let investigationReadContract = + Contract.create( + Operation.READ, + path = Path.InvestigationFileName, + dtoType = DTOType.ISA_Investigation, + dto = DTO.Spreadsheet Investigation.fullInvestigation) \ No newline at end of file diff --git a/tests/ARCtrl/paket.references b/tests/ARCtrl/paket.references new file mode 100644 index 00000000..2561dfaa --- /dev/null +++ b/tests/ARCtrl/paket.references @@ -0,0 +1,6 @@ +FSharp.Core +Fable.Core +Expecto +Fable.Mocha +Microsoft.NET.Test.Sdk +YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/FileSystem/FileSystem.Tests.fsproj b/tests/FileSystem/FileSystem.Tests.fsproj new file mode 100644 index 00000000..013ed572 --- /dev/null +++ b/tests/FileSystem/FileSystem.Tests.fsproj @@ -0,0 +1,18 @@ + + + + Exe + net6.0 + false + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/FileSystem/FileSystem.Tests/FileSystem.Tests.fsproj b/tests/FileSystem/FileSystem.Tests/FileSystem.Tests.fsproj deleted file mode 100644 index 2685a07e..00000000 --- a/tests/FileSystem/FileSystem.Tests/FileSystem.Tests.fsproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - Exe - net6.0 - false - - - - - - - - - - - - - - - - - - - - diff --git a/tests/FileSystem/FileSystem.Tests/FileSystemTree.Tests.fs b/tests/FileSystem/FileSystemTree.Tests.fs similarity index 100% rename from tests/FileSystem/FileSystem.Tests/FileSystemTree.Tests.fs rename to tests/FileSystem/FileSystemTree.Tests.fs diff --git a/tests/FileSystem/FileSystem.Tests/Main.fs b/tests/FileSystem/Main.fs similarity index 100% rename from tests/FileSystem/FileSystem.Tests/Main.fs rename to tests/FileSystem/Main.fs diff --git a/tests/FileSystem/FileSystem.Tests/Utils.fs b/tests/FileSystem/Utils.fs similarity index 100% rename from tests/FileSystem/FileSystem.Tests/Utils.fs rename to tests/FileSystem/Utils.fs diff --git a/tests/FileSystem/paket.references b/tests/FileSystem/paket.references new file mode 100644 index 00000000..2561dfaa --- /dev/null +++ b/tests/FileSystem/paket.references @@ -0,0 +1,6 @@ +FSharp.Core +Fable.Core +Expecto +Fable.Mocha +Microsoft.NET.Test.Sdk +YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj b/tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj index 504210c1..78e9bcd5 100644 --- a/tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj +++ b/tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj @@ -1,12 +1,12 @@ - - + + Exe net6.0 false - + @@ -21,18 +21,8 @@ - - - - - - - - + - - - - - + + \ No newline at end of file diff --git a/tests/ISA/ISA.Json.Tests/Json.Tests.fs b/tests/ISA/ISA.Json.Tests/Json.Tests.fs index a910da96..086405f4 100644 --- a/tests/ISA/ISA.Json.Tests/Json.Tests.fs +++ b/tests/ISA/ISA.Json.Tests/Json.Tests.fs @@ -160,7 +160,7 @@ let testOntoloyAnnotation = o_out |> Utils.wordFrequency - Expect.equal actual expected "Written processInput does not match read process input" + mySequenceEqual actual expected "Written processInput does not match read process input" ) ] @@ -191,7 +191,7 @@ let testOntoloyAnnotationLD = o_out |> Utils.wordFrequency - Expect.equal actual expected "Written processInput does not match read process input" + mySequenceEqual actual expected "Written processInput does not match read process input" ) testCase "WriterOutputMatchesInputDefaultIDs" (fun () -> @@ -206,7 +206,7 @@ let testOntoloyAnnotationLD = o_out |> Utils.wordFrequency - Expect.equal actual expected "Written processInput does not match read process input" + mySequenceEqual actual expected "Written processInput does not match read process input" ) ] @@ -239,7 +239,7 @@ let testProcessInput = o_out |> Utils.wordFrequency - Expect.equal actual expected "Written processInput does not match read process input" + mySequenceEqual actual expected "Written processInput does not match read process input" ) ] testList "Material" [ @@ -881,6 +881,48 @@ let testPersonFile = mySequenceEqual actual expected "Written person file does not match read person file" ) + + + testCase "WithORCID ReaderCorrectness" (fun () -> + + let p = Person.fromString TestObjects.Person.personWithORCID + Expect.isNone p.Comments "Comments should be None" + Expect.isSome p.ORCID "ORCID should be Some" + Expect.equal p.ORCID.Value "0000-0002-1825-0097" "ORCID not as expected" + + ) + + testAsync "WithORCID WriterSchemaCorrectness" { + + let a = Person.fromString TestObjects.Person.personWithORCID + + let s = Person.toString a + + let! validation = Validation.validatePerson s + + Expect.isTrue validation.Success $"Person did not match schema: {validation.GetErrors()}" + } + + testCase "WithORCID OutputMatchesInput" (fun () -> + + let o = + Person.fromString TestObjects.Person.personWithORCID + |> Person.toString + + let expected = + TestObjects.Person.personWithORCID + |> Utils.extractWords + |> Array.countBy id + |> Array.sortBy fst + + let actual = + o + |> Utils.extractWords + |> Array.countBy id + |> Array.sortBy fst + + mySequenceEqual actual expected "Written person file does not match read person file" + ) ] let testPersonFileLD = @@ -1235,14 +1277,13 @@ let testInvestigationFile = (Some "filePath.txt") (Some "OO") (Some "1.3.3") - (Some [comment]) + (Some [|comment|]) let publicationStatus = OntologyAnnotation.make (Some "OntologyTerm/Published") (Some (AnnotationValue.Text "published")) (Some "pso") - (Some "published") (Some "http://purl.org/spar/pso/published") (Some [|comment|]) @@ -1260,13 +1301,13 @@ let testInvestigationFile = (Some "OntologyTerm/SoftwareDeveloperRole") (Some (AnnotationValue.Text "software developer role")) (Some "swo") - (Some "0000392") (Some "http://www.ebi.ac.uk/swo/SWO_0000392") (Some [|comment|]) let person = Person.make (Some "Persons/LukasWeil") + None (Some "Weil") (Some "Lukas") (Some "H") @@ -1286,7 +1327,6 @@ let testInvestigationFile = (Some "OntologyTerm/Organism") (Some (AnnotationValue.Text "organism")) (Some "obi") - (Some "0100026") (Some "http://purl.obolibrary.org/obo/OBI_0100026") (Some [|comment|]) )) @@ -1300,7 +1340,6 @@ let testInvestigationFile = (Some "OntologyTerm/Organism") (Some (AnnotationValue.Text "Arabidopsis thaliana")) (Some "obi") - (Some "0100026") (Some "http://purl.obolibrary.org/obo/OBI_0100026") (Some [|comment|]) |> Value.Ontology @@ -1312,7 +1351,6 @@ let testInvestigationFile = (Some "OntologyTerm/TimeSeries") (Some (AnnotationValue.Text "Time Series Analysis")) (Some "ncit") - (Some "C18235") (Some "http://purl.obolibrary.org/obo/NCIT_C18235") (Some [|comment|]) @@ -1321,7 +1359,6 @@ let testInvestigationFile = (Some "OntologyTerm/GrowthProtocol") (Some (AnnotationValue.Text "growth protocol")) (Some "dfbo") - (Some "DFBA_0000001") (Some "http://purl.obolibrary.org/obo/DFBO_1000162") (Some [|comment|]) @@ -1333,7 +1370,6 @@ let testInvestigationFile = (Some "OntologyTerm/Temperature") (Some (AnnotationValue.Text "temperature unit")) (Some "uo") - (Some "UO_0000005") (Some "http://purl.obolibrary.org/obo/UO_0000005") (Some [|comment|]) )) @@ -1343,7 +1379,6 @@ let testInvestigationFile = (Some "OntologyTerm/DegreeCelsius") (Some (AnnotationValue.Text "degree celsius")) (Some "uo") - (Some "UO_0000027") (Some "http://purl.obolibrary.org/obo/UO_0000027") (Some [|comment|]) @@ -1361,7 +1396,6 @@ let testInvestigationFile = (Some "OntologyTerm/RTPCR") (Some (AnnotationValue.Text "real-time PCR machine")) (Some "obi") - (Some "0001110") (Some "http://purl.obolibrary.org/obo/OBI_0001110") (Some [|comment|]) |> Value.Ontology @@ -1372,7 +1406,6 @@ let testInvestigationFile = (Some "OntologyTerm/PCR") (Some (AnnotationValue.Text "PCR instrument")) (Some "obi") - (Some "0000989") (Some "http://purl.obolibrary.org/obo/OBI_0000989") (Some [|comment|]) )) @@ -1398,7 +1431,6 @@ let testInvestigationFile = (Some "OntologyTerm/Time") (Some (AnnotationValue.Text "time")) (Some "pato") - (Some "0000165") (Some "http://purl.obolibrary.org/obo/PATO_0000165") (Some [|comment|]) )) @@ -1409,7 +1441,6 @@ let testInvestigationFile = (Some "OntologyTerm/Hour") (Some (AnnotationValue.Text "hour")) (Some "uo") - (Some "0000032") (Some "http://purl.obolibrary.org/obo/UO_0000032") (Some [|comment|]) @@ -1498,7 +1529,6 @@ let testInvestigationFile = (Some "OntologyTerm/LFQuantification") (Some (AnnotationValue.Text "LC/MS Label-Free Quantification")) (Some "ncit") - (Some "C161813") (Some "http://purl.obolibrary.org/obo/NCIT_C161813") (Some [|comment|]) @@ -1507,7 +1537,6 @@ let testInvestigationFile = (Some "OntologyTerm/TOF") (Some (AnnotationValue.Text "Time-of-Flight")) (Some "ncit") - (Some "C70698") (Some "http://purl.obolibrary.org/obo/NCIT_C70698") (Some [|comment|]) @@ -1671,14 +1700,13 @@ let testInvestigationFileLD = (Some "filePath.txt") (Some "OO") (Some "1.3.3") - (Some [comment]) + (Some [|comment|]) let publicationStatus = OntologyAnnotation.make (Some "OntologyTerm/Published") (Some (AnnotationValue.Text "published")) (Some "pso") - (Some "published") (Some "http://purl.org/spar/pso/published") (Some [|comment|]) @@ -1696,13 +1724,13 @@ let testInvestigationFileLD = (Some "OntologyTerm/SoftwareDeveloperRole") (Some (AnnotationValue.Text "software developer role")) (Some "swo") - (Some "0000392") (Some "http://www.ebi.ac.uk/swo/SWO_0000392") (Some [|comment|]) let person = Person.make (Some "Persons/LukasWeil") + None (Some "Weil") (Some "Lukas") (Some "H") @@ -1722,7 +1750,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/Organism") (Some (AnnotationValue.Text "organism")) (Some "obi") - (Some "0100026") (Some "http://purl.obolibrary.org/obo/OBI_0100026") (Some [|comment|]) )) @@ -1736,7 +1763,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/Organism") (Some (AnnotationValue.Text "Arabidopsis thaliana")) (Some "obi") - (Some "0100026") (Some "http://purl.obolibrary.org/obo/OBI_0100026") (Some [|comment|]) |> Value.Ontology @@ -1748,7 +1774,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/TimeSeries") (Some (AnnotationValue.Text "Time Series Analysis")) (Some "ncit") - (Some "C18235") (Some "http://purl.obolibrary.org/obo/NCIT_C18235") (Some [|comment|]) @@ -1757,7 +1782,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/GrowthProtocol") (Some (AnnotationValue.Text "growth protocol")) (Some "dfbo") - (Some "0000001") (Some "http://purl.obolibrary.org/obo/DFBO_1000162") (Some [|comment|]) @@ -1769,7 +1793,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/Temperature") (Some (AnnotationValue.Text "temperature unit")) (Some "uo") - (Some "UO_0000005") (Some "http://purl.obolibrary.org/obo/UO_0000005") (Some [|comment|]) )) @@ -1779,7 +1802,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/DegreeCelsius") (Some (AnnotationValue.Text "degree celsius")) (Some "uo") - (Some "0000027") (Some "http://purl.obolibrary.org/obo/UO_0000027") (Some [|comment|]) @@ -1797,7 +1819,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/RTPCR") (Some (AnnotationValue.Text "real-time PCR machine")) (Some "obi") - (Some "0001110") (Some "http://purl.obolibrary.org/obo/OBI_0001110") (Some [|comment|]) |> Value.Ontology @@ -1808,7 +1829,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/PCR") (Some (AnnotationValue.Text "PCR instrument")) (Some "obi") - (Some "0000989") (Some "http://purl.obolibrary.org/obo/OBI_0000989") (Some [|comment|]) )) @@ -1834,7 +1854,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/Time") (Some (AnnotationValue.Text "time")) (Some "pato") - (Some "0000165") (Some "http://purl.obolibrary.org/obo/PATO_0000165") (Some [|comment|]) )) @@ -1845,7 +1864,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/Hour") (Some (AnnotationValue.Text "hour")) (Some "uo") - (Some "0000032") (Some "http://purl.obolibrary.org/obo/UO_0000032") (Some [|comment|]) @@ -1934,7 +1952,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/LFQuantification") (Some (AnnotationValue.Text "LC/MS Label-Free Quantification")) (Some "ncit") - (Some "C161813") (Some "http://purl.obolibrary.org/obo/NCIT_C161813") (Some [|comment|]) @@ -1943,7 +1960,6 @@ let testInvestigationFileLD = (Some "OntologyTerm/TOF") (Some (AnnotationValue.Text "Time-of-Flight")) (Some "ncit") - (Some "C70698") (Some "http://purl.obolibrary.org/obo/NCIT_C70698") (Some [|comment|]) diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/Person.fs b/tests/ISA/ISA.Json.Tests/TestObjects/Person.fs index c7430b33..53cacd1e 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/Person.fs +++ b/tests/ISA/ISA.Json.Tests/TestObjects/Person.fs @@ -26,6 +26,20 @@ let person = } """ +let personWithORCID = + """ + { + "firstName": "Juan", + "lastName": "Castrillo", + "comments": [ + { + "value": "0000-0002-1825-0097", + "name": "ORCID" + } + ] + } + """ + let personLD = """ { diff --git a/tests/ISA/ISA.Json.Tests/paket.references b/tests/ISA/ISA.Json.Tests/paket.references new file mode 100644 index 00000000..2561dfaa --- /dev/null +++ b/tests/ISA/ISA.Json.Tests/paket.references @@ -0,0 +1,6 @@ +FSharp.Core +Fable.Core +Expecto +Fable.Mocha +Microsoft.NET.Test.Sdk +YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs index bc9c8393..44000340 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs @@ -29,6 +29,18 @@ let testMetaDataFunctions = ) + testCase "ReaderReadsORCID" (fun () -> + + let assay = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadata + Expect.equal assay.Performers.Length 3 "Assay should have 3 performers" + Expect.isSome assay.Performers.[0].ORCID "ORCID should be set" + Expect.equal assay.Performers.[0].ORCID.Value "0000-0002-1825-0097" "ORCID not read correctly" + Expect.isNone assay.Performers.[1].ORCID "ORCID should not be set" + Expect.isSome assay.Performers.[2].ORCID "ORCID should be set" + Expect.equal assay.Performers.[2].ORCID.Value "0000-0002-1825-0098" "ORCID not read correctly" + + ) + testCase "ReaderSuccessObsoleteSheetName" (fun () -> let readingSuccess = @@ -56,6 +68,16 @@ let testMetaDataFunctions = Expect.isOk writingSuccess (Result.getMessage writingSuccess) ) + testCase "WriterCreatesNoEmptyCells" (fun () -> + + let o = + ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadata + |> ArcAssay.toMetadataSheet + + o.CellCollection.GetCells() + |> Seq.iter (fun c -> Expect.notEqual (c.Value.Trim()) "" $"Cell {c.Address.ToString()} should not contain empty string") + ) + testCase "WriterSuccessObsoleteSheetName" (fun () -> let a = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataObsoleteSheetName diff --git a/tests/ISA/ISA.Spreadsheet.Tests/ISA.Spreadsheet.Tests.fsproj b/tests/ISA/ISA.Spreadsheet.Tests/ISA.Spreadsheet.Tests.fsproj index f25b614a..fc91acb1 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/ISA.Spreadsheet.Tests.fsproj +++ b/tests/ISA/ISA.Spreadsheet.Tests/ISA.Spreadsheet.Tests.fsproj @@ -1,15 +1,15 @@ - - + + Exe net6.0 false - + - + @@ -25,14 +25,8 @@ - - - - - - - - + + \ No newline at end of file diff --git a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Assay.fs b/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Assay.fs index fa32fa0d..334a39b4 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Assay.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Assay.fs @@ -2,6 +2,9 @@ open FsSpreadsheet +[] +let assayIdentifier = "proteome" + let assayMetadata = let ws = FsWorksheet("isa_assay") let row1 = ws.Row(1) @@ -28,7 +31,7 @@ let assayMetadata = row8.[2].Value <- "iTRAQ" let row9 = ws.Row(9) row9.[1].Value <- "Assay File Name" - row9.[2].Value <- "assays/myassay/isa.assay.xlsx" + row9.[2].Value <- $"assays/{assayIdentifier}/isa.assay.xlsx" let row10 = ws.Row(10) row10.[1].Value <- "ASSAY PERFORMERS" let row11 = ws.Row(11) @@ -76,6 +79,10 @@ let assayMetadata = row22.[2].Value <- "Sheet1;Sheet2" row22.[3].Value <- "Sheet2" row22.[4].Value <- "Sheet3" + let row23 = ws.Row(23) + row23.[1].Value <- "Comment[ORCID]" + row23.[2].Value <- "0000-0002-1825-0097" + row23.[4].Value <- "0000-0002-1825-0098" ws let assayMetadataDeprecatedKeys = @@ -104,7 +111,7 @@ let assayMetadataDeprecatedKeys = row8.[2].Value <- "iTRAQ" let row9 = ws.Row(9) row9.[1].Value <- "File Name" - row9.[2].Value <- "assays/myassay/isa.assay.xlsx" + row9.[2].Value <- $"assays/{assayIdentifier}/isa.assay.xlsx" let row10 = ws.Row(10) row10.[1].Value <- "ASSAY PERFORMERS" let row11 = ws.Row(11) @@ -152,6 +159,10 @@ let assayMetadataDeprecatedKeys = row22.[2].Value <- "Sheet1;Sheet2" row22.[3].Value <- "Sheet2" row22.[4].Value <- "Sheet3" + let row23 = ws.Row(23) + row23.[1].Value <- "Comment[Assay ORCID]" + row23.[2].Value <- "0000-0002-1825-0097" + row23.[4].Value <- "0000-0002-1825-0098" ws let assayMetadataObsoleteSheetName = diff --git a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/InvestigationFile.fs b/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/InvestigationFile.fs index 78d9f782..4bb9af13 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/InvestigationFile.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/InvestigationFile.fs @@ -190,6 +190,9 @@ let emptyInvestigation = row91.[1].Value <- "Study Person Roles Term Source REF" wb +[] +let investigationIdentifier = "BII-I-1" + let fullInvestigation = let wb = new FsWorkbook() let ws = wb.InitWorksheet("Investigation") @@ -232,7 +235,7 @@ let fullInvestigation = row7.[1].Value <- "INVESTIGATION" let row8 = ws.Row(8) row8.[1].Value <- "Investigation Identifier" - row8.[2].Value <- "BII-I-1" + row8.[2].Value <- investigationIdentifier let row9 = ws.Row(9) row9.[1].Value <- "Investigation Title" row9.[2].Value <- "Growth control of the eukaryote cell: a systems biology study in yeast" @@ -319,7 +322,7 @@ let fullInvestigation = row36.[1].Value <- "STUDY" let row37 = ws.Row(37) row37.[1].Value <- "Study Identifier" - row37.[2].Value <- "BII-S-1" + row37.[2].Value <- Study.studyIdentifier let row38 = ws.Row(38) row38.[1].Value <- "Study Title" row38.[2].Value <- "Study of the impact of changes in flux on the transcriptome, proteome, endometabolome and exometabolome of the yeast Saccharomyces cerevisiae under different nutrient limitations" @@ -334,7 +337,7 @@ let fullInvestigation = row41.[2].Value <- "2009-03-10" let row42 = ws.Row(42) row42.[1].Value <- "Study File Name" - row42.[2].Value <- "s_BII-S-1.txt" + row42.[2].Value <- $"studies/{Study.studyIdentifier}/isa.study.xlsx" let row43 = ws.Row(43) row43.[1].Value <- "Comment[Study Grant Number]" let row44 = ws.Row(44) @@ -426,9 +429,9 @@ let fullInvestigation = row70.[4].Value <- "Affymetrix" let row71 = ws.Row(71) row71.[1].Value <- "Study Assay File Name" - row71.[2].Value <- "a_proteome.txt" - row71.[3].Value <- "a_metabolome.txt" - row71.[4].Value <- "a_transcriptome.txt" + row71.[2].Value <- $"assays/{Assay.assayIdentifier}/isa.assay.xlsx" + row71.[3].Value <- "assays/metabolome/isa.assay.xlsx" + row71.[4].Value <- "assays/transcriptome/isa.assay.xlsx" let row72 = ws.Row(72) row72.[1].Value <- "STUDY PROTOCOLS" let row73 = ws.Row(73) @@ -547,7 +550,7 @@ let fullInvestigation = row106.[2].Value <- "2009-03-10" let row107 = ws.Row(107) row107.[1].Value <- "Study File Name" - row107.[2].Value <- "s_BII-S-2.txt" + row107.[2].Value <- "studies/BII-S-2/isa.study.xlsx" let row108 = ws.Row(108) row108.[1].Value <- "Comment[Study Grant Number]" let row109 = ws.Row(109) @@ -627,7 +630,7 @@ let fullInvestigation = row134.[2].Value <- "Affymetrix" let row135 = ws.Row(135) row135.[1].Value <- "Study Assay File Name" - row135.[2].Value <- "a_microarray.txt" + row135.[2].Value <- "assays/microarray/isa.assay.xlsx" let row136 = ws.Row(136) row136.[1].Value <- "STUDY PROTOCOLS" let row137 = ws.Row(137) diff --git a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Study.fs b/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Study.fs index 74cb845c..49c25def 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Study.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Study.fs @@ -20,6 +20,33 @@ let studyMetadataEmpty = row7.[1].Value <- "Study File Name" ws +[] +let studyIdentifier = "BII-S-1" + +let studyMetadata = + let ws = FsWorksheet("isa_study") + let row1 = ws.Row(1) + row1.[1].Value <- "STUDY" + let row2 = ws.Row(2) + row2.[1].Value <- "Study Identifier" + row2.[2].Value <- studyIdentifier + let row3 = ws.Row(3) + row3.[1].Value <- "Study Title" + row3.[2].Value <- "Study of the impact of changes in flux on the transcriptome, proteome, endometabolome and exometabolome of the yeast Saccharomyces cerevisiae under different nutrient limitations" + let row4 = ws.Row(4) + row4.[1].Value <- "Study Description" + row4.[2].Value <- "We wished to study the impact of growth rate on the total complement of mRNA molecules, proteins, and metabolites in S. cerevisiae, independent of any nutritional or other physiological effects. To achieve this, we carried out our analyses on yeast grown in steady-state chemostat culture under four different nutrient limitations (glucose, ammonium, phosphate, and sulfate) at three different dilution (that is, growth) rates (D = u = 0.07, 0.1, and 0.2/hour, equivalent to population doubling times (Td) of 10 hours, 7 hours, and 3.5 hours, respectively; u = specific growth rate defined as grams of biomass generated per gram of biomass present per unit time)." + let row5 = ws.Row(5) + row5.[1].Value <- "Study Submission Date" + row5.[2].Value <- "2007-04-30" + let row6 = ws.Row(6) + row6.[1].Value <- "Study Public Release Date" + row6.[2].Value <- "2009-03-10" + let row7 = ws.Row(7) + row7.[1].Value <- "Study File Name" + row7.[2].Value <- $"studies/{studyIdentifier}/isa.study.xlsx" + ws + let studyMetadataEmptyObsoleteSheetName = let cp = studyMetadataEmpty.Copy() cp.Name <- "Study" diff --git a/tests/ISA/ISA.Spreadsheet.Tests/paket.references b/tests/ISA/ISA.Spreadsheet.Tests/paket.references new file mode 100644 index 00000000..2561dfaa --- /dev/null +++ b/tests/ISA/ISA.Spreadsheet.Tests/paket.references @@ -0,0 +1,6 @@ +FSharp.Core +Fable.Core +Expecto +Fable.Mocha +Microsoft.NET.Test.Sdk +YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs b/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs index 383306b0..2a68f260 100644 --- a/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs @@ -392,6 +392,25 @@ let tests_Assay = testList "CRUD Assay" [ Expect.equal i.Studies.[0].Assays.[0].TechnologyPlatform tech "TechnologyPlatform, direct" Expect.equal copy.Studies.[0].Assays.[0].TechnologyPlatform None "TechnologyPlatform, copy direct" ] + testList "FindAssay" [ + testCase "by identifier" <| fun _ -> + let i = createExampleInvestigation() + let a = i.FindAssay("Assay 1") + Expect.equal a.Identifier "Assay 1" "Identifier" + testCase "mutability" <| fun _ -> + let i = createExampleInvestigation() + let a = i.FindAssay("Assay 1") + let t = a.InitTable("NewTable") + t.AddColumn(CompositeHeader.Input IOType.Sample,[|for i in 1 .. 10 do yield CompositeCell.createFreeText $"My awesome probe {i}"|]) + Expect.equal t.Name "NewTable" "table name" + Expect.equal t.ColumnCount 1 "column count" + Expect.equal t.RowCount 10 "row count" + let aNew = i.FindAssay("Assay 1") + Expect.equal aNew.TableCount 1 "table count" + Expect.equal aNew.Tables.[0].Name "NewTable" "next table name" + Expect.equal aNew.Tables.[0].ColumnCount 1 "next column count" + Expect.equal aNew.Tables.[0].RowCount 10 "next row count" + ] ] diff --git a/tests/ISA/ISA.Tests/ArcTable.Tests.fs b/tests/ISA/ISA.Tests/ArcTable.Tests.fs index f781b976..185dabc3 100644 --- a/tests/ISA/ISA.Tests/ArcTable.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcTable.Tests.fs @@ -446,21 +446,21 @@ let private tests_UpdateColumn = ) testCase "set valid, at invalid index = columnCount" (fun () -> let table = create_testTable() - let h = CompositeHeader.Component <| OntologyAnnotation.fromString(term="TestTerm") + let h = CompositeHeader.Component <| OntologyAnnotation.fromString(termName="TestTerm") let cells = createCells_Term 5 let eval() = table.UpdateColumn(table.ColumnCount, h, cells) Expect.throws eval "" ) testCase "set valid, at invalid negative index" (fun () -> let table = create_testTable() - let h = CompositeHeader.Component <| OntologyAnnotation.fromString(term="TestTerm") + let h = CompositeHeader.Component <| OntologyAnnotation.fromString(termName="TestTerm") let cells = createCells_Term 5 let eval() = table.UpdateColumn(-1, h, cells) Expect.throws eval "" ) testCase "set valid" (fun () -> let table = create_testTable() - let h = CompositeHeader.Component <| OntologyAnnotation.fromString(term="TestTerm") + let h = CompositeHeader.Component <| OntologyAnnotation.fromString(termName="TestTerm") let cells = createCells_Term 5 table.UpdateColumn(0, h, cells) Expect.equal table.RowCount 5 "RowCount" @@ -498,7 +498,7 @@ let private tests_UpdateColumn = ) testCase "set valid, less rows" (fun () -> let table = create_testTable() - let h = CompositeHeader.Component <| OntologyAnnotation.fromString(term="TestTerm") + let h = CompositeHeader.Component <| OntologyAnnotation.fromString(termName="TestTerm") let cells = createCells_Term 2 table.UpdateColumn(0, h, cells) Expect.equal table.RowCount 5 "RowCount" @@ -514,7 +514,7 @@ let private tests_UpdateColumn = ) testCase "set valid, more rows" (fun () -> let table = create_testTable() - let h = CompositeHeader.Component <| OntologyAnnotation.fromString(term="TestTerm") + let h = CompositeHeader.Component <| OntologyAnnotation.fromString(termName="TestTerm") let cells = createCells_Term 7 table.UpdateColumn(0, h, cells) Expect.equal table.RowCount 7 "RowCount" diff --git a/tests/ISA/ISA.Tests/CompositeCell.Tests.fs b/tests/ISA/ISA.Tests/CompositeCell.Tests.fs index 59527597..1c570974 100644 --- a/tests/ISA/ISA.Tests/CompositeCell.Tests.fs +++ b/tests/ISA/ISA.Tests/CompositeCell.Tests.fs @@ -113,8 +113,27 @@ let private tests_create = ) ] +let private tests_ToString = testList "ToString" [ + testCase "FreeText" <| fun _ -> + let cc = CompositeCell.createFreeText "My Text" + let actual = cc.ToString() + let expected = "My Text" + Expect.equal actual expected "" + testCase "Term" <| fun _ -> + let cc = CompositeCell.createTermFromString("instrument model", "MS", "MS:0000000") + let actual = cc.ToString() + let expected = "instrument model" + Expect.equal actual expected "" + testCase "Unitized" <| fun _ -> + let cc = CompositeCell.createUnitizedFromString("20", "degree celcius", "UO", "UO:0000000") + let actual = cc.ToString() + let expected = "20 degree celcius" + Expect.equal actual expected "" +] + let main = testList "CompositeCell" [ tests_cellConverter tests_create + tests_ToString ] \ No newline at end of file diff --git a/tests/ISA/ISA.Tests/ISA.Tests.fsproj b/tests/ISA/ISA.Tests/ISA.Tests.fsproj index ce704485..1cb3d262 100644 --- a/tests/ISA/ISA.Tests/ISA.Tests.fsproj +++ b/tests/ISA/ISA.Tests/ISA.Tests.fsproj @@ -1,16 +1,15 @@ - + + Exe net6.0 false - - - - + + @@ -25,15 +24,9 @@ - - - - - - - + \ No newline at end of file diff --git a/tests/ISA/ISA.Tests/Main.fs b/tests/ISA/ISA.Tests/Main.fs index 86157087..b821bcec 100644 --- a/tests/ISA/ISA.Tests/Main.fs +++ b/tests/ISA/ISA.Tests/Main.fs @@ -11,6 +11,7 @@ let all = testSequenced <| testList "All" [ Update.Tests.main DataModel.Tests.main Regex.Tests.main + Person.Tests.main CompositeHeader.Tests.main CompositeCell.Tests.main CompositeColumn.Tests.main diff --git a/tests/ISA/ISA.Tests/Person.Tests.fs b/tests/ISA/ISA.Tests/Person.Tests.fs new file mode 100644 index 00000000..4275cbaf --- /dev/null +++ b/tests/ISA/ISA.Tests/Person.Tests.fs @@ -0,0 +1,70 @@ +module Person.Tests + +open ARCtrl.ISA + +#if FABLE_COMPILER +open Fable.Mocha +#else +open Expecto +#endif + +let private createTestPerson() = Person.create(FirstName="Kevin", LastName="Frey",Email="MyAwesomeMail@Awesome.mail") + +let private tests_ORCID = + testList "ORCID" [ + testCase "fromComment correctORCID" (fun () -> + let comment = Comment.create(Name = Person.orcidKey, Value = "0000-0002-1825-0097") + let p = Person.create(FirstName="My", LastName="Dude",Comments =[|comment|]) + let newP = Person.setOrcidFromComments p + Expect.isSome newP.ORCID "ORCID should now be set" + Expect.equal newP.ORCID.Value "0000-0002-1825-0097" "ORCID not taken correctly" + Expect.isNone newP.Comments "Comments not set to None" + ) + testCase "fromComment wrongORCID" (fun () -> + let comment = Comment.create(Name = "WrongKey", Value = "0000-0002-1825-0097") + let p = Person.create(FirstName="My", LastName="Dude",Comments =[|comment|]) + let newP = Person.setOrcidFromComments p + Expect.isNone newP.ORCID "ORCID should not have been taken" + Expect.isSome newP.Comments "Comments should still be there" + Expect.equal newP.Comments.Value.Length 1 "Comments should still be there" + ) + testCase "fromComment deprecatedORCID" (fun () -> + let comment = Comment.create(Name = "Investigation Person Orcid", Value = "0000-0002-1825-0097") + let p = Person.create(FirstName="My", LastName="Dude",Comments =[|comment|]) + let newP = Person.setOrcidFromComments p + Expect.isSome newP.ORCID "ORCID should now be set" + Expect.equal newP.ORCID.Value "0000-0002-1825-0097" "ORCID not taken correctly" + Expect.isNone newP.Comments "Comments not set to None" + ) + testCase "toComment SomeORCID" (fun () -> + let p = Person.create(FirstName="My", LastName="Dude",ORCID = "0000-0002-1825-0097") + let newP = Person.setCommentFromORCID p + Expect.isSome newP.Comments "Comments should now be set" + Expect.equal newP.Comments.Value.Length 1 "Comments should now be set" + Expect.equal newP.Comments.Value.[0].Name.Value Person.orcidKey "Comments should now be set" + Expect.equal newP.Comments.Value.[0].Value.Value "0000-0002-1825-0097" "Comments should now be set" + ) + testCase "toComment NoneORCID" (fun () -> + let p = Person.create(FirstName="My", LastName="Dude") + let newP = Person.setCommentFromORCID p + Expect.isNone newP.Comments "Comments should not be set" + ) + + ] + +let private tests_Copy = testList "Copy" [ + testCase "test copy" <| fun _ -> + // this test is silly in dotnet as record types are immutable. Test this in js native too! + let person = createTestPerson() + Expect.equal person.FirstName (Some "Kevin") "firstname" + let copy = person.Copy() + let changedPerson = {person with FirstName = Some "DefNotKevin"} + Expect.equal copy.FirstName (Some "Kevin") "copy firstname" + Expect.equal changedPerson.FirstName (Some "DefNotKevin") "changedPerson firstname" +] + +let main = + testList "Person" [ + tests_Copy + tests_ORCID + ] \ No newline at end of file diff --git a/tests/ISA/ISA.Tests/Regex.Tests.fs b/tests/ISA/ISA.Tests/Regex.Tests.fs index d9383a83..00a5cf96 100644 --- a/tests/ISA/ISA.Tests/Regex.Tests.fs +++ b/tests/ISA/ISA.Tests/Regex.Tests.fs @@ -65,9 +65,8 @@ let private tests_AnnotationTableColums = | _ -> None Expect.isSome r "Could not match TSRColumnHeader" let rv = r.Value - Expect.equal rv.LocalTAN localID "LocalId did not match" - Expect.equal rv.TermSourceREF space "TermSourceREF did not match" - Expect.equal rv.TermAccessionNumber $"{space}:{localID}" "TermAccessionNumber did not match" + Expect.equal rv.LocalID localID "LocalId did not match" + Expect.equal rv.IDSpace space "TermSourceREF did not match" ) testCase "Term Source REF Empty" (fun () -> let testString = $"Term Source REF ()" @@ -77,9 +76,8 @@ let private tests_AnnotationTableColums = | _ -> None Expect.isSome r "Could not match TSRColumnHeader" let rv = r.Value - Expect.equal rv.LocalTAN "" "LocalID should be empty" - Expect.equal rv.TermSourceREF "" "TermSourceREF should be empty" - Expect.equal rv.TermAccessionNumber "" "TermAccessionNumber should be empty" + Expect.equal rv.LocalID "" "LocalID should be empty" + Expect.equal rv.IDSpace "" "TermSourceREF should be empty" ) testCase "Term Accession Number" (fun () -> let localID = "12345" @@ -91,9 +89,8 @@ let private tests_AnnotationTableColums = | _ -> None Expect.isSome r "Could not match TANColumnHeader" let rv = r.Value - Expect.equal rv.LocalTAN localID "LocalId did not match" - Expect.equal rv.TermSourceREF space "TermSourceREF did not match" - Expect.equal rv.TermAccessionNumber $"{space}:{localID}" "TermAccessionNumber did not match" + Expect.equal rv.LocalID localID "LocalId did not match" + Expect.equal rv.IDSpace space "TermSourceREF did not match" ) testCase "Term Accession Number Empty" (fun () -> let testString = $"Term Accession Number ()" @@ -103,9 +100,8 @@ let private tests_AnnotationTableColums = | _ -> None Expect.isSome r "Could not match TANColumnHeader" let rv = r.Value - Expect.equal rv.LocalTAN "" "LocalID should be empty" - Expect.equal rv.TermSourceREF "" "TermSourceREF should be empty" - Expect.equal rv.TermAccessionNumber "" "TermAccessionNumber should be empty" + Expect.equal rv.LocalID "" "LocalID should be empty" + Expect.equal rv.IDSpace "" "TermSourceREF should be empty" ) testCase "Reference Column Header Empty" (fun () -> diff --git a/tests/ISA/ISA.Tests/paket.references b/tests/ISA/ISA.Tests/paket.references new file mode 100644 index 00000000..2561dfaa --- /dev/null +++ b/tests/ISA/ISA.Tests/paket.references @@ -0,0 +1,6 @@ +FSharp.Core +Fable.Core +Expecto +Fable.Mocha +Microsoft.NET.Test.Sdk +YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/JavaScript/ISA.Person.js b/tests/JavaScript/ISA.Person.js new file mode 100644 index 00000000..339cd541 --- /dev/null +++ b/tests/JavaScript/ISA.Person.js @@ -0,0 +1,30 @@ +import { equal, deepEqual } from 'assert'; +import { Person } from "./ARCtrl/ISA/ISA/JsonTypes/Person.js"; +import { Comment$ as Comment } from "./ARCtrl/ISA/ISA/JsonTypes/Comment.js"; + +describe('ISA.Person', function () { + describe('copy', function () { + it('check mutable', function () { + const person = Person.create(void 0, "0000-0002-1825-0097", "Frey", "Kevin", void 0, "MyAwesomeMail@Awesome.mail"); + const copy = person.Copy() + equal(person.ORCID, "0000-0002-1825-0097") + equal(copy.ORCID, "0000-0002-1825-0097") + equal(person.FirstName, "Kevin"); + equal(copy.FirstName, "Kevin"); + person.FirstName = "NotKevin" + equal(person.FirstName, "NotKevin"); + equal(copy.FirstName, "Kevin"); + }); + it('check nested mutable', function(){ + const comment = Comment.fromString("TestKey", "TestValue") + const person = Person.create(void 0, void 0, "Frey", "Kevin", void 0, "MyAwesomeMail@Awesome.mail", void 0, void 0, void 0, void 0, void 0, [comment]); + const copy = person.Copy() + equal(person.Comments.length,1) + deepEqual(person.Comments,copy.Comments, "Should be same") + person.Comments[0].Name = "NewTestName" + let expectedComment = Comment.fromString("NewTestName", "TestValue") + deepEqual(person.Comments[0], expectedComment,"Should be new comment") + deepEqual(copy.Comments[0], Comment.fromString("TestKey", "TestValue"), "should be original comment") + }) + }); +}); \ No newline at end of file diff --git a/ts/ARCtrl.ts b/ts/ARCtrl.ts deleted file mode 100644 index a04516ee..00000000 --- a/ts/ARCtrl.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { tryFind, exactlyOne, choose, map } from "./fable_modules/fable-library-ts/Array.js"; -import { fromFsWorkbook } from "./ISA/ISA.Spreadsheet/ArcAssay.js"; -import { FsWorkbook } from "./fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; -import { ArcAssay } from "./ISA/ISA/ArcTypes/ArcAssay.js"; -import { tryFromContract } from "./Contracts/Contracts.ArcAssay.js"; -import { Contract } from "./Contract/Contract.js"; -import { defaultArg, value, Option } from "./fable_modules/fable-library-ts/Option.js"; -import { fromFsWorkbook as fromFsWorkbook_1 } from "./ISA/ISA.Spreadsheet/ArcStudy.js"; -import { ArcStudy } from "./ISA/ISA/ArcTypes/ArcStudy.js"; -import { tryFromContract as tryFromContract_1 } from "./Contracts/Contracts.ArcStudy.js"; -import { fromFsWorkbook as fromFsWorkbook_2 } from "./ISA/ISA.Spreadsheet/InvestigationFile/Investigation.js"; -import { tryFromContract as tryFromContract_2 } from "./Contracts/Contracts.ArcInvestigation.js"; -import { ArcInvestigation_$reflection, ArcInvestigation } from "./ISA/ISA/ArcTypes/ArcInvestigation.js"; -import { FileSystem_$reflection, FileSystem as FileSystem_1 } from "./FileSystem/FileSystem.js"; -import { tryISAReadContractFromPath } from "./Contracts/Contracts.ARCtrl.js"; -import { iterate } from "./fable_modules/fable-library-ts/Seq.js"; -import { printf, toConsole } from "./fable_modules/fable-library-ts/String.js"; -import { Record } from "./fable_modules/fable-library-ts/Types.js"; -import { IEquatable } from "./fable_modules/fable-library-ts/Util.js"; -import { record_type, unit_type, option_type, TypeInfo } from "./fable_modules/fable-library-ts/Reflection.js"; - -export function ARCAux_getArcAssaysFromContracts(contracts: Contract[]): ArcAssay[] { - return map(fromFsWorkbook, choose(tryFromContract, contracts)); -} - -export function ARCAux_getArcStudiesFromContracts(contracts: Contract[]): ArcStudy[] { - return map(fromFsWorkbook_1, choose(tryFromContract_1, contracts)); -} - -export function ARCAux_getArcInvestigationFromContracts(contracts: Contract[]): ArcInvestigation { - return fromFsWorkbook_2(exactlyOne(choose(tryFromContract_2, contracts))); -} - -export class ARC extends Record implements IEquatable { - readonly ISA: Option; - readonly CWL: Option; - readonly FileSystem: Option; - constructor(ISA: Option, CWL: Option, FileSystem: Option) { - super(); - this.ISA = ISA; - this.CWL = CWL; - this.FileSystem = FileSystem; - } - static create(isa?: ArcInvestigation, cwl?: Option, fs?: FileSystem_1): ARC { - return new ARC(isa, cwl, fs); - } - static fromFilePaths(filePaths: string[]): ARC { - const fs: FileSystem_1 = FileSystem_1.fromFilePaths(filePaths); - return ARC.create(void 0, void 0, fs); - } - addFSFromFilePaths(filePaths: string[]): ARC { - const this$: ARC = this; - return new ARC(this$.ISA, this$.CWL, FileSystem_1.fromFilePaths(filePaths)); - } - getReadContracts(): Contract[] { - const this$: ARC = this; - const matchValue: Option = this$.FileSystem; - if (matchValue == null) { - throw new Error("Cannot create READ contracts from ARC without FileSystem.\r\n\r\nYou could initialized your ARC with `ARC.fromFilePaths` or run `yourArc.addFSFromFilePaths` to avoid this issue."); - } - else { - const fs: FileSystem_1 = value(matchValue); - return choose(tryISAReadContractFromPath, fs.Tree.ToFilePaths()); - } - } - addISAFromContracts(contracts: Contract[], enableLogging?: boolean): ARC { - const this$: ARC = this; - const enableLogging_1: boolean = defaultArg(enableLogging, false); - const investigation: ArcInvestigation = ARCAux_getArcInvestigationFromContracts(contracts); - const studies: ArcStudy[] = ARCAux_getArcStudiesFromContracts(contracts); - const assays: ArcAssay[] = ARCAux_getArcAssaysFromContracts(contracts); - const copy: ArcInvestigation = investigation.Copy(); - iterate((studyRegisteredIdent: string): void => { - const studyOpt: Option = tryFind((s: ArcStudy): boolean => (s.Identifier === studyRegisteredIdent), studies); - if (studyOpt == null) { - if (enableLogging_1) { - toConsole(printf("Unable to find registered study \'%s\' in fullfilled READ contracts!"))(studyRegisteredIdent); - } - } - else { - const study: ArcStudy = value(studyOpt); - if (enableLogging_1) { - toConsole(printf("Found study: %s"))(studyRegisteredIdent); - } - iterate((assayRegisteredIdent: string): void => { - const assayOpt: Option = tryFind((a: ArcAssay): boolean => (a.Identifier === assayRegisteredIdent), assays); - if (assayOpt == null) { - if (enableLogging_1) { - toConsole(printf("Unable to find registered assay \'%s\' in fullfilled READ contracts!"))(assayRegisteredIdent); - } - } - else { - const assay: ArcAssay = value(assayOpt); - if (enableLogging_1) { - toConsole(printf("Found assay: %s - %s"))(studyRegisteredIdent)(assayRegisteredIdent); - } - study.AddAssay(assay); - } - }, copy.GetStudy(studyRegisteredIdent).AssayIdentifiers); - investigation.SetStudy(studyRegisteredIdent, study); - } - }, copy.StudyIdentifiers); - return new ARC(investigation, this$.CWL, this$.FileSystem); - } -} - -export function ARC_$reflection(): TypeInfo { - return record_type("ARCtrl.ARC", [], ARC, () => [["ISA", option_type(ArcInvestigation_$reflection())], ["CWL", option_type(unit_type)], ["FileSystem", option_type(FileSystem_$reflection())]]); -} - diff --git a/ts/Contract/Contract.ts b/ts/Contract/Contract.ts deleted file mode 100644 index 7a9b01b6..00000000 --- a/ts/Contract/Contract.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { Record } from "../fable_modules/fable-library-ts/Types.js"; -import { IComparable, IEquatable } from "../fable_modules/fable-library-ts/Util.js"; -import { class_type, option_type, record_type, array_type, string_type, TypeInfo } from "../fable_modules/fable-library-ts/Reflection.js"; -import { FsWorkbook } from "../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; -import { Option, defaultArg } from "../fable_modules/fable-library-ts/Option.js"; - -export type DTOType = - | "ISA_Assay" - | "ISA_Study" - | "ISA_Investigation" - | "JSON" - | "Markdown" - | "CWL" - | "PlainText" - | "Cli" - -export class CLITool extends Record implements IEquatable, IComparable { - readonly Name: string; - readonly Arguments: string[]; - constructor(Name: string, Arguments: string[]) { - super(); - this.Name = Name; - this.Arguments = Arguments; - } - static create(name: string, arguments$: string[]): CLITool { - return new CLITool(name, arguments$); - } -} - -export function CLITool_$reflection(): TypeInfo { - return record_type("Contract.CLITool", [], CLITool, () => [["Name", string_type], ["Arguments", array_type(string_type)]]); -} - -export type DTO = - | FsWorkbook - | string - | CLITool - -export type Operation = - | "CREATE" - | "UPDATE" - | "DELETE" - | "READ" - | "EXECUTE" - -export class Contract extends Record implements IEquatable { - readonly Operation: Operation; - readonly Path: string; - readonly DTOType: Option; - readonly DTO: Option; - constructor(Operation: Operation, Path: string, DTOType: Option, DTO: Option) { - super(); - this.Operation = Operation; - this.Path = Path; - this.DTOType = DTOType; - this.DTO = DTO; - } - static create(op: Operation, path: string, { dtoType, dto }: {dtoType?: DTOType, dto?: DTO }): Contract { - return new Contract(op, path, dtoType, dto); - } - static createCreate(path: string, dtoType: DTOType, dto: DTO): Contract { - return new Contract("CREATE", path, dtoType, dto); - } - static createUpdate(path: string, dtoType: DTOType, dto: DTO): Contract { - return new Contract("UPDATE", path, dtoType, dto); - } - static createDelete(path: string): Contract { - return new Contract("DELETE", path, void 0, void 0); - } - static createRead(path: string, dtoType: DTOType): Contract { - return new Contract("READ", path, dtoType, void 0); - } - static createExecute(dto: CLITool, { path }: {path?: string }): Contract { - return new Contract("EXECUTE", defaultArg(path, ""), "Cli", dto); - } -} - -export function Contract_$reflection(): TypeInfo { - return record_type("Contract.Contract", [], Contract, () => [["Operation", string_type], ["Path", string_type], ["DTOType", option_type(string_type)], ["DTO", option_type(class_type("Contract.DTO"))]]); -} - diff --git a/ts/Contracts/Contracts.ARCtrl.ts b/ts/Contracts/Contracts.ARCtrl.ts deleted file mode 100644 index 9dd9a144..00000000 --- a/ts/Contracts/Contracts.ARCtrl.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { split as split_1 } from "../FileSystem/Path.js"; -import { $007CInvestigationPath$007C_$007C } from "./Contracts.ArcInvestigation.js"; -import { value, Option } from "../fable_modules/fable-library-ts/Option.js"; -import { Contract } from "../Contract/Contract.js"; -import { $007CAssayPath$007C_$007C } from "./Contracts.ArcAssay.js"; -import { $007CStudyPath$007C_$007C } from "./Contracts.ArcStudy.js"; - -/** - * Tries to create READ contract with DTOType = ISA_Assay, ISA_Study or ISA_Investigation from given path relative to ARC root. - */ -export function tryISAReadContractFromPath(path: string): Option { - const split: string[] = split_1(path); - const activePatternResult: Option = $007CInvestigationPath$007C_$007C(split); - if (activePatternResult != null) { - const p: string = value(activePatternResult); - return Contract.createRead(p, "ISA_Investigation"); - } - else { - const activePatternResult_1: Option = $007CAssayPath$007C_$007C(split); - if (activePatternResult_1 != null) { - const p_1: string = value(activePatternResult_1); - return Contract.createRead(p_1, "ISA_Assay"); - } - else { - const activePatternResult_2: Option = $007CStudyPath$007C_$007C(split); - if (activePatternResult_2 != null) { - const p_2: string = value(activePatternResult_2); - return Contract.createRead(p_2, "ISA_Study"); - } - else { - return void 0; - } - } - } -} - diff --git a/ts/Contracts/Contracts.ArcAssay.ts b/ts/Contracts/Contracts.ArcAssay.ts deleted file mode 100644 index f812817d..00000000 --- a/ts/Contracts/Contracts.ArcAssay.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { int32 } from "../fable_modules/fable-library-ts/Int32.js"; -import { FsWorkbook } from "../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; -import { Option, value } from "../fable_modules/fable-library-ts/Option.js"; -import { Contract } from "../Contract/Contract.js"; -import { combineMany } from "../FileSystem/Path.js"; -import { equalsWith } from "../fable_modules/fable-library-ts/Array.js"; -import { defaultOf } from "../fable_modules/fable-library-ts/Util.js"; - -export function tryFromContract(c: Contract): Option { - let matchResult: int32, fsworkbook: FsWorkbook; - if (c.Operation === "READ") { - if (c.DTOType != null) { - if (value(c.DTOType) === "ISA_Assay") { - if (c.DTO != null) { - if (value(c.DTO) instanceof FsWorkbook) { - matchResult = 0; - fsworkbook = value(c.DTO); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return fsworkbook!; - default: - return void 0; - } -} - -export function $007CAssayPath$007C_$007C(input: string[]): Option { - let matchResult: int32; - if (!equalsWith((x: string, y: string): boolean => (x === y), input, defaultOf()) && (input.length === 3)) { - if (input[0] === "assays") { - if (input[2] === "isa.assay.xlsx") { - matchResult = 0; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: { - const anyAssayName: string = input[1]; - return combineMany(input); - } - default: - return void 0; - } -} - diff --git a/ts/Contracts/Contracts.ArcInvestigation.ts b/ts/Contracts/Contracts.ArcInvestigation.ts deleted file mode 100644 index 42bd5134..00000000 --- a/ts/Contracts/Contracts.ArcInvestigation.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { int32 } from "../fable_modules/fable-library-ts/Int32.js"; -import { FsWorkbook } from "../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; -import { Option, value } from "../fable_modules/fable-library-ts/Option.js"; -import { Contract } from "../Contract/Contract.js"; -import { combineMany } from "../FileSystem/Path.js"; -import { equalsWith } from "../fable_modules/fable-library-ts/Array.js"; -import { defaultOf } from "../fable_modules/fable-library-ts/Util.js"; - -export function tryFromContract(c: Contract): Option { - let matchResult: int32, fsworkbook: FsWorkbook; - if (c.Operation === "READ") { - if (c.DTOType != null) { - if (value(c.DTOType) === "ISA_Investigation") { - if (c.DTO != null) { - if (value(c.DTO) instanceof FsWorkbook) { - matchResult = 0; - fsworkbook = value(c.DTO); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return fsworkbook!; - default: - return void 0; - } -} - -export function $007CInvestigationPath$007C_$007C(input: string[]): Option { - let matchResult: int32; - if (!equalsWith((x: string, y: string): boolean => (x === y), input, defaultOf()) && (input.length === 1)) { - if (input[0] === "isa.investigation.xlsx") { - matchResult = 0; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return combineMany(input); - default: - return void 0; - } -} - diff --git a/ts/Contracts/Contracts.ArcStudy.ts b/ts/Contracts/Contracts.ArcStudy.ts deleted file mode 100644 index fce0706b..00000000 --- a/ts/Contracts/Contracts.ArcStudy.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { int32 } from "../fable_modules/fable-library-ts/Int32.js"; -import { FsWorkbook } from "../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; -import { Option, value } from "../fable_modules/fable-library-ts/Option.js"; -import { Contract } from "../Contract/Contract.js"; -import { combineMany } from "../FileSystem/Path.js"; -import { equalsWith } from "../fable_modules/fable-library-ts/Array.js"; -import { defaultOf } from "../fable_modules/fable-library-ts/Util.js"; - -export function tryFromContract(c: Contract): Option { - let matchResult: int32, fsworkbook: FsWorkbook; - if (c.Operation === "READ") { - if (c.DTOType != null) { - if (value(c.DTOType) === "ISA_Study") { - if (c.DTO != null) { - if (value(c.DTO) instanceof FsWorkbook) { - matchResult = 0; - fsworkbook = value(c.DTO); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return fsworkbook!; - default: - return void 0; - } -} - -export function $007CStudyPath$007C_$007C(input: string[]): Option { - let matchResult: int32; - if (!equalsWith((x: string, y: string): boolean => (x === y), input, defaultOf()) && (input.length === 3)) { - if (input[0] === "studies") { - if (input[2] === "isa.study.xlsx") { - matchResult = 0; - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: { - const anyStudyName: string = input[1]; - return combineMany(input); - } - default: - return void 0; - } -} - diff --git a/ts/FileSystem/Commit.ts b/ts/FileSystem/Commit.ts deleted file mode 100644 index 0f2fde07..00000000 --- a/ts/FileSystem/Commit.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Record } from "../fable_modules/fable-library-ts/Types.js"; -import { IComparable, IEquatable } from "../fable_modules/fable-library-ts/Util.js"; -import { record_type, class_type, string_type, TypeInfo } from "../fable_modules/fable-library-ts/Reflection.js"; - -export class Commit extends Record implements IEquatable, IComparable { - readonly Hash: string; - readonly UserName: string; - readonly UserEmail: string; - readonly Date: Date; - readonly Message: string; - constructor(Hash: string, UserName: string, UserEmail: string, Date$: Date, Message: string) { - super(); - this.Hash = Hash; - this.UserName = UserName; - this.UserEmail = UserEmail; - this.Date = Date$; - this.Message = Message; - } -} - -export function Commit_$reflection(): TypeInfo { - return record_type("FileSystem.Commit", [], Commit, () => [["Hash", string_type], ["UserName", string_type], ["UserEmail", string_type], ["Date", class_type("System.DateTime")], ["Message", string_type]]); -} - diff --git a/ts/FileSystem/FileSystem.ts b/ts/FileSystem/FileSystem.ts deleted file mode 100644 index c1b87684..00000000 --- a/ts/FileSystem/FileSystem.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { defaultArg } from "../fable_modules/fable-library-ts/Option.js"; -import { Commit_$reflection, Commit } from "./Commit.js"; -import { FileSystemTree_$reflection, FileSystemTree, FileSystemTree_$union } from "./FileSystemTree.js"; -import { Record } from "../fable_modules/fable-library-ts/Types.js"; -import { IComparable, IEquatable } from "../fable_modules/fable-library-ts/Util.js"; -import { record_type, array_type, TypeInfo } from "../fable_modules/fable-library-ts/Reflection.js"; - -export class FileSystem extends Record implements IEquatable, IComparable { - readonly Tree: FileSystemTree_$union; - readonly History: Commit[]; - constructor(Tree: FileSystemTree_$union, History: Commit[]) { - super(); - this.Tree = Tree; - this.History = History; - } - static create({ tree, history }: {tree: FileSystemTree_$union, history?: Commit[] }): FileSystem { - return new FileSystem(tree, defaultArg(history, [])); - } - AddFile(path: string): FileSystem { - const this$: FileSystem = this; - return new FileSystem(this$.Tree.AddFile(path), this$.History); - } - static addFile(path: string): ((arg0: FileSystem) => FileSystem) { - return (fs: FileSystem): FileSystem => fs.AddFile(path); - } - static fromFilePaths(paths: string[]): FileSystem { - const tree: FileSystemTree_$union = FileSystemTree.fromFilePaths(paths); - return FileSystem.create({ - tree: tree, - }); - } -} - -export function FileSystem_$reflection(): TypeInfo { - return record_type("FileSystem.FileSystem", [], FileSystem, () => [["Tree", FileSystemTree_$reflection()], ["History", array_type(Commit_$reflection())]]); -} - diff --git a/ts/FileSystem/FileSystemTree.ts b/ts/FileSystem/FileSystemTree.ts deleted file mode 100644 index aea9fba6..00000000 --- a/ts/FileSystem/FileSystemTree.ts +++ /dev/null @@ -1,167 +0,0 @@ -import { Option, unwrap, defaultArg } from "../fable_modules/fable-library-ts/Option.js"; -import { singleton, append, delay, toArray } from "../fable_modules/fable-library-ts/Seq.js"; -import { choose, equalsWith, tail, head, map } from "../fable_modules/fable-library-ts/Array.js"; -import { Array_distinct, Array_groupBy } from "../fable_modules/fable-library-ts/Seq2.js"; -import { curry2, arrayHash, stringHash } from "../fable_modules/fable-library-ts/Util.js"; -import { int32 } from "../fable_modules/fable-library-ts/Int32.js"; -import { combineMany, split } from "./Path.js"; -import { empty, FSharpList, reverse, toArray as toArray_1, cons } from "../fable_modules/fable-library-ts/List.js"; -import { Union } from "../fable_modules/fable-library-ts/Types.js"; -import { union_type, array_type, string_type, TypeInfo } from "../fable_modules/fable-library-ts/Reflection.js"; - -export type FileSystemTree_$union = - | FileSystemTree<0> - | FileSystemTree<1> - -export type FileSystemTree_$cases = { - 0: ["File", [string]], - 1: ["Folder", [string, FileSystemTree_$union[]]] -} - -export function FileSystemTree_File(name: string) { - return new FileSystemTree<0>(0, [name]); -} - -export function FileSystemTree_Folder(name: string, children: FileSystemTree_$union[]) { - return new FileSystemTree<1>(1, [name, children]); -} - -export class FileSystemTree extends Union { - constructor(readonly tag: Tag, readonly fields: FileSystemTree_$cases[Tag][1]) { - super(); - } - cases() { - return ["File", "Folder"]; - } - get Name(): string { - const this$ = this as FileSystemTree_$union; - let n: string; - if (this$.tag === /* Folder */ 1) { - n = this$.fields[0]; - } - else { - n = this$.fields[0]; - } - return n!; - } - get isFolder(): boolean { - const this$ = this as FileSystemTree_$union; - return this$.tag === /* Folder */ 1; - } - get isFile(): boolean { - const this$ = this as FileSystemTree_$union; - return this$.tag === /* File */ 0; - } - static get ROOT_NAME(): string { - return "root"; - } - static createFile(name: string): FileSystemTree_$union { - return FileSystemTree_File(name); - } - static createFolder(name: string, children?: FileSystemTree_$union[]): FileSystemTree_$union { - return FileSystemTree_Folder(name, defaultArg(children, [])); - } - AddFile(path: string): FileSystemTree_$union { - const this$ = this as FileSystemTree_$union; - const existingPaths: string[] = this$.ToFilePaths(); - const filePaths: string[] = toArray(delay((): Iterable => append(singleton(path), delay((): Iterable => existingPaths)))); - return FileSystemTree.fromFilePaths(filePaths); - } - static addFile(path: string): ((arg0: FileSystemTree_$union) => FileSystemTree_$union) { - return (tree: FileSystemTree_$union): FileSystemTree_$union => tree.AddFile(path); - } - static fromFilePaths(paths: string[]): FileSystemTree_$union { - const loop = (paths_1: string[][], parent: FileSystemTree_$union): FileSystemTree_$union => { - const files: FileSystemTree_$union[] = map((arg_1: string[]): FileSystemTree_$union => { - const arg: string = head(arg_1); - return FileSystemTree.createFile(arg); - }, paths_1.filter((p: string[]): boolean => (p.length === 1))); - const folders: FileSystemTree_$union[] = map<[string, string[][]], FileSystemTree_$union>((tupledArg: [string, string[][]]): FileSystemTree_$union => { - const parent_1: FileSystemTree_$union = FileSystemTree.createFolder(tupledArg[0], []); - return loop(map(tail, tupledArg[1]), parent_1); - }, Array_groupBy(head, paths_1.filter((p_1: string[]): boolean => (p_1.length > 1)), { - Equals: (x_3: string, y_2: string): boolean => (x_3 === y_2), - GetHashCode: stringHash, - })); - if (parent.tag === /* Folder */ 1) { - const name: string = parent.fields[0]; - return FileSystemTree.createFolder(name, toArray(delay((): Iterable => append(files, delay((): Iterable => folders))))); - } - else { - return parent; - } - }; - return loop(Array_distinct(map(split, paths), { - Equals: (x: string[], y: string[]): boolean => equalsWith((x_1: string, y_1: string): boolean => (x_1 === y_1), x, y), - GetHashCode: arrayHash, - }), FileSystemTree.createFolder(FileSystemTree.ROOT_NAME, [])); - } - ToFilePaths(removeRoot?: boolean): string[] { - const this$ = this as FileSystemTree_$union; - const res: string[] = []; - const loop = (output: FSharpList, parent: FileSystemTree_$union): void => { - if (parent.tag === /* Folder */ 1) { - const n_1: string = parent.fields[0]; - const array: FileSystemTree_$union[] = parent.fields[1]; - array.forEach((filest: FileSystemTree_$union): void => { - loop(cons(n_1, output), filest); - }); - } - else { - const arg: string = combineMany(toArray_1(reverse(cons(parent.fields[0], output)))); - void (res.push(arg)); - } - }; - if (defaultArg(removeRoot, true)) { - if (this$.tag === /* File */ 0) { - const n_2: string = this$.fields[0]; - void (res.push(n_2)); - } - else { - const children_1: FileSystemTree_$union[] = this$.fields[1]; - const action_1: ((arg0: FileSystemTree_$union) => void) = curry2(loop)(empty()); - children_1.forEach(action_1); - } - } - else { - loop(empty(), this$); - } - return Array.from(res); - } - static toFilePaths(removeRoot?: boolean): ((arg0: FileSystemTree_$union) => string[]) { - return (root: FileSystemTree_$union): string[] => root.ToFilePaths(unwrap(removeRoot)); - } - Filter(predicate: ((arg0: string) => boolean)): Option { - const this$ = this as FileSystemTree_$union; - const loop = (parent: FileSystemTree_$union): Option => { - if (parent.tag === /* Folder */ 1) { - const n_1: string = parent.fields[0]; - const filteredChildren: FileSystemTree_$union[] = choose(loop, parent.fields[1]); - if (filteredChildren.length === 0) { - return void 0; - } - else { - return FileSystemTree_Folder(n_1, filteredChildren); - } - } - else { - const n: string = parent.fields[0]; - if (predicate(n)) { - return FileSystemTree_File(n); - } - else { - return void 0; - } - } - }; - return loop(this$); - } - static filter(predicate: ((arg0: string) => boolean)): ((arg0: FileSystemTree_$union) => Option) { - return (tree: FileSystemTree_$union): Option => tree.Filter(predicate); - } -} - -export function FileSystemTree_$reflection(): TypeInfo { - return union_type("FileSystem.FileSystemTree", [], FileSystemTree, () => [[["name", string_type]], [["name", string_type], ["children", array_type(FileSystemTree_$reflection())]]]); -} - diff --git a/ts/FileSystem/Path.ts b/ts/FileSystem/Path.ts deleted file mode 100644 index a5291fa2..00000000 --- a/ts/FileSystem/Path.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { trim, join, trimStart, trimEnd, split as split_1 } from "../fable_modules/fable-library-ts/String.js"; -import { last, mapIndexed } from "../fable_modules/fable-library-ts/Array.js"; -import { int32 } from "../fable_modules/fable-library-ts/Int32.js"; - -export const seperators: string[] = ["/", "\\"]; - -export function split(path: string): string[] { - return split_1(path, seperators, void 0, 3); -} - -export function combine(path1: string, path2: string): string { - return (trimEnd(path1, ...seperators) + "/") + trimStart(path2, ...seperators); -} - -export function combineMany(paths: string[]): string { - return join("/", mapIndexed((i: int32, p: string): string => { - if (i === 0) { - return trimEnd(p, ...seperators); - } - else if (i === (paths.length - 1)) { - return trimStart(p, ...seperators); - } - else { - return trim(p, ...seperators); - } - }, paths)); -} - -export function getFileName(path: string): string { - return last(split(path)); -} - -/** - * Checks if `path` points to a file with the name `fileName` - */ -export function isFile(fileName: string, path: string): boolean { - return getFileName(path) === fileName; -} - diff --git a/ts/ISA/ISA.Json/Assay.ts b/ts/ISA/ISA.Json/Assay.ts deleted file mode 100644 index fb6782ca..00000000 --- a/ts/ISA/ISA.Json/Assay.ts +++ /dev/null @@ -1,133 +0,0 @@ -import { toString, nil, object as object_22 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { FSharpList, ofArray, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { value as value_13, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { tryInclude } from "./GEncode.js"; -import { Data_decoder, Data_encoder, Sample_decoder, Sample_encoder } from "./Data.js"; -import { MaterialAttribute_decoder, MaterialAttribute_encoder, Material_decoder, Material_encoder } from "./Material.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID, ConverterOptions } from "./ConverterOptions.js"; -import { string, IOptionalGetter, IGetters, list as list_1, object as object_23 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { Sample } from "../ISA/JsonTypes/Sample.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { Material } from "../ISA/JsonTypes/Material.js"; -import { AssayMaterials } from "../ISA/JsonTypes/AssayMaterials.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { Assay } from "../ISA/JsonTypes/Assay.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { Process_decoder, Process_encoder } from "./Process.js"; -import { decoder as decoder_5, encoder } from "./Comment.js"; -import { fromString, uri } from "./Decode.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { Data } from "../ISA/JsonTypes/Data.js"; -import { MaterialAttribute } from "../ISA/JsonTypes/MaterialAttribute.js"; -import { Process } from "../ISA/JsonTypes/Process.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; -import { ArcAssay } from "../ISA/ArcTypes/ArcAssay.js"; - -export function AssayMaterials_encoder(options: ConverterOptions, oa: any): any { - return object_22(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, ofArray([tryInclude("samples", (oa_1: any): any => Sample_encoder(options, oa_1), oa["Samples"]), tryInclude("otherMaterials", (oa_2: any): any => Material_encoder(options, oa_2), oa["OtherMaterials"])]))); -} - -export function AssayMaterials_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_2: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_23((get$: IGetters): AssayMaterials => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter; - return new AssayMaterials((objectArg = get$.Optional, objectArg.Field>("samples", (path: string, value: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s: string, json: any): FSharpResult$2_$union => Sample_decoder(options, s, json), path, value))), (objectArg_1 = get$.Optional, objectArg_1.Field>("otherMaterials", (path_1: string, value_1: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_1: string, json_1: any): FSharpResult$2_$union => Material_decoder(options, s_1, json_1), path_1, value_1)))); - }, path_2, v)); -} - -export function Assay_genID(a: Assay): string { - const matchValue: Option = a.ID; - if (matchValue == null) { - const matchValue_1: Option = a.FileName; - if (matchValue_1 == null) { - return "#EmptyAssay"; - } - else { - return value_13(matchValue_1); - } - } - else { - return URIModule_toString(value_13(matchValue)); - } -} - -export function Assay_encoder(options: ConverterOptions, oa: any): any { - return object_22(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Assay_genID(oa as Assay), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Assay", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("filename", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["FileName"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("measurementType", (oa_1: any): any => OntologyAnnotation_encoder(options, oa_1), oa["MeasurementType"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("technologyType", (oa_2: any): any => OntologyAnnotation_encoder(options, oa_2), oa["TechnologyType"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("technologyPlatform", (value_10: any): any => { - let s_4: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_4 = (value_11 as string), s_4)) : nil; - }, oa["TechnologyPlatform"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("dataFiles", (oa_3: any): any => Data_encoder(options, oa_3), oa["DataFiles"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("materials", (oa_4: any): any => AssayMaterials_encoder(options, oa_4), oa["Materials"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("characteristicCategories", (oa_5: any): any => MaterialAttribute_encoder(options, oa_5), oa["CharacteristicCategories"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("unitCategories", (oa_6: any): any => OntologyAnnotation_encoder(options, oa_6), oa["UnitCategories"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("processSequence", (oa_7: any): any => Process_encoder(options, oa_7), oa["ProcessSequence"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder(options, comment), oa["Comments"])))))))))))))))))))))); - })); - })))); -} - -export function Assay_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_7: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_23((get$: IGetters): Assay => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_2: IOptionalGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, arg_13: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_6: IOptionalGetter, arg_15: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_7: IOptionalGetter, arg_17: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_2: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_8: IOptionalGetter, arg_19: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_9: IOptionalGetter, arg_21: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_4: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_10: IOptionalGetter; - return new Assay((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("filename", string)), (arg_5 = OntologyAnnotation_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("measurementType", uncurry2(arg_5)))), (arg_7 = OntologyAnnotation_decoder(options), (objectArg_3 = get$.Optional, objectArg_3.Field("technologyType", uncurry2(arg_7)))), (objectArg_4 = get$.Optional, objectArg_4.Field("technologyPlatform", string)), (objectArg_5 = get$.Optional, objectArg_5.Field>("dataFiles", (path_2: string, value_2: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_1: string, json_1: any): FSharpResult$2_$union => Data_decoder(options, s_1, json_1), path_2, value_2))), (arg_13 = AssayMaterials_decoder(options), (objectArg_6 = get$.Optional, objectArg_6.Field("materials", uncurry2(arg_13)))), (arg_15 = ((decoder_1 = MaterialAttribute_decoder(options), (path_3: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_3: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_1), path_3, value_3)))), (objectArg_7 = get$.Optional, objectArg_7.Field>("characteristicCategories", uncurry2(arg_15)))), (arg_17 = ((decoder_2 = OntologyAnnotation_decoder(options), (path_4: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_4: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_2), path_4, value_4)))), (objectArg_8 = get$.Optional, objectArg_8.Field>("unitCategories", uncurry2(arg_17)))), (arg_19 = ((decoder_3 = Process_decoder(options), (path_5: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_5: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_3), path_5, value_5)))), (objectArg_9 = get$.Optional, objectArg_9.Field>("processSequence", uncurry2(arg_19)))), (arg_21 = ((decoder_4 = decoder_5(options), (path_6: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_6: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_4), path_6, value_6)))), (objectArg_10 = get$.Optional, objectArg_10.Field>("comments", uncurry2(arg_21))))); - }, path_7, v)); -} - -export function Assay_fromString(s: string): Assay { - return fromString(uncurry2(Assay_decoder(ConverterOptions_$ctor())), s); -} - -export function Assay_toString(p: Assay): string { - return toString(2, Assay_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Assay_toStringLD(a: Assay): string { - let returnVal: ConverterOptions; - return toString(2, Assay_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), a)); -} - -export function ArcAssay_fromString(s: string): ArcAssay { - const arg: Assay = fromString(uncurry2(Assay_decoder(ConverterOptions_$ctor())), s); - return ArcAssay.fromAssay(arg); -} - -export function ArcAssay_toString(a: ArcAssay): string { - return toString(2, Assay_encoder(ConverterOptions_$ctor(), a.ToAssay())); -} - -/** - * exports in json-ld format - */ -export function ArcAssay_toStringLD(a: ArcAssay): string { - let returnVal: ConverterOptions; - return toString(2, Assay_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), a.ToAssay())); -} - diff --git a/ts/ISA/ISA.Json/Comment.ts b/ts/ISA/ISA.Json/Comment.ts deleted file mode 100644 index e13bebd0..00000000 --- a/ts/ISA/ISA.Json/Comment.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { value as value_13, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; -import { toString as toString_1, nil, object as object_6 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { IOptionalGetter, IGetters, string, object as object_7 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { fromString as fromString_1, uri } from "./Decode.js"; -import { FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; - -export function genID(c: Comment$): string { - const matchValue: Option = c.ID; - if (matchValue == null) { - const matchValue_1: Option = c.Name; - if (matchValue_1 == null) { - return "#EmptyComment"; - } - else { - const n: string = value_13(matchValue_1); - const v: string = (c.Value != null) ? ("_" + replace(value_13(c.Value), " ", "_")) : ""; - return ("#Comment_" + replace(n, " ", "_")) + v; - } - } - else { - return URIModule_toString(value_13(matchValue)); - } -} - -export function encoder(options: ConverterOptions, comment: any): any { - return object_6(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = genID(comment as Comment$), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, comment["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Comment", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("name", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, comment["Name"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("value", (value_10: any): any => { - let s_4: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_4 = (value_11 as string), s_4)) : nil; - }, comment["Value"])))))); - })); - })))); -} - -export function decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_2: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_7((get$: IGetters): Comment$ => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter; - return new Comment$((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("value", string))); - }, path_2, v)); -} - -export function fromString(s: string): Comment$ { - return fromString_1(uncurry2(decoder(ConverterOptions_$ctor())), s); -} - -export function toString(c: Comment$): string { - return toString_1(2, encoder(ConverterOptions_$ctor(), c)); -} - -/** - * exports in json-ld format - */ -export function toStringLD(c: Comment$): string { - let returnVal: ConverterOptions; - return toString_1(2, encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), c)); -} - diff --git a/ts/ISA/ISA.Json/ConverterOptions.ts b/ts/ISA/ISA.Json/ConverterOptions.ts deleted file mode 100644 index 72867407..00000000 --- a/ts/ISA/ISA.Json/ConverterOptions.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { class_type, TypeInfo } from "../../fable_modules/fable-library-ts/Reflection.js"; - -export class ConverterOptions { - setID: boolean; - includeType: boolean; - constructor() { - this.setID = false; - this.includeType = false; - } -} - -export function ConverterOptions_$reflection(): TypeInfo { - return class_type("ISA.Json.ConverterOptions", void 0, ConverterOptions); -} - -export function ConverterOptions_$ctor(): ConverterOptions { - return new ConverterOptions(); -} - -export function ConverterOptions__get_SetID(this$: ConverterOptions): boolean { - return this$.setID; -} - -export function ConverterOptions__set_SetID_Z1FBCCD16(this$: ConverterOptions, setId: boolean): void { - this$.setID = setId; -} - -export function ConverterOptions__get_IncludeType(this$: ConverterOptions): boolean { - return this$.includeType; -} - -export function ConverterOptions__set_IncludeType_Z1FBCCD16(this$: ConverterOptions, iT: boolean): void { - this$.includeType = iT; -} - diff --git a/ts/ISA/ISA.Json/Data.ts b/ts/ISA/ISA.Json/Data.ts deleted file mode 100644 index f7fc5544..00000000 --- a/ts/ISA/ISA.Json/Data.ts +++ /dev/null @@ -1,275 +0,0 @@ -import { DataFile_ImageFile, DataFile_DerivedDataFile, DataFile_RawDataFile, DataFile_$union, DataFile } from "../ISA/JsonTypes/DataFile.js"; -import { toString, object as object_10, nil } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID, ConverterOptions } from "./ConverterOptions.js"; -import { IOptionalGetter, IGetters, list as list_1, object as object_11, string } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_BadPrimitive, ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { value as value_11, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { Data } from "../ISA/JsonTypes/Data.js"; -import { FSharpList, ofArray, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { tryInclude } from "./GEncode.js"; -import { decoder as decoder_3, encoder } from "./Comment.js"; -import { fromString, uri, hasUnknownFields } from "./Decode.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { Source } from "../ISA/JsonTypes/Source.js"; -import { MaterialAttributeValue_decoder, MaterialAttributeValue_encoder } from "./Material.js"; -import { MaterialAttributeValue } from "../ISA/JsonTypes/MaterialAttributeValue.js"; -import { Sample } from "../ISA/JsonTypes/Sample.js"; -import { FactorValue_decoder, FactorValue_encoder } from "./Factor.js"; -import { FactorValue } from "../ISA/JsonTypes/FactorValue.js"; - -export function DataFile_encoder(options: ConverterOptions, value: any): any { - if (value instanceof DataFile) { - if (value.tag === /* DerivedDataFile */ 1) { - return "Derived Data File"; - } - else if (value.tag === /* ImageFile */ 2) { - return "Image File"; - } - else { - return "Raw Data File"; - } - } - else { - return nil; - } -} - -export function DataFile_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - const matchValue: FSharpResult$2_$union = string(s, json); - if (matchValue.tag === /* Error */ 1) { - return FSharpResult$2_Error(matchValue.fields[0]); - } - else { - switch (matchValue.fields[0]) { - case "Raw Data File": - return FSharpResult$2_Ok(DataFile_RawDataFile()); - case "Derived Data File": - return FSharpResult$2_Ok(DataFile_DerivedDataFile()); - case "Image File": - return FSharpResult$2_Ok(DataFile_ImageFile()); - default: { - const s_1: string = matchValue.fields[0]; - return FSharpResult$2_Error([`Could not parse ${s_1}.`, ErrorReason_BadPrimitive(s_1, nil)] as [string, ErrorReason_$union]); - } - } - } -} - -export function Data_genID(d: Data): string { - const matchValue: Option = d.ID; - if (matchValue == null) { - const matchValue_1: Option = d.Name; - if (matchValue_1 == null) { - return "#EmptyData"; - } - else { - return value_11(matchValue_1); - } - } - else { - return URIModule_toString(value_11(matchValue)); - } -} - -export function Data_encoder(options: ConverterOptions, oa: any): any { - return object_10(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Data_genID(oa as Data), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Data", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("name", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["Name"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("type", (value_10: any): any => DataFile_encoder(options, value_10), oa["DataType"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder(options, comment), oa["Comments"])))))))); - })); - })))); -} - -export function Data_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - if (hasUnknownFields(ofArray(["@id", "name", "type", "comments", "@type"]), json)) { - return FSharpResult$2_Error(["Unknown fields in Data", ErrorReason_BadPrimitive(s, nil)] as [string, ErrorReason_$union]); - } - else { - return object_11((get$: IGetters): Data => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_3: IOptionalGetter; - return new Data((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("type", (s_2: string, json_2: any): FSharpResult$2_$union => DataFile_decoder(options, s_2, json_2))), (arg_7 = ((decoder = decoder_3(options), (path_1: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_3 = get$.Optional, objectArg_3.Field>("comments", uncurry2(arg_7))))); - }, s, json); - } -} - -export function Data_fromString(s: string): Data { - let options: ConverterOptions; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1: string): ((arg0: any) => FSharpResult$2_$union) => ((json: any): FSharpResult$2_$union => Data_decoder(options, s_1, json)))), s); -} - -export function Data_toString(m: Data): string { - return toString(2, Data_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function Data_toStringLD(d: Data): string { - let returnVal: ConverterOptions; - return toString(2, Data_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), d)); -} - -export function Source_genID(s: Source): string { - const matchValue: Option = s.ID; - if (matchValue == null) { - const matchValue_1: Option = s.Name; - if (matchValue_1 == null) { - return "#EmptySource"; - } - else { - return "#Source_" + replace(value_11(matchValue_1), " ", "_"); - } - } - else { - return URIModule_toString(value_11(matchValue)); - } -} - -export function Source_encoder(options: ConverterOptions, oa: any): any { - return object_10(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s_1: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Source_genID(oa as Source), (typeof value === "string") ? ((s_1 = (value as string), s_1)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_2: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_2 = (value_3 as string), s_2)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_3: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Source", (typeof value_5 === "string") ? ((s_3 = (value_5 as string), s_3)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("name", (value_7: any): any => { - let s_4: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_4 = (value_8 as string), s_4)) : nil; - }, oa["Name"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("characteristics", (oa_1: any): any => MaterialAttributeValue_encoder(options, oa_1), oa["Characteristics"])))))); - })); - })))); -} - -export function Source_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - if (hasUnknownFields(ofArray(["@id", "name", "characteristics", "@type"]), json)) { - return FSharpResult$2_Error(["Unknown fields in Source", ErrorReason_BadPrimitive(s, nil)] as [string, ErrorReason_$union]); - } - else { - return object_11((get$: IGetters): Source => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_2: IOptionalGetter; - return new Source((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = ((decoder = MaterialAttributeValue_decoder(options), (path_1: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_2 = get$.Optional, objectArg_2.Field>("characteristics", uncurry2(arg_5))))); - }, s, json); - } -} - -export function Source_fromString(s: string): Source { - let options: ConverterOptions; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1: string): ((arg0: any) => FSharpResult$2_$union) => ((json: any): FSharpResult$2_$union => Source_decoder(options, s_1, json)))), s); -} - -export function Source_toString(m: Source): string { - return toString(2, Source_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function Source_toStringLD(s: Source): string { - let returnVal: ConverterOptions; - return toString(2, Source_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), s)); -} - -export function Sample_genID(s: Sample): string { - const matchValue: Option = s.ID; - if (matchValue == null) { - const matchValue_1: Option = s.Name; - if (matchValue_1 == null) { - return "#EmptySample"; - } - else { - return "#Sample_" + replace(value_11(matchValue_1), " ", "_"); - } - } - else { - return value_11(matchValue); - } -} - -export function Sample_encoder(options: ConverterOptions, oa: any): any { - return object_10(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s_1: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Sample_genID(oa as Sample), (typeof value === "string") ? ((s_1 = (value as string), s_1)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_2: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_2 = (value_3 as string), s_2)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_3: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Sample", (typeof value_5 === "string") ? ((s_3 = (value_5 as string), s_3)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("name", (value_7: any): any => { - let s_4: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_4 = (value_8 as string), s_4)) : nil; - }, oa["Name"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("characteristics", (oa_1: any): any => MaterialAttributeValue_encoder(options, oa_1), oa["Characteristics"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("factorValues", (oa_2: any): any => FactorValue_encoder(options, oa_2), oa["FactorValues"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("derivesFrom", (oa_3: any): any => Source_encoder(options, oa_3), oa["DerivesFrom"])))))))))); - })); - })))); -} - -export function Sample_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - if (hasUnknownFields(ofArray(["@id", "name", "characteristics", "factorValues", "derivesFrom", "@type"]), json)) { - return FSharpResult$2_Error(["Unknown fields in Sample", ErrorReason_BadPrimitive(s, nil)] as [string, ErrorReason_$union]); - } - else { - return object_11((get$: IGetters): Sample => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_2: IOptionalGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter; - return new Sample((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = ((decoder = MaterialAttributeValue_decoder(options), (path_1: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_2 = get$.Optional, objectArg_2.Field>("characteristics", uncurry2(arg_5)))), (arg_7 = ((decoder_1 = FactorValue_decoder(options), (path_2: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_2: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_1), path_2, value_2)))), (objectArg_3 = get$.Optional, objectArg_3.Field>("factorValues", uncurry2(arg_7)))), (objectArg_4 = get$.Optional, objectArg_4.Field>("derivesFrom", (path_3: string, value_3: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_2: string, json_2: any): FSharpResult$2_$union => Source_decoder(options, s_2, json_2), path_3, value_3)))); - }, s, json); - } -} - -export function Sample_fromString(s: string): Sample { - let options: ConverterOptions; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1: string): ((arg0: any) => FSharpResult$2_$union) => ((json: any): FSharpResult$2_$union => Sample_decoder(options, s_1, json)))), s); -} - -export function Sample_toString(m: Sample): string { - return toString(2, Sample_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function Sample_toStringLD(s: Sample): string { - let returnVal: ConverterOptions; - return toString(2, Sample_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), s)); -} - diff --git a/ts/ISA/ISA.Json/Decode.ts b/ts/ISA/ISA.Json/Decode.ts deleted file mode 100644 index ce2254af..00000000 --- a/ts/ISA/ISA.Json/Decode.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { fromString as fromString_1, string } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_FailMessage, ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { printf, toText } from "../../fable_modules/fable-library-ts/String.js"; -import { contains, exists } from "../../fable_modules/fable-library-ts/Seq.js"; -import { stringHash } from "../../fable_modules/fable-library-ts/Util.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { FSharpList } from "../../fable_modules/fable-library-ts/List.js"; - -export function isURI(s: string): boolean { - return true; -} - -export function uri<$a>(s: string, json: $a): FSharpResult$2_$union { - const matchValue: FSharpResult$2_$union = string(s, json); - if (matchValue.tag === /* Error */ 1) { - return FSharpResult$2_Error(matchValue.fields[0]); - } - else if (isURI(matchValue.fields[0])) { - return FSharpResult$2_Ok(matchValue.fields[0]); - } - else { - const s_3: string = matchValue.fields[0]; - return FSharpResult$2_Error([s_3, ErrorReason_FailMessage(toText(printf("Expected URI, got %s"))(s_3))] as [string, ErrorReason_$union]); - } -} - -export function fromString(decoder: ((arg0: string, arg1: any) => FSharpResult$2_$union), s: string): a { - let arg: string; - const matchValue: FSharpResult$2_$union = fromString_1(decoder, s); - if (matchValue.tag === /* Error */ 1) { - throw new Error((arg = matchValue.fields[0], toText(printf("Error decoding string: %s"))(arg))); - } - else { - return matchValue.fields[0]; - } -} - -export function getFieldNames<$a>(json: any): $a { - return Object.getOwnPropertyNames(json); -} - -export function hasUnknownFields(knownFields: FSharpList, json: any): boolean { - return exists((x: string): boolean => !contains(x, knownFields, { - Equals: (x_1: string, y: string): boolean => (x_1 === y), - GetHashCode: stringHash, - }), getFieldNames>(json)); -} - diff --git a/ts/ISA/ISA.Json/Factor.ts b/ts/ISA/ISA.Json/Factor.ts deleted file mode 100644 index f41f8011..00000000 --- a/ts/ISA/ISA.Json/Factor.ts +++ /dev/null @@ -1,199 +0,0 @@ -import { Value_Int, Value_Float, Value_Ontology, Value_Name, Value_$union, Value } from "../ISA/JsonTypes/Value.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { object as object_8, toString, nil } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID, ConverterOptions_$ctor, ConverterOptions } from "./ConverterOptions.js"; -import { IOptionalGetter, IGetters, list as list_1, object as object_9, string, float, int } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { float64, int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { uri, fromString } from "./Decode.js"; -import { equals, uncurry2 } from "../../fable_modules/fable-library-ts/Util.js"; -import { value as value_10, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { Factor } from "../ISA/JsonTypes/Factor.js"; -import { FSharpList, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { tryInclude } from "./GEncode.js"; -import { decoder as decoder_1, encoder } from "./Comment.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; -import { FactorValue } from "../ISA/JsonTypes/FactorValue.js"; - -export function Value_encoder(options: ConverterOptions, value: any): any { - if (value instanceof Value) { - if (value.tag === /* Int */ 1) { - return (value as Value<1>).fields[0]; - } - else if (value.tag === /* Name */ 3) { - return (value as Value<3>).fields[0]; - } - else if (value.tag === /* Ontology */ 0) { - return OntologyAnnotation_encoder(options, (value as Value<0>).fields[0]); - } - else { - return (value as Value<2>).fields[0]; - } - } - else { - return nil; - } -} - -export function Value_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - const matchValue: FSharpResult$2_$union = int(s)(json); - if (matchValue.tag === /* Error */ 1) { - const matchValue_1: FSharpResult$2_$union = float(s, json); - if (matchValue_1.tag === /* Error */ 1) { - const matchValue_2: FSharpResult$2_$union = OntologyAnnotation_decoder(options)(s)(json); - if (matchValue_2.tag === /* Error */ 1) { - const matchValue_3: FSharpResult$2_$union = string(s, json); - if (matchValue_3.tag === /* Error */ 1) { - return FSharpResult$2_Error(matchValue_3.fields[0]); - } - else { - return FSharpResult$2_Ok(Value_Name(matchValue_3.fields[0])); - } - } - else { - return FSharpResult$2_Ok(Value_Ontology(matchValue_2.fields[0])); - } - } - else { - return FSharpResult$2_Ok(Value_Float(matchValue_1.fields[0])); - } - } - else { - return FSharpResult$2_Ok(Value_Int(matchValue.fields[0])); - } -} - -export function Value_fromString(s: string): Value_$union { - let options: ConverterOptions; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1: string): ((arg0: any) => FSharpResult$2_$union) => ((json: any): FSharpResult$2_$union => Value_decoder(options, s_1, json)))), s); -} - -export function Value_toString(v: Value_$union): string { - return toString(2, Value_encoder(ConverterOptions_$ctor(), v)); -} - -export function Factor_genID(f: Factor): string { - const matchValue: Option = f.ID; - if (matchValue == null) { - const matchValue_1: Option = f.Name; - if (matchValue_1 == null) { - return "#EmptyFactor"; - } - else { - return "#Factor_" + replace(value_10(matchValue_1), " ", "_"); - } - } - else { - return URIModule_toString(value_10(matchValue)); - } -} - -export function Factor_encoder(options: ConverterOptions, oa: any): any { - return object_8(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Factor_genID(oa as Factor), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Factor", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("factorName", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["Name"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("factorType", (oa_1: any): any => OntologyAnnotation_encoder(options, oa_1), oa["FactorType"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder(options, comment), oa["Comments"])))))))); - })); - })))); -} - -export function Factor_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_2: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_9((get$: IGetters): Factor => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_2: IOptionalGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_3: IOptionalGetter; - return new Factor((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("factorName", string)), (arg_5 = OntologyAnnotation_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("factorType", uncurry2(arg_5)))), (arg_7 = ((decoder = decoder_1(options), (path_1: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_3 = get$.Optional, objectArg_3.Field>("comments", uncurry2(arg_7))))); - }, path_2, v)); -} - -export function Factor_fromString(s: string): Factor { - return fromString(uncurry2(Factor_decoder(ConverterOptions_$ctor())), s); -} - -export function Factor_toString(f: Factor): string { - return toString(2, Factor_encoder(ConverterOptions_$ctor(), f)); -} - -/** - * exports in json-ld format - */ -export function Factor_toStringLD(f: Factor): string { - let returnVal: ConverterOptions; - return toString(2, Factor_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), f)); -} - -export function FactorValue_genID(fv: FactorValue): string { - const matchValue: Option = fv.ID; - if (matchValue == null) { - return "#EmptyFactorValue"; - } - else { - return URIModule_toString(value_10(matchValue)); - } -} - -export function FactorValue_encoder(options: ConverterOptions, oa: any): any { - return object_8(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = FactorValue_genID(oa as FactorValue), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "FactorValue", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("category", (oa_1: any): any => Factor_encoder(options, oa_1), oa["Category"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("value", (value_7: any): any => Value_encoder(options, value_7), oa["Value"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("unit", (oa_2: any): any => OntologyAnnotation_encoder(options, oa_2), oa["Unit"])))))))); - })); - })))); -} - -export function FactorValue_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_9((get$: IGetters): FactorValue => { - let objectArg: IOptionalGetter, arg_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_3: IOptionalGetter; - return new FactorValue((objectArg = get$.Optional, objectArg.Field("@id", uri)), (arg_3 = Factor_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("category", uncurry2(arg_3)))), (objectArg_2 = get$.Optional, objectArg_2.Field("value", (s_1: string, json_1: any): FSharpResult$2_$union => Value_decoder(options, s_1, json_1))), (arg_7 = OntologyAnnotation_decoder(options), (objectArg_3 = get$.Optional, objectArg_3.Field("unit", uncurry2(arg_7))))); - }, path, v)); -} - -export function FactorValue_fromString(s: string): FactorValue { - return fromString(uncurry2(FactorValue_decoder(ConverterOptions_$ctor())), s); -} - -export function FactorValue_toString(f: FactorValue): string { - return toString(2, FactorValue_encoder(ConverterOptions_$ctor(), f)); -} - -/** - * exports in json-ld format - */ -export function FactorValue_toStringLD(f: FactorValue): string { - let returnVal: ConverterOptions; - return toString(2, FactorValue_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), f)); -} - diff --git a/ts/ISA/ISA.Json/GEncode.ts b/ts/ISA/ISA.Json/GEncode.ts deleted file mode 100644 index 56f9b54a..00000000 --- a/ts/ISA/ISA.Json/GEncode.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Option, value as value_1 } from "../../fable_modules/fable-library-ts/Option.js"; -import { isIterable } from "../../fable_modules/fable-library-ts/Util.js"; -import { nil, seq } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { map } from "../../fable_modules/fable-library-ts/Seq.js"; - -/** - * Try to encode the given object using the given encoder, or return Encode.nil if the object is null - * - * If the object is a sequence, encode each element using the given encoder and return the resulting sequence - */ -export function tryInclude<$a>(name: $a, encoder: ((arg0: any) => any), value: Option): [$a, any] { - let v: Iterable, o: any; - return [name, (value != null) ? (isIterable(value_1(value)) ? ((v = (value_1(value) as Iterable), seq(map(encoder, v)))) : ((o = value_1(value), encoder(o)))) : nil] as [$a, any]; -} - diff --git a/ts/ISA/ISA.Json/Investigation.ts b/ts/ISA/ISA.Json/Investigation.ts deleted file mode 100644 index 3b1cec25..00000000 --- a/ts/ISA/ISA.Json/Investigation.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { value as value_25, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { Investigation } from "../ISA/JsonTypes/Investigation.js"; -import { toString, nil, object as object_24 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { empty as empty_1, FSharpList, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologySourceReference_decoder, OntologySourceReference_encoder } from "./Ontology.js"; -import { decoder as decoder_5, encoder } from "./Publication.js"; -import { decoder as decoder_6, encoder as encoder_1 } from "./Person.js"; -import { Study_decoder, Study_encoder } from "./Study.js"; -import { decoder as decoder_7, encoder as encoder_2 } from "./Comment.js"; -import { IOptionalGetter, IGetters, list as list_1, string, object as object_25 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { OntologySourceReference } from "../ISA/JsonTypes/OntologySourceReference.js"; -import { Publication } from "../ISA/JsonTypes/Publication.js"; -import { Person } from "../ISA/JsonTypes/Person.js"; -import { Study } from "../ISA/JsonTypes/Study.js"; -import { Remark, Comment$ } from "../ISA/JsonTypes/Comment.js"; -import { fromString } from "./Decode.js"; -import { ArcInvestigation } from "../ISA/ArcTypes/ArcInvestigation.js"; - -export function Investigation_genID(i: Investigation): string { - const matchValue: Option = i.ID; - if (matchValue == null) { - const matchValue_1: Option = i.FileName; - if (matchValue_1 == null) { - const matchValue_2: Option = i.Identifier; - if (matchValue_2 == null) { - const matchValue_3: Option = i.Title; - if (matchValue_3 == null) { - return "#EmptyStudy"; - } - else { - return "#Study_" + replace(value_25(matchValue_3), " ", "_"); - } - } - else { - return "#Study_" + replace(value_25(matchValue_2), " ", "_"); - } - } - else { - return "#Study_" + replace(value_25(matchValue_1), " ", "_"); - } - } - else { - return URIModule_toString(value_25(matchValue)); - } -} - -export function Investigation_encoder(options: ConverterOptions, oa: any): any { - return object_24(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Investigation_genID(oa as Investigation), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Investigation", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("filename", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["FileName"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("identifier", (value_10: any): any => { - let s_4: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_4 = (value_11 as string), s_4)) : nil; - }, oa["Identifier"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("title", (value_13: any): any => { - let s_5: string; - const value_14: any = value_13; - return (typeof value_14 === "string") ? ((s_5 = (value_14 as string), s_5)) : nil; - }, oa["Title"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("description", (value_16: any): any => { - let s_6: string; - const value_17: any = value_16; - return (typeof value_17 === "string") ? ((s_6 = (value_17 as string), s_6)) : nil; - }, oa["Description"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("submissionDate", (value_19: any): any => { - let s_7: string; - const value_20: any = value_19; - return (typeof value_20 === "string") ? ((s_7 = (value_20 as string), s_7)) : nil; - }, oa["SubmissionDate"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("publicReleaseDate", (value_22: any): any => { - let s_8: string; - const value_23: any = value_22; - return (typeof value_23 === "string") ? ((s_8 = (value_23 as string), s_8)) : nil; - }, oa["PublicReleaseDate"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("ontologySourceReferences", (osr: any): any => OntologySourceReference_encoder(options, osr), oa["OntologySourceReferences"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("publications", (oa_1: any): any => encoder(options, oa_1), oa["Publications"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("people", (oa_2: any): any => encoder_1(options, oa_2), oa["Contacts"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("studies", (oa_3: any): any => Study_encoder(options, oa_3), oa["Studies"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder_2(options, comment), oa["Comments"])))))))))))))))))))))))); - })); - })))); -} - -export function Investigation_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_12: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_25((get$: IGetters): Investigation => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, objectArg_6: IOptionalGetter, arg_15: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_7: IOptionalGetter, arg_17: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_8: IOptionalGetter, arg_19: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_2: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_9: IOptionalGetter, arg_21: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_10: IOptionalGetter, arg_23: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_4: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_11: IOptionalGetter; - return new Investigation((objectArg = get$.Optional, objectArg.Field("@id", string)), (objectArg_1 = get$.Optional, objectArg_1.Field("filename", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("identifier", string)), (objectArg_3 = get$.Optional, objectArg_3.Field("title", string)), (objectArg_4 = get$.Optional, objectArg_4.Field("description", string)), (objectArg_5 = get$.Optional, objectArg_5.Field("submissionDate", string)), (objectArg_6 = get$.Optional, objectArg_6.Field("publicReleaseDate", string)), (arg_15 = ((decoder = OntologySourceReference_decoder(options), (path_7: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_7: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_7, value_7)))), (objectArg_7 = get$.Optional, objectArg_7.Field>("ontologySourceReferences", uncurry2(arg_15)))), (arg_17 = ((decoder_1 = decoder_5(options), (path_8: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_8: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_1), path_8, value_8)))), (objectArg_8 = get$.Optional, objectArg_8.Field>("publications", uncurry2(arg_17)))), (arg_19 = ((decoder_2 = decoder_6(options), (path_9: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_9: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_2), path_9, value_9)))), (objectArg_9 = get$.Optional, objectArg_9.Field>("people", uncurry2(arg_19)))), (arg_21 = ((decoder_3 = Study_decoder(options), (path_10: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_10: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_3), path_10, value_10)))), (objectArg_10 = get$.Optional, objectArg_10.Field>("studies", uncurry2(arg_21)))), (arg_23 = ((decoder_4 = decoder_7(options), (path_11: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_11: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_4), path_11, value_11)))), (objectArg_11 = get$.Optional, objectArg_11.Field>("comments", uncurry2(arg_23)))), empty_1()); - }, path_12, v)); -} - -export function Investigation_fromString(s: string): Investigation { - return fromString(uncurry2(Investigation_decoder(ConverterOptions_$ctor())), s); -} - -export function Investigation_toString(p: Investigation): string { - return toString(2, Investigation_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Investigation_toStringLD(i: Investigation): string { - let returnVal: ConverterOptions; - return toString(2, Investigation_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), i)); -} - -export function ArcInvestigation_fromString(s: string): ArcInvestigation { - const arg: Investigation = fromString(uncurry2(Investigation_decoder(ConverterOptions_$ctor())), s); - return ArcInvestigation.fromInvestigation(arg); -} - -export function ArcInvestigation_toString(a: ArcInvestigation): string { - return toString(2, Investigation_encoder(ConverterOptions_$ctor(), a.ToInvestigation())); -} - -/** - * exports in json-ld format - */ -export function ArcInvestigation_toStringLD(a: ArcInvestigation): string { - let returnVal: ConverterOptions; - return toString(2, Investigation_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), a.ToInvestigation())); -} - diff --git a/ts/ISA/ISA.Json/Material.ts b/ts/ISA/ISA.Json/Material.ts deleted file mode 100644 index 997241e1..00000000 --- a/ts/ISA/ISA.Json/Material.ts +++ /dev/null @@ -1,236 +0,0 @@ -import { MaterialType_LabeledExtractName, MaterialType_ExtractName, MaterialType_$union, MaterialType } from "../ISA/JsonTypes/MaterialType.js"; -import { toString, object as object_10, nil } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID, ConverterOptions } from "./ConverterOptions.js"; -import { list as list_1, IOptionalGetter, IGetters, object as object_11, string } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_BadPrimitive, ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { value as value_11, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { MaterialAttribute } from "../ISA/JsonTypes/MaterialAttribute.js"; -import { FSharpList, ofArray, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { hasUnknownFields, fromString, uri } from "./Decode.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { MaterialAttributeValue } from "../ISA/JsonTypes/MaterialAttributeValue.js"; -import { Value_decoder, Value_encoder } from "./Factor.js"; -import { Value_$union } from "../ISA/JsonTypes/Value.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { Material } from "../ISA/JsonTypes/Material.js"; - -export function MaterialType_encoder(options: ConverterOptions, value: any): any { - if (value instanceof MaterialType) { - if (value.tag === /* LabeledExtractName */ 1) { - return "Labeled Extract Name"; - } - else { - return "Extract Name"; - } - } - else { - return nil; - } -} - -export function MaterialType_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - const matchValue: FSharpResult$2_$union = string(s, json); - if (matchValue.tag === /* Error */ 1) { - return FSharpResult$2_Error(matchValue.fields[0]); - } - else { - switch (matchValue.fields[0]) { - case "Extract Name": - return FSharpResult$2_Ok(MaterialType_ExtractName()); - case "Labeled Extract Name": - return FSharpResult$2_Ok(MaterialType_LabeledExtractName()); - default: { - const s_1: string = matchValue.fields[0]; - return FSharpResult$2_Error([`Could not parse ${s_1}No other value than "Extract Name" or "Labeled Extract Name" allowed for materialtype`, ErrorReason_BadPrimitive(s_1, nil)] as [string, ErrorReason_$union]); - } - } - } -} - -export function MaterialAttribute_genID(m: MaterialAttribute): string { - const matchValue: Option = m.ID; - if (matchValue == null) { - return "#EmptyMaterialAttribute"; - } - else { - return URIModule_toString(value_11(matchValue)); - } -} - -export function MaterialAttribute_encoder(options: ConverterOptions, oa: any): any { - return object_10(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = MaterialAttribute_genID(oa as MaterialAttribute), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "MaterialAttribute", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("characteristicType", (oa_1: any): any => OntologyAnnotation_encoder(options, oa_1), oa["CharacteristicType"])))); - })); - })))); -} - -export function MaterialAttribute_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_11((get$: IGetters): MaterialAttribute => { - let objectArg: IOptionalGetter, arg_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_1: IOptionalGetter; - return new MaterialAttribute((objectArg = get$.Optional, objectArg.Field("@id", uri)), (arg_3 = OntologyAnnotation_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("characteristicType", uncurry2(arg_3))))); - }, path, v)); -} - -export function MaterialAttribute_fromString(s: string): MaterialAttribute { - return fromString(uncurry2(MaterialAttribute_decoder(ConverterOptions_$ctor())), s); -} - -export function MaterialAttribute_toString(m: MaterialAttribute): string { - return toString(2, MaterialAttribute_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function MaterialAttribute_toStringLD(m: MaterialAttribute): string { - let returnVal: ConverterOptions; - return toString(2, MaterialAttribute_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), m)); -} - -export function MaterialAttributeValue_genID(m: MaterialAttributeValue): string { - const matchValue: Option = m.ID; - if (matchValue == null) { - return "#EmptyMaterialAttributeValue"; - } - else { - return URIModule_toString(value_11(matchValue)); - } -} - -export function MaterialAttributeValue_encoder(options: ConverterOptions, oa: any): any { - return object_10(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = MaterialAttributeValue_genID(oa as MaterialAttributeValue), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "MaterialAttributeValue", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("category", (oa_1: any): any => MaterialAttribute_encoder(options, oa_1), oa["Category"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("value", (value_7: any): any => Value_encoder(options, value_7), oa["Value"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("unit", (oa_2: any): any => OntologyAnnotation_encoder(options, oa_2), oa["Unit"])))))))); - })); - })))); -} - -export function MaterialAttributeValue_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_11((get$: IGetters): MaterialAttributeValue => { - let objectArg: IOptionalGetter, arg_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_3: IOptionalGetter; - return new MaterialAttributeValue((objectArg = get$.Optional, objectArg.Field("@id", uri)), (arg_3 = MaterialAttribute_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("category", uncurry2(arg_3)))), (objectArg_2 = get$.Optional, objectArg_2.Field("value", (s_1: string, json_1: any): FSharpResult$2_$union => Value_decoder(options, s_1, json_1))), (arg_7 = OntologyAnnotation_decoder(options), (objectArg_3 = get$.Optional, objectArg_3.Field("unit", uncurry2(arg_7))))); - }, path, v)); -} - -export function MaterialAttributeValue_fromString(s: string): MaterialAttributeValue { - return fromString(uncurry2(MaterialAttributeValue_decoder(ConverterOptions_$ctor())), s); -} - -export function MaterialAttributeValue_toString(m: MaterialAttributeValue): string { - return toString(2, MaterialAttributeValue_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function MaterialAttributeValue_toStringLD(m: MaterialAttributeValue): string { - let returnVal: ConverterOptions; - return toString(2, MaterialAttributeValue_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), m)); -} - -export function Material_genID(m: Material): string { - const matchValue: Option = m.ID; - if (matchValue == null) { - const matchValue_1: Option = m.Name; - if (matchValue_1 == null) { - return "#EmptyMaterial"; - } - else { - return "#Material_" + replace(value_11(matchValue_1), " ", "_"); - } - } - else { - return value_11(matchValue); - } -} - -export function Material_encoder(options: ConverterOptions, oa: any): any { - return object_10(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Material_genID(oa as Material), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Material", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("name", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["Name"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("type", (value_10: any): any => MaterialType_encoder(options, value_10), oa["MaterialType"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("characteristics", (oa_1: any): any => MaterialAttributeValue_encoder(options, oa_1), oa["Characteristics"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("derivesFrom", (oa_2: any): any => Material_encoder(options, oa_2), oa["DerivesFrom"])))))))))); - })); - })))); -} - -export function Material_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - if (hasUnknownFields(ofArray(["@id", "@type", "name", "type", "characteristics", "derivesFrom"]), json)) { - return FSharpResult$2_Error(["Unknown fields in material", ErrorReason_BadPrimitive(s, nil)] as [string, ErrorReason_$union]); - } - else { - return object_11((get$: IGetters): Material => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter; - return new Material((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("type", (s_2: string, json_2: any): FSharpResult$2_$union => MaterialType_decoder(options, s_2, json_2))), (arg_7 = ((decoder = MaterialAttributeValue_decoder(options), (path_1: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_3 = get$.Optional, objectArg_3.Field>("characteristics", uncurry2(arg_7)))), (objectArg_4 = get$.Optional, objectArg_4.Field>("derivesFrom", (path_2: string, value_2: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_3: string, json_3: any): FSharpResult$2_$union => Material_decoder(options, s_3, json_3), path_2, value_2)))); - }, s, json); - } -} - -export function Material_fromString(s: string): Material { - let options: ConverterOptions; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1: string): ((arg0: any) => FSharpResult$2_$union) => ((json: any): FSharpResult$2_$union => Material_decoder(options, s_1, json)))), s); -} - -export function Material_toString(m: Material): string { - return toString(2, Material_encoder(ConverterOptions_$ctor(), m)); -} - -/** - * exports in json-ld format - */ -export function Material_toStringLD(m: Material): string { - let returnVal: ConverterOptions; - return toString(2, Material_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), m)); -} - diff --git a/ts/ISA/ISA.Json/Ontology.ts b/ts/ISA/ISA.Json/Ontology.ts deleted file mode 100644 index a8abb1ed..00000000 --- a/ts/ISA/ISA.Json/Ontology.ts +++ /dev/null @@ -1,239 +0,0 @@ -import { AnnotationValue_Int, AnnotationValue_Float, AnnotationValue_Text, AnnotationValue_$union, AnnotationValue } from "../ISA/JsonTypes/AnnotationValue.js"; -import { toString, object as object_10, nil } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID, ConverterOptions } from "./ConverterOptions.js"; -import { IOptionalGetter, IGetters, list as list_1, object as object_11, string, float, int } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { float64, int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { bind, value as value_16, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { OntologySourceReference } from "../ISA/JsonTypes/OntologySourceReference.js"; -import { FSharpList, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { tryInclude } from "./GEncode.js"; -import { decoder as decoder_1, encoder } from "./Comment.js"; -import { fromString, uri } from "./Decode.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { ActivePatterns_$007CTermAnnotation$007C_$007C } from "../ISA/Regex.js"; - -export function AnnotationValue_encoder(options: ConverterOptions, value: any): any { - if (value instanceof AnnotationValue) { - if (value.tag === /* Int */ 2) { - return (value as AnnotationValue<2>).fields[0]; - } - else if (value.tag === /* Text */ 0) { - return (value as AnnotationValue<0>).fields[0]; - } - else { - return (value as AnnotationValue<1>).fields[0]; - } - } - else { - return nil; - } -} - -export function AnnotationValue_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - const matchValue: FSharpResult$2_$union = int(s)(json); - if (matchValue.tag === /* Error */ 1) { - const matchValue_1: FSharpResult$2_$union = float(s, json); - if (matchValue_1.tag === /* Error */ 1) { - const matchValue_2: FSharpResult$2_$union = string(s, json); - if (matchValue_2.tag === /* Error */ 1) { - return FSharpResult$2_Error(matchValue_2.fields[0]); - } - else { - return FSharpResult$2_Ok(AnnotationValue_Text(matchValue_2.fields[0])); - } - } - else { - return FSharpResult$2_Ok(AnnotationValue_Float(matchValue_1.fields[0])); - } - } - else { - return FSharpResult$2_Ok(AnnotationValue_Int(matchValue.fields[0])); - } -} - -export function OntologySourceReference_genID(o: OntologySourceReference): string { - const matchValue: Option = o.File; - if (matchValue == null) { - const matchValue_1: Option = o.Name; - if (matchValue_1 == null) { - return "#DummyOntologySourceRef"; - } - else { - return "#OntologySourceRef_" + replace(value_16(matchValue_1), " ", "_"); - } - } - else { - return value_16(matchValue); - } -} - -export function OntologySourceReference_encoder(options: ConverterOptions, osr: any): any { - return object_10(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = OntologySourceReference_genID(osr as OntologySourceReference), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => { - let value_2: any, s_1: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_2 = "OntologySourceReference", (typeof value_2 === "string") ? ((s_1 = (value_2 as string), s_1)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("description", (value_4: any): any => { - let s_2: string; - const value_5: any = value_4; - return (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil; - }, osr["Description"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("file", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, osr["File"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("name", (value_10: any): any => { - let s_4: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_4 = (value_11 as string), s_4)) : nil; - }, osr["Name"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("version", (value_13: any): any => { - let s_5: string; - const value_14: any = value_13; - return (typeof value_14 === "string") ? ((s_5 = (value_14 as string), s_5)) : nil; - }, osr["Version"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder(options, comment), osr["Comments"])))))))))))); - })); - })))); -} - -export function OntologySourceReference_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_4: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_11((get$: IGetters): OntologySourceReference => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, objectArg_3: IOptionalGetter, arg_9: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_4: IOptionalGetter; - return new OntologySourceReference((objectArg = get$.Optional, objectArg.Field("description", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("file", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("name", string)), (objectArg_3 = get$.Optional, objectArg_3.Field("version", string)), (arg_9 = ((decoder = decoder_1(options), (path_3: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_3: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_3, value_3)))), (objectArg_4 = get$.Optional, objectArg_4.Field>("comments", uncurry2(arg_9))))); - }, path_4, v)); -} - -export function OntologySourceReference_fromString(s: string): OntologySourceReference { - return fromString(uncurry2(OntologySourceReference_decoder(ConverterOptions_$ctor())), s); -} - -export function OntologySourceReference_toString(oa: OntologySourceReference): string { - return toString(2, OntologySourceReference_encoder(ConverterOptions_$ctor(), oa)); -} - -/** - * exports in json-ld format - */ -export function OntologySourceReference_toStringLD(oa: OntologySourceReference): string { - let returnVal: ConverterOptions; - return toString(2, OntologySourceReference_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), oa)); -} - -export function OntologyAnnotation_genID(o: OntologyAnnotation): string { - const matchValue: Option = o.ID; - if (matchValue == null) { - const matchValue_1: Option = o.TermAccessionNumber; - if (matchValue_1 == null) { - const matchValue_2: Option = o.TermSourceREF; - if (matchValue_2 == null) { - return "#DummyOntologyAnnotation"; - } - else { - return "#" + replace(value_16(matchValue_2), " ", "_"); - } - } - else { - return value_16(matchValue_1); - } - } - else { - return URIModule_toString(value_16(matchValue)); - } -} - -export function OntologyAnnotation_encoder(options: ConverterOptions, oa: any): any { - return object_10(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = OntologyAnnotation_genID(oa as OntologyAnnotation), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "OntologyAnnotation", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("annotationValue", (value_7: any): any => AnnotationValue_encoder(options, value_7), oa["Name"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("termSource", (value_8: any): any => { - let s_3: string; - const value_9: any = value_8; - return (typeof value_9 === "string") ? ((s_3 = (value_9 as string), s_3)) : nil; - }, oa["TermSourceREF"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("termAccession", (value_11: any): any => { - let s_4: string; - const value_12: any = value_11; - return (typeof value_12 === "string") ? ((s_4 = (value_12 as string), s_4)) : nil; - }, oa["TermAccessionNumber"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder(options, comment), oa["Comments"])))))))))); - })); - })))); -} - -export function OntologyAnnotation_localIDDecoder(s: string, json: any): FSharpResult$2_$union { - const matchValue: FSharpResult$2_$union = string(s, json); - let matchResult: int32, tan: { LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }; - if (matchValue.tag === /* Ok */ 0) { - const activePatternResult: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTermAnnotation$007C_$007C(matchValue.fields[0]); - if (activePatternResult != null) { - matchResult = 0; - tan = value_16(activePatternResult); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return FSharpResult$2_Ok(tan!.TermSourceREF); - default: - return FSharpResult$2_Ok(""); - } -} - -export function OntologyAnnotation_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_3: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_11((get$: IGetters): OntologyAnnotation => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter, arg_11: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_5: IOptionalGetter; - return new OntologyAnnotation((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("annotationValue", (s_1: string, json_1: any): FSharpResult$2_$union => AnnotationValue_decoder(options, s_1, json_1))), (objectArg_2 = get$.Optional, objectArg_2.Field("termSource", string)), bind((s_3: string): Option => { - if (s_3 === "") { - return void 0; - } - else { - return s_3; - } - }, (objectArg_3 = get$.Optional, objectArg_3.Field("termAccession", OntologyAnnotation_localIDDecoder))), (objectArg_4 = get$.Optional, objectArg_4.Field("termAccession", string)), (arg_11 = ((decoder = decoder_1(options), (path_2: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_2: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_2, value_2)))), (objectArg_5 = get$.Optional, objectArg_5.Field>("comments", uncurry2(arg_11))))); - }, path_3, v)); -} - -export function OntologyAnnotation_fromString(s: string): OntologyAnnotation { - return fromString(uncurry2(OntologyAnnotation_decoder(ConverterOptions_$ctor())), s); -} - -export function OntologyAnnotation_toString(oa: OntologyAnnotation): string { - return toString(2, OntologyAnnotation_encoder(ConverterOptions_$ctor(), oa)); -} - -/** - * exports in json-ld format - */ -export function OntologyAnnotation_toStringLD(oa: OntologyAnnotation): string { - let returnVal: ConverterOptions; - return toString(2, OntologyAnnotation_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), oa)); -} - diff --git a/ts/ISA/ISA.Json/Person.ts b/ts/ISA/ISA.Json/Person.ts deleted file mode 100644 index fdb5879f..00000000 --- a/ts/ISA/ISA.Json/Person.ts +++ /dev/null @@ -1,204 +0,0 @@ -import { value as value_31, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { choose, tryPick, FSharpList } from "../../fable_modules/fable-library-ts/List.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { Person } from "../ISA/JsonTypes/Person.js"; -import { toString as toString_1, nil, object as object_22 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { decoder as decoder_3, encoder as encoder_1 } from "./Comment.js"; -import { IGetters, list as list_1, string, IOptionalGetter, object as object_23 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { fromString as fromString_1, uri } from "./Decode.js"; -import { FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; - -export function genID(p: Person): string { - const matchValue: Option = p.ID; - if (matchValue == null) { - let orcid: Option; - const matchValue_1: Option> = p.Comments; - orcid = ((matchValue_1 == null) ? void 0 : tryPick((c: Comment$): Option => { - const matchValue_2: Option = c.Name; - const matchValue_3: Option = c.Value; - let matchResult: int32, n: string, v: string; - if (matchValue_2 != null) { - if (matchValue_3 != null) { - matchResult = 0; - n = value_31(matchValue_2); - v = value_31(matchValue_3); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - if (((n! === "orcid") ? true : (n! === "Orcid")) ? true : (n! === "ORCID")) { - return v!; - } - else { - return void 0; - } - default: - return void 0; - } - }, value_31(matchValue_1))); - if (orcid == null) { - const matchValue_5: Option = p.EMail; - if (matchValue_5 == null) { - const matchValue_6: Option = p.FirstName; - const matchValue_7: Option = p.MidInitials; - const matchValue_8: Option = p.LastName; - let matchResult_1: int32, fn: string, ln: string, mn: string, fn_1: string, ln_1: string, ln_2: string, fn_2: string; - if (matchValue_6 == null) { - if (matchValue_7 == null) { - if (matchValue_8 != null) { - matchResult_1 = 2; - ln_2 = value_31(matchValue_8); - } - else { - matchResult_1 = 4; - } - } - else { - matchResult_1 = 4; - } - } - else if (matchValue_7 == null) { - if (matchValue_8 == null) { - matchResult_1 = 3; - fn_2 = value_31(matchValue_6); - } - else { - matchResult_1 = 1; - fn_1 = value_31(matchValue_6); - ln_1 = value_31(matchValue_8); - } - } - else if (matchValue_8 != null) { - matchResult_1 = 0; - fn = value_31(matchValue_6); - ln = value_31(matchValue_8); - mn = value_31(matchValue_7); - } - else { - matchResult_1 = 4; - } - switch (matchResult_1) { - case 0: - return (((("#" + replace(fn!, " ", "_")) + "_") + replace(mn!, " ", "_")) + "_") + replace(ln!, " ", "_"); - case 1: - return (("#" + replace(fn_1!, " ", "_")) + "_") + replace(ln_1!, " ", "_"); - case 2: - return "#" + replace(ln_2!, " ", "_"); - case 3: - return "#" + replace(fn_2!, " ", "_"); - default: - return "#EmptyPerson"; - } - } - else { - return value_31(matchValue_5); - } - } - else { - return value_31(orcid); - } - } - else { - return URIModule_toString(value_31(matchValue)); - } -} - -export function encoder(options: ConverterOptions, oa: any): any { - return object_22(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = genID(oa as Person), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Person", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("firstName", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["FirstName"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("lastName", (value_10: any): any => { - let s_4: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_4 = (value_11 as string), s_4)) : nil; - }, oa["LastName"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("midInitials", (value_13: any): any => { - let s_5: string; - const value_14: any = value_13; - return (typeof value_14 === "string") ? ((s_5 = (value_14 as string), s_5)) : nil; - }, oa["MidInitials"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("email", (value_16: any): any => { - let s_6: string; - const value_17: any = value_16; - return (typeof value_17 === "string") ? ((s_6 = (value_17 as string), s_6)) : nil; - }, oa["EMail"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("phone", (value_19: any): any => { - let s_7: string; - const value_20: any = value_19; - return (typeof value_20 === "string") ? ((s_7 = (value_20 as string), s_7)) : nil; - }, oa["Phone"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("fax", (value_22: any): any => { - let s_8: string; - const value_23: any = value_22; - return (typeof value_23 === "string") ? ((s_8 = (value_23 as string), s_8)) : nil; - }, oa["Fax"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("address", (value_25: any): any => { - let s_9: string; - const value_26: any = value_25; - return (typeof value_26 === "string") ? ((s_9 = (value_26 as string), s_9)) : nil; - }, oa["Address"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("affiliation", (value_28: any): any => { - let s_10: string; - const value_29: any = value_28; - return (typeof value_29 === "string") ? ((s_10 = (value_29 as string), s_10)) : nil; - }, oa["Affiliation"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("roles", (oa_1: any): any => OntologyAnnotation_encoder(options, oa_1), oa["Roles"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder_1(options, comment), oa["Comments"])))))))))))))))))))))); - })); - })))); -} - -export function decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_10: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_23((get$: IGetters): Person => { - let objectArg_2: IOptionalGetter, objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, objectArg_6: IOptionalGetter, objectArg_7: IOptionalGetter, objectArg_8: IOptionalGetter, arg_19: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_9: IOptionalGetter, arg_21: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_2: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_10: IOptionalGetter; - let ID: Option; - const objectArg: IOptionalGetter = get$.Optional; - ID = objectArg.Field("@id", uri); - let FirstName: Option; - const objectArg_1: IOptionalGetter = get$.Optional; - FirstName = objectArg_1.Field("firstName", string); - return new Person(ID, (objectArg_2 = get$.Optional, objectArg_2.Field("lastName", string)), FirstName, (objectArg_3 = get$.Optional, objectArg_3.Field("midInitials", string)), (objectArg_4 = get$.Optional, objectArg_4.Field("email", string)), (objectArg_5 = get$.Optional, objectArg_5.Field("phone", string)), (objectArg_6 = get$.Optional, objectArg_6.Field("fax", string)), (objectArg_7 = get$.Optional, objectArg_7.Field("address", string)), (objectArg_8 = get$.Optional, objectArg_8.Field("affiliation", string)), (arg_19 = ((decoder_1 = OntologyAnnotation_decoder(options), (path_8: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_8: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_1), path_8, value_8)))), (objectArg_9 = get$.Optional, objectArg_9.Field>("roles", uncurry2(arg_19)))), (arg_21 = ((decoder_2 = decoder_3(options), (path_9: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_9: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_2), path_9, value_9)))), (objectArg_10 = get$.Optional, objectArg_10.Field>("comments", uncurry2(arg_21))))); - }, path_10, v)); -} - -export function fromString(s: string): Person { - return fromString_1(uncurry2(decoder(ConverterOptions_$ctor())), s); -} - -export function toString(p: Person): string { - return toString_1(2, encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function toStringLD(p: Person): string { - let returnVal: ConverterOptions; - return toString_1(2, encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - diff --git a/ts/ISA/ISA.Json/Process.ts b/ts/ISA/ISA.Json/Process.ts deleted file mode 100644 index b9b4e393..00000000 --- a/ts/ISA/ISA.Json/Process.ts +++ /dev/null @@ -1,301 +0,0 @@ -import { value as value_18, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { Value_getText_Z277CD705, Value_$union } from "../ISA/JsonTypes/Value.js"; -import { ProtocolParameter_getNameText_2762A46F, ProtocolParameter } from "../ISA/JsonTypes/ProtocolParameter.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { ProcessParameterValue } from "../ISA/JsonTypes/ProcessParameterValue.js"; -import { list as list_2, toString, nil, object as object_22 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { map, FSharpList, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { Protocol_decoder, Protocol_encoder, ProtocolParameter_decoder, ProtocolParameter_encoder } from "./Protocol.js"; -import { Value_decoder, Value_encoder } from "./Factor.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { list as list_1, string, IOptionalGetter, IGetters, object as object_23 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { uri, fromString } from "./Decode.js"; -import { ProcessInput_Source, ProcessInput_Sample, ProcessInput_Data, ProcessInput_Material, ProcessInput_$union, ProcessInput } from "../ISA/JsonTypes/ProcessInput.js"; -import { Data_decoder, Sample_decoder, Source_decoder, Source_encoder, Data_encoder, Sample_encoder } from "./Data.js"; -import { Material_decoder, Material_encoder } from "./Material.js"; -import { Source } from "../ISA/JsonTypes/Source.js"; -import { Sample } from "../ISA/JsonTypes/Sample.js"; -import { Data } from "../ISA/JsonTypes/Data.js"; -import { Material } from "../ISA/JsonTypes/Material.js"; -import { ProcessOutput_Sample, ProcessOutput_Data, ProcessOutput_Material, ProcessOutput_$union, ProcessOutput } from "../ISA/JsonTypes/ProcessOutput.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { Process } from "../ISA/JsonTypes/Process.js"; -import { decoder as decoder_4, encoder } from "./Comment.js"; -import { Protocol } from "../ISA/JsonTypes/Protocol.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; - -export function ProcessParameterValue_genID(p: ProcessParameterValue): string { - const matchValue: Option = p.Value; - const matchValue_1: Option = p.Category; - let matchResult: int32, c: ProtocolParameter, v: Value_$union; - if (matchValue != null) { - if (matchValue_1 != null) { - matchResult = 0; - c = value_18(matchValue_1); - v = value_18(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return (("#Param_" + replace(ProtocolParameter_getNameText_2762A46F(c!), " ", "_")) + "_") + replace(Value_getText_Z277CD705(v!), " ", "_"); - default: - return "#EmptyParameterValue"; - } -} - -export function ProcessParameterValue_encoder(options: ConverterOptions, oa: any): any { - return object_22(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = ProcessParameterValue_genID(oa as ProcessParameterValue), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => { - let value_2: any, s_1: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_2 = "ProcessParameterValue", (typeof value_2 === "string") ? ((s_1 = (value_2 as string), s_1)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("category", (oa_1: any): any => ProtocolParameter_encoder(options, oa_1), oa["Category"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("value", (value_4: any): any => Value_encoder(options, value_4), oa["Value"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("unit", (oa_2: any): any => OntologyAnnotation_encoder(options, oa_2), oa["Unit"])))))))); - })); - })))); -} - -export function ProcessParameterValue_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_23((get$: IGetters): ProcessParameterValue => { - let arg_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_2: IOptionalGetter; - return new ProcessParameterValue((arg_1 = ProtocolParameter_decoder(options), (objectArg = get$.Optional, objectArg.Field("category", uncurry2(arg_1)))), (objectArg_1 = get$.Optional, objectArg_1.Field("value", (s: string, json: any): FSharpResult$2_$union => Value_decoder(options, s, json))), (arg_5 = OntologyAnnotation_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("unit", uncurry2(arg_5))))); - }, path, v)); -} - -export function ProcessParameterValue_fromString(s: string): ProcessParameterValue { - return fromString(uncurry2(ProcessParameterValue_decoder(ConverterOptions_$ctor())), s); -} - -export function ProcessParameterValue_toString(p: ProcessParameterValue): string { - return toString(2, ProcessParameterValue_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function ProcessParameterValue_toStringLD(p: ProcessParameterValue): string { - let returnVal: ConverterOptions; - return toString(2, ProcessParameterValue_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - -export function ProcessInput_encoder(options: ConverterOptions, value: any): any { - if (value instanceof ProcessInput) { - if (value.tag === /* Sample */ 1) { - return Sample_encoder(options, (value as ProcessInput<1>).fields[0]); - } - else if (value.tag === /* Data */ 2) { - return Data_encoder(options, (value as ProcessInput<2>).fields[0]); - } - else if (value.tag === /* Material */ 3) { - return Material_encoder(options, (value as ProcessInput<3>).fields[0]); - } - else { - return Source_encoder(options, (value as ProcessInput<0>).fields[0]); - } - } - else { - return nil; - } -} - -export function ProcessInput_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - const matchValue: FSharpResult$2_$union = Source_decoder(options, s, json); - if (matchValue.tag === /* Error */ 1) { - const matchValue_1: FSharpResult$2_$union = Sample_decoder(options, s, json); - if (matchValue_1.tag === /* Error */ 1) { - const matchValue_2: FSharpResult$2_$union = Data_decoder(options, s, json); - if (matchValue_2.tag === /* Error */ 1) { - const matchValue_3: FSharpResult$2_$union = Material_decoder(options, s, json); - if (matchValue_3.tag === /* Error */ 1) { - return FSharpResult$2_Error(matchValue_3.fields[0]); - } - else { - return FSharpResult$2_Ok(ProcessInput_Material(matchValue_3.fields[0])); - } - } - else { - return FSharpResult$2_Ok(ProcessInput_Data(matchValue_2.fields[0])); - } - } - else { - return FSharpResult$2_Ok(ProcessInput_Sample(matchValue_1.fields[0])); - } - } - else { - return FSharpResult$2_Ok(ProcessInput_Source(matchValue.fields[0])); - } -} - -export function ProcessInput_fromString(s: string): ProcessInput_$union { - let options: ConverterOptions; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1: string): ((arg0: any) => FSharpResult$2_$union) => ((json: any): FSharpResult$2_$union => ProcessInput_decoder(options, s_1, json)))), s); -} - -export function ProcessInput_toString(m: ProcessInput_$union): string { - return toString(2, ProcessInput_encoder(ConverterOptions_$ctor(), m)); -} - -export function ProcessInput_toStringLD(m: ProcessInput_$union): string { - let returnVal: ConverterOptions; - return toString(2, ProcessInput_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), m)); -} - -export function ProcessOutput_encoder(options: ConverterOptions, value: any): any { - if (value instanceof ProcessOutput) { - if (value.tag === /* Data */ 1) { - return Data_encoder(options, (value as ProcessOutput<1>).fields[0]); - } - else if (value.tag === /* Material */ 2) { - return Material_encoder(options, (value as ProcessOutput<2>).fields[0]); - } - else { - return Sample_encoder(options, (value as ProcessOutput<0>).fields[0]); - } - } - else { - return nil; - } -} - -export function ProcessOutput_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - const matchValue: FSharpResult$2_$union = Sample_decoder(options, s, json); - if (matchValue.tag === /* Error */ 1) { - const matchValue_1: FSharpResult$2_$union = Data_decoder(options, s, json); - if (matchValue_1.tag === /* Error */ 1) { - const matchValue_2: FSharpResult$2_$union = Material_decoder(options, s, json); - if (matchValue_2.tag === /* Error */ 1) { - return FSharpResult$2_Error(matchValue_2.fields[0]); - } - else { - return FSharpResult$2_Ok(ProcessOutput_Material(matchValue_2.fields[0])); - } - } - else { - return FSharpResult$2_Ok(ProcessOutput_Data(matchValue_1.fields[0])); - } - } - else { - return FSharpResult$2_Ok(ProcessOutput_Sample(matchValue.fields[0])); - } -} - -export function ProcessOutput_fromString(s: string): ProcessOutput_$union { - let options: ConverterOptions; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1: string): ((arg0: any) => FSharpResult$2_$union) => ((json: any): FSharpResult$2_$union => ProcessOutput_decoder(options, s_1, json)))), s); -} - -export function ProcessOutput_toString(m: ProcessInput_$union): string { - return toString(2, ProcessOutput_encoder(ConverterOptions_$ctor(), m)); -} - -export function Process_genID(p: Process): string { - const matchValue: Option = p.ID; - if (matchValue == null) { - const matchValue_1: Option = p.Name; - if (matchValue_1 == null) { - return "#EmptyProcess"; - } - else { - return "#Process_" + replace(value_18(matchValue_1), " ", "_"); - } - } - else { - return URIModule_toString(value_18(matchValue)); - } -} - -export function Process_encoder(options: ConverterOptions, oa: any): any { - return object_22(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Process_genID(oa as Process), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Process", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("name", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["Name"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("executesProtocol", (oa_1: any): any => Protocol_encoder(options, oa_1), oa["ExecutesProtocol"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("parameterValues", (oa_2: any): any => ProcessParameterValue_encoder(options, oa_2), oa["ParameterValues"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("performer", (value_10: any): any => { - let s_4: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_4 = (value_11 as string), s_4)) : nil; - }, oa["Performer"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("date", (value_13: any): any => { - let s_5: string; - const value_14: any = value_13; - return (typeof value_14 === "string") ? ((s_5 = (value_14 as string), s_5)) : nil; - }, oa["Date"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("previousProcess", (oa_3: any): any => Process_encoder(options, oa_3), oa["PreviousProcess"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("nextProcess", (oa_4: any): any => Process_encoder(options, oa_4), oa["NextProcess"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("inputs", (value_16: any): any => ProcessInput_encoder(options, value_16), oa["Inputs"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("outputs", (value_17: any): any => ProcessOutput_encoder(options, value_17), oa["Outputs"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder(options, comment), oa["Comments"])))))))))))))))))))))); - })); - })))); -} - -export function Process_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_7: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_23((get$: IGetters): Process => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_2: IOptionalGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, arg_13: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_6: IOptionalGetter, arg_15: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_7: IOptionalGetter, objectArg_8: IOptionalGetter, objectArg_9: IOptionalGetter, arg_21: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_10: IOptionalGetter; - return new Process((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = Protocol_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("executesProtocol", uncurry2(arg_5)))), (arg_7 = ((decoder = ProcessParameterValue_decoder(options), (path_1: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_1, value_1)))), (objectArg_3 = get$.Optional, objectArg_3.Field>("parameterValues", uncurry2(arg_7)))), (objectArg_4 = get$.Optional, objectArg_4.Field("performer", string)), (objectArg_5 = get$.Optional, objectArg_5.Field("date", string)), (arg_13 = Process_decoder(options), (objectArg_6 = get$.Optional, objectArg_6.Field("previousProcess", uncurry2(arg_13)))), (arg_15 = Process_decoder(options), (objectArg_7 = get$.Optional, objectArg_7.Field("nextProcess", uncurry2(arg_15)))), (objectArg_8 = get$.Optional, objectArg_8.Field>("inputs", (path_4: string, value_4: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_1: string, json_1: any): FSharpResult$2_$union => ProcessInput_decoder(options, s_1, json_1), path_4, value_4))), (objectArg_9 = get$.Optional, objectArg_9.Field>("outputs", (path_5: string, value_5: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_2: string, json_2: any): FSharpResult$2_$union => ProcessOutput_decoder(options, s_2, json_2), path_5, value_5))), (arg_21 = ((decoder_3 = decoder_4(options), (path_6: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_6: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_3), path_6, value_6)))), (objectArg_10 = get$.Optional, objectArg_10.Field>("comments", uncurry2(arg_21))))); - }, path_7, v)); -} - -export function Process_fromString(s: string): Process { - return fromString(uncurry2(Process_decoder(ConverterOptions_$ctor())), s); -} - -export function Process_toString(p: Process): string { - return toString(2, Process_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Process_toStringLD(p: Process): string { - let returnVal: ConverterOptions; - return toString(2, Process_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - -export function ProcessSequence_fromString(s: string): FSharpList { - let decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)); - return fromString>(uncurry2((decoder = Process_decoder(ConverterOptions_$ctor()), (path: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path, value)))), s); -} - -export function ProcessSequence_toString(p: FSharpList): string { - let options: ConverterOptions; - return toString(2, list_2(map((options = ConverterOptions_$ctor(), (oa: Process): any => Process_encoder(options, oa)), p))); -} - -/** - * exports in json-ld format - */ -export function ProcessSequence_toStringLD(p: FSharpList): string { - let options: ConverterOptions, returnVal: ConverterOptions; - return toString(2, list_2(map((options = ((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal))), (oa: Process): any => Process_encoder(options, oa)), p))); -} - diff --git a/ts/ISA/ISA.Json/Protocol.ts b/ts/ISA/ISA.Json/Protocol.ts deleted file mode 100644 index 9dd34916..00000000 --- a/ts/ISA/ISA.Json/Protocol.ts +++ /dev/null @@ -1,247 +0,0 @@ -import { value as value_19, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { ProtocolParameter } from "../ISA/JsonTypes/ProtocolParameter.js"; -import { toString, nil, object as object_18 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { FSharpList, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { list as list_1, string, IOptionalGetter, IGetters, object as object_19 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { fromString, uri } from "./Decode.js"; -import { Result_Map, FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { Component_decomposeName_Z721C83C5, Component } from "../ISA/JsonTypes/Component.js"; -import { Value_$union } from "../ISA/JsonTypes/Value.js"; -import { Protocol } from "../ISA/JsonTypes/Protocol.js"; -import { decoder as decoder_3, encoder } from "./Comment.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; - -export function ProtocolParameter_genID(pp: ProtocolParameter): string { - const matchValue: Option = pp.ID; - if (matchValue == null) { - const matchValue_1: Option = pp.ParameterName; - let matchResult: int32, n_1: OntologyAnnotation; - if (matchValue_1 != null) { - if (!(value_19(matchValue_1).ID == null)) { - matchResult = 0; - n_1 = value_19(matchValue_1); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return "#Param_" + value_19(n_1!.ID); - default: - return "#EmptyProtocolParameter"; - } - } - else { - return URIModule_toString(value_19(matchValue)); - } -} - -export function ProtocolParameter_encoder(options: ConverterOptions, oa: any): any { - return object_18(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = ProtocolParameter_genID(oa as ProtocolParameter), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "ProtocolParameter", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("parameterName", (oa_1: any): any => OntologyAnnotation_encoder(options, oa_1), oa["ParameterName"])))); - })); - })))); -} - -export function ProtocolParameter_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_19((get$: IGetters): ProtocolParameter => { - let objectArg: IOptionalGetter, arg_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_1: IOptionalGetter; - return new ProtocolParameter((objectArg = get$.Optional, objectArg.Field("@id", uri)), (arg_3 = OntologyAnnotation_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("parameterName", uncurry2(arg_3))))); - }, path, v)); -} - -export function ProtocolParameter_fromString(s: string): ProtocolParameter { - return fromString(uncurry2(ProtocolParameter_decoder(ConverterOptions_$ctor())), s); -} - -export function ProtocolParameter_toString(p: ProtocolParameter): string { - return toString(2, ProtocolParameter_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function ProtocolParameter_toStringLD(p: ProtocolParameter): string { - let returnVal: ConverterOptions; - return toString(2, ProtocolParameter_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - -export function Component_genID(c: Component): string { - const matchValue: Option = c.ComponentName; - if (matchValue == null) { - return "#EmptyComponent"; - } - else { - return "#Component_" + replace(value_19(matchValue), " ", "_"); - } -} - -export function Component_encoder(options: ConverterOptions, oa: any): any { - return object_18(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Component_genID(oa as Component), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => { - let value_2: any, s_1: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_2 = "Component", (typeof value_2 === "string") ? ((s_1 = (value_2 as string), s_1)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("componentName", (value_4: any): any => { - let s_2: string; - const value_5: any = value_4; - return (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil; - }, oa["ComponentName"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("componentType", (oa_1: any): any => OntologyAnnotation_encoder(options, oa_1), oa["ComponentType"])))))); - })); - })))); -} - -export function Component_decoder(options: ConverterOptions, s: string, json: any): FSharpResult$2_$union { - return Result_Map((c: Component): Component => { - let patternInput: [Option, Option]; - const matchValue: Option = c.ComponentName; - if (matchValue == null) { - patternInput = ([void 0, void 0] as [Option, Option]); - } - else { - const tupledArg: [Value_$union, Option] = Component_decomposeName_Z721C83C5(value_19(matchValue)); - patternInput = ([tupledArg[0], tupledArg[1]] as [Option, Option]); - } - return new Component(c.ComponentName, patternInput[0], patternInput[1], c.ComponentType); - }, object_19((get$: IGetters): Component => { - let objectArg: IOptionalGetter, arg_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_1: IOptionalGetter; - return new Component((objectArg = get$.Optional, objectArg.Field("componentName", uri)), void 0, void 0, (arg_3 = OntologyAnnotation_decoder(options), (objectArg_1 = get$.Optional, objectArg_1.Field("componentType", uncurry2(arg_3))))); - }, s, json)); -} - -export function Component_fromString(s: string): Component { - let options: ConverterOptions; - return fromString(uncurry2((options = ConverterOptions_$ctor(), (s_1: string): ((arg0: any) => FSharpResult$2_$union) => ((json: any): FSharpResult$2_$union => Component_decoder(options, s_1, json)))), s); -} - -export function Component_toString(p: Component): string { - return toString(2, Component_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Component_toStringLD(p: Component): string { - let returnVal: ConverterOptions; - return toString(2, Component_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - -export function Protocol_genID(p: Protocol): string { - const matchValue: Option = p.ID; - if (matchValue == null) { - const matchValue_1: Option = p.Uri; - if (matchValue_1 == null) { - const matchValue_2: Option = p.Name; - if (matchValue_2 == null) { - return "#EmptyProtocol"; - } - else { - return "#Protocol_" + replace(value_19(matchValue_2), " ", "_"); - } - } - else { - return value_19(matchValue_1); - } - } - else { - return URIModule_toString(value_19(matchValue)); - } -} - -export function Protocol_encoder(options: ConverterOptions, oa: any): any { - return object_18(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Protocol_genID(oa as Protocol), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_1: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_1 = (value_3 as string), s_1)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_2: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Protocol", (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("name", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["Name"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("protocolType", (oa_1: any): any => OntologyAnnotation_encoder(options, oa_1), oa["ProtocolType"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("description", (value_10: any): any => { - let s_4: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_4 = (value_11 as string), s_4)) : nil; - }, oa["Description"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("uri", (value_13: any): any => { - let s_5: string; - const value_14: any = value_13; - return (typeof value_14 === "string") ? ((s_5 = (value_14 as string), s_5)) : nil; - }, oa["Uri"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("version", (value_16: any): any => { - let s_6: string; - const value_17: any = value_16; - return (typeof value_17 === "string") ? ((s_6 = (value_17 as string), s_6)) : nil; - }, oa["Version"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("parameters", (oa_2: any): any => ProtocolParameter_encoder(options, oa_2), oa["Parameters"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("components", (oa_3: any): any => Component_encoder(options, oa_3), oa["Components"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder(options, comment), oa["Comments"])))))))))))))))))); - })); - })))); -} - -export function Protocol_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_6: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_19((get$: IGetters): Protocol => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_2: IOptionalGetter, objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, arg_13: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_6: IOptionalGetter, objectArg_7: IOptionalGetter, arg_17: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_2: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_8: IOptionalGetter; - return new Protocol((objectArg = get$.Optional, objectArg.Field("@id", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = OntologyAnnotation_decoder(options), (objectArg_2 = get$.Optional, objectArg_2.Field("protocolType", uncurry2(arg_5)))), (objectArg_3 = get$.Optional, objectArg_3.Field("description", string)), (objectArg_4 = get$.Optional, objectArg_4.Field("uri", uri)), (objectArg_5 = get$.Optional, objectArg_5.Field("version", string)), (arg_13 = ((decoder = ProtocolParameter_decoder(options), (path_3: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_3: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_3, value_3)))), (objectArg_6 = get$.Optional, objectArg_6.Field>("parameters", uncurry2(arg_13)))), (objectArg_7 = get$.Optional, objectArg_7.Field>("components", (path_4: string, value_4: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_2: string, json_2: any): FSharpResult$2_$union => Component_decoder(options, s_2, json_2), path_4, value_4))), (arg_17 = ((decoder_2 = decoder_3(options), (path_5: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_5: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_2), path_5, value_5)))), (objectArg_8 = get$.Optional, objectArg_8.Field>("comments", uncurry2(arg_17))))); - }, path_6, v)); -} - -export function Protocol_fromString(s: string): Protocol { - return fromString(uncurry2(Protocol_decoder(ConverterOptions_$ctor())), s); -} - -export function Protocol_toString(p: Protocol): string { - return toString(2, Protocol_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Protocol_toStringLD(p: Protocol): string { - let returnVal: ConverterOptions; - return toString(2, Protocol_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - diff --git a/ts/ISA/ISA.Json/Publication.ts b/ts/ISA/ISA.Json/Publication.ts deleted file mode 100644 index 3da70c7f..00000000 --- a/ts/ISA/ISA.Json/Publication.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { value as value_16, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { Publication } from "../ISA/JsonTypes/Publication.js"; -import { toString as toString_1, nil, object as object_12 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { FSharpList, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID } from "./ConverterOptions.js"; -import { tryInclude } from "./GEncode.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { decoder as decoder_2, encoder as encoder_1 } from "./Comment.js"; -import { IOptionalGetter, IGetters, list as list_1, string, object as object_13 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { fromString as fromString_1, uri } from "./Decode.js"; -import { FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; - -export function genID(p: Publication): string { - const matchValue: Option = p.DOI; - if (matchValue == null) { - const matchValue_1: Option = p.PubMedID; - if (matchValue_1 == null) { - const matchValue_2: Option = p.Title; - if (matchValue_2 == null) { - return "#EmptyPublication"; - } - else { - return "#Pub_" + replace(value_16(matchValue_2), " ", "_"); - } - } - else { - return value_16(matchValue_1); - } - } - else { - return value_16(matchValue); - } -} - -export function encoder(options: ConverterOptions, oa: any): any { - return object_12(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = genID(oa as Publication), (typeof value === "string") ? ((s = (value as string), s)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => { - let value_2: any, s_1: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_2 = "Publication", (typeof value_2 === "string") ? ((s_1 = (value_2 as string), s_1)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("pubMedID", (value_4: any): any => { - let s_2: string; - const value_5: any = value_4; - return (typeof value_5 === "string") ? ((s_2 = (value_5 as string), s_2)) : nil; - }, oa["PubMedID"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("doi", (value_7: any): any => { - let s_3: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_3 = (value_8 as string), s_3)) : nil; - }, oa["DOI"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("authorList", (value_10: any): any => { - let s_4: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_4 = (value_11 as string), s_4)) : nil; - }, oa["Authors"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("title", (value_13: any): any => { - let s_5: string; - const value_14: any = value_13; - return (typeof value_14 === "string") ? ((s_5 = (value_14 as string), s_5)) : nil; - }, oa["Title"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("status", (oa_1: any): any => OntologyAnnotation_encoder(options, oa_1), oa["Status"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder_1(options, comment), oa["Comments"])))))))))))))); - })); - })))); -} - -export function decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_4: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_13((get$: IGetters): Publication => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, objectArg_3: IOptionalGetter, arg_9: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_4: IOptionalGetter, arg_11: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_5: IOptionalGetter; - return new Publication((objectArg = get$.Optional, objectArg.Field("pubMedID", uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("doi", string)), (objectArg_2 = get$.Optional, objectArg_2.Field("authorList", string)), (objectArg_3 = get$.Optional, objectArg_3.Field("title", string)), (arg_9 = OntologyAnnotation_decoder(options), (objectArg_4 = get$.Optional, objectArg_4.Field("status", uncurry2(arg_9)))), (arg_11 = ((decoder_1 = decoder_2(options), (path_3: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_3: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_1), path_3, value_3)))), (objectArg_5 = get$.Optional, objectArg_5.Field>("comments", uncurry2(arg_11))))); - }, path_4, v)); -} - -export function fromString(s: string): Publication { - return fromString_1(uncurry2(decoder(ConverterOptions_$ctor())), s); -} - -export function toString(p: Publication): string { - return toString_1(2, encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function toStringLD(p: Publication): string { - let returnVal: ConverterOptions; - return toString_1(2, encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), p)); -} - diff --git a/ts/ISA/ISA.Json/Study.ts b/ts/ISA/ISA.Json/Study.ts deleted file mode 100644 index 3809718d..00000000 --- a/ts/ISA/ISA.Json/Study.ts +++ /dev/null @@ -1,245 +0,0 @@ -import { toString, nil, object as object_36 } from "../../fable_modules/Thoth.Json.10.1.0/Encode.fs.js"; -import { FSharpList, ofArray, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { uncurry2, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { value as value_25, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { tryInclude } from "./GEncode.js"; -import { Sample_decoder, Source_decoder, Sample_encoder, Source_encoder } from "./Data.js"; -import { MaterialAttribute_decoder, MaterialAttribute_encoder, Material_decoder, Material_encoder } from "./Material.js"; -import { ConverterOptions__set_IncludeType_Z1FBCCD16, ConverterOptions__set_SetID_Z1FBCCD16, ConverterOptions_$ctor, ConverterOptions__get_IncludeType, ConverterOptions__get_SetID, ConverterOptions } from "./ConverterOptions.js"; -import { string, IOptionalGetter, IGetters, list as list_1, object as object_37 } from "../../fable_modules/Thoth.Json.10.1.0/Decode.fs.js"; -import { FSharpResult$2_$union } from "../../fable_modules/fable-library-ts/Choice.js"; -import { Source } from "../ISA/JsonTypes/Source.js"; -import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.1.0/Types.fs.js"; -import { Sample } from "../ISA/JsonTypes/Sample.js"; -import { Material } from "../ISA/JsonTypes/Material.js"; -import { StudyMaterials } from "../ISA/JsonTypes/StudyMaterials.js"; -import { replace } from "../../fable_modules/fable-library-ts/String.js"; -import { URIModule_toString } from "../ISA/JsonTypes/URI.js"; -import { Study } from "../ISA/JsonTypes/Study.js"; -import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; -import { decoder as decoder_10, encoder } from "./Publication.js"; -import { decoder as decoder_11, encoder as encoder_1 } from "./Person.js"; -import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "./Ontology.js"; -import { Protocol_decoder, Protocol_encoder } from "./Protocol.js"; -import { Process_decoder, Process_encoder } from "./Process.js"; -import { Assay_decoder, Assay_encoder } from "./Assay.js"; -import { Factor_decoder, Factor_encoder } from "./Factor.js"; -import { decoder as decoder_12, encoder as encoder_2 } from "./Comment.js"; -import { fromString, uri } from "./Decode.js"; -import { Publication } from "../ISA/JsonTypes/Publication.js"; -import { Person } from "../ISA/JsonTypes/Person.js"; -import { OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { Protocol } from "../ISA/JsonTypes/Protocol.js"; -import { Assay } from "../ISA/JsonTypes/Assay.js"; -import { Factor } from "../ISA/JsonTypes/Factor.js"; -import { MaterialAttribute } from "../ISA/JsonTypes/MaterialAttribute.js"; -import { Process } from "../ISA/JsonTypes/Process.js"; -import { Comment$ } from "../ISA/JsonTypes/Comment.js"; -import { ArcStudy } from "../ISA/ArcTypes/ArcStudy.js"; - -export function StudyMaterials_encoder(options: ConverterOptions, oa: any): any { - return object_36(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, ofArray([tryInclude("sources", (oa_1: any): any => Source_encoder(options, oa_1), oa["Sources"]), tryInclude("samples", (oa_2: any): any => Sample_encoder(options, oa_2), oa["Samples"]), tryInclude("otherMaterials", (oa_3: any): any => Material_encoder(options, oa_3), oa["OtherMaterials"])]))); -} - -export function StudyMaterials_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_3: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_37((get$: IGetters): StudyMaterials => { - let objectArg: IOptionalGetter, objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter; - return new StudyMaterials((objectArg = get$.Optional, objectArg.Field>("sources", (path: string, value: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s: string, json: any): FSharpResult$2_$union => Source_decoder(options, s, json), path, value))), (objectArg_1 = get$.Optional, objectArg_1.Field>("samples", (path_1: string, value_1: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_1: string, json_1: any): FSharpResult$2_$union => Sample_decoder(options, s_1, json_1), path_1, value_1))), (objectArg_2 = get$.Optional, objectArg_2.Field>("otherMaterials", (path_2: string, value_2: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1((s_2: string, json_2: any): FSharpResult$2_$union => Material_decoder(options, s_2, json_2), path_2, value_2)))); - }, path_3, v)); -} - -export function Study_genID(s: Study): string { - const matchValue: Option = s.ID; - if (matchValue == null) { - const matchValue_1: Option = s.FileName; - if (matchValue_1 == null) { - const matchValue_2: Option = s.Identifier; - if (matchValue_2 == null) { - const matchValue_3: Option = s.Title; - if (matchValue_3 == null) { - return "#EmptyStudy"; - } - else { - return "#Study_" + replace(value_25(matchValue_3), " ", "_"); - } - } - else { - return "#Study_" + replace(value_25(matchValue_2), " ", "_"); - } - } - else { - return "#Study" + replace(value_25(matchValue_1), " ", "_"); - } - } - else { - return URIModule_toString(value_25(matchValue)); - } -} - -export function Study_encoder(options: ConverterOptions, oa: any): any { - return object_36(choose<[string, any], [string, any]>((tupledArg: [string, any]): Option<[string, any]> => { - const v: any = tupledArg[1]; - if (equals(v, nil)) { - return void 0; - } - else { - return [tupledArg[0], v] as [string, any]; - } - }, toList<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => { - let value: any, s_1: string; - return append<[string, any]>(ConverterOptions__get_SetID(options) ? singleton<[string, any]>(["@id", (value = Study_genID(oa as Study), (typeof value === "string") ? ((s_1 = (value as string), s_1)) : nil)] as [string, any]) : singleton<[string, any]>(tryInclude("@id", (value_2: any): any => { - let s_2: string; - const value_3: any = value_2; - return (typeof value_3 === "string") ? ((s_2 = (value_3 as string), s_2)) : nil; - }, oa["ID"])), delay<[string, any]>((): Iterable<[string, any]> => { - let value_5: any, s_3: string; - return append<[string, any]>(ConverterOptions__get_IncludeType(options) ? singleton<[string, any]>(["@type", (value_5 = "Study", (typeof value_5 === "string") ? ((s_3 = (value_5 as string), s_3)) : nil)] as [string, any]) : empty<[string, any]>(), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("filename", (value_7: any): any => { - let s_4: string; - const value_8: any = value_7; - return (typeof value_8 === "string") ? ((s_4 = (value_8 as string), s_4)) : nil; - }, oa["FileName"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("identifier", (value_10: any): any => { - let s_5: string; - const value_11: any = value_10; - return (typeof value_11 === "string") ? ((s_5 = (value_11 as string), s_5)) : nil; - }, oa["Identifier"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("title", (value_13: any): any => { - let s_6: string; - const value_14: any = value_13; - return (typeof value_14 === "string") ? ((s_6 = (value_14 as string), s_6)) : nil; - }, oa["Title"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("description", (value_16: any): any => { - let s_7: string; - const value_17: any = value_16; - return (typeof value_17 === "string") ? ((s_7 = (value_17 as string), s_7)) : nil; - }, oa["Description"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("submissionDate", (value_19: any): any => { - let s_8: string; - const value_20: any = value_19; - return (typeof value_20 === "string") ? ((s_8 = (value_20 as string), s_8)) : nil; - }, oa["SubmissionDate"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("publicReleaseDate", (value_22: any): any => { - let s_9: string; - const value_23: any = value_22; - return (typeof value_23 === "string") ? ((s_9 = (value_23 as string), s_9)) : nil; - }, oa["PublicReleaseDate"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("publications", (oa_1: any): any => encoder(options, oa_1), oa["Publications"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("people", (oa_2: any): any => encoder_1(options, oa_2), oa["Contacts"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("studyDesignDescriptors", (oa_3: any): any => OntologyAnnotation_encoder(options, oa_3), oa["StudyDesignDescriptors"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("protocols", (oa_4: any): any => Protocol_encoder(options, oa_4), oa["Protocols"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("materials", (oa_5: any): any => StudyMaterials_encoder(options, oa_5), oa["Materials"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("processSequence", (oa_6: any): any => Process_encoder(options, oa_6), oa["ProcessSequence"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("assays", (oa_7: any): any => Assay_encoder(options, oa_7), oa["Assays"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("factors", (oa_8: any): any => Factor_encoder(options, oa_8), oa["Factors"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("characteristicCategories", (oa_9: any): any => MaterialAttribute_encoder(options, oa_9), oa["CharacteristicCategories"])), delay<[string, any]>((): Iterable<[string, any]> => append<[string, any]>(singleton<[string, any]>(tryInclude("unitCategories", (oa_10: any): any => OntologyAnnotation_encoder(options, oa_10), oa["UnitCategories"])), delay<[string, any]>((): Iterable<[string, any]> => singleton<[string, any]>(tryInclude("comments", (comment: any): any => encoder_2(options, comment), oa["Comments"])))))))))))))))))))))))))))))))))))); - })); - })))); -} - -export function Study_decoder(options: ConverterOptions): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) { - return (path_16: string): ((arg0: any) => FSharpResult$2_$union) => ((v: any): FSharpResult$2_$union => object_37((get$: IGetters): Study => { - let arg_33: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_8: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_16: IOptionalGetter, arg_35: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)), decoder_9: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)), objectArg_17: IOptionalGetter; - let ID: Option; - const objectArg: IOptionalGetter = get$.Optional; - ID = objectArg.Field("@id", uri); - let FileName: Option; - const objectArg_1: IOptionalGetter = get$.Optional; - FileName = objectArg_1.Field("filename", string); - let Identifier: Option; - const objectArg_2: IOptionalGetter = get$.Optional; - Identifier = objectArg_2.Field("identifier", string); - let Title: Option; - const objectArg_3: IOptionalGetter = get$.Optional; - Title = objectArg_3.Field("title", string); - let Description: Option; - const objectArg_4: IOptionalGetter = get$.Optional; - Description = objectArg_4.Field("description", string); - let SubmissionDate: Option; - const objectArg_5: IOptionalGetter = get$.Optional; - SubmissionDate = objectArg_5.Field("submissionDate", string); - let PublicReleaseDate: Option; - const objectArg_6: IOptionalGetter = get$.Optional; - PublicReleaseDate = objectArg_6.Field("publicReleaseDate", string); - let Publications: Option>; - let arg_15: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)); - const decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = decoder_10(options); - arg_15 = ((path_6: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_6: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder), path_6, value_6))); - const objectArg_7: IOptionalGetter = get$.Optional; - Publications = objectArg_7.Field>("publications", uncurry2(arg_15)); - let Contacts: Option>; - let arg_17: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)); - const decoder_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = decoder_11(options); - arg_17 = ((path_7: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_7: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_1), path_7, value_7))); - const objectArg_8: IOptionalGetter = get$.Optional; - Contacts = objectArg_8.Field>("people", uncurry2(arg_17)); - let StudyDesignDescriptors: Option>; - let arg_19: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)); - const decoder_2: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = OntologyAnnotation_decoder(options); - arg_19 = ((path_8: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_8: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_2), path_8, value_8))); - const objectArg_9: IOptionalGetter = get$.Optional; - StudyDesignDescriptors = objectArg_9.Field>("studyDesignDescriptors", uncurry2(arg_19)); - let Protocols: Option>; - let arg_21: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)); - const decoder_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = Protocol_decoder(options); - arg_21 = ((path_9: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_9: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_3), path_9, value_9))); - const objectArg_10: IOptionalGetter = get$.Optional; - Protocols = objectArg_10.Field>("protocols", uncurry2(arg_21)); - let Materials: Option; - const arg_23: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = StudyMaterials_decoder(options); - const objectArg_11: IOptionalGetter = get$.Optional; - Materials = objectArg_11.Field("materials", uncurry2(arg_23)); - let Assays: Option>; - let arg_25: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)); - const decoder_4: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = Assay_decoder(options); - arg_25 = ((path_10: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_10: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_4), path_10, value_10))); - const objectArg_12: IOptionalGetter = get$.Optional; - Assays = objectArg_12.Field>("assays", uncurry2(arg_25)); - let Factors: Option>; - let arg_27: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)); - const decoder_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = Factor_decoder(options); - arg_27 = ((path_11: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_11: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_5), path_11, value_11))); - const objectArg_13: IOptionalGetter = get$.Optional; - Factors = objectArg_13.Field>("factors", uncurry2(arg_27)); - let CharacteristicCategories: Option>; - let arg_29: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)); - const decoder_6: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = MaterialAttribute_decoder(options); - arg_29 = ((path_12: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_12: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_6), path_12, value_12))); - const objectArg_14: IOptionalGetter = get$.Optional; - CharacteristicCategories = objectArg_14.Field>("characteristicCategories", uncurry2(arg_29)); - let UnitCategories: Option>; - let arg_31: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>)); - const decoder_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union)) = OntologyAnnotation_decoder(options); - arg_31 = ((path_13: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_13: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_7), path_13, value_13))); - const objectArg_15: IOptionalGetter = get$.Optional; - UnitCategories = objectArg_15.Field>("unitCategories", uncurry2(arg_31)); - return new Study(ID, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, Publications, Contacts, StudyDesignDescriptors, Protocols, Materials, (arg_33 = ((decoder_8 = Process_decoder(options), (path_14: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_14: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_8), path_14, value_14)))), (objectArg_16 = get$.Optional, objectArg_16.Field>("processSequence", uncurry2(arg_33)))), Assays, Factors, CharacteristicCategories, UnitCategories, (arg_35 = ((decoder_9 = decoder_12(options), (path_15: string): ((arg0: any) => FSharpResult$2_$union, [string, ErrorReason_$union]>) => ((value_15: any): FSharpResult$2_$union, [string, ErrorReason_$union]> => list_1(uncurry2(decoder_9), path_15, value_15)))), (objectArg_17 = get$.Optional, objectArg_17.Field>("comments", uncurry2(arg_35))))); - }, path_16, v)); -} - -export function Study_fromString(s: string): Study { - return fromString(uncurry2(Study_decoder(ConverterOptions_$ctor())), s); -} - -export function Study_toString(p: Study): string { - return toString(2, Study_encoder(ConverterOptions_$ctor(), p)); -} - -/** - * exports in json-ld format - */ -export function Study_toStringLD(s: Study): string { - let returnVal: ConverterOptions; - return toString(2, Study_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), s)); -} - -export function ArcStudy_fromString(s: string): ArcStudy { - const arg: Study = fromString(uncurry2(Study_decoder(ConverterOptions_$ctor())), s); - return ArcStudy.fromStudy(arg); -} - -export function ArcStudy_toString(a: ArcStudy): string { - return toString(2, Study_encoder(ConverterOptions_$ctor(), a.ToStudy())); -} - -/** - * exports in json-ld format - */ -export function ArcStudy_toStringLD(a: ArcStudy): string { - let returnVal: ConverterOptions; - return toString(2, Study_encoder((returnVal = ConverterOptions_$ctor(), ((ConverterOptions__set_SetID_Z1FBCCD16(returnVal, true), ConverterOptions__set_IncludeType_Z1FBCCD16(returnVal, true)), returnVal)), a.ToStudy())); -} - diff --git a/ts/ISA/ISA.Json/Validation/Fable.ts b/ts/ISA/ISA.Json/Validation/Fable.ts deleted file mode 100644 index d5109eee..00000000 --- a/ts/ISA/ISA.Json/Validation/Fable.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { bool_type, option_type, array_type, record_type, string_type, obj_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { value, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { map } from "../../../fable_modules/fable-library-ts/Array.js"; -import { singleton } from "../../../fable_modules/fable-library-ts/AsyncBuilder.js"; -import { awaitPromise } from "../../../fable_modules/fable-library-ts/Async.js"; -import * as JsonValidation from "../../../../src/ISA/ISA.Json/Validation/JsonValidation.js"; - -export class ValidationError extends Record implements IEquatable { - readonly path: any; - readonly property: string; - readonly message: string; - readonly schema: any; - readonly instance: any; - readonly name: string; - readonly argument: any; - readonly stack: string; - constructor(path: any, property: string, message: string, schema: any, instance: any, name: string, argument: any, stack: string) { - super(); - this.path = path; - this.property = property; - this.message = message; - this.schema = schema; - this.instance = instance; - this.name = name; - this.argument = argument; - this.stack = stack; - } -} - -export function ValidationError_$reflection(): TypeInfo { - return record_type("ISA.Json.Fable.ValidationError", [], ValidationError, () => [["path", obj_type], ["property", string_type], ["message", string_type], ["schema", obj_type], ["instance", obj_type], ["name", string_type], ["argument", obj_type], ["stack", string_type]]); -} - -export function ValidationError__ToErrorString(this$: ValidationError): string { - return `Property ${this$.property} (${this$.instance}) ${this$.message}.`; -} - -export class ValidatorResult extends Record implements IEquatable { - readonly instance: any; - readonly schema: any; - readonly options: any; - readonly path: any[]; - readonly propertyPath: string; - readonly errors: ValidationError[]; - readonly throwError: Option; - readonly throFirst: Option; - readonly throwAll: Option; - readonly disableFormat: boolean; - constructor(instance: any, schema: any, options: any, path: any[], propertyPath: string, errors: ValidationError[], throwError: Option, throFirst: Option, throwAll: Option, disableFormat: boolean) { - super(); - this.instance = instance; - this.schema = schema; - this.options = options; - this.path = path; - this.propertyPath = propertyPath; - this.errors = errors; - this.throwError = throwError; - this.throFirst = throFirst; - this.throwAll = throwAll; - this.disableFormat = disableFormat; - } -} - -export function ValidatorResult_$reflection(): TypeInfo { - return record_type("ISA.Json.Fable.ValidatorResult", [], ValidatorResult, () => [["instance", obj_type], ["schema", obj_type], ["options", obj_type], ["path", array_type(obj_type)], ["propertyPath", string_type], ["errors", array_type(ValidationError_$reflection())], ["throwError", option_type(obj_type)], ["throFirst", option_type(obj_type)], ["throwAll", option_type(obj_type)], ["disableFormat", bool_type]]); -} - -export function ValidatorResult__ToValidationResult(this$: ValidatorResult): [boolean, string[]] { - if (this$.errors.length === 0) { - return [true, []] as [boolean, string[]]; - } - else { - return [false, map(ValidationError__ToErrorString, this$.errors)] as [boolean, string[]]; - } -} - -export interface IValidate { - helloWorld(): string, - validateAgainstSchema(jsonString: string, schemaUrl: string): Promise -} - -export function validate(schemaURL: string, objectString: string): any { - let validationResult: Option = void 0; - return singleton.Delay<[boolean, string[]]>((): any => singleton.Bind(awaitPromise(JsonValidation.validateAgainstSchema(objectString, schemaURL).then((o: ValidatorResult): void => { - validationResult = o; - })), (): any => { - const output: [boolean, string[]] = ValidatorResult__ToValidationResult(value(validationResult)); - return singleton.Return<[boolean, string[]]>(output); - })); -} - diff --git a/ts/ISA/ISA.Json/Validation/JsonSchemaValidation.ts b/ts/ISA/ISA.Json/Validation/JsonSchemaValidation.ts deleted file mode 100644 index b020288d..00000000 --- a/ts/ISA/ISA.Json/Validation/JsonSchemaValidation.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { singleton } from "../../../fable_modules/fable-library-ts/AsyncBuilder.js"; -import { validate } from "./Fable.js"; -import { ValidationResult_Failed, ValidationResult_$union, ValidationResult_OfJSchemaOutput_Z6EC48F6B } from "./ValidationResult.js"; - -export function Validation_validate(schemaURL: string, objectString: string): any { - return singleton.Delay((): any => singleton.TryWith(singleton.Delay((): any => singleton.Bind<[boolean, string[]], ValidationResult_$union>(validate(schemaURL, objectString), (_arg: [boolean, string[]]): any => singleton.Return(ValidationResult_OfJSchemaOutput_Z6EC48F6B([_arg[0], _arg[1]] as [boolean, string[]])))), (_arg_1: Error): any => singleton.Return(ValidationResult_Failed([_arg_1.message])))); -} - -export function Validation_validateAssay(assayString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/assay_schema.json", assayString); -} - -export function Validation_validateComment(commentString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/comment_schema.json", commentString); -} - -export function Validation_validateData(dataString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/data_schema.json", dataString); -} - -export function Validation_validateFactor(factorString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/factor_schema.json", factorString); -} - -export function Validation_validateFactorValue(factorValueString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/factor_value_schema.json", factorValueString); -} - -export function Validation_validateInvestigation(investigationString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/investigation_schema.json", investigationString); -} - -export function Validation_validateMaterialAttribute(materialAttributeString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/material_attribute_schema.json", materialAttributeString); -} - -export function Validation_validateMaterialAttributeValue(materialAttributeValueString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/material_attribute_value_schema.json", materialAttributeValueString); -} - -export function Validation_validateMaterial(materialString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/material_schema.json", materialString); -} - -export function Validation_validateOntologyAnnotation(ontologyAnnotationString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/ontology_annotation_schema.json", ontologyAnnotationString); -} - -export function Validation_validateOntologySourceReference(ontologySourceReferenceString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/ontology_source_reference_schema.json", ontologySourceReferenceString); -} - -export function Validation_validatePerson(personString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/person_schema.json", personString); -} - -export function Validation_validateProcessParameterValue(processParameterValueString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/process_parameter_value_schema.json", processParameterValueString); -} - -export function Validation_validateProcess(processString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/process_schema.json", processString); -} - -export function Validation_validateProtocolParameter(protocolParameterString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/protocol_parameter_schema.json", protocolParameterString); -} - -export function Validation_validateProtocol(protocolString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/protocol_schema.json", protocolString); -} - -export function Validation_validatePublication(publicationString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/publication_schema.json", publicationString); -} - -export function Validation_validateSample(sampleString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/sample_schema.json", sampleString); -} - -export function Validation_validateSource(sourceString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/source_schema.json", sourceString); -} - -export function Validation_validateStudy(studyString: string): any { - return Validation_validate("https://raw.githubusercontent.com/HLWeil/isa-specs/anyof/source/_static/isajson/study_schema.json", studyString); -} - diff --git a/ts/ISA/ISA.Json/Validation/ValidationResult.ts b/ts/ISA/ISA.Json/Validation/ValidationResult.ts deleted file mode 100644 index c300a6e5..00000000 --- a/ts/ISA/ISA.Json/Validation/ValidationResult.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library-ts/Types.js"; -import { union_type, array_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export type ValidationResult_$union = - | ValidationResult<0> - | ValidationResult<1> - -export type ValidationResult_$cases = { - 0: ["Ok", []], - 1: ["Failed", [string[]]] -} - -export function ValidationResult_Ok() { - return new ValidationResult<0>(0, []); -} - -export function ValidationResult_Failed(Item: string[]) { - return new ValidationResult<1>(1, [Item]); -} - -export class ValidationResult extends Union { - constructor(readonly tag: Tag, readonly fields: ValidationResult_$cases[Tag][1]) { - super(); - } - cases() { - return ["Ok", "Failed"]; - } -} - -export function ValidationResult_$reflection(): TypeInfo { - return union_type("ISA.Json.ValidationTypes.ValidationResult", [], ValidationResult, () => [[], [["Item", array_type(string_type)]]]); -} - -export function ValidationResult__get_Success(this$: ValidationResult_$union): boolean { - if (this$.tag === /* Ok */ 0) { - return true; - } - else { - return false; - } -} - -export function ValidationResult__GetErrors(this$: ValidationResult_$union): string[] { - if (this$.tag === /* Failed */ 1) { - return this$.fields[0]; - } - else { - return []; - } -} - -export function ValidationResult_OfJSchemaOutput_Z6EC48F6B(output: [boolean, string[]]): ValidationResult_$union { - if (output[0]) { - return ValidationResult_Ok(); - } - else { - return ValidationResult_Failed(output[1]); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/ArcAssay.ts b/ts/ISA/ISA.Spreadsheet/ArcAssay.ts deleted file mode 100644 index 51a4b743..00000000 --- a/ts/ISA/ISA.Spreadsheet/ArcAssay.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { FsWorksheet } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { iterate, tryHead, head, exists, map, singleton, append, delay, iterateIndexed } from "../../fable_modules/fable-library-ts/Seq.js"; -import { SparseRowModule_tryGetValueAt, SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_writeToSheet } from "./SparseTable.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { fromRows as fromRows_1, toRows as toRows_1 } from "./InvestigationFile/Assays.js"; -import { choose, empty, isEmpty, FSharpList, singleton as singleton_1 } from "../../fable_modules/fable-library-ts/List.js"; -import { fromRows as fromRows_2, toRows as toRows_2 } from "./InvestigationFile/Contacts.js"; -import { ArcAssay } from "../ISA/ArcTypes/ArcAssay.js"; -import { FsRow } from "../../fable_modules/FsSpreadsheet.3.1.1/FsRow.fs.js"; -import { value as value_1, defaultArg, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { IEnumerator, getEnumerator } from "../../fable_modules/fable-library-ts/Util.js"; -import { Remark } from "../ISA/JsonTypes/Comment.js"; -import { Person } from "../ISA/JsonTypes/Person.js"; -import { createMissingIdentifier } from "../ISA/ArcTypes/Identifier.js"; -import { printf, toConsole } from "../../fable_modules/fable-library-ts/String.js"; -import { toFsWorksheet, tryFromFsWorksheet } from "./ArcTable.js"; -import { ArcTable } from "../ISA/ArcTypes/ArcTable.js"; -import { FsWorkbook } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; - -export function toMetadataSheet(assay: ArcAssay): FsWorksheet { - let assay_1: ArcAssay; - const sheet: FsWorksheet = new FsWorksheet("isa_assay"); - iterateIndexed>((rowI: int32, r: Iterable<[int32, string]>): void => { - SparseRowModule_writeToSheet(rowI + 1, r, sheet); - }, (assay_1 = assay, delay>((): Iterable> => append>(singleton>(SparseRowModule_fromValues(["ASSAY"])), delay>((): Iterable> => append>(toRows_1("Assay", singleton_1(assay_1)), delay>((): Iterable> => append>(singleton>(SparseRowModule_fromValues(["ASSAY PERFORMERS"])), delay>((): Iterable> => toRows_2("Assay Person", assay_1.Performers)))))))))); - return sheet; -} - -export function fromMetadataSheet(sheet: FsWorksheet): ArcAssay { - const rows_1: Iterable> = map>(SparseRowModule_fromFsRow, sheet.Rows); - const patternInput: [Option, Option] = exists>((row: Iterable<[int32, string]>): boolean => { - const s: string = head<[int32, string]>(row)[1]; - return s.indexOf("Assay") === 0; - }, rows_1) ? (["Assay", "Assay Person"] as [Option, Option]) : ([void 0, void 0] as [Option, Option]); - const en: IEnumerator> = getEnumerator(rows_1); - const loop = (lastLine_mut: Option, assays_mut: FSharpList, contacts_mut: FSharpList, lineNumber_mut: int32): ArcAssay => { - let k: string; - loop: - while (true) { - const lastLine: Option = lastLine_mut, assays: FSharpList = assays_mut, contacts: FSharpList = contacts_mut, lineNumber: int32 = lineNumber_mut; - let matchResult: int32, k_2: string, k_3: string, k_4: Option; - if (lastLine != null) { - if ((k = value_1(lastLine), (k === "ASSAY") ? true : (k === "ASSAY METADATA"))) { - matchResult = 0; - k_2 = value_1(lastLine); - } - else if (value_1(lastLine) === "ASSAY PERFORMERS") { - matchResult = 1; - k_3 = value_1(lastLine); - } - else { - matchResult = 2; - k_4 = lastLine; - } - } - else { - matchResult = 2; - k_4 = lastLine; - } - switch (matchResult) { - case 0: { - const patternInput_1: [Option, int32, FSharpList, FSharpList] = fromRows_1(patternInput[0], lineNumber + 1, en); - lastLine_mut = patternInput_1[0]; - assays_mut = patternInput_1[3]; - contacts_mut = contacts; - lineNumber_mut = patternInput_1[1]; - continue loop; - } - case 1: { - const patternInput_2: [Option, int32, FSharpList, FSharpList] = fromRows_2(patternInput[1], lineNumber + 1, en); - lastLine_mut = patternInput_2[0]; - assays_mut = assays; - contacts_mut = patternInput_2[3]; - lineNumber_mut = patternInput_2[1]; - continue loop; - } - default: { - let matchResult_1: int32, assays_2: FSharpList, contacts_2: FSharpList; - if (isEmpty(assays)) { - if (isEmpty(contacts)) { - matchResult_1 = 0; - } - else { - matchResult_1 = 1; - assays_2 = assays; - contacts_2 = contacts; - } - } - else { - matchResult_1 = 1; - assays_2 = assays; - contacts_2 = contacts; - } - switch (matchResult_1) { - case 0: - return ArcAssay.create(createMissingIdentifier()); - default: { - const arg_1: ArcAssay = defaultArg(tryHead(assays_2!), ArcAssay.create(createMissingIdentifier())); - return ArcAssay.setPerformers(contacts_2!, arg_1); - } - } - } - } - break; - } - }; - if (en["System.Collections.IEnumerator.MoveNext"]()) { - return loop(SparseRowModule_tryGetValueAt(0, en["System.Collections.Generic.IEnumerator`1.get_Current"]()), empty(), empty(), 1); - } - else { - throw new Error("empty assay metadata sheet"); - } -} - -/** - * Reads an assay from a spreadsheet - */ -export function fromFsWorkbook(doc: FsWorkbook): ArcAssay { - let assayMetaData: ArcAssay; - const matchValue: Option = doc.TryGetWorksheetByName("isa_assay"); - if (matchValue == null) { - const matchValue_1: Option = doc.TryGetWorksheetByName("Assay"); - if (matchValue_1 == null) { - toConsole(printf("Cannot retrieve metadata: Assay file does not contain \"%s\" or \"%s\" sheet."))("isa_assay")("Assay"); - assayMetaData = ArcAssay.create(createMissingIdentifier()); - } - else { - assayMetaData = fromMetadataSheet(value_1(matchValue_1)); - } - } - else { - assayMetaData = fromMetadataSheet(value_1(matchValue)); - } - const sheets: FSharpList = choose(tryFromFsWorksheet, doc.GetWorksheets()); - if (isEmpty(sheets)) { - return assayMetaData; - } - else { - assayMetaData.Tables = Array.from(sheets); - return assayMetaData; - } -} - -export function toFsWorkbook(assay: ArcAssay): FsWorkbook { - const doc: FsWorkbook = new FsWorkbook(); - const metaDataSheet: FsWorksheet = toMetadataSheet(assay); - doc.AddWorksheet(metaDataSheet); - iterate((arg_1: ArcTable): void => { - const arg: FsWorksheet = toFsWorksheet(arg_1); - doc.AddWorksheet(arg); - }, assay.Tables); - return doc; -} - diff --git a/ts/ISA/ISA.Spreadsheet/ArcStudy.ts b/ts/ISA/ISA.Spreadsheet/ArcStudy.ts deleted file mode 100644 index c91885cc..00000000 --- a/ts/ISA/ISA.Spreadsheet/ArcStudy.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { FsWorksheet } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { iterate, map, singleton, append, delay, iterateIndexed } from "../../fable_modules/fable-library-ts/Seq.js"; -import { SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_writeToSheet } from "./SparseTable.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { fromRows as fromRows_1, StudyInfo_toRows_331096F } from "./InvestigationFile/Study.js"; -import { ArcStudy } from "../ISA/ArcTypes/ArcStudy.js"; -import { value as value_2, Option, defaultArg } from "../../fable_modules/fable-library-ts/Option.js"; -import { IEnumerator, getEnumerator } from "../../fable_modules/fable-library-ts/Util.js"; -import { FsRow } from "../../fable_modules/FsSpreadsheet.3.1.1/FsRow.fs.js"; -import { createMissingIdentifier } from "../ISA/ArcTypes/Identifier.js"; -import { printf, toConsole } from "../../fable_modules/fable-library-ts/String.js"; -import { isEmpty, FSharpList, choose } from "../../fable_modules/fable-library-ts/List.js"; -import { toFsWorksheet, tryFromFsWorksheet } from "./ArcTable.js"; -import { ArcTable } from "../ISA/ArcTypes/ArcTable.js"; -import { FsWorkbook } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; - -export function toMetadataSheet(study: ArcStudy): FsWorksheet { - const sheet: FsWorksheet = new FsWorksheet("isa_study"); - iterateIndexed>((rowI: int32, r: Iterable<[int32, string]>): void => { - SparseRowModule_writeToSheet(rowI + 1, r, sheet); - }, delay>((): Iterable> => append>(singleton>(SparseRowModule_fromValues(["STUDY"])), delay>((): Iterable> => StudyInfo_toRows_331096F(study))))); - return sheet; -} - -export function fromMetadataSheet(sheet: FsWorksheet): ArcStudy { - let en: IEnumerator>; - return defaultArg((en = getEnumerator(map>(SparseRowModule_fromFsRow, sheet.Rows)), (void en["System.Collections.IEnumerator.MoveNext"](), fromRows_1(2, en)[3])), ArcStudy.create(createMissingIdentifier())); -} - -/** - * Reads an assay from a spreadsheet - */ -export function fromFsWorkbook(doc: FsWorkbook): ArcStudy { - let studyMetadata: ArcStudy; - const matchValue: Option = doc.TryGetWorksheetByName("isa_study"); - if (matchValue == null) { - const matchValue_1: Option = doc.TryGetWorksheetByName("Study"); - if (matchValue_1 == null) { - toConsole(printf("Cannot retrieve metadata: Study file does not contain \"%s\" or \"%s\" sheet."))("isa_study")("Study"); - studyMetadata = ArcStudy.create(createMissingIdentifier()); - } - else { - studyMetadata = fromMetadataSheet(value_2(matchValue_1)); - } - } - else { - studyMetadata = fromMetadataSheet(value_2(matchValue)); - } - const sheets: FSharpList = choose(tryFromFsWorksheet, doc.GetWorksheets()); - if (isEmpty(sheets)) { - return studyMetadata; - } - else { - studyMetadata.Tables = Array.from(sheets); - return studyMetadata; - } -} - -export function toFsWorkbook(study: ArcStudy): FsWorkbook { - const doc: FsWorkbook = new FsWorkbook(); - const metaDataSheet: FsWorksheet = toMetadataSheet(study); - doc.AddWorksheet(metaDataSheet); - iterate((arg_1: ArcTable): void => { - const arg: FsWorksheet = toFsWorksheet(arg_1); - doc.AddWorksheet(arg); - }, study.Tables); - return doc; -} - diff --git a/ts/ISA/ISA.Spreadsheet/ArcTable.ts b/ts/ISA/ISA.Spreadsheet/ArcTable.ts deleted file mode 100644 index 97051a01..00000000 --- a/ts/ISA/ISA.Spreadsheet/ArcTable.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { iterateIndexed, length, sortBy, collect, toArray, empty, tail, head, isEmpty, cons, singleton, fold, FSharpList, map, reverse } from "../../fable_modules/fable-library-ts/List.js"; -import { CompositeHeader_$union } from "../ISA/ArcTypes/CompositeHeader.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { CompositeColumn } from "../ISA/ArcTypes/CompositeColumn.js"; -import { tryParseTermAnnotation } from "../ISA/Regex.js"; -import { FsColumn } from "../../fable_modules/FsSpreadsheet.3.1.1/FsColumn.fs.js"; -import { map as map_1, toList, tryFind } from "../../fable_modules/fable-library-ts/Seq.js"; -import { FsTable } from "../../fable_modules/FsSpreadsheet.3.1.1/Tables/FsTable.fs.js"; -import { FsWorksheet } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { value, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { toFsColumns, fixDeprecatedIOHeader, fromFsColumns } from "./CompositeColumn.js"; -import { ArcTable } from "../ISA/ArcTypes/ArcTable.js"; -import { FsCell } from "../../fable_modules/FsSpreadsheet.3.1.1/Cells/FsCell.fs.js"; -import { comparePrimitives } from "../../fable_modules/fable-library-ts/Util.js"; -import { FsRangeAddress_$ctor_7E77A4A0 } from "../../fable_modules/FsSpreadsheet.3.1.1/Ranges/FsRangeAddress.fs.js"; -import { FsAddress, FsAddress_$ctor_Z37302880 } from "../../fable_modules/FsSpreadsheet.3.1.1/FsAddress.fs.js"; -import { FsRangeBase__Cell_Z3407A44B } from "../../fable_modules/FsSpreadsheet.3.1.1/Ranges/FsRangeBase.fs.js"; - -/** - * Iterates over elements of the input list and groups adjacent elements. - * A new group is started when the specified predicate holds about the element - * of the list (and at the beginning of the iteration). - * - * For example: - * List.groupWhen isOdd [3;3;2;4;1;2] = [[3]; [3; 2; 4]; [1; 2]] - */ -export function Aux_List_groupWhen<$a>(f: ((arg0: $a) => boolean), list: FSharpList<$a>): FSharpList> { - return reverse>(map, FSharpList<$a>>(reverse, fold<$a, FSharpList>>((acc: FSharpList>, e: $a): FSharpList> => { - const matchValue: boolean = f(e); - if (matchValue) { - return cons(singleton(e), acc); - } - else if (!isEmpty(acc)) { - return cons(cons(e, head(acc)), tail(acc)); - } - else { - return singleton(singleton(e)); - } - }, empty>(), list))); -} - -export function classifyHeaderOrder(header: CompositeHeader_$union): int32 { - switch (header.tag) { - case /* ProtocolType */ 4: - case /* ProtocolDescription */ 5: - case /* ProtocolUri */ 6: - case /* ProtocolVersion */ 7: - case /* ProtocolREF */ 8: - case /* Performer */ 9: - case /* Date */ 10: - return 2; - case /* Component */ 0: - case /* Characteristic */ 1: - case /* Factor */ 2: - case /* Parameter */ 3: - case /* FreeText */ 13: - return 3; - case /* Output */ 12: - return 4; - default: - return 1; - } -} - -export function classifyColumnOrder(column: CompositeColumn): int32 { - return classifyHeaderOrder(column.Header); -} - -export function groupColumnsByHeader(columns: FSharpList): FSharpList> { - return Aux_List_groupWhen((c: FsColumn): boolean => { - if (tryParseTermAnnotation(c.Item(1).Value) == null) { - return c.Item(1).Value !== "Unit"; - } - else { - return false; - } - }, columns); -} - -/** - * Returns the annotation table of the worksheet if it exists, else returns None - */ -export function tryAnnotationTable(sheet: FsWorksheet): Option { - return tryFind((t: FsTable): boolean => (t.Name.indexOf("annotationTable") === 0), sheet.Tables); -} - -/** - * Groups and parses a collection of single columns into the according ISA composite columns - */ -export function composeColumns(columns: Iterable): CompositeColumn[] { - return toArray(map, CompositeColumn>(fromFsColumns, groupColumnsByHeader(toList(columns)))); -} - -/** - * Returns the protocol described by the headers and a function for parsing the values of the matrix to the processes of this protocol - */ -export function tryFromFsWorksheet(sheet: FsWorksheet): Option { - const matchValue: Option = tryAnnotationTable(sheet); - if (matchValue == null) { - return void 0; - } - else { - const t: FsTable = value(matchValue); - const compositeColumns: CompositeColumn[] = composeColumns(map_1(fixDeprecatedIOHeader, t.GetColumns(sheet.CellCollection))); - return ArcTable.addColumns(compositeColumns)(ArcTable.init(sheet.Name)); - } -} - -export function toFsWorksheet(table: ArcTable): FsWorksheet { - const ws: FsWorksheet = new FsWorksheet(table.Name); - const columns: FSharpList> = collect>(toFsColumns, sortBy(classifyColumnOrder, table.Columns, { - Compare: comparePrimitives, - })); - const maxRow: int32 = length(head(columns)) | 0; - const maxCol: int32 = length(columns) | 0; - const fsTable: FsTable = ws.Table("annotationTable", FsRangeAddress_$ctor_7E77A4A0(FsAddress_$ctor_Z37302880(1, 1), FsAddress_$ctor_Z37302880(maxRow, maxCol))); - iterateIndexed>((colI: int32, col: FSharpList): void => { - iterateIndexed((rowI: int32, cell: FsCell): void => { - const address: FsAddress = FsAddress_$ctor_Z37302880(rowI + 1, colI + 1); - FsRangeBase__Cell_Z3407A44B(fsTable, address, ws.CellCollection).SetValueAs(cell.Value); - }, col); - }, columns); - return ws; -} - diff --git a/ts/ISA/ISA.Spreadsheet/CollectionAux.ts b/ts/ISA/ISA.Spreadsheet/CollectionAux.ts deleted file mode 100644 index 442bcb8e..00000000 --- a/ts/ISA/ISA.Spreadsheet/CollectionAux.ts +++ /dev/null @@ -1,161 +0,0 @@ -import { tryFind, maxBy, skip } from "../../fable_modules/fable-library-ts/Seq.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { some, value, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { IMap, defaultOf, comparePrimitives, IDisposable, disposeSafe, IEnumerator, getEnumerator } from "../../fable_modules/fable-library-ts/Util.js"; -import { reverse, tryPick, FSharpList, empty, ofArrayWithTail, cons, head, tail, singleton, isEmpty } from "../../fable_modules/fable-library-ts/List.js"; -import { tryItem, skip as skip_1, initialize } from "../../fable_modules/fable-library-ts/Array.js"; -import { tryGetValue } from "../../fable_modules/fable-library-ts/MapUtil.js"; -import { FSharpRef } from "../../fable_modules/fable-library-ts/Types.js"; - -/** - * If at least i values exist in seq a, builds a new array that contains the elements of the given seq, exluding the first i elements - */ -export function Seq_trySkip<$a>(i: int32, s: Iterable<$a>): Option> { - try { - return skip<$a>(i, s); - } - catch (matchValue: any) { - return void 0; - } -} - -function Seq_groupWhen(withOverlap: boolean, predicate: ((arg0: a) => boolean), input: Iterable): Iterable> { - let matchValue: FSharpList>, t_4: FSharpList>, h_4: FSharpList; - const en: IEnumerator = getEnumerator(input); - try { - const loop = <$b>(cont_mut: ((arg0: FSharpList>) => $b)): $b => { - loop: - while (true) { - const cont: ((arg0: FSharpList>) => $b) = cont_mut; - if (en["System.Collections.IEnumerator.MoveNext"]()) { - const temp: a = en["System.Collections.Generic.IEnumerator`1.get_Current"](); - if (predicate(temp)) { - cont_mut = ((y: FSharpList>): $b => cont(isEmpty(y) ? singleton(singleton(temp)) : (withOverlap ? ofArrayWithTail([singleton(temp), cons(temp, head(y))], tail(y)) : ofArrayWithTail([empty(), cons(temp, head(y))], tail(y))))); - continue loop; - } - else { - cont_mut = ((y_1: FSharpList>): $b => cont(isEmpty(y_1) ? singleton(singleton(temp)) : cons(cons(temp, head(y_1)), tail(y_1)))); - continue loop; - } - } - else { - return cont(empty>()); - } - break; - } - }; - return (matchValue = loop((x: FSharpList>): FSharpList> => x), isEmpty(matchValue) ? empty>() : ((t_4 = tail(matchValue), (h_4 = head(matchValue), isEmpty(h_4) ? t_4 : (isEmpty(tail(h_4)) ? ((predicate(head(h_4)) && withOverlap) ? t_4 : cons(h_4, t_4)) : cons(h_4, t_4)))))) as Iterable>; - } - finally { - disposeSafe(en as IDisposable); - } -} - -export function Array_ofIndexedSeq(s: Iterable<[int32, string]>): string[] { - return initialize(1 + maxBy<[int32, string], int32>((tuple: [int32, string]): int32 => tuple[0], s, { - Compare: comparePrimitives, - })[0], (i: int32): string => { - const matchValue: Option<[int32, string]> = tryFind<[int32, string]>((arg: [int32, string]): boolean => (i === arg[0]), s); - if (matchValue == null) { - return ""; - } - else { - const i_1: int32 = value(matchValue)[0] | 0; - return value(matchValue)[1]; - } - }); -} - -/** - * If at least i values exist in array a, builds a new array that contains the elements of the given array, exluding the first i elements - */ -export function Array_trySkip<$a>(i: int32, a: $a[]): Option<$a[]> { - try { - return skip_1<$a>(i, a); - } - catch (matchValue: any) { - return void 0; - } -} - -/** - * Returns Item of array at index i if existing, else returns default value - */ -export function Array_tryItemDefault<$a>(i: int32, d: $a, a: $a[]): $a { - const matchValue: Option<$a> = tryItem<$a>(i, a); - if (matchValue == null) { - return d; - } - else { - return value(matchValue); - } -} - -export function Array_map4(f: ((arg0: A, arg1: B, arg2: C, arg3: D) => T), aa: A[], ba: B[], ca: C[], da: D[]): T[] { - if (!(((aa.length === ba.length) && (ba.length === ca.length)) && (ca.length === da.length))) { - throw new Error(""); - } - return initialize(aa.length, (i: int32): T => f(aa[i], ba[i], ca[i], da[i])); -} - -export function List_tryPickDefault(chooser: ((arg0: T) => Option), d: U, list: FSharpList): U { - const matchValue: Option = tryPick(chooser, list); - if (matchValue == null) { - return d; - } - else { - return value(matchValue); - } -} - -export function List_unzip4(l: FSharpList<[A, B, C, D]>): [FSharpList, FSharpList, FSharpList, FSharpList] { - const loop = <$a, $b, $c, $d>(la_mut: FSharpList<$a>, lb_mut: FSharpList<$b>, lc_mut: FSharpList<$c>, ld_mut: FSharpList<$d>, l_1_mut: FSharpList<[$a, $b, $c, $d]>): [FSharpList<$a>, FSharpList<$b>, FSharpList<$c>, FSharpList<$d>] => { - loop: - while (true) { - const la: FSharpList<$a> = la_mut, lb: FSharpList<$b> = lb_mut, lc: FSharpList<$c> = lc_mut, ld: FSharpList<$d> = ld_mut, l_1: FSharpList<[$a, $b, $c, $d]> = l_1_mut; - if (isEmpty(l_1)) { - return [reverse<$a>(la), reverse<$b>(lb), reverse<$c>(lc), reverse<$d>(ld)] as [FSharpList<$a>, FSharpList<$b>, FSharpList<$c>, FSharpList<$d>]; - } - else { - la_mut = cons(head(l_1)[0], la); - lb_mut = cons(head(l_1)[1], lb); - lc_mut = cons(head(l_1)[2], lc); - ld_mut = cons(head(l_1)[3], ld); - l_1_mut = tail(l_1); - continue loop; - } - break; - } - }; - return loop(empty(), empty(), empty(), empty(), l); -} - -export function Dictionary_tryGetValue(k: K, dict: IMap): Option { - let patternInput: [boolean, V]; - let outArg: V = defaultOf(); - patternInput = ([tryGetValue(dict, k, new FSharpRef((): V => outArg, (v: V): void => { - outArg = v; - })), outArg] as [boolean, V]); - if (patternInput[0]) { - return some(patternInput[1]); - } - else { - return void 0; - } -} - -export function Dictionary_tryGetString(k: K, dict: IMap): Option { - let patternInput: [boolean, string]; - let outArg: string = defaultOf(); - patternInput = ([tryGetValue(dict, k, new FSharpRef((): string => outArg, (v: string): void => { - outArg = v; - })), outArg] as [boolean, string]); - const v_1: string = patternInput[1]; - if (patternInput[0] && (v_1.trim() !== "")) { - return v_1.trim(); - } - else { - return void 0; - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/Comment.ts b/ts/ISA/ISA.Spreadsheet/Comment.ts deleted file mode 100644 index 5460860e..00000000 --- a/ts/ISA/ISA.Spreadsheet/Comment.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { defaultArg, Option, bind } from "../../fable_modules/fable-library-ts/Option.js"; -import { match } from "../../fable_modules/fable-library-ts/RegExp.js"; -import { printf, toText } from "../../fable_modules/fable-library-ts/String.js"; -import { Comment$, Comment_make } from "../ISA/JsonTypes/Comment.js"; -import { Option_fromValueWithDefault } from "./Conversions.js"; - -export const Comment_commentRegex = /(?<=Comment\[<).*(?=>\])/gu; - -export const Comment_commentRegexNoAngleBrackets = /(?<=Comment\[).*(?=\])/gu; - -export function Comment_$007CComment$007C_$007C(key: Option): Option { - return bind((k: string): Option => { - const r: any = match(Comment_commentRegex, k); - if (r != null) { - return r[0]; - } - else { - const r_1: any = match(Comment_commentRegexNoAngleBrackets, k); - if (r_1 != null) { - return r_1[0]; - } - else { - return void 0; - } - } - }, key); -} - -export function Comment_wrapCommentKey(k: string): string { - return toText(printf("Comment[%s]"))(k); -} - -export function Comment_fromString(k: string, v: string): Comment$ { - return Comment_make(void 0, Option_fromValueWithDefault("", k), Option_fromValueWithDefault("", v)); -} - -export function Comment_toString(c: Comment$): [string, string] { - return [defaultArg(c.Name, ""), defaultArg(c.Value, "")] as [string, string]; -} - -export const Remark_remarkRegex = /(?<=#).*/gu; - -export function Remark_$007CRemark$007C_$007C(key: Option): Option { - return bind((k: string): Option => { - const r: any = match(Remark_remarkRegex, k); - if (r != null) { - return r[0]; - } - else { - return void 0; - } - }, key); -} - -export function Remark_wrapRemark(r: string): string { - return toText(printf("#%s"))(r); -} - diff --git a/ts/ISA/ISA.Spreadsheet/CompositeCell.ts b/ts/ISA/ISA.Spreadsheet/CompositeCell.ts deleted file mode 100644 index a01aa0cb..00000000 --- a/ts/ISA/ISA.Spreadsheet/CompositeCell.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { singleton, ofArray, head, tail, isEmpty, FSharpList, map } from "../../fable_modules/fable-library-ts/List.js"; -import { FsCell } from "../../fable_modules/FsSpreadsheet.3.1.1/Cells/FsCell.fs.js"; -import { CompositeCell_$union, CompositeCell } from "../ISA/ArcTypes/CompositeCell.js"; -import { printf, toFail } from "../../fable_modules/fable-library-ts/String.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { OntologyAnnotation__get_TermAccessionOntobeeUrl, OntologyAnnotation__get_TermSourceREFString, OntologyAnnotation__get_NameText, OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; - -export function fromFsCells(cells: FSharpList): CompositeCell_$union { - const cellValues: FSharpList = map((c: FsCell): string => c.Value, cells); - let matchResult: int32, v: string, v1: string, v2: string, v3: string, v1_1: string, v2_1: string, v3_1: string, v4: string; - if (!isEmpty(cellValues)) { - if (!isEmpty(tail(cellValues))) { - if (!isEmpty(tail(tail(cellValues)))) { - if (!isEmpty(tail(tail(tail(cellValues))))) { - if (isEmpty(tail(tail(tail(tail(cellValues)))))) { - matchResult = 2; - v1_1 = head(cellValues); - v2_1 = head(tail(cellValues)); - v3_1 = head(tail(tail(cellValues))); - v4 = head(tail(tail(tail(cellValues)))); - } - else { - matchResult = 3; - } - } - else { - matchResult = 1; - v1 = head(cellValues); - v2 = head(tail(cellValues)); - v3 = head(tail(tail(cellValues))); - } - } - else { - matchResult = 3; - } - } - else { - matchResult = 0; - v = head(cellValues); - } - } - else { - matchResult = 3; - } - switch (matchResult) { - case 0: - return CompositeCell.createFreeText(v!); - case 1: - return CompositeCell.createTermFromString(v1!, v2!, v3!); - case 2: - return CompositeCell.createUnitizedFromString(v1_1!, v2_1!, v3_1!, v4!); - default: - return toFail(printf("Dafuq")); - } -} - -export function toFsCells(isTerm: boolean, hasUnit: boolean, cell: CompositeCell_$union): FSharpList { - let v: OntologyAnnotation, v_1: string, v_2: string; - switch (cell.tag) { - case /* Term */ 0: - if ((v = cell.fields[0], hasUnit)) { - const v_6: OntologyAnnotation = cell.fields[0]; - return ofArray([new FsCell(OntologyAnnotation__get_NameText(v_6)), new FsCell(""), new FsCell(OntologyAnnotation__get_TermSourceREFString(v_6)), new FsCell(OntologyAnnotation__get_TermAccessionOntobeeUrl(v_6))]); - } - else { - const v_7: OntologyAnnotation = cell.fields[0]; - return ofArray([new FsCell(OntologyAnnotation__get_NameText(v_7)), new FsCell(OntologyAnnotation__get_TermSourceREFString(v_7)), new FsCell(OntologyAnnotation__get_TermAccessionOntobeeUrl(v_7))]); - } - case /* Unitized */ 2: { - const unit: OntologyAnnotation = cell.fields[1]; - const v_8: string = cell.fields[0]; - return ofArray([new FsCell(v_8), new FsCell(OntologyAnnotation__get_NameText(unit)), new FsCell(OntologyAnnotation__get_TermSourceREFString(unit)), new FsCell(OntologyAnnotation__get_TermAccessionOntobeeUrl(unit))]); - } - default: - if ((v_1 = cell.fields[0], hasUnit)) { - const v_3: string = cell.fields[0]; - return ofArray([new FsCell(v_3), new FsCell(""), new FsCell(""), new FsCell("")]); - } - else if ((v_2 = cell.fields[0], isTerm)) { - const v_4: string = cell.fields[0]; - return ofArray([new FsCell(v_4), new FsCell(""), new FsCell("")]); - } - else { - const v_5: string = cell.fields[0]; - return singleton(new FsCell(v_5)); - } - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/CompositeColumn.ts b/ts/ISA/ISA.Spreadsheet/CompositeColumn.ts deleted file mode 100644 index 1f57825d..00000000 --- a/ts/ISA/ISA.Spreadsheet/CompositeColumn.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { CompositeHeader_$union, CompositeHeader_Output, CompositeHeader_Input, IOType_Source, IOType_$union, IOType } from "../ISA/ArcTypes/CompositeHeader.js"; -import { toString } from "../../fable_modules/fable-library-ts/Types.js"; -import { FsColumn } from "../../fable_modules/FsSpreadsheet.3.1.1/FsColumn.fs.js"; -import { toFsCells, fromFsCells } from "./CompositeHeader.js"; -import { singleton as singleton_1, ofArray, FSharpList, item, map } from "../../fable_modules/fable-library-ts/List.js"; -import { FsCell } from "../../fable_modules/FsSpreadsheet.3.1.1/Cells/FsCell.fs.js"; -import { FsAddress__get_RowNumber } from "../../fable_modules/FsSpreadsheet.3.1.1/FsAddress.fs.js"; -import { FsRangeAddress__get_LastAddress } from "../../fable_modules/FsSpreadsheet.3.1.1/Ranges/FsRangeAddress.fs.js"; -import { FsRangeBase__get_RangeAddress } from "../../fable_modules/FsSpreadsheet.3.1.1/Ranges/FsRangeBase.fs.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { singleton, append, toList, exists, map as map_1, delay, toArray } from "../../fable_modules/fable-library-ts/Seq.js"; -import { toFsCells as toFsCells_1, fromFsCells as fromFsCells_1 } from "./CompositeCell.js"; -import { CompositeCell_$union } from "../ISA/ArcTypes/CompositeCell.js"; -import { rangeDouble } from "../../fable_modules/fable-library-ts/Range.js"; -import { CompositeColumn } from "../ISA/ArcTypes/CompositeColumn.js"; -import { map as map_2 } from "../../fable_modules/fable-library-ts/Array.js"; - -/** - * Checks if the column header is a deprecated IO Header. If so, fixes it. - * - * The old format of IO Headers was only the type of IO so, e.g. "Source Name" or "Raw Data File". - * - * A "Source Name" column will now be mapped to the propper "Input [Source Name]", and all other IO types will be mapped to "Output []". - */ -export function fixDeprecatedIOHeader(col: FsColumn): FsColumn { - const matchValue: IOType_$union = IOType.ofString(col.Item(1).Value); - switch (matchValue.tag) { - case /* FreeText */ 6: - return col; - case /* Source */ 0: { - col.Item(1).SetValueAs(toString(CompositeHeader_Input(IOType_Source()))); - return col; - } - default: { - col.Item(1).SetValueAs(toString(CompositeHeader_Output(matchValue))); - return col; - } - } -} - -export function fromFsColumns(columns: FSharpList): CompositeColumn { - const header: CompositeHeader_$union = fromFsCells(map((c: FsColumn): FsCell => c.Item(1), columns)); - const l: int32 = FsAddress__get_RowNumber(FsRangeAddress__get_LastAddress(FsRangeBase__get_RangeAddress(item(0, columns)))) | 0; - const cells_2: CompositeCell_$union[] = toArray(delay((): Iterable => map_1((i: int32): CompositeCell_$union => fromFsCells_1(map((c_1: FsColumn): FsCell => c_1.Item(i), columns)), rangeDouble(2, 1, l)))); - return CompositeColumn.create(header, cells_2); -} - -export function toFsColumns(column: CompositeColumn): FSharpList> { - const hasUnit: boolean = exists((c: CompositeCell_$union): boolean => c.isUnitized, column.Cells); - const isTerm: boolean = column.Header.IsTermColumn; - const header: FSharpList = toFsCells(hasUnit, column.Header); - const cells: FSharpList[] = map_2>((cell: CompositeCell_$union): FSharpList => toFsCells_1(isTerm, hasUnit, cell), column.Cells); - if (hasUnit) { - return ofArray([toList(delay((): Iterable => append(singleton(item(0, header)), delay((): Iterable => map_1((i: int32): FsCell => item(0, cells[i]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay((): Iterable => append(singleton(item(1, header)), delay((): Iterable => map_1((i_1: int32): FsCell => item(1, cells[i_1]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay((): Iterable => append(singleton(item(2, header)), delay((): Iterable => map_1((i_2: int32): FsCell => item(2, cells[i_2]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay((): Iterable => append(singleton(item(3, header)), delay((): Iterable => map_1((i_3: int32): FsCell => item(3, cells[i_3]), rangeDouble(0, 1, column.Cells.length - 1))))))]); - } - else if (isTerm) { - return ofArray([toList(delay((): Iterable => append(singleton(item(0, header)), delay((): Iterable => map_1((i_4: int32): FsCell => item(0, cells[i_4]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay((): Iterable => append(singleton(item(1, header)), delay((): Iterable => map_1((i_5: int32): FsCell => item(1, cells[i_5]), rangeDouble(0, 1, column.Cells.length - 1)))))), toList(delay((): Iterable => append(singleton(item(2, header)), delay((): Iterable => map_1((i_6: int32): FsCell => item(2, cells[i_6]), rangeDouble(0, 1, column.Cells.length - 1))))))]); - } - else { - return singleton_1(toList(delay((): Iterable => append(singleton(item(0, header)), delay((): Iterable => map_1((i_7: int32): FsCell => item(0, cells[i_7]), rangeDouble(0, 1, column.Cells.length - 1))))))); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/CompositeHeader.ts b/ts/ISA/ISA.Spreadsheet/CompositeHeader.ts deleted file mode 100644 index 15f2cee5..00000000 --- a/ts/ISA/ISA.Spreadsheet/CompositeHeader.ts +++ /dev/null @@ -1,462 +0,0 @@ -import { printf, toFail } from "../../fable_modules/fable-library-ts/String.js"; -import { value, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { singleton, tail, head, isEmpty, FSharpList, map } from "../../fable_modules/fable-library-ts/List.js"; -import { FsCell } from "../../fable_modules/FsSpreadsheet.3.1.1/Cells/FsCell.fs.js"; -import { OntologyAnnotation, OntologyAnnotation_fromString_Z7D8EB286 } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { ActivePatterns_$007COutputColumnHeader$007C_$007C, ActivePatterns_$007CInputColumnHeader$007C_$007C, tryParseCharacteristicColumnHeader, tryParseFactorColumnHeader, tryParseParameterColumnHeader, ActivePatterns_$007CUnitColumnHeader$007C_$007C, ActivePatterns_$007CTANColumnHeader$007C_$007C, ActivePatterns_$007CTSRColumnHeader$007C_$007C } from "../ISA/Regex.js"; -import { CompositeHeader_FreeText, CompositeHeader_Date, CompositeHeader_Performer, CompositeHeader_ProtocolVersion, CompositeHeader_ProtocolUri, CompositeHeader_ProtocolDescription, CompositeHeader_ProtocolREF, CompositeHeader_ProtocolType, CompositeHeader_Output, CompositeHeader_Input, IOType, CompositeHeader_Characteristic, CompositeHeader_Factor, CompositeHeader_Parameter, CompositeHeader_$union } from "../ISA/ArcTypes/CompositeHeader.js"; -import { toString } from "../../fable_modules/fable-library-ts/Types.js"; -import { empty, singleton as singleton_1, append, delay, toList } from "../../fable_modules/fable-library-ts/Seq.js"; - -export function ActivePattern_mergeTerms(tsr1: string, tan1: string, tsr2: string, tan2: string): { TermAccessionNumber: string, TermSourceRef: string } { - if (tsr1 !== tsr2) { - toFail(printf("TermSourceRef %s and %s do not match"))(tsr1)(tsr2); - } - if (tan1 !== tan2) { - toFail(printf("TermAccessionNumber %s and %s do not match"))(tan1)(tan2); - } - return { - TermAccessionNumber: tan1, - TermSourceRef: tsr1, - }; -} - -export function ActivePattern_$007CTerm$007C_$007C(categoryParser: ((arg0: string) => Option), f: ((arg0: OntologyAnnotation) => CompositeHeader_$union), cells: FSharpList): Option { - const $007CAC$007C_$007C = categoryParser; - const cellValues: FSharpList = map((c: FsCell): string => c.Value, cells); - let matchResult: int32, name: string; - if (!isEmpty(cellValues)) { - const activePatternResult: Option = $007CAC$007C_$007C(head(cellValues)); - if (activePatternResult != null) { - if (isEmpty(tail(cellValues))) { - matchResult = 0; - name = value(activePatternResult); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return f(OntologyAnnotation_fromString_Z7D8EB286(name!)); - default: { - let matchResult_1: int32, name_1: string, term1: { LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }, term2: { LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }; - if (!isEmpty(cellValues)) { - const activePatternResult_1: Option = $007CAC$007C_$007C(head(cellValues)); - if (activePatternResult_1 != null) { - if (!isEmpty(tail(cellValues))) { - const activePatternResult_2: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTSRColumnHeader$007C_$007C(head(tail(cellValues))); - if (activePatternResult_2 != null) { - if (!isEmpty(tail(tail(cellValues)))) { - const activePatternResult_3: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTANColumnHeader$007C_$007C(head(tail(tail(cellValues)))); - if (activePatternResult_3 != null) { - if (!isEmpty(tail(tail(tail(cellValues))))) { - const activePatternResult_4: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTANColumnHeader$007C_$007C(head(tail(tail(tail(cellValues))))); - if (activePatternResult_4 != null) { - if (isEmpty(tail(tail(tail(tail(cellValues)))))) { - const activePatternResult_5: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTSRColumnHeader$007C_$007C(head(tail(tail(cellValues)))); - if (activePatternResult_5 != null) { - if (ActivePatterns_$007CUnitColumnHeader$007C_$007C(head(tail(cellValues))) != null) { - matchResult_1 = 0; - name_1 = value(activePatternResult_1); - term1 = value(activePatternResult_5); - term2 = value(activePatternResult_4); - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 0; - name_1 = value(activePatternResult_1); - term1 = value(activePatternResult_2); - term2 = value(activePatternResult_3); - } - } - else { - const activePatternResult_7: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTSRColumnHeader$007C_$007C(head(tail(tail(cellValues)))); - if (activePatternResult_7 != null) { - if (!isEmpty(tail(tail(tail(cellValues))))) { - const activePatternResult_8: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTANColumnHeader$007C_$007C(head(tail(tail(tail(cellValues))))); - if (activePatternResult_8 != null) { - if (isEmpty(tail(tail(tail(tail(cellValues)))))) { - if (ActivePatterns_$007CUnitColumnHeader$007C_$007C(head(tail(cellValues))) != null) { - matchResult_1 = 0; - name_1 = value(activePatternResult_1); - term1 = value(activePatternResult_7); - term2 = value(activePatternResult_8); - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - } - else { - matchResult_1 = 1; - } - } - else if (ActivePatterns_$007CUnitColumnHeader$007C_$007C(head(tail(cellValues))) != null) { - if (!isEmpty(tail(tail(cellValues)))) { - const activePatternResult_11: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTSRColumnHeader$007C_$007C(head(tail(tail(cellValues)))); - if (activePatternResult_11 != null) { - if (!isEmpty(tail(tail(tail(cellValues))))) { - const activePatternResult_12: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTANColumnHeader$007C_$007C(head(tail(tail(tail(cellValues))))); - if (activePatternResult_12 != null) { - if (isEmpty(tail(tail(tail(tail(cellValues)))))) { - matchResult_1 = 0; - name_1 = value(activePatternResult_1); - term1 = value(activePatternResult_11); - term2 = value(activePatternResult_12); - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - switch (matchResult_1) { - case 0: { - const term: { TermAccessionNumber: string, TermSourceRef: string } = ActivePattern_mergeTerms(term1!.TermSourceREF, term1!.TermAccessionNumber, term2!.TermSourceREF, term2!.TermAccessionNumber); - return f(OntologyAnnotation_fromString_Z7D8EB286(name_1!, term.TermSourceRef, term.TermAccessionNumber)); - } - default: - return void 0; - } - } - } -} - -export function ActivePattern_$007CParameter$007C_$007C(cells: FSharpList): Option { - const activePatternResult: Option = ActivePattern_$007CTerm$007C_$007C(tryParseParameterColumnHeader, CompositeHeader_Parameter, cells); - if (activePatternResult != null) { - const r: CompositeHeader_$union = value(activePatternResult); - return r; - } - else { - return void 0; - } -} - -export function ActivePattern_$007CFactor$007C_$007C(cells: FSharpList): Option { - const activePatternResult: Option = ActivePattern_$007CTerm$007C_$007C(tryParseFactorColumnHeader, CompositeHeader_Factor, cells); - if (activePatternResult != null) { - const r: CompositeHeader_$union = value(activePatternResult); - return r; - } - else { - return void 0; - } -} - -export function ActivePattern_$007CCharacteristic$007C_$007C(cells: FSharpList): Option { - const activePatternResult: Option = ActivePattern_$007CTerm$007C_$007C(tryParseCharacteristicColumnHeader, CompositeHeader_Characteristic, cells); - if (activePatternResult != null) { - const r: CompositeHeader_$union = value(activePatternResult); - return r; - } - else { - return void 0; - } -} - -export function ActivePattern_$007CInput$007C_$007C(cells: FSharpList): Option { - const cellValues: FSharpList = map((c: FsCell): string => c.Value, cells); - let matchResult: int32, ioType: string; - if (!isEmpty(cellValues)) { - const activePatternResult: Option = ActivePatterns_$007CInputColumnHeader$007C_$007C(head(cellValues)); - if (activePatternResult != null) { - if (isEmpty(tail(cellValues))) { - matchResult = 0; - ioType = value(activePatternResult); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return CompositeHeader_Input(IOType.ofString(ioType!)); - default: - return void 0; - } -} - -export function ActivePattern_$007COutput$007C_$007C(cells: FSharpList): Option { - const cellValues: FSharpList = map((c: FsCell): string => c.Value, cells); - let matchResult: int32, ioType: string; - if (!isEmpty(cellValues)) { - const activePatternResult: Option = ActivePatterns_$007COutputColumnHeader$007C_$007C(head(cellValues)); - if (activePatternResult != null) { - if (isEmpty(tail(cellValues))) { - matchResult = 0; - ioType = value(activePatternResult); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return CompositeHeader_Output(IOType.ofString(ioType!)); - default: - return void 0; - } -} - -export function ActivePattern_$007CProtocolHeader$007C_$007C(cells: FSharpList): Option { - const cellValues: FSharpList = map((c: FsCell): string => c.Value, cells); - let matchResult: int32; - if (!isEmpty(cellValues)) { - switch (head(cellValues)) { - case "Protocol Type": { - matchResult = 0; - break; - } - case "Protocol REF": { - if (isEmpty(tail(cellValues))) { - matchResult = 1; - } - else { - matchResult = 7; - } - break; - } - case "Protocol Description": { - if (isEmpty(tail(cellValues))) { - matchResult = 2; - } - else { - matchResult = 7; - } - break; - } - case "Protocol Uri": { - if (isEmpty(tail(cellValues))) { - matchResult = 3; - } - else { - matchResult = 7; - } - break; - } - case "Protocol Version": { - if (isEmpty(tail(cellValues))) { - matchResult = 4; - } - else { - matchResult = 7; - } - break; - } - case "Performer": { - if (isEmpty(tail(cellValues))) { - matchResult = 5; - } - else { - matchResult = 7; - } - break; - } - case "Date": { - if (isEmpty(tail(cellValues))) { - matchResult = 6; - } - else { - matchResult = 7; - } - break; - } - default: - matchResult = 7; - } - } - else { - matchResult = 7; - } - switch (matchResult) { - case 0: - return CompositeHeader_ProtocolType(); - case 1: - return CompositeHeader_ProtocolREF(); - case 2: - return CompositeHeader_ProtocolDescription(); - case 3: - return CompositeHeader_ProtocolUri(); - case 4: - return CompositeHeader_ProtocolVersion(); - case 5: - return CompositeHeader_Performer(); - case 6: - return CompositeHeader_Date(); - default: - return void 0; - } -} - -export function ActivePattern_$007CFreeText$007C_$007C(cells: FSharpList): Option { - const cellValues: FSharpList = map((c: FsCell): string => c.Value, cells); - let matchResult: int32, text: string; - if (!isEmpty(cellValues)) { - if (isEmpty(tail(cellValues))) { - matchResult = 0; - text = head(cellValues); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return CompositeHeader_FreeText(text!); - default: - return void 0; - } -} - -export function fromFsCells(cells: FSharpList): CompositeHeader_$union { - const activePatternResult: Option = ActivePattern_$007CParameter$007C_$007C(cells); - if (activePatternResult != null) { - const p: CompositeHeader_$union = value(activePatternResult); - return p; - } - else { - const activePatternResult_1: Option = ActivePattern_$007CFactor$007C_$007C(cells); - if (activePatternResult_1 != null) { - const f: CompositeHeader_$union = value(activePatternResult_1); - return f; - } - else { - const activePatternResult_2: Option = ActivePattern_$007CCharacteristic$007C_$007C(cells); - if (activePatternResult_2 != null) { - const c: CompositeHeader_$union = value(activePatternResult_2); - return c; - } - else { - const activePatternResult_3: Option = ActivePattern_$007CInput$007C_$007C(cells); - if (activePatternResult_3 != null) { - const i: CompositeHeader_$union = value(activePatternResult_3); - return i; - } - else { - const activePatternResult_4: Option = ActivePattern_$007COutput$007C_$007C(cells); - if (activePatternResult_4 != null) { - const o: CompositeHeader_$union = value(activePatternResult_4); - return o; - } - else { - const activePatternResult_5: Option = ActivePattern_$007CProtocolHeader$007C_$007C(cells); - if (activePatternResult_5 != null) { - const ph: CompositeHeader_$union = value(activePatternResult_5); - return ph; - } - else { - const activePatternResult_6: Option = ActivePattern_$007CFreeText$007C_$007C(cells); - if (activePatternResult_6 != null) { - const ft: CompositeHeader_$union = value(activePatternResult_6); - return ft; - } - else { - throw new Error("parseCompositeHeader"); - } - } - } - } - } - } - } -} - -export function toFsCells(hasUnit: boolean, header: CompositeHeader_$union): FSharpList { - if (header.IsSingleColumn) { - return singleton(new FsCell(toString(header))); - } - else if (header.IsTermColumn) { - return toList(delay((): Iterable => append(singleton_1(new FsCell(toString(header))), delay((): Iterable => append(hasUnit ? singleton_1(new FsCell("Unit")) : empty(), delay((): Iterable => append(singleton_1(new FsCell(`Term Source REF (${header.GetColumnAccessionShort})`)), delay((): Iterable => singleton_1(new FsCell(`Term Accession Number (${header.GetColumnAccessionShort})`)))))))))); - } - else { - return toFail(printf("header %O is neither single nor term column"))(header); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/Conversions.ts b/ts/ISA/ISA.Spreadsheet/Conversions.ts deleted file mode 100644 index 79d75f74..00000000 --- a/ts/ISA/ISA.Spreadsheet/Conversions.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { value, Option, some } from "../../fable_modules/fable-library-ts/Option.js"; -import { fill, map3, fold } from "../../fable_modules/fable-library-ts/Array.js"; -import { toText, printf, toFail } from "../../fable_modules/fable-library-ts/String.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation } from "../ISA/JsonTypes/OntologyAnnotation.js"; -import { map, fold as fold_1, FSharpList, ofArray, empty } from "../../fable_modules/fable-library-ts/List.js"; -import { Component_toString_Z7E9B32A1, Component_fromString_55205B02, Component } from "../ISA/JsonTypes/Component.js"; -import { Array_map4 } from "./CollectionAux.js"; -import { ProtocolParameter_toString_2762A46F, ProtocolParameter, ProtocolParameter_make } from "../ISA/JsonTypes/ProtocolParameter.js"; - -/** - * If the value matches the default, a None is returned, else a Some is returned - */ -export function Option_fromValueWithDefault<$a>(d: $a, v: $a): Option<$a> { - if (equals(d, v)) { - return void 0; - } - else { - return some(v); - } -} - -/** - * Applies the function f on the value of the option if it exists, else applies it on the default value. If the result value matches the default, a None is returned - */ -export function Option_mapDefault(d: T, f: ((arg0: T) => T), o: Option): Option { - return Option_fromValueWithDefault(d, (o == null) ? f(d) : f(value(o))); -} - -/** - * Returns the length of a subpropertylist from the aggregated strings - * - * In ISATab format, some subproperties which are stored as lists in ISAJson are stored as semicolon delimited tables - * - * These strings should either contain the same number of semicolon delimited elements or be empty. - */ -export function OntologyAnnotation_getLengthOfAggregatedStrings(separator: string, strings: string[]): int32 { - return fold((l: int32, s: string): int32 => { - if (s === "") { - return l | 0; - } - else if (l === 0) { - return s.split(separator).length | 0; - } - else if (l === s.split(separator).length) { - return l | 0; - } - else { - return toFail(printf("The length of the aggregated string %s does not match the length of the others"))(s) | 0; - } - }, 0, strings); -} - -/** - * Returns a list of ISAJson OntologyAnnotation objects from ISATab aggregated strings - */ -export function OntologyAnnotation_fromAggregatedStrings(separator: string, terms: string, source: string, accessions: string): FSharpList { - const l: int32 = OntologyAnnotation_getLengthOfAggregatedStrings(separator, [terms, source, accessions]) | 0; - if (l === 0) { - return empty(); - } - else { - return ofArray(map3(OntologyAnnotation_fromString_Z7D8EB286, (terms === "") ? fill(new Array(l), 0, l, "") : terms.split(separator), (source === "") ? fill(new Array(l), 0, l, "") : source.split(separator), (accessions === "") ? fill(new Array(l), 0, l, "") : accessions.split(separator))); - } -} - -/** - * Returns the aggregated ISATab OntologyAnnotation Name, ontology source and Accession number from a list of ISAJson OntologyAnnotation objects - */ -export function OntologyAnnotation_toAggregatedStrings(separator: string, oas: FSharpList): { TermAccessionNumberAgg: string, TermNameAgg: string, TermSourceREFAgg: string } { - let first = true; - if (equals(oas, empty())) { - return { - TermAccessionNumberAgg: "", - TermNameAgg: "", - TermSourceREFAgg: "", - }; - } - else { - const tupledArg_1: [string, string, string] = fold_1<{ TermAccessionNumber: string, TermName: string, TermSourceREF: string }, [string, string, string]>((tupledArg: [string, string, string], term: { TermAccessionNumber: string, TermName: string, TermSourceREF: string }): [string, string, string] => { - if (first) { - first = false; - return [term.TermName, term.TermSourceREF, term.TermAccessionNumber] as [string, string, string]; - } - else { - return [toText(printf("%s%c%s"))(tupledArg[0])(separator)(term.TermName), toText(printf("%s%c%s"))(tupledArg[1])(separator)(term.TermSourceREF), toText(printf("%s%c%s"))(tupledArg[2])(separator)(term.TermAccessionNumber)] as [string, string, string]; - } - }, ["", "", ""] as [string, string, string], map(OntologyAnnotation_toString_473B9D79, oas)); - return { - TermAccessionNumberAgg: tupledArg_1[2], - TermNameAgg: tupledArg_1[0], - TermSourceREFAgg: tupledArg_1[1], - }; - } -} - -/** - * Returns a list of ISAJson Component objects from ISATab aggregated strings - */ -export function Component_fromAggregatedStrings(separator: string, names: string, terms: string, source: string, accessions: string): FSharpList { - const l: int32 = OntologyAnnotation_getLengthOfAggregatedStrings(separator, [names, terms, source, accessions]) | 0; - if (l === 0) { - return empty(); - } - else { - return ofArray(Array_map4(Component_fromString_55205B02, (names === "") ? fill(new Array(l), 0, l, "") : names.split(separator), (terms === "") ? fill(new Array(l), 0, l, "") : terms.split(separator), (source === "") ? fill(new Array(l), 0, l, "") : source.split(separator), (accessions === "") ? fill(new Array(l), 0, l, "") : accessions.split(separator))); - } -} - -/** - * Returns the aggregated ISATAb Component Name, Ontology Annotation value, Accession number and ontology source from a list of ISAJson Component objects - */ -export function Component_toAggregatedStrings(separator: string, cs: FSharpList): { NameAgg: string, TermAccessionNumberAgg: string, TermNameAgg: string, TermSourceREFAgg: string } { - let first = true; - if (equals(cs, empty())) { - return { - NameAgg: "", - TermAccessionNumberAgg: "", - TermNameAgg: "", - TermSourceREFAgg: "", - }; - } - else { - const tupledArg_2: [string, string, string, string] = fold_1<[string, { TermAccessionNumber: string, TermName: string, TermSourceREF: string }], [string, string, string, string]>((tupledArg: [string, string, string, string], tupledArg_1: [string, { TermAccessionNumber: string, TermName: string, TermSourceREF: string }]): [string, string, string, string] => { - const name: string = tupledArg_1[0]; - const term: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = tupledArg_1[1]; - if (first) { - first = false; - return [name, term.TermName, term.TermSourceREF, term.TermAccessionNumber] as [string, string, string, string]; - } - else { - return [toText(printf("%s%c%s"))(tupledArg[0])(separator)(name), toText(printf("%s%c%s"))(tupledArg[1])(separator)(term.TermName), toText(printf("%s%c%s"))(tupledArg[2])(separator)(term.TermSourceREF), toText(printf("%s%c%s"))(tupledArg[3])(separator)(term.TermAccessionNumber)] as [string, string, string, string]; - } - }, ["", "", "", ""] as [string, string, string, string], map(Component_toString_Z7E9B32A1, cs)); - return { - NameAgg: tupledArg_2[0], - TermAccessionNumberAgg: tupledArg_2[3], - TermNameAgg: tupledArg_2[1], - TermSourceREFAgg: tupledArg_2[2], - }; - } -} - -/** - * Returns a list of ISAJson ProtocolParameter objects from ISATab aggregated strings - */ -export function ProtocolParameter_fromAggregatedStrings(separator: string, terms: string, source: string, accessions: string): FSharpList { - return map((arg_3: OntologyAnnotation): ProtocolParameter => ((arg_2: Option): ProtocolParameter => ProtocolParameter_make(void 0, arg_2))(arg_3), OntologyAnnotation_fromAggregatedStrings(separator, terms, source, accessions)); -} - -/** - * Returns the aggregated ISATAb Ontology Annotation value, Accession number and ontology source from a list of ISAJson ProtocolParameter objects - */ -export function ProtocolParameter_toAggregatedStrings(separator: string, oas: FSharpList): { TermAccessionNumberAgg: string, TermNameAgg: string, TermSourceREFAgg: string } { - let first = true; - if (equals(oas, empty())) { - return { - TermAccessionNumberAgg: "", - TermNameAgg: "", - TermSourceREFAgg: "", - }; - } - else { - const tupledArg_1: [string, string, string] = fold_1<{ TermAccessionNumber: string, TermName: string, TermSourceREF: string }, [string, string, string]>((tupledArg: [string, string, string], term: { TermAccessionNumber: string, TermName: string, TermSourceREF: string }): [string, string, string] => { - if (first) { - first = false; - return [term.TermName, term.TermSourceREF, term.TermAccessionNumber] as [string, string, string]; - } - else { - return [toText(printf("%s%c%s"))(tupledArg[0])(separator)(term.TermName), toText(printf("%s%c%s"))(tupledArg[1])(separator)(term.TermSourceREF), toText(printf("%s%c%s"))(tupledArg[2])(separator)(term.TermAccessionNumber)] as [string, string, string]; - } - }, ["", "", ""] as [string, string, string], map(ProtocolParameter_toString_2762A46F, oas)); - return { - TermAccessionNumberAgg: tupledArg_1[2], - TermNameAgg: tupledArg_1[0], - TermSourceREFAgg: tupledArg_1[1], - }; - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Assays.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/Assays.ts deleted file mode 100644 index bfc95b28..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Assays.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { reverse, cons, iterate, isEmpty, iterateIndexed, map, initialize, singleton, length, empty, FSharpList, ofArray } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation, OntologyAnnotation_fromString_Z7D8EB286 } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { unwrap, defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { ArcAssay } from "../../ISA/ArcTypes/ArcAssay.js"; -import { Person } from "../../ISA/JsonTypes/Person.js"; -import { Remark, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValue_11FD62A8, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Assay_fileNameFromIdentifier, removeMissingIdentifier, Assay_identifierFromFileName, createMissingIdentifier } from "../../ISA/ArcTypes/Identifier.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { IEnumerator, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; - -export const labels: FSharpList = ofArray(["Measurement Type", "Measurement Type Term Accession Number", "Measurement Type Term Source REF", "Technology Type", "Technology Type Term Accession Number", "Technology Type Term Source REF", "Technology Platform", "File Name"]); - -export function fromString(measurementType: string, measurementTypeTermSourceREF: Option, measurementTypeTermAccessionNumber: Option, technologyType: string, technologyTypeTermSourceREF: Option, technologyTypeTermAccessionNumber: Option, technologyPlatform: string, fileName: string, comments: FSharpList): ArcAssay { - const measurementType_1: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(measurementType, measurementTypeTermSourceREF, measurementTypeTermAccessionNumber); - const technologyType_1: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(technologyType, technologyTypeTermSourceREF, technologyTypeTermAccessionNumber); - const arg_1: Option = Option_fromValueWithDefault(OntologyAnnotation_get_empty(), measurementType_1); - const arg_2: Option = Option_fromValueWithDefault(OntologyAnnotation_get_empty(), technologyType_1); - const arg_3: Option = Option_fromValueWithDefault("", technologyPlatform); - return ArcAssay.make(fileName, arg_1, arg_2, arg_3, [], empty(), comments); -} - -export function fromSparseTable(matrix: SparseTable): FSharpList { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - const comments: FSharpList = SparseTable_GetEmptyComments_Z15A4F148(matrix); - return singleton(ArcAssay.create(createMissingIdentifier(), void 0, void 0, void 0, void 0, void 0, comments)); - } - else { - return initialize(matrix.ColumnCount, (i: int32): ArcAssay => { - const comments_1: FSharpList = map((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i] as [string, int32])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Measurement Type", i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, ["Measurement Type Term Source REF", i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, ["Measurement Type Term Accession Number", i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Technology Type", i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, ["Technology Type Term Source REF", i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, ["Technology Type Term Accession Number", i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Technology Platform", i] as [string, int32]), Assay_identifierFromFileName(SparseTable__TryGetValueDefault_5BAE6133(matrix, createMissingIdentifier(), ["File Name", i] as [string, int32])), comments_1); - }); - } -} - -export function toSparseTable(assays: FSharpList): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(assays) + 1); - let commentKeys: FSharpList = empty(); - iterateIndexed((i: int32, a: ArcAssay): void => { - const processedFileName: string = (a.Identifier.indexOf("MISSING_IDENTIFIER_") === 0) ? removeMissingIdentifier(a.Identifier) : Assay_fileNameFromIdentifier(a.Identifier); - const i_1: int32 = (i + 1) | 0; - const mt_1: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = OntologyAnnotation_toString_473B9D79(defaultArg(a.MeasurementType, OntologyAnnotation_get_empty()), true); - const tt_1: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = OntologyAnnotation_toString_473B9D79(defaultArg(a.TechnologyType, OntologyAnnotation_get_empty()), true); - addToDict(matrix.Matrix, ["Measurement Type", i_1] as [string, int32], mt_1.TermName); - addToDict(matrix.Matrix, ["Measurement Type Term Accession Number", i_1] as [string, int32], mt_1.TermAccessionNumber); - addToDict(matrix.Matrix, ["Measurement Type Term Source REF", i_1] as [string, int32], mt_1.TermSourceREF); - addToDict(matrix.Matrix, ["Technology Type", i_1] as [string, int32], tt_1.TermName); - addToDict(matrix.Matrix, ["Technology Type Term Accession Number", i_1] as [string, int32], tt_1.TermAccessionNumber); - addToDict(matrix.Matrix, ["Technology Type Term Source REF", i_1] as [string, int32], tt_1.TermSourceREF); - addToDict(matrix.Matrix, ["Technology Platform", i_1] as [string, int32], defaultArg(a.TechnologyPlatform, "")); - addToDict(matrix.Matrix, ["File Name", i_1] as [string, int32], processedFileName); - if (!isEmpty(a.Comments)) { - iterate((comment: Comment$): void => { - const patternInput: [string, string] = Comment_toString(comment); - const n: string = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1] as [string, int32], patternInput[1]); - }, a.Comments); - } - }, assays); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix: Option, lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, FSharpList] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, unwrap(prefix)); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])] as [Option, int32, FSharpList, FSharpList]; -} - -export function toRows(prefix: Option, assays: FSharpList): Iterable> { - return SparseTable_ToRows_584133C0(toSparseTable(assays), unwrap(prefix)); -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.ts deleted file mode 100644 index b2ad40ae..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Contacts.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map, initialize, singleton, length, empty, FSharpList, ofArray } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologyAnnotation_toAggregatedStrings, Option_fromValueWithDefault, OntologyAnnotation_fromAggregatedStrings } from "../Conversions.js"; -import { OntologyAnnotation } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Person_create_28E835CB, Person, Person_make } from "../../ISA/JsonTypes/Person.js"; -import { Remark, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { unwrap, value as value_1, Option, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { IEnumerator, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; - -export const lastNameLabel = "Last Name"; - -export const firstNameLabel = "First Name"; - -export const midInitialsLabel = "Mid Initials"; - -export const emailLabel = "Email"; - -export const phoneLabel = "Phone"; - -export const faxLabel = "Fax"; - -export const addressLabel = "Address"; - -export const affiliationLabel = "Affiliation"; - -export const rolesLabel = "Roles"; - -export const rolesTermAccessionNumberLabel = "Roles Term Accession Number"; - -export const rolesTermSourceREFLabel = "Roles Term Source REF"; - -export const labels: FSharpList = ofArray([lastNameLabel, firstNameLabel, midInitialsLabel, emailLabel, phoneLabel, faxLabel, addressLabel, affiliationLabel, rolesLabel, rolesTermAccessionNumberLabel, rolesTermSourceREFLabel]); - -export function fromString(lastName: string, firstName: string, midInitials: string, email: string, phone: string, fax: string, address: string, affiliation: string, role: string, rolesTermAccessionNumber: string, rolesTermSourceREF: string, comments: FSharpList): Person { - const roles: FSharpList = OntologyAnnotation_fromAggregatedStrings(";", role, rolesTermSourceREF, rolesTermAccessionNumber); - return Person_make(void 0, Option_fromValueWithDefault("", lastName), Option_fromValueWithDefault("", firstName), Option_fromValueWithDefault("", midInitials), Option_fromValueWithDefault("", email), Option_fromValueWithDefault("", phone), Option_fromValueWithDefault("", fax), Option_fromValueWithDefault("", address), Option_fromValueWithDefault("", affiliation), Option_fromValueWithDefault>(empty(), roles), Option_fromValueWithDefault>(empty(), comments)); -} - -export function fromSparseTable(matrix: SparseTable): FSharpList { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(Person_create_28E835CB(void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i: int32): Person => { - const comments_1: FSharpList = map((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i] as [string, int32])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [lastNameLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [firstNameLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [midInitialsLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [emailLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [phoneLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [faxLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [addressLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [affiliationLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [rolesLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [rolesTermAccessionNumberLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [rolesTermSourceREFLabel, i] as [string, int32]), comments_1); - }); - } -} - -export function toSparseTable(persons: FSharpList): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(persons) + 1); - let commentKeys: FSharpList = empty(); - iterateIndexed((i: int32, p: Person): void => { - const i_1: int32 = (i + 1) | 0; - const rAgg: { TermAccessionNumberAgg: string, TermNameAgg: string, TermSourceREFAgg: string } = OntologyAnnotation_toAggregatedStrings(";", defaultArg(p.Roles, empty())); - addToDict(matrix.Matrix, [lastNameLabel, i_1] as [string, int32], defaultArg(p.LastName, "")); - addToDict(matrix.Matrix, [firstNameLabel, i_1] as [string, int32], defaultArg(p.FirstName, "")); - addToDict(matrix.Matrix, [midInitialsLabel, i_1] as [string, int32], defaultArg(p.MidInitials, "")); - addToDict(matrix.Matrix, [emailLabel, i_1] as [string, int32], defaultArg(p.EMail, "")); - addToDict(matrix.Matrix, [phoneLabel, i_1] as [string, int32], defaultArg(p.Phone, "")); - addToDict(matrix.Matrix, [faxLabel, i_1] as [string, int32], defaultArg(p.Fax, "")); - addToDict(matrix.Matrix, [addressLabel, i_1] as [string, int32], defaultArg(p.Address, "")); - addToDict(matrix.Matrix, [affiliationLabel, i_1] as [string, int32], defaultArg(p.Affiliation, "")); - addToDict(matrix.Matrix, [rolesLabel, i_1] as [string, int32], rAgg.TermNameAgg); - addToDict(matrix.Matrix, [rolesTermAccessionNumberLabel, i_1] as [string, int32], rAgg.TermAccessionNumberAgg); - addToDict(matrix.Matrix, [rolesTermSourceREFLabel, i_1] as [string, int32], rAgg.TermSourceREFAgg); - const matchValue: Option> = p.Comments; - if (matchValue != null) { - iterate((comment: Comment$): void => { - const patternInput: [string, string] = Comment_toString(comment); - const n: string = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1] as [string, int32], patternInput[1]); - }, value_1(matchValue)); - } - }, persons); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix: Option, lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, FSharpList] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, unwrap(prefix)); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])] as [Option, int32, FSharpList, FSharpList]; -} - -export function toRows(prefix: Option, persons: FSharpList): Iterable> { - const m: SparseTable = toSparseTable(persons); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, value_1(prefix)); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/DesignDescriptors.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/DesignDescriptors.ts deleted file mode 100644 index 7aee7f2c..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/DesignDescriptors.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, empty, map, initialize, singleton, length, FSharpList, ofArray } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_create_131C8C9D } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { Remark, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { value as value_1, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { IEnumerator, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; - -export const designTypeLabel = "Type"; - -export const designTypeTermAccessionNumberLabel = "Type Term Accession Number"; - -export const designTypeTermSourceREFLabel = "Type Term Source REF"; - -export const labels: FSharpList = ofArray([designTypeLabel, designTypeTermAccessionNumberLabel, designTypeTermSourceREFLabel]); - -export function fromSparseTable(matrix: SparseTable): FSharpList { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(OntologyAnnotation_create_131C8C9D(void 0, void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i: int32): OntologyAnnotation => { - const comments_1: FSharpList = map((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i] as [string, int32])), matrix.CommentKeys); - return OntologyAnnotation_fromString_Z7D8EB286(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [designTypeLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [designTypeTermSourceREFLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [designTypeTermAccessionNumberLabel, i] as [string, int32]), comments_1); - }); - } -} - -export function toSparseTable(designs: FSharpList): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(designs) + 1); - let commentKeys: FSharpList = empty(); - iterateIndexed((i: int32, d: OntologyAnnotation): void => { - const i_1: int32 = (i + 1) | 0; - const oa: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = OntologyAnnotation_toString_473B9D79(d, true); - addToDict(matrix.Matrix, [designTypeLabel, i_1] as [string, int32], oa.TermName); - addToDict(matrix.Matrix, [designTypeTermAccessionNumberLabel, i_1] as [string, int32], oa.TermAccessionNumber); - addToDict(matrix.Matrix, [designTypeTermSourceREFLabel, i_1] as [string, int32], oa.TermSourceREF); - const matchValue: Option> = d.Comments; - if (matchValue != null) { - iterate((comment: Comment$): void => { - const patternInput: [string, string] = Comment_toString(comment); - const n: string = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1] as [string, int32], patternInput[1]); - }, value_1(matchValue)); - } - }, designs); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix: Option, lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, FSharpList] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = (prefix == null) ? SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber) : SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, value_1(prefix)); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])] as [Option, int32, FSharpList, FSharpList]; -} - -export function toRows(prefix: Option, designs: FSharpList): Iterable> { - const m: SparseTable = toSparseTable(designs); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, value_1(prefix)); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Factors.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/Factors.ts deleted file mode 100644 index dc4e2869..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Factors.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map, initialize, singleton, length, empty, FSharpList, ofArray } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation, OntologyAnnotation_fromString_Z7D8EB286 } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Factor_create_Z3D2B374F, Factor, Factor_make } from "../../ISA/JsonTypes/Factor.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { Remark, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { value as value_1, defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValue_11FD62A8, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { IEnumerator, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; - -export const nameLabel = "Name"; - -export const factorTypeLabel = "Type"; - -export const typeTermAccessionNumberLabel = "Type Term Accession Number"; - -export const typeTermSourceREFLabel = "Type Term Source REF"; - -export const labels: FSharpList = ofArray([nameLabel, factorTypeLabel, typeTermAccessionNumberLabel, typeTermSourceREFLabel]); - -export function fromString(name: string, designType: string, typeTermSourceREF: Option, typeTermAccessionNumber: Option, comments: FSharpList): Factor { - const factorType: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(designType, typeTermSourceREF, typeTermAccessionNumber); - return Factor_make(void 0, Option_fromValueWithDefault("", name), Option_fromValueWithDefault(OntologyAnnotation_get_empty(), factorType), Option_fromValueWithDefault>(empty(), comments)); -} - -export function fromSparseTable(matrix: SparseTable): FSharpList { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(Factor_create_Z3D2B374F(void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i: int32): Factor => { - const comments_1: FSharpList = map((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i] as [string, int32])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [nameLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [factorTypeLabel, i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, [typeTermSourceREFLabel, i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, [typeTermAccessionNumberLabel, i] as [string, int32]), comments_1); - }); - } -} - -export function toSparseTable(factors: FSharpList): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(factors) + 1); - let commentKeys: FSharpList = empty(); - iterateIndexed((i: int32, f: Factor): void => { - const i_1: int32 = (i + 1) | 0; - const ft: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = OntologyAnnotation_toString_473B9D79(defaultArg(f.FactorType, OntologyAnnotation_get_empty()), true); - addToDict(matrix.Matrix, [nameLabel, i_1] as [string, int32], defaultArg(f.Name, "")); - addToDict(matrix.Matrix, [factorTypeLabel, i_1] as [string, int32], ft.TermName); - addToDict(matrix.Matrix, [typeTermAccessionNumberLabel, i_1] as [string, int32], ft.TermAccessionNumber); - addToDict(matrix.Matrix, [typeTermSourceREFLabel, i_1] as [string, int32], ft.TermSourceREF); - const matchValue: Option> = f.Comments; - if (matchValue != null) { - iterate((comment: Comment$): void => { - const patternInput: [string, string] = Comment_toString(comment); - const n: string = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1] as [string, int32], patternInput[1]); - }, value_1(matchValue)); - } - }, factors); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix: Option, lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, FSharpList] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = (prefix == null) ? SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber) : SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, value_1(prefix)); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])] as [Option, int32, FSharpList, FSharpList]; -} - -export function toRows(prefix: Option, factors: FSharpList): Iterable> { - const m: SparseTable = toSparseTable(factors); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, value_1(prefix)); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Investigation.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/Investigation.ts deleted file mode 100644 index a4269d64..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Investigation.ts +++ /dev/null @@ -1,308 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { head, tail, ofSeq, append, reverse, cons, iterate, isEmpty, empty, map, ofArray, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Remark_toTuple_Z2023CF4E, Remark, Comment$_$reflection, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { comparePrimitives, getEnumerator, IEnumerator, stringHash, IComparable, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, list_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Remark_wrapRemark, Comment_toString, Comment_fromString } from "../Comment.js"; -import { SparseRowModule_writeToSheet, SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_tryGetValueAt, SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValueDefault_5BAE6133 } from "../SparseTable.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { value as value_1, Option, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { ArcInvestigation } from "../../ISA/ArcTypes/ArcInvestigation.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { ArcStudy } from "../../ISA/ArcTypes/ArcStudy.js"; -import { OntologySourceReference } from "../../ISA/JsonTypes/OntologySourceReference.js"; -import { Publication } from "../../ISA/JsonTypes/Publication.js"; -import { Person } from "../../ISA/JsonTypes/Person.js"; -import { toRows as toRows_1, fromRows as fromRows_1 } from "./OntologySourceReference.js"; -import { toRows as toRows_2, fromRows as fromRows_2 } from "./Publication.js"; -import { toRows as toRows_3, fromRows as fromRows_3 } from "./Contacts.js"; -import { toRows as toRows_4, fromRows as fromRows_4 } from "./Study.js"; -import { iterateIndexed, map as map_1, toList, collect, singleton, append as append_1, delay } from "../../../fable_modules/fable-library-ts/Seq.js"; -import { tryFind, FSharpMap, ofList } from "../../../fable_modules/fable-library-ts/Map.js"; -import { printf, toFail } from "../../../fable_modules/fable-library-ts/String.js"; -import { FsRow } from "../../../fable_modules/FsSpreadsheet.3.1.1/FsRow.fs.js"; -import { FsWorksheet } from "../../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { FsWorkbook } from "../../../fable_modules/FsSpreadsheet.3.1.1/FsWorkbook.fs.js"; - -export class InvestigationInfo extends Record implements IEquatable, IComparable { - readonly Identifier: string; - readonly Title: string; - readonly Description: string; - readonly SubmissionDate: string; - readonly PublicReleaseDate: string; - readonly Comments: FSharpList; - constructor(Identifier: string, Title: string, Description: string, SubmissionDate: string, PublicReleaseDate: string, Comments: FSharpList) { - super(); - this.Identifier = Identifier; - this.Title = Title; - this.Description = Description; - this.SubmissionDate = SubmissionDate; - this.PublicReleaseDate = PublicReleaseDate; - this.Comments = Comments; - } -} - -export function InvestigationInfo_$reflection(): TypeInfo { - return record_type("ISA.Spreadsheet.ArcInvestigation.InvestigationInfo", [], InvestigationInfo, () => [["Identifier", string_type], ["Title", string_type], ["Description", string_type], ["SubmissionDate", string_type], ["PublicReleaseDate", string_type], ["Comments", list_type(Comment$_$reflection())]]); -} - -export function InvestigationInfo_create(identifier: string, title: string, description: string, submissionDate: string, publicReleaseDate: string, comments: FSharpList): InvestigationInfo { - return new InvestigationInfo(identifier, title, description, submissionDate, publicReleaseDate, comments); -} - -export function InvestigationInfo_get_Labels(): FSharpList { - return ofArray(["Investigation Identifier", "Investigation Title", "Investigation Description", "Investigation Submission Date", "Investigation Public Release Date"]); -} - -export function InvestigationInfo_FromSparseTable_Z15A4F148(matrix: SparseTable): InvestigationInfo { - const comments: FSharpList = map((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, 0] as [string, int32])), matrix.CommentKeys); - return InvestigationInfo_create(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Identifier", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Title", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Description", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Submission Date", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Investigation Public Release Date", 0] as [string, int32]), comments); -} - -export function InvestigationInfo_ToSparseTable_Z1FC82C0(investigation: ArcInvestigation): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, InvestigationInfo_get_Labels(), void 0, 2); - let commentKeys: FSharpList = empty(); - addToDict(matrix.Matrix, ["Investigation Identifier", 1] as [string, int32], investigation.Identifier); - addToDict(matrix.Matrix, ["Investigation Title", 1] as [string, int32], defaultArg(investigation.Title, "")); - addToDict(matrix.Matrix, ["Investigation Description", 1] as [string, int32], defaultArg(investigation.Description, "")); - addToDict(matrix.Matrix, ["Investigation Submission Date", 1] as [string, int32], defaultArg(investigation.SubmissionDate, "")); - addToDict(matrix.Matrix, ["Investigation Public Release Date", 1] as [string, int32], defaultArg(investigation.PublicReleaseDate, "")); - if (!isEmpty(investigation.Comments)) { - iterate((comment: Comment$): void => { - const patternInput: [string, string] = Comment_toString(comment); - const n: string = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, 1] as [string, int32], patternInput[1]); - }, investigation.Comments); - } - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function InvestigationInfo_fromRows(lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, InvestigationInfo] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = SparseTable_FromRows_Z5579EC29(rows, InvestigationInfo_get_Labels(), lineNumber); - return [tupledArg[0], tupledArg[1], tupledArg[2], InvestigationInfo_FromSparseTable_Z15A4F148(tupledArg[3])] as [Option, int32, FSharpList, InvestigationInfo]; -} - -export function InvestigationInfo_toRows_Z1FC82C0(investigation: ArcInvestigation): Iterable> { - return SparseTable_ToRows_584133C0(InvestigationInfo_ToSparseTable_Z1FC82C0(investigation)); -} - -export function fromParts(investigationInfo: InvestigationInfo, ontologySourceReference: FSharpList, publications: FSharpList, contacts: FSharpList, studies: FSharpList, remarks: FSharpList): ArcInvestigation { - const arg_1: Option = Option_fromValueWithDefault("", investigationInfo.Title); - const arg_2: Option = Option_fromValueWithDefault("", investigationInfo.Description); - const arg_3: Option = Option_fromValueWithDefault("", investigationInfo.SubmissionDate); - const arg_4: Option = Option_fromValueWithDefault("", investigationInfo.PublicReleaseDate); - const arg_8: ArcStudy[] = Array.from(studies); - return ArcInvestigation.make(investigationInfo.Identifier, arg_1, arg_2, arg_3, arg_4, ontologySourceReference, publications, contacts, arg_8, investigationInfo.Comments, remarks); -} - -export function fromRows(rows: Iterable>): ArcInvestigation { - const en: IEnumerator> = getEnumerator(rows); - const emptyInvestigationInfo: InvestigationInfo = InvestigationInfo_create("", "", "", "", "", empty()); - const loop = (lastLine_mut: Option, ontologySourceReferences_mut: FSharpList, investigationInfo_mut: InvestigationInfo, publications_mut: FSharpList, contacts_mut: FSharpList, studies_mut: FSharpList, remarks_mut: FSharpList, lineNumber_mut: int32): ArcInvestigation => { - loop: - while (true) { - const lastLine: Option = lastLine_mut, ontologySourceReferences: FSharpList = ontologySourceReferences_mut, investigationInfo: InvestigationInfo = investigationInfo_mut, publications: FSharpList = publications_mut, contacts: FSharpList = contacts_mut, studies: FSharpList = studies_mut, remarks: FSharpList = remarks_mut, lineNumber: int32 = lineNumber_mut; - let matchResult: int32, k_5: string, k_6: string, k_7: string, k_8: string, k_9: string, k_10: Option; - if (lastLine != null) { - switch (value_1(lastLine)) { - case "ONTOLOGY SOURCE REFERENCE": { - matchResult = 0; - k_5 = value_1(lastLine); - break; - } - case "INVESTIGATION": { - matchResult = 1; - k_6 = value_1(lastLine); - break; - } - case "INVESTIGATION PUBLICATIONS": { - matchResult = 2; - k_7 = value_1(lastLine); - break; - } - case "INVESTIGATION CONTACTS": { - matchResult = 3; - k_8 = value_1(lastLine); - break; - } - case "STUDY": { - matchResult = 4; - k_9 = value_1(lastLine); - break; - } - default: { - matchResult = 5; - k_10 = lastLine; - } - } - } - else { - matchResult = 5; - k_10 = lastLine; - } - switch (matchResult) { - case 0: { - const patternInput: [Option, int32, FSharpList, FSharpList] = fromRows_1(lineNumber + 1, en); - lastLine_mut = patternInput[0]; - ontologySourceReferences_mut = patternInput[3]; - investigationInfo_mut = investigationInfo; - publications_mut = publications; - contacts_mut = contacts; - studies_mut = studies; - remarks_mut = append(remarks, patternInput[2]); - lineNumber_mut = patternInput[1]; - continue loop; - } - case 1: { - const patternInput_1: [Option, int32, FSharpList, InvestigationInfo] = InvestigationInfo_fromRows(lineNumber + 1, en); - lastLine_mut = patternInput_1[0]; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = patternInput_1[3]; - publications_mut = publications; - contacts_mut = contacts; - studies_mut = studies; - remarks_mut = append(remarks, patternInput_1[2]); - lineNumber_mut = patternInput_1[1]; - continue loop; - } - case 2: { - const patternInput_2: [Option, int32, FSharpList, FSharpList] = fromRows_2("Investigation Publication", lineNumber + 1, en); - lastLine_mut = patternInput_2[0]; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = investigationInfo; - publications_mut = patternInput_2[3]; - contacts_mut = contacts; - studies_mut = studies; - remarks_mut = append(remarks, patternInput_2[2]); - lineNumber_mut = patternInput_2[1]; - continue loop; - } - case 3: { - const patternInput_3: [Option, int32, FSharpList, FSharpList] = fromRows_3("Investigation Person", lineNumber + 1, en); - lastLine_mut = patternInput_3[0]; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = investigationInfo; - publications_mut = publications; - contacts_mut = patternInput_3[3]; - studies_mut = studies; - remarks_mut = append(remarks, patternInput_3[2]); - lineNumber_mut = patternInput_3[1]; - continue loop; - } - case 4: { - const patternInput_4: [Option, int32, FSharpList, Option] = fromRows_4(lineNumber + 1, en); - const study: Option = patternInput_4[3]; - const newRemarks_4: FSharpList = patternInput_4[2]; - const lineNumber_5: int32 = patternInput_4[1] | 0; - const currentLine_4: Option = patternInput_4[0]; - if (study != null) { - lastLine_mut = currentLine_4; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = investigationInfo; - publications_mut = publications; - contacts_mut = contacts; - studies_mut = cons(value_1(study), studies); - remarks_mut = append(remarks, newRemarks_4); - lineNumber_mut = lineNumber_5; - continue loop; - } - else { - lastLine_mut = currentLine_4; - ontologySourceReferences_mut = ontologySourceReferences; - investigationInfo_mut = investigationInfo; - publications_mut = publications; - contacts_mut = contacts; - studies_mut = studies; - remarks_mut = append(remarks, newRemarks_4); - lineNumber_mut = lineNumber_5; - continue loop; - } - } - default: - return fromParts(investigationInfo, ontologySourceReferences, publications, contacts, reverse(studies), remarks); - } - break; - } - }; - if (en["System.Collections.IEnumerator.MoveNext"]()) { - return loop(SparseRowModule_tryGetValueAt(0, en["System.Collections.Generic.IEnumerator`1.get_Current"]()), empty(), emptyInvestigationInfo, empty(), empty(), empty(), empty(), 1); - } - else { - throw new Error("emptyInvestigationFile"); - } -} - -export function toRows(investigation: ArcInvestigation): Iterable> { - let remarks: FSharpList, rows: Iterable>; - return (remarks = investigation.Remarks, (rows = delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["ONTOLOGY SOURCE REFERENCE"])), delay>((): Iterable> => append_1>(toRows_1(investigation.OntologySourceReferences), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["INVESTIGATION"])), delay>((): Iterable> => append_1>(InvestigationInfo_toRows_Z1FC82C0(investigation), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["INVESTIGATION PUBLICATIONS"])), delay>((): Iterable> => append_1>(toRows_2("Investigation Publication", investigation.Publications), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["INVESTIGATION CONTACTS"])), delay>((): Iterable> => append_1>(toRows_3("Investigation Person", investigation.Contacts), delay>((): Iterable> => collect>, Iterable<[int32, string]>>((study: ArcStudy): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["STUDY"])), delay>((): Iterable> => toRows_4(study))), ofSeq(investigation.Studies))))))))))))))))))), (() => { - try { - const rm: FSharpMap = ofList(map(Remark_toTuple_Z2023CF4E, remarks), { - Compare: comparePrimitives, - }); - const loop = (i_mut: int32, l_mut: FSharpList>, nl_mut: FSharpList>): FSharpList> => { - loop: - while (true) { - const i: int32 = i_mut, l: FSharpList> = l_mut, nl: FSharpList> = nl_mut; - const matchValue: Option = tryFind(i, rm); - if (matchValue == null) { - if (!isEmpty(l)) { - i_mut = (i + 1); - l_mut = tail(l); - nl_mut = cons(head(l), nl); - continue loop; - } - else { - return nl; - } - } - else { - const remark: string = value_1(matchValue); - i_mut = (i + 1); - l_mut = l; - nl_mut = cons(SparseRowModule_fromValues([Remark_wrapRemark(remark)]), nl); - continue loop; - } - break; - } - }; - return reverse>(loop(1, ofSeq>(rows), empty>())); - } - catch (matchValue_1: any) { - return toList>(rows); - } - })())); -} - -export function fromFsWorkbook(doc: FsWorkbook): ArcInvestigation { - let arg: FsWorksheet; - try { - return fromRows(map_1>(SparseRowModule_fromFsRow, (arg = head(doc.GetWorksheets()), FsWorksheet.getRows(arg)))); - } - catch (err: any) { - const arg_1: string = err.message; - return toFail(printf("Could not read investigation from spreadsheet: %s"))(arg_1); - } -} - -export function toFsWorkbook(investigation: ArcInvestigation): FsWorkbook { - try { - const wb: FsWorkbook = new FsWorkbook(); - const sheet: FsWorksheet = new FsWorksheet("Investigation"); - iterateIndexed>((rowI: int32, r: Iterable<[int32, string]>): void => { - SparseRowModule_writeToSheet(rowI + 1, r, sheet); - }, toRows(investigation)); - wb.AddWorksheet(sheet); - return wb; - } - catch (err: any) { - const arg: string = err.message; - return toFail(printf("Could not write investigation to spreadsheet: %s"))(arg); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.ts deleted file mode 100644 index 3f768718..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/OntologySourceReference.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map, initialize, singleton, length, empty, FSharpList, ofArray } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologySourceReference_create_55205B02, OntologySourceReference, OntologySourceReference_make } from "../../ISA/JsonTypes/OntologySourceReference.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { Remark, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { value as value_1, Option, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { IEnumerator, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; - -export const nameLabel = "Term Source Name"; - -export const fileLabel = "Term Source File"; - -export const versionLabel = "Term Source Version"; - -export const descriptionLabel = "Term Source Description"; - -export const labels: FSharpList = ofArray([nameLabel, fileLabel, versionLabel, descriptionLabel]); - -export function fromString(description: string, file: string, name: string, version: string, comments: FSharpList): OntologySourceReference { - return OntologySourceReference_make(Option_fromValueWithDefault("", description), Option_fromValueWithDefault("", file), Option_fromValueWithDefault("", name), Option_fromValueWithDefault("", version), Option_fromValueWithDefault>(empty(), comments)); -} - -export function fromSparseTable(matrix: SparseTable): FSharpList { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(OntologySourceReference_create_55205B02(void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i: int32): OntologySourceReference => { - const comments_1: FSharpList = map((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i] as [string, int32])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [descriptionLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [fileLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [nameLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [versionLabel, i] as [string, int32]), comments_1); - }); - } -} - -export function toSparseTable(ontologySources: FSharpList): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(ontologySources) + 1); - let commentKeys: FSharpList = empty(); - iterateIndexed((i: int32, o: OntologySourceReference): void => { - const i_1: int32 = (i + 1) | 0; - addToDict(matrix.Matrix, [nameLabel, i_1] as [string, int32], defaultArg(o.Name, "")); - addToDict(matrix.Matrix, [fileLabel, i_1] as [string, int32], defaultArg(o.File, "")); - addToDict(matrix.Matrix, [versionLabel, i_1] as [string, int32], defaultArg(o.Version, "")); - addToDict(matrix.Matrix, [descriptionLabel, i_1] as [string, int32], defaultArg(o.Description, "")); - const matchValue: Option> = o.Comments; - if (matchValue != null) { - iterate((comment: Comment$): void => { - const patternInput: [string, string] = Comment_toString(comment); - const n: string = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1] as [string, int32], patternInput[1]); - }, value_1(matchValue)); - } - }, ontologySources); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, FSharpList] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])] as [Option, int32, FSharpList, FSharpList]; -} - -export function toRows(termSources: FSharpList): Iterable> { - return SparseTable_ToRows_584133C0(toSparseTable(termSources)); -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Protocols.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/Protocols.ts deleted file mode 100644 index 61e5ac47..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Protocols.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map as map_1, initialize, singleton, length, empty, FSharpList, ofArray } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation, OntologyAnnotation_fromString_Z7D8EB286 } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Component_toAggregatedStrings, ProtocolParameter_toAggregatedStrings, Option_fromValueWithDefault, Component_fromAggregatedStrings, ProtocolParameter_fromAggregatedStrings } from "../Conversions.js"; -import { ProtocolParameter } from "../../ISA/JsonTypes/ProtocolParameter.js"; -import { Component } from "../../ISA/JsonTypes/Component.js"; -import { Protocol_create_Z4D717767, Protocol, Protocol_make } from "../../ISA/JsonTypes/Protocol.js"; -import { value as value_3, defaultArg, Option, map } from "../../../fable_modules/fable-library-ts/Option.js"; -import { URIModule_fromString } from "../../ISA/JsonTypes/URI.js"; -import { Remark, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValue_11FD62A8, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { IEnumerator, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; - -export const nameLabel = "Name"; - -export const protocolTypeLabel = "Type"; - -export const typeTermAccessionNumberLabel = "Type Term Accession Number"; - -export const typeTermSourceREFLabel = "Type Term Source REF"; - -export const descriptionLabel = "Description"; - -export const uriLabel = "URI"; - -export const versionLabel = "Version"; - -export const parametersNameLabel = "Parameters Name"; - -export const parametersTermAccessionNumberLabel = "Parameters Term Accession Number"; - -export const parametersTermSourceREFLabel = "Parameters Term Source REF"; - -export const componentsNameLabel = "Components Name"; - -export const componentsTypeLabel = "Components Type"; - -export const componentsTypeTermAccessionNumberLabel = "Components Type Term Accession Number"; - -export const componentsTypeTermSourceREFLabel = "Components Type Term Source REF"; - -export const labels: FSharpList = ofArray([nameLabel, protocolTypeLabel, typeTermAccessionNumberLabel, typeTermSourceREFLabel, descriptionLabel, uriLabel, versionLabel, parametersNameLabel, parametersTermAccessionNumberLabel, parametersTermSourceREFLabel, componentsNameLabel, componentsTypeLabel, componentsTypeTermAccessionNumberLabel, componentsTypeTermSourceREFLabel]); - -export function fromString(name: string, protocolType: string, typeTermAccessionNumber: Option, typeTermSourceREF: Option, description: string, uri: string, version: string, parametersName: string, parametersTermAccessionNumber: string, parametersTermSourceREF: string, componentsName: string, componentsType: string, componentsTypeTermAccessionNumber: string, componentsTypeTermSourceREF: string, comments: FSharpList): Protocol { - const protocolType_1: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(protocolType, typeTermSourceREF, typeTermAccessionNumber); - const parameters: FSharpList = ProtocolParameter_fromAggregatedStrings(";", parametersName, parametersTermSourceREF, parametersTermAccessionNumber); - const components: FSharpList = Component_fromAggregatedStrings(";", componentsName, componentsType, componentsTypeTermSourceREF, componentsTypeTermAccessionNumber); - return Protocol_make(void 0, map(URIModule_fromString, Option_fromValueWithDefault("", name)), Option_fromValueWithDefault(OntologyAnnotation_get_empty(), protocolType_1), Option_fromValueWithDefault("", description), map(URIModule_fromString, Option_fromValueWithDefault("", uri)), Option_fromValueWithDefault("", version), Option_fromValueWithDefault>(empty(), parameters), Option_fromValueWithDefault>(empty(), components), Option_fromValueWithDefault>(empty(), comments)); -} - -export function fromSparseTable(matrix: SparseTable): FSharpList { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(Protocol_create_Z4D717767(void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i: int32): Protocol => { - const comments_1: FSharpList = map_1((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i] as [string, int32])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [nameLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [protocolTypeLabel, i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, [typeTermAccessionNumberLabel, i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, [typeTermSourceREFLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [descriptionLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [uriLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [versionLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [parametersNameLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [parametersTermAccessionNumberLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [parametersTermSourceREFLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [componentsNameLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [componentsTypeLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [componentsTypeTermAccessionNumberLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [componentsTypeTermSourceREFLabel, i] as [string, int32]), comments_1); - }); - } -} - -export function toSparseTable(protocols: FSharpList): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(protocols) + 1); - let commentKeys: FSharpList = empty(); - iterateIndexed((i: int32, p: Protocol): void => { - const i_1: int32 = (i + 1) | 0; - const pt_1: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = OntologyAnnotation_toString_473B9D79(defaultArg(p.ProtocolType, OntologyAnnotation_get_empty()), true); - const pAgg: { TermAccessionNumberAgg: string, TermNameAgg: string, TermSourceREFAgg: string } = ProtocolParameter_toAggregatedStrings(";", defaultArg(p.Parameters, empty())); - const cAgg: { NameAgg: string, TermAccessionNumberAgg: string, TermNameAgg: string, TermSourceREFAgg: string } = Component_toAggregatedStrings(";", defaultArg(p.Components, empty())); - addToDict(matrix.Matrix, [nameLabel, i_1] as [string, int32], defaultArg(p.Name, "")); - addToDict(matrix.Matrix, [protocolTypeLabel, i_1] as [string, int32], pt_1.TermName); - addToDict(matrix.Matrix, [typeTermAccessionNumberLabel, i_1] as [string, int32], pt_1.TermAccessionNumber); - addToDict(matrix.Matrix, [typeTermSourceREFLabel, i_1] as [string, int32], pt_1.TermSourceREF); - addToDict(matrix.Matrix, [descriptionLabel, i_1] as [string, int32], defaultArg(p.Description, "")); - addToDict(matrix.Matrix, [uriLabel, i_1] as [string, int32], defaultArg(p.Uri, "")); - addToDict(matrix.Matrix, [versionLabel, i_1] as [string, int32], defaultArg(p.Version, "")); - addToDict(matrix.Matrix, [parametersNameLabel, i_1] as [string, int32], pAgg.TermNameAgg); - addToDict(matrix.Matrix, [parametersTermAccessionNumberLabel, i_1] as [string, int32], pAgg.TermAccessionNumberAgg); - addToDict(matrix.Matrix, [parametersTermSourceREFLabel, i_1] as [string, int32], pAgg.TermSourceREFAgg); - addToDict(matrix.Matrix, [componentsNameLabel, i_1] as [string, int32], cAgg.NameAgg); - addToDict(matrix.Matrix, [componentsTypeLabel, i_1] as [string, int32], cAgg.TermNameAgg); - addToDict(matrix.Matrix, [componentsTypeTermAccessionNumberLabel, i_1] as [string, int32], cAgg.TermAccessionNumberAgg); - addToDict(matrix.Matrix, [componentsTypeTermSourceREFLabel, i_1] as [string, int32], cAgg.TermSourceREFAgg); - const matchValue: Option> = p.Comments; - if (matchValue != null) { - iterate((comment: Comment$): void => { - const patternInput: [string, string] = Comment_toString(comment); - const n: string = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1] as [string, int32], patternInput[1]); - }, value_3(matchValue)); - } - }, protocols); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix: Option, lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, FSharpList] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = (prefix == null) ? SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber) : SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, value_3(prefix)); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])] as [Option, int32, FSharpList, FSharpList]; -} - -export function toRows(prefix: Option, protocols: FSharpList): Iterable> { - const m: SparseTable = toSparseTable(protocols); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, value_3(prefix)); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Publication.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/Publication.ts deleted file mode 100644 index d94f0145..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Publication.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { reverse, cons, iterate, iterateIndexed, map as map_1, initialize, singleton, length, empty, FSharpList, ofArray } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation, OntologyAnnotation_fromString_Z7D8EB286 } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Publication_create_Z3E55064F, Publication, Publication_make } from "../../ISA/JsonTypes/Publication.js"; -import { value as value_1, defaultArg, Option, map } from "../../../fable_modules/fable-library-ts/Option.js"; -import { URIModule_fromString } from "../../ISA/JsonTypes/URI.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { Remark, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValue_11FD62A8, SparseTable__TryGetValueDefault_5BAE6133, SparseTable_GetEmptyComments_Z15A4F148 } from "../SparseTable.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { IEnumerator, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; - -export const pubMedIDLabel = "PubMed ID"; - -export const doiLabel = "DOI"; - -export const authorListLabel = "Author List"; - -export const titleLabel = "Title"; - -export const statusLabel = "Status"; - -export const statusTermAccessionNumberLabel = "Status Term Accession Number"; - -export const statusTermSourceREFLabel = "Status Term Source REF"; - -export const labels: FSharpList = ofArray([pubMedIDLabel, doiLabel, authorListLabel, titleLabel, statusLabel, statusTermAccessionNumberLabel, statusTermSourceREFLabel]); - -export function fromString(pubMedID: string, doi: string, author: string, title: string, status: string, statusTermSourceREF: Option, statusTermAccessionNumber: Option, comments: FSharpList): Publication { - const status_1: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(status, statusTermSourceREF, statusTermAccessionNumber); - return Publication_make(map(URIModule_fromString, Option_fromValueWithDefault("", pubMedID)), Option_fromValueWithDefault("", doi), Option_fromValueWithDefault("", author), Option_fromValueWithDefault("", title), Option_fromValueWithDefault(OntologyAnnotation_get_empty(), status_1), Option_fromValueWithDefault>(empty(), comments)); -} - -export function fromSparseTable(matrix: SparseTable): FSharpList { - if ((matrix.ColumnCount === 0) && (length(matrix.CommentKeys) !== 0)) { - return singleton(Publication_create_Z3E55064F(void 0, void 0, void 0, void 0, void 0, SparseTable_GetEmptyComments_Z15A4F148(matrix))); - } - else { - return initialize(matrix.ColumnCount, (i: int32): Publication => { - const comments_1: FSharpList = map_1((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, i] as [string, int32])), matrix.CommentKeys); - return fromString(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [pubMedIDLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [doiLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [authorListLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [titleLabel, i] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [statusLabel, i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, [statusTermSourceREFLabel, i] as [string, int32]), SparseTable__TryGetValue_11FD62A8(matrix, [statusTermAccessionNumberLabel, i] as [string, int32]), comments_1); - }); - } -} - -export function toSparseTable(publications: FSharpList): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, labels, void 0, length(publications) + 1); - let commentKeys: FSharpList = empty(); - iterateIndexed((i: int32, p: Publication): void => { - const i_1: int32 = (i + 1) | 0; - const s_1: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = OntologyAnnotation_toString_473B9D79(defaultArg(p.Status, OntologyAnnotation_get_empty()), true); - addToDict(matrix.Matrix, [pubMedIDLabel, i_1] as [string, int32], defaultArg(p.PubMedID, "")); - addToDict(matrix.Matrix, [doiLabel, i_1] as [string, int32], defaultArg(p.DOI, "")); - addToDict(matrix.Matrix, [authorListLabel, i_1] as [string, int32], defaultArg(p.Authors, "")); - addToDict(matrix.Matrix, [titleLabel, i_1] as [string, int32], defaultArg(p.Title, "")); - addToDict(matrix.Matrix, [statusLabel, i_1] as [string, int32], s_1.TermName); - addToDict(matrix.Matrix, [statusTermAccessionNumberLabel, i_1] as [string, int32], s_1.TermAccessionNumber); - addToDict(matrix.Matrix, [statusTermSourceREFLabel, i_1] as [string, int32], s_1.TermSourceREF); - const matchValue: Option> = p.Comments; - if (matchValue != null) { - iterate((comment: Comment$): void => { - const patternInput: [string, string] = Comment_toString(comment); - const n: string = patternInput[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, i_1] as [string, int32], patternInput[1]); - }, value_1(matchValue)); - } - }, publications); - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function fromRows(prefix: Option, lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, FSharpList] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = (prefix == null) ? SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber) : SparseTable_FromRows_Z5579EC29(rows, labels, lineNumber, value_1(prefix)); - return [tupledArg[0], tupledArg[1], tupledArg[2], fromSparseTable(tupledArg[3])] as [Option, int32, FSharpList, FSharpList]; -} - -export function toRows(prefix: Option, publications: FSharpList): Iterable> { - const m: SparseTable = toSparseTable(publications); - if (prefix == null) { - return SparseTable_ToRows_584133C0(m); - } - else { - return SparseTable_ToRows_584133C0(m, value_1(prefix)); - } -} - diff --git a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Study.ts b/ts/ISA/ISA.Spreadsheet/InvestigationFile/Study.ts deleted file mode 100644 index c04048d1..00000000 --- a/ts/ISA/ISA.Spreadsheet/InvestigationFile/Study.ts +++ /dev/null @@ -1,266 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { ofSeq, append, reverse, cons, iterate, isEmpty, empty, map, ofArray, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Remark, Comment$_$reflection, Comment$ } from "../../ISA/JsonTypes/Comment.js"; -import { IEnumerator, stringHash, IComparable, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, list_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Comment_toString, Comment_fromString } from "../Comment.js"; -import { SparseRowModule_fromValues, SparseTable_ToRows_584133C0, SparseTable_FromRows_Z5579EC29, SparseTable_Create_Z2192E64B, SparseTable, SparseTable__TryGetValueDefault_5BAE6133 } from "../SparseTable.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { Study_fileNameFromIdentifier } from "../../ISA/ArcTypes/Identifier.js"; -import { addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { value as value_1, Option, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { ArcStudy } from "../../ISA/ArcTypes/ArcStudy.js"; -import { Option_fromValueWithDefault } from "../Conversions.js"; -import { ArcTable } from "../../ISA/ArcTypes/ArcTable.js"; -import { Protocol } from "../../ISA/JsonTypes/Protocol.js"; -import { ArcAssay } from "../../ISA/ArcTypes/ArcAssay.js"; -import { OntologyAnnotation } from "../../ISA/JsonTypes/OntologyAnnotation.js"; -import { Publication } from "../../ISA/JsonTypes/Publication.js"; -import { Factor } from "../../ISA/JsonTypes/Factor.js"; -import { Person } from "../../ISA/JsonTypes/Person.js"; -import { toRows as toRows_1, fromRows as fromRows_1 } from "./DesignDescriptors.js"; -import { toRows as toRows_2, fromRows as fromRows_2 } from "./Publication.js"; -import { toRows as toRows_3, fromRows as fromRows_3 } from "./Factors.js"; -import { toRows as toRows_4, fromRows as fromRows_4 } from "./Assays.js"; -import { toRows as toRows_5, fromRows as fromRows_5 } from "./Protocols.js"; -import { toRows as toRows_6, fromRows as fromRows_6 } from "./Contacts.js"; -import { singleton, append as append_1, delay, collect } from "../../../fable_modules/fable-library-ts/Seq.js"; - -export class StudyInfo extends Record implements IEquatable, IComparable { - readonly Identifier: string; - readonly Title: string; - readonly Description: string; - readonly SubmissionDate: string; - readonly PublicReleaseDate: string; - readonly FileName: string; - readonly Comments: FSharpList; - constructor(Identifier: string, Title: string, Description: string, SubmissionDate: string, PublicReleaseDate: string, FileName: string, Comments: FSharpList) { - super(); - this.Identifier = Identifier; - this.Title = Title; - this.Description = Description; - this.SubmissionDate = SubmissionDate; - this.PublicReleaseDate = PublicReleaseDate; - this.FileName = FileName; - this.Comments = Comments; - } -} - -export function StudyInfo_$reflection(): TypeInfo { - return record_type("ISA.Spreadsheet.Studies.StudyInfo", [], StudyInfo, () => [["Identifier", string_type], ["Title", string_type], ["Description", string_type], ["SubmissionDate", string_type], ["PublicReleaseDate", string_type], ["FileName", string_type], ["Comments", list_type(Comment$_$reflection())]]); -} - -export function StudyInfo_create(identifier: string, title: string, description: string, submissionDate: string, publicReleaseDate: string, fileName: string, comments: FSharpList): StudyInfo { - return new StudyInfo(identifier, title, description, submissionDate, publicReleaseDate, fileName, comments); -} - -export function StudyInfo_get_Labels(): FSharpList { - return ofArray(["Study Identifier", "Study Title", "Study Description", "Study Submission Date", "Study Public Release Date", "Study File Name"]); -} - -export function StudyInfo_FromSparseTable_Z15A4F148(matrix: SparseTable): StudyInfo { - const comments: FSharpList = map((k: string): Comment$ => Comment_fromString(k, SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [k, 0] as [string, int32])), matrix.CommentKeys); - return StudyInfo_create(SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Identifier", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Title", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Description", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Submission Date", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study Public Release Date", 0] as [string, int32]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Study File Name", 0] as [string, int32]), comments); -} - -export function StudyInfo_ToSparseTable_331096F(study: ArcStudy): SparseTable { - const matrix: SparseTable = SparseTable_Create_Z2192E64B(void 0, StudyInfo_get_Labels(), void 0, 2); - let commentKeys: FSharpList = empty(); - const patternInput: [string, string] = (study.Identifier.indexOf("MISSING_IDENTIFIER_") === 0) ? (["", ""] as [string, string]) : ([study.Identifier, Study_fileNameFromIdentifier(study.Identifier)] as [string, string]); - addToDict(matrix.Matrix, ["Study Identifier", 1] as [string, int32], patternInput[0]); - addToDict(matrix.Matrix, ["Study Title", 1] as [string, int32], defaultArg(study.Title, "")); - addToDict(matrix.Matrix, ["Study Description", 1] as [string, int32], defaultArg(study.Description, "")); - addToDict(matrix.Matrix, ["Study Submission Date", 1] as [string, int32], defaultArg(study.SubmissionDate, "")); - addToDict(matrix.Matrix, ["Study Public Release Date", 1] as [string, int32], defaultArg(study.PublicReleaseDate, "")); - addToDict(matrix.Matrix, ["Study File Name", 1] as [string, int32], patternInput[1]); - if (!isEmpty(study.Comments)) { - iterate((comment: Comment$): void => { - const patternInput_1: [string, string] = Comment_toString(comment); - const n: string = patternInput_1[0]; - commentKeys = cons(n, commentKeys); - addToDict(matrix.Matrix, [n, 1] as [string, int32], patternInput_1[1]); - }, study.Comments); - } - return new SparseTable(matrix.Matrix, matrix.Keys, reverse(List_distinct(commentKeys, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })), matrix.ColumnCount); -} - -export function StudyInfo_fromRows(lineNumber: int32, rows: IEnumerator>): [Option, int32, FSharpList, StudyInfo] { - const tupledArg: [Option, int32, FSharpList, SparseTable] = SparseTable_FromRows_Z5579EC29(rows, StudyInfo_get_Labels(), lineNumber); - return [tupledArg[0], tupledArg[1], tupledArg[2], StudyInfo_FromSparseTable_Z15A4F148(tupledArg[3])] as [Option, int32, FSharpList, StudyInfo]; -} - -export function StudyInfo_toRows_331096F(study: ArcStudy): Iterable> { - return SparseTable_ToRows_584133C0(StudyInfo_ToSparseTable_331096F(study)); -} - -export function fromParts(studyInfo: StudyInfo, designDescriptors: FSharpList, publications: FSharpList, factors: FSharpList, assays: FSharpList, protocols: FSharpList, contacts: FSharpList): Option { - let arcstudy: ArcStudy; - const arg_1: Option = Option_fromValueWithDefault("", studyInfo.Title); - const arg_2: Option = Option_fromValueWithDefault("", studyInfo.Description); - const arg_3: Option = Option_fromValueWithDefault("", studyInfo.SubmissionDate); - const arg_4: Option = Option_fromValueWithDefault("", studyInfo.PublicReleaseDate); - let arg_8: ArcTable[]; - const arg_13: FSharpList = map((arg_12: Protocol): ArcTable => ArcTable.fromProtocol(arg_12), protocols); - arg_8 = Array.from(arg_13); - const arg_9: ArcAssay[] = Array.from(assays); - arcstudy = ArcStudy.make(studyInfo.Identifier, arg_1, arg_2, arg_3, arg_4, publications, contacts, designDescriptors, arg_8, arg_9, factors, studyInfo.Comments); - if (arcstudy.isEmpty && (arcstudy.Identifier === "")) { - return void 0; - } - else { - return arcstudy; - } -} - -export function fromRows(lineNumber: int32, en: IEnumerator>): [Option, int32, FSharpList, Option] { - const loop = (lastLine_mut: Option, studyInfo_mut: StudyInfo, designDescriptors_mut: FSharpList, publications_mut: FSharpList, factors_mut: FSharpList, assays_mut: FSharpList, protocols_mut: FSharpList, contacts_mut: FSharpList, remarks_mut: FSharpList, lineNumber_1_mut: int32): [Option, int32, FSharpList, Option] => { - loop: - while (true) { - const lastLine: Option = lastLine_mut, studyInfo: StudyInfo = studyInfo_mut, designDescriptors: FSharpList = designDescriptors_mut, publications: FSharpList = publications_mut, factors: FSharpList = factors_mut, assays: FSharpList = assays_mut, protocols: FSharpList = protocols_mut, contacts: FSharpList = contacts_mut, remarks: FSharpList = remarks_mut, lineNumber_1: int32 = lineNumber_1_mut; - let matchResult: int32, k_6: string, k_7: string, k_8: string, k_9: string, k_10: string, k_11: string, k_12: Option; - if (lastLine != null) { - switch (value_1(lastLine)) { - case "STUDY DESIGN DESCRIPTORS": { - matchResult = 0; - k_6 = value_1(lastLine); - break; - } - case "STUDY PUBLICATIONS": { - matchResult = 1; - k_7 = value_1(lastLine); - break; - } - case "STUDY FACTORS": { - matchResult = 2; - k_8 = value_1(lastLine); - break; - } - case "STUDY ASSAYS": { - matchResult = 3; - k_9 = value_1(lastLine); - break; - } - case "STUDY PROTOCOLS": { - matchResult = 4; - k_10 = value_1(lastLine); - break; - } - case "STUDY CONTACTS": { - matchResult = 5; - k_11 = value_1(lastLine); - break; - } - default: { - matchResult = 6; - k_12 = lastLine; - } - } - } - else { - matchResult = 6; - k_12 = lastLine; - } - switch (matchResult) { - case 0: { - const patternInput: [Option, int32, FSharpList, FSharpList] = fromRows_1("Study Design", lineNumber_1 + 1, en); - lastLine_mut = patternInput[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = patternInput[3]; - publications_mut = publications; - factors_mut = factors; - assays_mut = assays; - protocols_mut = protocols; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput[2]); - lineNumber_1_mut = patternInput[1]; - continue loop; - } - case 1: { - const patternInput_1: [Option, int32, FSharpList, FSharpList] = fromRows_2("Study Publication", lineNumber_1 + 1, en); - lastLine_mut = patternInput_1[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = patternInput_1[3]; - factors_mut = factors; - assays_mut = assays; - protocols_mut = protocols; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput_1[2]); - lineNumber_1_mut = patternInput_1[1]; - continue loop; - } - case 2: { - const patternInput_2: [Option, int32, FSharpList, FSharpList] = fromRows_3("Study Factor", lineNumber_1 + 1, en); - lastLine_mut = patternInput_2[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = publications; - factors_mut = patternInput_2[3]; - assays_mut = assays; - protocols_mut = protocols; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput_2[2]); - lineNumber_1_mut = patternInput_2[1]; - continue loop; - } - case 3: { - const patternInput_3: [Option, int32, FSharpList, FSharpList] = fromRows_4("Study Assay", lineNumber_1 + 1, en); - lastLine_mut = patternInput_3[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = publications; - factors_mut = factors; - assays_mut = patternInput_3[3]; - protocols_mut = protocols; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput_3[2]); - lineNumber_1_mut = patternInput_3[1]; - continue loop; - } - case 4: { - const patternInput_4: [Option, int32, FSharpList, FSharpList] = fromRows_5("Study Protocol", lineNumber_1 + 1, en); - lastLine_mut = patternInput_4[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = publications; - factors_mut = factors; - assays_mut = assays; - protocols_mut = patternInput_4[3]; - contacts_mut = contacts; - remarks_mut = append(remarks, patternInput_4[2]); - lineNumber_1_mut = patternInput_4[1]; - continue loop; - } - case 5: { - const patternInput_5: [Option, int32, FSharpList, FSharpList] = fromRows_6("Study Person", lineNumber_1 + 1, en); - lastLine_mut = patternInput_5[0]; - studyInfo_mut = studyInfo; - designDescriptors_mut = designDescriptors; - publications_mut = publications; - factors_mut = factors; - assays_mut = assays; - protocols_mut = protocols; - contacts_mut = patternInput_5[3]; - remarks_mut = append(remarks, patternInput_5[2]); - lineNumber_1_mut = patternInput_5[1]; - continue loop; - } - default: - return [k_12!, lineNumber_1, remarks, fromParts(studyInfo, designDescriptors, publications, factors, assays, protocols, contacts)] as [Option, int32, FSharpList, Option]; - } - break; - } - }; - const patternInput_6: [Option, int32, FSharpList, StudyInfo] = StudyInfo_fromRows(lineNumber, en); - return loop(patternInput_6[0], patternInput_6[3], empty(), empty(), empty(), empty(), empty(), empty(), patternInput_6[2], patternInput_6[1]); -} - -export function toRows(study: ArcStudy): Iterable> { - const protocols: FSharpList = ofSeq(collect, Protocol>((p: ArcTable): FSharpList => p.GetProtocols(), study.Tables)); - return delay>((): Iterable> => append_1>(StudyInfo_toRows_331096F(study), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["STUDY DESIGN DESCRIPTORS"])), delay>((): Iterable> => append_1>(toRows_1("Study Design", study.StudyDesignDescriptors), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["STUDY PUBLICATIONS"])), delay>((): Iterable> => append_1>(toRows_2("Study Publication", study.Publications), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["STUDY FACTORS"])), delay>((): Iterable> => append_1>(toRows_3("Study Factor", study.Factors), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["STUDY ASSAYS"])), delay>((): Iterable> => append_1>(toRows_4("Study Assay", ofSeq(study.Assays)), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["STUDY PROTOCOLS"])), delay>((): Iterable> => append_1>(toRows_5("Study Protocol", protocols), delay>((): Iterable> => append_1>(singleton>(SparseRowModule_fromValues(["STUDY CONTACTS"])), delay>((): Iterable> => toRows_6("Study Person", study.Contacts)))))))))))))))))))))))))); -} - diff --git a/ts/ISA/ISA.Spreadsheet/SparseTable.ts b/ts/ISA/ISA.Spreadsheet/SparseTable.ts deleted file mode 100644 index de936228..00000000 --- a/ts/ISA/ISA.Spreadsheet/SparseTable.ts +++ /dev/null @@ -1,449 +0,0 @@ -import { append as append_1, delay, tryItem, length as length_1, isEmpty, iterate, fold, tryPick, maxBy, initialize, choose, map, indexed } from "../../fable_modules/fable-library-ts/Seq.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { defaultArg, value, Option, map as map_1 } from "../../fable_modules/fable-library-ts/Option.js"; -import { tryFind, FSharpMap, ofSeq } from "../../fable_modules/fable-library-ts/Map.js"; -import { IEnumerator, arrayHash, equalArrays, IEquatable, IMap, equals, comparePrimitives } from "../../fable_modules/fable-library-ts/Util.js"; -import { DataType_String, DataType_$union, FsCell } from "../../fable_modules/FsSpreadsheet.3.1.1/Cells/FsCell.fs.js"; -import { FsRow } from "../../fable_modules/FsSpreadsheet.3.1.1/FsRow.fs.js"; -import { RowBuilder_get_Empty, RowBuilder__Combine_19F30600, RowBuilder_$ctor } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/RowBuilder.fs.js"; -import { RowBuilder } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/RowBuilder.fs.js"; -import { RowElement_IndexedCell, ColumnIndex, RowElement_UnindexedCell, Message_$union, RowElement_$union, SheetEntity$1_$union } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/Types.fs.js"; -import { map as map_2, initialize as initialize_1, exists, find, cons, append, empty, singleton, FSharpList } from "../../fable_modules/fable-library-ts/List.js"; -import { CellBuilder_$ctor, CellBuilder__AsCellElement_825BA8D } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/CellBuilder.fs.js"; -import { Messages_format, SheetEntity$1_some_2B595 } from "../../fable_modules/FsSpreadsheet.3.1.1/DSL/Types.fs.js"; -import { FsWorksheet } from "../../fable_modules/FsSpreadsheet.3.1.1/FsWorksheet.fs.js"; -import { Record } from "../../fable_modules/fable-library-ts/Types.js"; -import { record_type, list_type, class_type, tuple_type, int32_type, string_type, TypeInfo } from "../../fable_modules/fable-library-ts/Reflection.js"; -import { Seq_trySkip, Dictionary_tryGetValue } from "./CollectionAux.js"; -import { addToDict, getItemFromDict } from "../../fable_modules/fable-library-ts/MapUtil.js"; -import { Dictionary } from "../../fable_modules/fable-library-ts/MutableMap.js"; -import { printf, toFail } from "../../fable_modules/fable-library-ts/String.js"; -import { Comment$, Comment_create_250E0578, Remark, Remark_make } from "../ISA/JsonTypes/Comment.js"; -import { Comment_wrapCommentKey, Comment_$007CComment$007C_$007C, Remark_$007CRemark$007C_$007C } from "./Comment.js"; - -export function SparseRowModule_fromValues(v: Iterable): Iterable<[int32, string]> { - return indexed(v); -} - -export function SparseRowModule_getValues(i: Iterable<[int32, string]>): Iterable { - return map<[int32, string], string>((tuple: [int32, string]): string => tuple[1], i); -} - -export function SparseRowModule_fromAllValues(v: Iterable>): Iterable<[int32, string]> { - return choose<[int32, Option], [int32, string]>((tupledArg: [int32, Option]): Option<[int32, string]> => map_1((v_1: string): [int32, string] => ([tupledArg[0], v_1] as [int32, string]), tupledArg[1]), indexed>(v)); -} - -export function SparseRowModule_getAllValues(i: Iterable<[int32, string]>): Iterable> { - const m: FSharpMap = ofSeq(i, { - Compare: comparePrimitives, - }); - return initialize>(maxBy<[int32, string], int32>((tuple: [int32, string]): int32 => tuple[0], i, { - Compare: comparePrimitives, - })[0] + 1, (i_1: int32): Option => tryFind(i_1, m)); -} - -export function SparseRowModule_fromFsRow(r: FsRow): Iterable<[int32, string]> { - return map((c: FsCell): [int32, string] => ([c.ColumnNumber - 1, c.Value] as [int32, string]), r.Cells); -} - -export function SparseRowModule_tryGetValueAt(i: int32, vs: Iterable<[int32, string]>): Option { - return tryPick<[int32, string], string>((tupledArg: [int32, string]): Option => { - if (tupledArg[0] === i) { - return tupledArg[1]; - } - else { - return void 0; - } - }, vs); -} - -export function SparseRowModule_toDSLRow(vs: Iterable<[int32, string]>): FSharpList { - const builder$0040: RowBuilder = RowBuilder_$ctor(); - let this$_9: SheetEntity$1_$union>; - const arg: Iterable>> = map, SheetEntity$1_$union>>((_arg: Option): SheetEntity$1_$union> => { - const v: Option = _arg; - if (v == null) { - let c_1: [[DataType_$union, string], Option]; - const this$_5: SheetEntity$1_$union<[[DataType_$union, string], Option]> = CellBuilder__AsCellElement_825BA8D(CellBuilder_$ctor(), SheetEntity$1_some_2B595>(singleton([DataType_String(), ""] as [DataType_$union, string]))); - let matchResult: int32, errs_1: FSharpList, f_1: [[DataType_$union, string], Option], ms_2_1: FSharpList; - switch (this$_5.tag) { - case /* NoneOptional */ 1: { - if (equals(this$_5.fields[0], empty())) { - matchResult = 1; - ms_2_1 = this$_5.fields[0]; - } - else { - matchResult = 2; - } - break; - } - case /* NoneRequired */ 2: { - if (equals(this$_5.fields[0], empty())) { - matchResult = 1; - ms_2_1 = this$_5.fields[0]; - } - else { - matchResult = 2; - } - break; - } - default: { - matchResult = 0; - errs_1 = this$_5.fields[1]; - f_1 = this$_5.fields[0]; - } - } - switch (matchResult) { - case 0: { - c_1 = f_1!; - break; - } - case 1: { - throw new Error("SheetEntity does not contain Value."); - break; - } - default: { - let matchResult_1: int32, ms_3_1: FSharpList; - switch (this$_5.tag) { - case /* NoneOptional */ 1: { - matchResult_1 = 0; - ms_3_1 = this$_5.fields[0]; - break; - } - case /* NoneRequired */ 2: { - matchResult_1 = 0; - ms_3_1 = this$_5.fields[0]; - break; - } - default: - matchResult_1 = 1; - } - switch (matchResult_1) { - case 0: { - throw new Error(`SheetEntity does not contain Value: - ${Messages_format(ms_3_1!)}`); - break; - } - default: - throw new Error("Match failure: FsSpreadsheet.DSL.SheetEntity`1"); - } - } - } - return SheetEntity$1_some_2B595>(singleton((c_1[1] == null) ? RowElement_UnindexedCell(c_1[0]) : RowElement_IndexedCell(new ColumnIndex(value(c_1[1])), c_1[0]))); - } - else { - const v_1: string = value(v); - let c: [[DataType_$union, string], Option]; - const this$_2: SheetEntity$1_$union<[[DataType_$union, string], Option]> = CellBuilder__AsCellElement_825BA8D(CellBuilder_$ctor(), SheetEntity$1_some_2B595>(singleton([DataType_String(), v_1] as [DataType_$union, string]))); - let matchResult_2: int32, errs: FSharpList, f: [[DataType_$union, string], Option], ms_2: FSharpList; - switch (this$_2.tag) { - case /* NoneOptional */ 1: { - if (equals(this$_2.fields[0], empty())) { - matchResult_2 = 1; - ms_2 = this$_2.fields[0]; - } - else { - matchResult_2 = 2; - } - break; - } - case /* NoneRequired */ 2: { - if (equals(this$_2.fields[0], empty())) { - matchResult_2 = 1; - ms_2 = this$_2.fields[0]; - } - else { - matchResult_2 = 2; - } - break; - } - default: { - matchResult_2 = 0; - errs = this$_2.fields[1]; - f = this$_2.fields[0]; - } - } - switch (matchResult_2) { - case 0: { - c = f!; - break; - } - case 1: { - throw new Error("SheetEntity does not contain Value."); - break; - } - default: { - let matchResult_3: int32, ms_3: FSharpList; - switch (this$_2.tag) { - case /* NoneOptional */ 1: { - matchResult_3 = 0; - ms_3 = this$_2.fields[0]; - break; - } - case /* NoneRequired */ 2: { - matchResult_3 = 0; - ms_3 = this$_2.fields[0]; - break; - } - default: - matchResult_3 = 1; - } - switch (matchResult_3) { - case 0: { - throw new Error(`SheetEntity does not contain Value: - ${Messages_format(ms_3!)}`); - break; - } - default: - throw new Error("Match failure: FsSpreadsheet.DSL.SheetEntity`1"); - } - } - } - return SheetEntity$1_some_2B595>(singleton((c[1] == null) ? RowElement_UnindexedCell(c[0]) : RowElement_IndexedCell(new ColumnIndex(value(c[1])), c[0]))); - } - }, SparseRowModule_getAllValues(vs)); - this$_9 = fold>, SheetEntity$1_$union>>((state: SheetEntity$1_$union>, we: SheetEntity$1_$union>): SheetEntity$1_$union> => RowBuilder__Combine_19F30600(builder$0040, state, we), RowBuilder_get_Empty(), arg); - let matchResult_4: int32, errs_2: FSharpList, f_3: FSharpList, ms_2_2: FSharpList; - switch (this$_9.tag) { - case /* NoneOptional */ 1: { - if (equals(this$_9.fields[0], empty())) { - matchResult_4 = 1; - ms_2_2 = this$_9.fields[0]; - } - else { - matchResult_4 = 2; - } - break; - } - case /* NoneRequired */ 2: { - if (equals(this$_9.fields[0], empty())) { - matchResult_4 = 1; - ms_2_2 = this$_9.fields[0]; - } - else { - matchResult_4 = 2; - } - break; - } - default: { - matchResult_4 = 0; - errs_2 = this$_9.fields[1]; - f_3 = this$_9.fields[0]; - } - } - switch (matchResult_4) { - case 0: - return f_3!; - case 1: - throw new Error("SheetEntity does not contain Value."); - default: { - let matchResult_5: int32, ms_3_2: FSharpList; - switch (this$_9.tag) { - case /* NoneOptional */ 1: { - matchResult_5 = 0; - ms_3_2 = this$_9.fields[0]; - break; - } - case /* NoneRequired */ 2: { - matchResult_5 = 0; - ms_3_2 = this$_9.fields[0]; - break; - } - default: - matchResult_5 = 1; - } - switch (matchResult_5) { - case 0: - throw new Error(`SheetEntity does not contain Value: - ${Messages_format(ms_3_2!)}`); - default: - throw new Error("Match failure: FsSpreadsheet.DSL.SheetEntity`1"); - } - } - } -} - -export function SparseRowModule_readFromSheet(sheet: FsWorksheet): Iterable> { - return map>(SparseRowModule_fromFsRow, sheet.Rows); -} - -export function SparseRowModule_writeToSheet(rowI: int32, row: Iterable<[int32, string]>, sheet: FsWorksheet): void { - const fsRow: FsRow = sheet.Row(rowI); - iterate<[int32, string]>((tupledArg: [int32, string]): void => { - fsRow.Item(tupledArg[0] + 1).SetValueAs(tupledArg[1]); - }, row); -} - -export class SparseTable extends Record implements IEquatable { - readonly Matrix: IMap<[string, int32], string>; - readonly Keys: FSharpList; - readonly CommentKeys: FSharpList; - readonly ColumnCount: int32; - constructor(Matrix: IMap<[string, int32], string>, Keys: FSharpList, CommentKeys: FSharpList, ColumnCount: int32) { - super(); - this.Matrix = Matrix; - this.Keys = Keys; - this.CommentKeys = CommentKeys; - this.ColumnCount = (ColumnCount | 0); - } -} - -export function SparseTable_$reflection(): TypeInfo { - return record_type("ISA.Spreadsheet.SparseTable", [], SparseTable, () => [["Matrix", class_type("System.Collections.Generic.Dictionary`2", [tuple_type(string_type, int32_type), string_type])], ["Keys", list_type(string_type)], ["CommentKeys", list_type(string_type)], ["ColumnCount", int32_type]]); -} - -export function SparseTable__TryGetValue_11FD62A8(this$: SparseTable, key: [string, int32]): Option { - return Dictionary_tryGetValue<[string, int32], string>(key, this$.Matrix); -} - -export function SparseTable__TryGetValueDefault_5BAE6133(this$: SparseTable, defaultValue: string, key: [string, int32]): string { - if (this$.Matrix.has(key)) { - return getItemFromDict(this$.Matrix, key); - } - else { - return defaultValue; - } -} - -export function SparseTable_Create_Z2192E64B(matrix?: IMap<[string, int32], string>, keys?: FSharpList, commentKeys?: FSharpList, length?: int32): SparseTable { - return new SparseTable(defaultArg(matrix, new Dictionary<[string, int32], string>([], { - Equals: equalArrays, - GetHashCode: arrayHash, - })), defaultArg(keys, empty()), defaultArg(commentKeys, empty()), defaultArg(length, 0)); -} - -export function SparseTable_AddRow(key: string, values: Iterable<[int32, string]>, matrix: SparseTable): SparseTable { - iterate<[int32, string]>((tupledArg: [int32, string]): void => { - addToDict(matrix.Matrix, [key, tupledArg[0]] as [string, int32], tupledArg[1]); - }, values); - const length: int32 = (isEmpty<[int32, string]>(values) ? 0 : (1 + maxBy<[int32, string], int32>((tuple: [int32, string]): int32 => tuple[0], values, { - Compare: comparePrimitives, - })[0])) | 0; - return new SparseTable(matrix.Matrix, append(matrix.Keys, singleton(key)), matrix.CommentKeys, (length > matrix.ColumnCount) ? length : matrix.ColumnCount); -} - -export function SparseTable_AddEmptyComment(key: string, matrix: SparseTable): SparseTable { - return new SparseTable(matrix.Matrix, matrix.Keys, append(matrix.CommentKeys, singleton(key)), matrix.ColumnCount); -} - -export function SparseTable_AddComment(key: string, values: Iterable<[int32, string]>, matrix: SparseTable): SparseTable { - if (length_1<[int32, string]>(values) === 0) { - return SparseTable_AddEmptyComment(key, matrix); - } - else { - iterate<[int32, string]>((tupledArg: [int32, string]): void => { - addToDict(matrix.Matrix, [key, tupledArg[0]] as [string, int32], tupledArg[1]); - }, values); - const length: int32 = (isEmpty<[int32, string]>(values) ? 0 : (1 + maxBy<[int32, string], int32>((tuple: [int32, string]): int32 => tuple[0], values, { - Compare: comparePrimitives, - })[0])) | 0; - return new SparseTable(matrix.Matrix, matrix.Keys, append(matrix.CommentKeys, singleton(key)), (length > matrix.ColumnCount) ? length : matrix.ColumnCount); - } -} - -export function SparseTable_FromRows_Z5579EC29(en: IEnumerator>, labels: FSharpList, lineNumber: int32, prefix?: string): [Option, int32, FSharpList, SparseTable] { - try { - const prefix_1: string = (prefix == null) ? "" : (value(prefix) + " "); - const loop = (matrix_mut: SparseTable, remarks_mut: FSharpList, lineNumber_1_mut: int32): [Option, int32, FSharpList, SparseTable] => { - let v_2: Iterable<[int32, string]>, k_1: string; - loop: - while (true) { - const matrix: SparseTable = matrix_mut, remarks: FSharpList = remarks_mut, lineNumber_1: int32 = lineNumber_1_mut; - if (en["System.Collections.IEnumerator.MoveNext"]()) { - const row: Iterable<[int32, string]> = map<[int32, string], [int32, string]>((tupledArg: [int32, string]): [int32, string] => ([tupledArg[0] - 1, tupledArg[1]] as [int32, string]), en["System.Collections.Generic.IEnumerator`1.get_Current"]()); - const matchValue: Option = map_1<[int32, string], string>((tuple: [int32, string]): string => tuple[1], tryItem<[int32, string]>(0, row)); - const vals: Option> = Seq_trySkip<[int32, string]>(1, row); - const key: Option = matchValue; - let matchResult: int32, k: string, v_1: Iterable<[int32, string]>; - const activePatternResult: Option = Comment_$007CComment$007C_$007C(key); - if (activePatternResult != null) { - if (vals != null) { - matchResult = 0; - k = value(activePatternResult); - v_1 = value(vals); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: { - matrix_mut = SparseTable_AddComment(k!, v_1!, matrix); - remarks_mut = remarks; - lineNumber_1_mut = (lineNumber_1 + 1); - continue loop; - } - default: { - let matchResult_1: int32, k_2: string, k_3: string, v_3: Iterable<[int32, string]>, k_4: string; - const activePatternResult_1: Option = Remark_$007CRemark$007C_$007C(key); - if (activePatternResult_1 != null) { - matchResult_1 = 0; - k_2 = value(activePatternResult_1); - } - else if (key != null) { - if (vals != null) { - if ((v_2 = value(vals), (k_1 = value(key), exists((label: string): boolean => (k_1 === (prefix_1 + label)), labels)))) { - matchResult_1 = 1; - k_3 = value(key); - v_3 = value(vals); - } - else { - matchResult_1 = 2; - k_4 = value(key); - } - } - else { - matchResult_1 = 2; - k_4 = value(key); - } - } - else { - matchResult_1 = 3; - } - switch (matchResult_1) { - case 0: { - matrix_mut = matrix; - remarks_mut = cons(Remark_make(lineNumber_1, k_2!), remarks); - lineNumber_1_mut = (lineNumber_1 + 1); - continue loop; - } - case 1: { - matrix_mut = SparseTable_AddRow(find((label_1: string): boolean => (k_3! === (prefix_1 + label_1)), labels), v_3!, matrix); - remarks_mut = remarks; - lineNumber_1_mut = (lineNumber_1 + 1); - continue loop; - } - case 2: - return [k_4!, lineNumber_1, remarks, matrix] as [Option, int32, FSharpList, SparseTable]; - default: - return [void 0, lineNumber_1, remarks, matrix] as [Option, int32, FSharpList, SparseTable]; - } - } - } - } - else { - return [void 0, lineNumber_1, remarks, matrix] as [Option, int32, FSharpList, SparseTable]; - } - break; - } - }; - return loop(SparseTable_Create_Z2192E64B(), empty(), lineNumber); - } - catch (err: any) { - const arg_9: string = err.message; - return toFail(printf("Error parsing block in investigation file starting from line number %i: %s"))(lineNumber)(arg_9); - } -} - -export function SparseTable_ToRows_584133C0(matrix: SparseTable, prefix?: string): Iterable> { - const prefix_1: string = (prefix == null) ? "" : (value(prefix) + " "); - return delay>((): Iterable> => append_1>(map>((key: string): Iterable<[int32, string]> => SparseRowModule_fromValues(cons(prefix_1 + key, initialize_1(matrix.ColumnCount - 1, (i: int32): string => SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [key, i + 1] as [string, int32])))), matrix.Keys), delay>((): Iterable> => map>((key_1: string): Iterable<[int32, string]> => SparseRowModule_fromValues(cons(Comment_wrapCommentKey(key_1), initialize_1(matrix.ColumnCount - 1, (i_1: int32): string => SparseTable__TryGetValueDefault_5BAE6133(matrix, "", [key_1, i_1 + 1] as [string, int32])))), matrix.CommentKeys)))); -} - -export function SparseTable_GetEmptyComments_Z15A4F148(matrix: SparseTable): FSharpList { - return map_2((key: string): Comment$ => Comment_create_250E0578(void 0, key), matrix.CommentKeys); -} - diff --git a/ts/ISA/ISA/ArcTypes/ArcAssay.ts b/ts/ISA/ISA/ArcTypes/ArcAssay.ts deleted file mode 100644 index c5034a30..00000000 --- a/ts/ISA/ISA/ArcTypes/ArcAssay.ts +++ /dev/null @@ -1,489 +0,0 @@ -import { defaultArg, value, map, Option, unwrap } from "../../../fable_modules/fable-library-ts/Option.js"; -import { OntologyAnnotation } from "../JsonTypes/OntologyAnnotation.js"; -import { ArcTable } from "./ArcTable.js"; -import { empty, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Person } from "../JsonTypes/Person.js"; -import { Comment$ } from "../JsonTypes/Comment.js"; -import { ArcTables_fromProcesses_Z31821267, ArcTables__get_Tables, ArcTables__GetProcesses, ArcTables__GetRow_Z18115A39, ArcTables__GetRowAt_Z37302880, ArcTables__UpdateRow_Z5E65B4B1, ArcTables__UpdateRowAt_Z596C2D98, ArcTables__RemoveRow_Z18115A39, ArcTables__RemoveRowAt_Z37302880, ArcTables__AddRow_1177C4AF, ArcTables__AddRowAt_Z57F91678, ArcTables__GetColumn_Z18115A39, ArcTables__GetColumnAt_Z37302880, ArcTables__UpdateColumn_Z774BF72A, ArcTables__UpdateColumnAt_Z155350AF, ArcTables__RemoveColumn_Z18115A39, ArcTables__RemoveColumnAt_Z37302880, ArcTables__AddColumn_Z4FC90944, ArcTables__AddColumnAt_6647579B, ArcTables__RenameTable_Z384F8060, ArcTables__RenameTableAt_Z176EF219, ArcTables__MapTable_4E415F2F, ArcTables__MapTableAt_61602D68, ArcTables__RemoveTable_Z721C83C5, ArcTables__RemoveTableAt_Z524259A4, ArcTables__UpdateTable_4976F045, ArcTables__UpdateTableAt_66578202, ArcTables__GetTable_Z721C83C5, ArcTables__GetTableAt_Z524259A4, ArcTables__InitTables_7B28792B, ArcTables__InitTable_3B406CA4, ArcTables__AddTables_3601F24E, ArcTables__AddTable_16F700A1, ArcTables__get_TableNames, ArcTables_$ctor_Z68BECB99, ArcTables__get_Count } from "./ArcTables.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { CompositeHeader_$union } from "./CompositeHeader.js"; -import { CompositeCell_$union } from "./CompositeCell.js"; -import { CompositeColumn } from "./CompositeColumn.js"; -import { disposeSafe, getEnumerator } from "../../../fable_modules/fable-library-ts/Util.js"; -import { Process } from "../JsonTypes/Process.js"; -import { AssayMaterials_get_empty, AssayMaterials_create_1CB3546D, AssayMaterials } from "../JsonTypes/AssayMaterials.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { Sample } from "../JsonTypes/Sample.js"; -import { getUnits, getCharacteristics, getData, getMaterials, getSamples } from "../JsonTypes/ProcessSequence.js"; -import { Material } from "../JsonTypes/Material.js"; -import { Assay, Assay_create_ABF59A4 } from "../JsonTypes/Assay.js"; -import { Assay_identifierFromFileName, createMissingIdentifier, Assay_fileNameFromIdentifier, isMissingIdentifier } from "./Identifier.js"; -import { Data } from "../JsonTypes/Data.js"; -import { MaterialAttribute } from "../JsonTypes/MaterialAttribute.js"; -import { class_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export class ArcAssay { - "identifier@13": string; - "MeasurementType@": Option; - "TechnologyType@": Option; - "TechnologyPlatform@": Option; - "Tables@": ArcTable[]; - "Performers@": FSharpList; - "Comments@": FSharpList; - constructor(identifier: string, measurementType?: OntologyAnnotation, technologyType?: OntologyAnnotation, technologyPlatform?: string, tables?: ArcTable[], performers?: FSharpList, comments?: FSharpList) { - const tables_1: ArcTable[] = defaultArg(tables, []); - const performers_1: FSharpList = defaultArg>(performers, empty()); - const comments_1: FSharpList = defaultArg>(comments, empty()); - this["identifier@13"] = identifier; - this["MeasurementType@"] = measurementType; - this["TechnologyType@"] = technologyType; - this["TechnologyPlatform@"] = technologyPlatform; - this["Tables@"] = tables_1; - this["Performers@"] = performers_1; - this["Comments@"] = comments_1; - } - get Identifier(): string { - const this$: ArcAssay = this; - return this$["identifier@13"]; - } - set Identifier(i: string) { - const this$: ArcAssay = this; - this$["identifier@13"] = i; - } - static get FileName(): string { - return "isa.assay.xlsx"; - } - get MeasurementType(): OntologyAnnotation | undefined { - const __: ArcAssay = this; - return unwrap(__["MeasurementType@"]); - } - set MeasurementType(v: Option) { - const __: ArcAssay = this; - __["MeasurementType@"] = v; - } - get TechnologyType(): OntologyAnnotation | undefined { - const __: ArcAssay = this; - return unwrap(__["TechnologyType@"]); - } - set TechnologyType(v: Option) { - const __: ArcAssay = this; - __["TechnologyType@"] = v; - } - get TechnologyPlatform(): string | undefined { - const __: ArcAssay = this; - return unwrap(__["TechnologyPlatform@"]); - } - set TechnologyPlatform(v: Option) { - const __: ArcAssay = this; - __["TechnologyPlatform@"] = v; - } - get Tables(): ArcTable[] { - const __: ArcAssay = this; - return __["Tables@"]; - } - set Tables(v: ArcTable[]) { - const __: ArcAssay = this; - __["Tables@"] = v; - } - get Performers(): FSharpList { - const __: ArcAssay = this; - return __["Performers@"]; - } - set Performers(v: FSharpList) { - const __: ArcAssay = this; - __["Performers@"] = v; - } - get Comments(): FSharpList { - const __: ArcAssay = this; - return __["Comments@"]; - } - set Comments(v: FSharpList) { - const __: ArcAssay = this; - __["Comments@"] = v; - } - static init(identifier: string): ArcAssay { - return new ArcAssay(identifier); - } - static create(identifier: string, measurementType?: OntologyAnnotation, technologyType?: OntologyAnnotation, technologyPlatform?: string, tables?: ArcTable[], performers?: FSharpList, comments?: FSharpList): ArcAssay { - return new ArcAssay(identifier, unwrap(measurementType), unwrap(technologyType), unwrap(technologyPlatform), unwrap(tables), unwrap(performers), unwrap(comments)); - } - static make(identifier: string, measurementType: Option, technologyType: Option, technologyPlatform: Option, tables: ArcTable[], performers: FSharpList, comments: FSharpList): ArcAssay { - return new ArcAssay(identifier, unwrap(measurementType), unwrap(technologyType), unwrap(technologyPlatform), tables, performers, comments); - } - get TableCount(): int32 { - const this$: ArcAssay = this; - return ArcTables__get_Count(ArcTables_$ctor_Z68BECB99(this$.Tables)) | 0; - } - get TableNames(): FSharpList { - const this$: ArcAssay = this; - return ArcTables__get_TableNames(ArcTables_$ctor_Z68BECB99(this$.Tables)); - } - AddTable(table: ArcTable, index?: int32): void { - const this$: ArcAssay = this; - ArcTables__AddTable_16F700A1(ArcTables_$ctor_Z68BECB99(this$.Tables), table, unwrap(index)); - } - static addTable(table: ArcTable, index?: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const c: ArcAssay = assay.Copy(); - c.AddTable(table, unwrap(index)); - return c; - }; - } - AddTables(tables: Iterable, index?: int32): void { - const this$: ArcAssay = this; - ArcTables__AddTables_3601F24E(ArcTables_$ctor_Z68BECB99(this$.Tables), tables, unwrap(index)); - } - static addTables(tables: Iterable, index?: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const c: ArcAssay = assay.Copy(); - c.AddTables(tables, unwrap(index)); - return c; - }; - } - InitTable(tableName: string, index?: int32): void { - const this$: ArcAssay = this; - ArcTables__InitTable_3B406CA4(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, unwrap(index)); - } - static initTable(tableName: string, index?: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const c: ArcAssay = assay.Copy(); - c.InitTable(tableName, unwrap(index)); - return c; - }; - } - InitTables(tableNames: Iterable, index?: int32): void { - const this$: ArcAssay = this; - ArcTables__InitTables_7B28792B(ArcTables_$ctor_Z68BECB99(this$.Tables), tableNames, unwrap(index)); - } - static initTables(tableNames: Iterable, index?: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const c: ArcAssay = assay.Copy(); - c.InitTables(tableNames, unwrap(index)); - return c; - }; - } - GetTableAt(index: int32): ArcTable { - const this$: ArcAssay = this; - return ArcTables__GetTableAt_Z524259A4(ArcTables_$ctor_Z68BECB99(this$.Tables), index); - } - static getTableAt(index: int32): ((arg0: ArcAssay) => ArcTable) { - return (assay: ArcAssay): ArcTable => { - const newAssay: ArcAssay = assay.Copy(); - return newAssay.GetTableAt(index); - }; - } - GetTable(name: string): ArcTable { - const this$: ArcAssay = this; - return ArcTables__GetTable_Z721C83C5(ArcTables_$ctor_Z68BECB99(this$.Tables), name); - } - static getTable(name: string): ((arg0: ArcAssay) => ArcTable) { - return (assay: ArcAssay): ArcTable => { - const newAssay: ArcAssay = assay.Copy(); - return newAssay.GetTable(name); - }; - } - UpdateTableAt(index: int32, table: ArcTable): void { - const this$: ArcAssay = this; - ArcTables__UpdateTableAt_66578202(ArcTables_$ctor_Z68BECB99(this$.Tables), index, table); - } - static updateTableAt(index: int32, table: ArcTable): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.UpdateTableAt(index, table); - return newAssay; - }; - } - UpdateTable(name: string, table: ArcTable): void { - const this$: ArcAssay = this; - ArcTables__UpdateTable_4976F045(ArcTables_$ctor_Z68BECB99(this$.Tables), name, table); - } - static updateTable(name: string, table: ArcTable): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.UpdateTable(name, table); - return newAssay; - }; - } - RemoveTableAt(index: int32): void { - const this$: ArcAssay = this; - ArcTables__RemoveTableAt_Z524259A4(ArcTables_$ctor_Z68BECB99(this$.Tables), index); - } - static removeTableAt(index: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.RemoveTableAt(index); - return newAssay; - }; - } - RemoveTable(name: string): void { - const this$: ArcAssay = this; - ArcTables__RemoveTable_Z721C83C5(ArcTables_$ctor_Z68BECB99(this$.Tables), name); - } - static removeTable(name: string): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.RemoveTable(name); - return newAssay; - }; - } - MapTableAt(index: int32, updateFun: ((arg0: ArcTable) => void)): void { - const this$: ArcAssay = this; - ArcTables__MapTableAt_61602D68(ArcTables_$ctor_Z68BECB99(this$.Tables), index, updateFun); - } - static mapTableAt(index: int32, updateFun: ((arg0: ArcTable) => void)): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.MapTableAt(index, updateFun); - return newAssay; - }; - } - MapTable(name: string, updateFun: ((arg0: ArcTable) => void)): void { - const this$: ArcAssay = this; - ArcTables__MapTable_4E415F2F(ArcTables_$ctor_Z68BECB99(this$.Tables), name, updateFun); - } - static updateTable(name: string, updateFun: ((arg0: ArcTable) => void)): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.MapTable(name, updateFun); - return newAssay; - }; - } - RenameTableAt(index: int32, newName: string): void { - const this$: ArcAssay = this; - ArcTables__RenameTableAt_Z176EF219(ArcTables_$ctor_Z68BECB99(this$.Tables), index, newName); - } - static renameTableAt(index: int32, newName: string): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.RenameTableAt(index, newName); - return newAssay; - }; - } - RenameTable(name: string, newName: string): void { - const this$: ArcAssay = this; - ArcTables__RenameTable_Z384F8060(ArcTables_$ctor_Z68BECB99(this$.Tables), name, newName); - } - static renameTable(name: string, newName: string): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.RenameTable(name, newName); - return newAssay; - }; - } - AddColumnAt(tableIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[], columnIndex?: int32, forceReplace?: boolean): void { - const this$: ArcAssay = this; - ArcTables__AddColumnAt_6647579B(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - } - static addColumnAt(tableIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[], columnIndex?: int32, forceReplace?: boolean): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.AddColumnAt(tableIndex, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - return newAssay; - }; - } - AddColumn(tableName: string, header: CompositeHeader_$union, cells?: CompositeCell_$union[], columnIndex?: int32, forceReplace?: boolean): void { - const this$: ArcAssay = this; - ArcTables__AddColumn_Z4FC90944(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - } - static addColumn(tableName: string, header: CompositeHeader_$union, cells?: CompositeCell_$union[], columnIndex?: int32, forceReplace?: boolean): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.AddColumn(tableName, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - return newAssay; - }; - } - RemoveColumnAt(tableIndex: int32, columnIndex: int32): void { - const this$: ArcAssay = this; - ArcTables__RemoveColumnAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex); - } - static removeColumnAt(tableIndex: int32, columnIndex: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.RemoveColumnAt(tableIndex, columnIndex); - return newAssay; - }; - } - RemoveColumn(tableName: string, columnIndex: int32): void { - const this$: ArcAssay = this; - ArcTables__RemoveColumn_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex); - } - static removeColumn(tableName: string, columnIndex: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.RemoveColumn(tableName, columnIndex); - return newAssay; - }; - } - UpdateColumnAt(tableIndex: int32, columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): void { - const this$: ArcAssay = this; - ArcTables__UpdateColumnAt_Z155350AF(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex, header, unwrap(cells)); - } - static updateColumnAt(tableIndex: int32, columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.UpdateColumnAt(tableIndex, columnIndex, header, unwrap(cells)); - return newAssay; - }; - } - UpdateColumn(tableName: string, columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): void { - const this$: ArcAssay = this; - ArcTables__UpdateColumn_Z774BF72A(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex, header, unwrap(cells)); - } - static updateColumn(tableName: string, columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.UpdateColumn(tableName, columnIndex, header, unwrap(cells)); - return newAssay; - }; - } - GetColumnAt(tableIndex: int32, columnIndex: int32): CompositeColumn { - const this$: ArcAssay = this; - return ArcTables__GetColumnAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex); - } - static getColumnAt(tableIndex: int32, columnIndex: int32): ((arg0: ArcAssay) => CompositeColumn) { - return (assay: ArcAssay): CompositeColumn => { - const newAssay: ArcAssay = assay.Copy(); - return newAssay.GetColumnAt(tableIndex, columnIndex); - }; - } - GetColumn(tableName: string, columnIndex: int32): CompositeColumn { - const this$: ArcAssay = this; - return ArcTables__GetColumn_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex); - } - static getColumn(tableName: string, columnIndex: int32): ((arg0: ArcAssay) => CompositeColumn) { - return (assay: ArcAssay): CompositeColumn => { - const newAssay: ArcAssay = assay.Copy(); - return newAssay.GetColumn(tableName, columnIndex); - }; - } - AddRowAt(tableIndex: int32, cells?: CompositeCell_$union[], rowIndex?: int32): void { - const this$: ArcAssay = this; - ArcTables__AddRowAt_Z57F91678(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, unwrap(cells), unwrap(rowIndex)); - } - static addRowAt(tableIndex: int32, cells?: CompositeCell_$union[], rowIndex?: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.AddRowAt(tableIndex, unwrap(cells), unwrap(rowIndex)); - return newAssay; - }; - } - AddRow(tableName: string, cells?: CompositeCell_$union[], rowIndex?: int32): void { - const this$: ArcAssay = this; - ArcTables__AddRow_1177C4AF(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, unwrap(cells), unwrap(rowIndex)); - } - static addRow(tableName: string, cells?: CompositeCell_$union[], rowIndex?: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.AddRow(tableName, unwrap(cells), unwrap(rowIndex)); - return newAssay; - }; - } - RemoveRowAt(tableIndex: int32, rowIndex: int32): void { - const this$: ArcAssay = this; - ArcTables__RemoveRowAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex); - } - static removeRowAt(tableIndex: int32, rowIndex: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.RemoveColumnAt(tableIndex, rowIndex); - return newAssay; - }; - } - RemoveRow(tableName: string, rowIndex: int32): void { - const this$: ArcAssay = this; - ArcTables__RemoveRow_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex); - } - static removeRow(tableName: string, rowIndex: int32): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.RemoveRow(tableName, rowIndex); - return newAssay; - }; - } - UpdateRowAt(tableIndex: int32, rowIndex: int32, cells: CompositeCell_$union[]): void { - const this$: ArcAssay = this; - ArcTables__UpdateRowAt_Z596C2D98(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex, cells); - } - static updateRowAt(tableIndex: int32, rowIndex: int32, cells: CompositeCell_$union[]): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.UpdateRowAt(tableIndex, rowIndex, cells); - return newAssay; - }; - } - UpdateRow(tableName: string, rowIndex: int32, cells: CompositeCell_$union[]): void { - const this$: ArcAssay = this; - ArcTables__UpdateRow_Z5E65B4B1(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex, cells); - } - static updateRow(tableName: string, rowIndex: int32, cells: CompositeCell_$union[]): ((arg0: ArcAssay) => ArcAssay) { - return (assay: ArcAssay): ArcAssay => { - const newAssay: ArcAssay = assay.Copy(); - newAssay.UpdateRow(tableName, rowIndex, cells); - return newAssay; - }; - } - GetRowAt(tableIndex: int32, rowIndex: int32): CompositeCell_$union[] { - const this$: ArcAssay = this; - return ArcTables__GetRowAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex); - } - static getRowAt(tableIndex: int32, rowIndex: int32): ((arg0: ArcAssay) => CompositeCell_$union[]) { - return (assay: ArcAssay): CompositeCell_$union[] => { - const newAssay: ArcAssay = assay.Copy(); - return newAssay.GetRowAt(tableIndex, rowIndex); - }; - } - GetRow(tableName: string, rowIndex: int32): CompositeCell_$union[] { - const this$: ArcAssay = this; - return ArcTables__GetRow_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex); - } - static getRow(tableName: string, rowIndex: int32): ((arg0: ArcAssay) => CompositeCell_$union[]) { - return (assay: ArcAssay): CompositeCell_$union[] => { - const newAssay: ArcAssay = assay.Copy(); - return newAssay.GetRow(tableName, rowIndex); - }; - } - static setPerformers(performers: FSharpList, assay: ArcAssay): ArcAssay { - assay.Performers = performers; - return assay; - } - Copy(): ArcAssay { - const this$: ArcAssay = this; - const newTables: ArcTable[] = []; - let enumerator: any = getEnumerator(this$.Tables); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const table: ArcTable = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const copy: ArcTable = table.Copy(); - void (newTables.push(copy)); - } - } - finally { - disposeSafe(enumerator); - } - return new ArcAssay(this$.Identifier, unwrap(this$.MeasurementType), unwrap(this$.TechnologyType), unwrap(this$.TechnologyPlatform), newTables, this$.Performers, this$.Comments); - } - ToAssay(): Assay { - const this$: ArcAssay = this; - const processSeq: FSharpList = ArcTables__GetProcesses(ArcTables_$ctor_Z68BECB99(this$.Tables)); - let assayMaterials: Option; - const v_2: AssayMaterials = AssayMaterials_create_1CB3546D(unwrap(fromValueWithDefault>(empty(), getSamples(processSeq))), unwrap(fromValueWithDefault>(empty(), getMaterials(processSeq)))); - assayMaterials = fromValueWithDefault(AssayMaterials_get_empty(), v_2); - return Assay_create_ABF59A4(void 0, unwrap(isMissingIdentifier(this$.Identifier) ? void 0 : Assay_fileNameFromIdentifier(this$.Identifier)), unwrap(this$.MeasurementType), unwrap(this$.TechnologyType), unwrap(this$.TechnologyPlatform), unwrap(fromValueWithDefault>(empty(), getData(processSeq))), unwrap(assayMaterials), unwrap(fromValueWithDefault>(empty(), getCharacteristics(processSeq))), unwrap(fromValueWithDefault>(empty(), getUnits(processSeq))), unwrap(fromValueWithDefault>(empty(), processSeq)), unwrap(fromValueWithDefault>(empty(), this$.Comments))); - } - static fromAssay(a: Assay): ArcAssay { - const tables: Option = map, ArcTable[]>((arg_1: FSharpList): ArcTable[] => ArcTables__get_Tables(ArcTables_fromProcesses_Z31821267(arg_1)), a.ProcessSequence); - let identifer: string; - const matchValue: Option = a.FileName; - identifer = ((matchValue == null) ? createMissingIdentifier() : Assay_identifierFromFileName(value(matchValue))); - return ArcAssay.create(identifer, unwrap(a.MeasurementType), unwrap(a.TechnologyType), unwrap(a.TechnologyPlatform), unwrap(tables), void 0, unwrap(a.Comments)); - } -} - -export function ArcAssay_$reflection(): TypeInfo { - return class_type("ISA.ArcAssay", void 0, ArcAssay); -} - -export function ArcAssay_$ctor_4D629C41(identifier: string, measurementType?: OntologyAnnotation, technologyType?: OntologyAnnotation, technologyPlatform?: string, tables?: ArcTable[], performers?: FSharpList, comments?: FSharpList): ArcAssay { - return new ArcAssay(identifier, measurementType, technologyType, technologyPlatform, tables, performers, comments); -} - diff --git a/ts/ISA/ISA/ArcTypes/ArcInvestigation.ts b/ts/ISA/ISA/ArcTypes/ArcInvestigation.ts deleted file mode 100644 index b52e5255..00000000 --- a/ts/ISA/ISA/ArcTypes/ArcInvestigation.ts +++ /dev/null @@ -1,431 +0,0 @@ -import { map as map_2, defaultArg, value as value_1, Option, unwrap } from "../../../fable_modules/fable-library-ts/Option.js"; -import { map as map_1, empty, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologySourceReference } from "../JsonTypes/OntologySourceReference.js"; -import { Publication } from "../JsonTypes/Publication.js"; -import { Person } from "../JsonTypes/Person.js"; -import { ArcStudy } from "./ArcStudy.js"; -import { Remark, Comment$ } from "../JsonTypes/Comment.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { toList, removeAt, tryFindIndex, map } from "../../../fable_modules/fable-library-ts/Seq.js"; -import { tryFind, removeInPlace } from "../../../fable_modules/fable-library-ts/Array.js"; -import { disposeSafe, getEnumerator, defaultOf, safeHash, equals } from "../../../fable_modules/fable-library-ts/Util.js"; -import { ArcAssay } from "./ArcAssay.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { Study } from "../JsonTypes/Study.js"; -import { Investigation, Investigation_create_ZB2B0942 } from "../JsonTypes/Investigation.js"; -import { createMissingIdentifier, isMissingIdentifier } from "./Identifier.js"; -import { class_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export class ArcInvestigation { - "identifier@25": string; - "Title@": Option; - "Description@": Option; - "SubmissionDate@": Option; - "PublicReleaseDate@": Option; - "OntologySourceReferences@": FSharpList; - "Publications@": FSharpList; - "Contacts@": FSharpList; - "Studies@": ArcStudy[]; - "Comments@": FSharpList; - "Remarks@": FSharpList; - constructor(identifier: string, title?: string, description?: string, submissionDate?: string, publicReleaseDate?: string, ontologySourceReferences?: FSharpList, publications?: FSharpList, contacts?: FSharpList, studies?: ArcStudy[], comments?: FSharpList, remarks?: FSharpList) { - const ontologySourceReferences_1: FSharpList = defaultArg>(ontologySourceReferences, empty()); - const publications_1: FSharpList = defaultArg>(publications, empty()); - const contacts_1: FSharpList = defaultArg>(contacts, empty()); - const studies_1: ArcStudy[] = defaultArg(studies, []); - const comments_1: FSharpList = defaultArg>(comments, empty()); - const remarks_1: FSharpList = defaultArg>(remarks, empty()); - this["identifier@25"] = identifier; - this["Title@"] = title; - this["Description@"] = description; - this["SubmissionDate@"] = submissionDate; - this["PublicReleaseDate@"] = publicReleaseDate; - this["OntologySourceReferences@"] = ontologySourceReferences_1; - this["Publications@"] = publications_1; - this["Contacts@"] = contacts_1; - this["Studies@"] = studies_1; - this["Comments@"] = comments_1; - this["Remarks@"] = remarks_1; - } - get Identifier(): string { - const this$: ArcInvestigation = this; - return this$["identifier@25"]; - } - set Identifier(i: string) { - const this$: ArcInvestigation = this; - this$["identifier@25"] = i; - } - get Title(): string | undefined { - const __: ArcInvestigation = this; - return unwrap(__["Title@"]); - } - set Title(v: Option) { - const __: ArcInvestigation = this; - __["Title@"] = v; - } - get Description(): string | undefined { - const __: ArcInvestigation = this; - return unwrap(__["Description@"]); - } - set Description(v: Option) { - const __: ArcInvestigation = this; - __["Description@"] = v; - } - get SubmissionDate(): string | undefined { - const __: ArcInvestigation = this; - return unwrap(__["SubmissionDate@"]); - } - set SubmissionDate(v: Option) { - const __: ArcInvestigation = this; - __["SubmissionDate@"] = v; - } - get PublicReleaseDate(): string | undefined { - const __: ArcInvestigation = this; - return unwrap(__["PublicReleaseDate@"]); - } - set PublicReleaseDate(v: Option) { - const __: ArcInvestigation = this; - __["PublicReleaseDate@"] = v; - } - get OntologySourceReferences(): FSharpList { - const __: ArcInvestigation = this; - return __["OntologySourceReferences@"]; - } - set OntologySourceReferences(v: FSharpList) { - const __: ArcInvestigation = this; - __["OntologySourceReferences@"] = v; - } - get Publications(): FSharpList { - const __: ArcInvestigation = this; - return __["Publications@"]; - } - set Publications(v: FSharpList) { - const __: ArcInvestigation = this; - __["Publications@"] = v; - } - get Contacts(): FSharpList { - const __: ArcInvestigation = this; - return __["Contacts@"]; - } - set Contacts(v: FSharpList) { - const __: ArcInvestigation = this; - __["Contacts@"] = v; - } - get Studies(): ArcStudy[] { - const __: ArcInvestigation = this; - return __["Studies@"]; - } - set Studies(v: ArcStudy[]) { - const __: ArcInvestigation = this; - __["Studies@"] = v; - } - get Comments(): FSharpList { - const __: ArcInvestigation = this; - return __["Comments@"]; - } - set Comments(v: FSharpList) { - const __: ArcInvestigation = this; - __["Comments@"] = v; - } - get Remarks(): FSharpList { - const __: ArcInvestigation = this; - return __["Remarks@"]; - } - set Remarks(v: FSharpList) { - const __: ArcInvestigation = this; - __["Remarks@"] = v; - } - static get FileName(): string { - return "isa.investigation.xlsx"; - } - static init(identifier: string): ArcInvestigation { - return new ArcInvestigation(identifier); - } - static create(identifier: string, title?: string, description?: string, submissionDate?: string, publicReleaseDate?: string, ontologySourceReferences?: FSharpList, publications?: FSharpList, contacts?: FSharpList, studies?: ArcStudy[], comments?: FSharpList, remarks?: FSharpList): ArcInvestigation { - return new ArcInvestigation(identifier, unwrap(title), unwrap(description), unwrap(submissionDate), unwrap(publicReleaseDate), unwrap(ontologySourceReferences), unwrap(publications), unwrap(contacts), unwrap(studies), unwrap(comments), unwrap(remarks)); - } - static make(identifier: string, title: Option, description: Option, submissionDate: Option, publicReleaseDate: Option, ontologySourceReferences: FSharpList, publications: FSharpList, contacts: FSharpList, studies: ArcStudy[], comments: FSharpList, remarks: FSharpList): ArcInvestigation { - return new ArcInvestigation(identifier, unwrap(title), unwrap(description), unwrap(submissionDate), unwrap(publicReleaseDate), ontologySourceReferences, publications, contacts, studies, comments, remarks); - } - get StudyCount(): int32 { - const this$: ArcInvestigation = this; - return this$.Studies.length | 0; - } - get StudyIdentifiers(): Iterable { - const this$: ArcInvestigation = this; - return map((x: ArcStudy): string => x.Identifier, this$.Studies); - } - AddStudy(study: ArcStudy): void { - const this$: ArcInvestigation = this; - const study_1: ArcStudy = study; - const matchValue: Option = tryFindIndex((x: ArcStudy): boolean => (x.Identifier === study_1.Identifier), this$.Studies); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create study with name ${study_1.Identifier}, as study names must be unique and study at index ${value_1(matchValue)} has the same name.`); - } - void (this$.Studies.push(study)); - } - static addStudy(study: ArcStudy): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const copy: ArcInvestigation = inv.Copy(); - copy.AddStudy(study); - return copy; - }; - } - InitStudy(studyName: string): void { - const this$: ArcInvestigation = this; - const study: ArcStudy = ArcStudy.init(studyName); - this$.AddStudy(study); - } - static initStudy(studyName: string): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const copy: ArcInvestigation = inv.Copy(); - copy.InitStudy(studyName); - return copy; - }; - } - RemoveStudyAt(index: int32): void { - const this$: ArcInvestigation = this; - this$.Studies.splice(index, 1); - } - static removeStudyAt(index: int32): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const newInv: ArcInvestigation = inv.Copy(); - newInv.RemoveStudyAt(index); - return newInv; - }; - } - RemoveStudy(studyIdentifier: string): void { - const this$: ArcInvestigation = this; - removeInPlace(this$.GetStudy(studyIdentifier), this$.Studies, { - Equals: equals, - GetHashCode: safeHash, - }); - } - static removeStudy(studyIdentifier: string): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const copy: ArcInvestigation = inv.Copy(); - copy.RemoveStudy(studyIdentifier); - return copy; - }; - } - SetStudyAt(index: int32, study: ArcStudy): void { - const this$: ArcInvestigation = this; - const study_1: ArcStudy = study; - const matchValue: Option = tryFindIndex((x: ArcStudy): boolean => (x.Identifier === study_1.Identifier), removeAt(index, this$.Studies)); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create study with name ${study_1.Identifier}, as study names must be unique and study at index ${value_1(matchValue)} has the same name.`); - } - this$.Studies[index] = study; - } - static setStudyAt(index: int32, study: ArcStudy): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const newInv: ArcInvestigation = inv.Copy(); - newInv.SetStudyAt(index, study); - return newInv; - }; - } - SetStudy(studyIdentifier: string, study: ArcStudy): void { - const this$: ArcInvestigation = this; - const index: int32 = this$.GetStudyIndex(studyIdentifier) | 0; - const study_1: ArcStudy = study; - const matchValue: Option = tryFindIndex((x: ArcStudy): boolean => (x.Identifier === study_1.Identifier), removeAt(index, this$.Studies)); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create study with name ${study_1.Identifier}, as study names must be unique and study at index ${value_1(matchValue)} has the same name.`); - } - this$.Studies[index] = study; - } - static setStudy(studyIdentifier: string, study: ArcStudy): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const newInv: ArcInvestigation = inv.Copy(); - newInv.SetStudy(studyIdentifier, study); - return newInv; - }; - } - GetStudyIndex(studyIdentifier: string): int32 { - const this$: ArcInvestigation = this; - const index: int32 = this$.Studies.findIndex((s: ArcStudy): boolean => (s.Identifier === studyIdentifier)) | 0; - if (index === -1) { - throw new Error(`Unable to find study with specified identifier '${studyIdentifier}'!`); - } - return index | 0; - } - static getStudyIndex(studyIdentifier: string): ((arg0: ArcInvestigation) => int32) { - return (inv: ArcInvestigation): int32 => inv.GetStudyIndex(studyIdentifier); - } - GetStudyAt(index: int32): ArcStudy { - const this$: ArcInvestigation = this; - return this$.Studies[index]; - } - static getStudyAt(index: int32): ((arg0: ArcInvestigation) => ArcStudy) { - return (inv: ArcInvestigation): ArcStudy => { - const newInv: ArcInvestigation = inv.Copy(); - return newInv.GetStudyAt(index); - }; - } - GetStudy(studyIdentifier: string): ArcStudy { - const this$: ArcInvestigation = this; - return defaultArg(tryFind((s: ArcStudy): boolean => (s.Identifier === studyIdentifier), this$.Studies), defaultOf()); - } - static getStudy(studyIdentifier: string): ((arg0: ArcInvestigation) => ArcStudy) { - return (inv: ArcInvestigation): ArcStudy => { - const newInv: ArcInvestigation = inv.Copy(); - return newInv.GetStudy(studyIdentifier); - }; - } - AddAssay(studyIdentifier: string, assay: ArcAssay): void { - const this$: ArcInvestigation = this; - const study: ArcStudy = this$.GetStudy(studyIdentifier); - const assay_1: ArcAssay = assay; - const matchValue: Option = tryFindIndex((x: ArcAssay): boolean => (x.Identifier === assay_1.Identifier), study.Assays); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create assay with name ${assay_1.Identifier}, as assay names must be unique and assay at index ${value_1(matchValue)} has the same name.`); - } - study.AddAssay(assay); - } - static addAssay(studyIdentifier: string, assay: ArcAssay): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const copy: ArcInvestigation = inv.Copy(); - copy.AddAssay(studyIdentifier, assay); - return copy; - }; - } - AddAssayAt(studyIndex: int32, assay: ArcAssay): void { - const this$: ArcInvestigation = this; - const study: ArcStudy = this$.GetStudyAt(studyIndex); - const assay_1: ArcAssay = assay; - const matchValue: Option = tryFindIndex((x: ArcAssay): boolean => (x.Identifier === assay_1.Identifier), study.Assays); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create assay with name ${assay_1.Identifier}, as assay names must be unique and assay at index ${value_1(matchValue)} has the same name.`); - } - study.AddAssay(assay); - } - static addAssayAt(studyIndex: int32, assay: ArcAssay): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const copy: ArcInvestigation = inv.Copy(); - copy.AddAssayAt(studyIndex, assay); - return copy; - }; - } - InitAssay(studyIdentifier: string, assayName: string): void { - const this$: ArcInvestigation = this; - const assay: ArcAssay = ArcAssay.init(assayName); - this$.AddAssay(studyIdentifier, assay); - } - static initAssay(studyIdentifier: string, assayName: string): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const copy: ArcInvestigation = inv.Copy(); - copy.InitAssay(studyIdentifier, assayName); - return copy; - }; - } - RemoveAssayAt(studyIdentifier: string, index: int32): void { - const this$: ArcInvestigation = this; - const study: ArcStudy = this$.GetStudy(studyIdentifier); - study.Assays.splice(index, 1); - } - static removeAssayAt(studyIdentifier: string, index: int32): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const newInv: ArcInvestigation = inv.Copy(); - newInv.RemoveAssayAt(studyIdentifier, index); - return newInv; - }; - } - SetAssayAt(studyIdentifier: string, index: int32, assay: ArcAssay): void { - const this$: ArcInvestigation = this; - const study: ArcStudy = this$.GetStudy(studyIdentifier); - study.SetAssayAt(index, assay); - this$.Studies[index] = study; - } - static setAssayAt(studyIdentifier: string, index: int32, assay: ArcAssay): ((arg0: ArcInvestigation) => ArcInvestigation) { - return (inv: ArcInvestigation): ArcInvestigation => { - const newInv: ArcInvestigation = inv.Copy(); - newInv.SetAssayAt(studyIdentifier, index, assay); - return newInv; - }; - } - SetAssay(studyIdentifier: string, assayIdentifier: string, assay: ArcAssay): void { - const this$: ArcInvestigation = this; - const study: ArcStudy = this$.GetStudy(studyIdentifier); - const index: int32 = study.GetAssayIndex(assayIdentifier) | 0; - study.SetAssayAt(index, assay); - } - static setAssay(studyIdentifier: string, assayIdentifier: string, assay: ArcAssay): ((arg0: ArcInvestigation) => void) { - return (inv: ArcInvestigation): void => { - const newInv: ArcInvestigation = inv.Copy(); - newInv.SetAssay(studyIdentifier, assayIdentifier, assay); - }; - } - GetAssayAt(studyIdentifier: string, index: int32): ArcAssay { - const this$: ArcInvestigation = this; - const study: ArcStudy = this$.GetStudy(studyIdentifier); - return study.GetAssayAt(index); - } - static getAssayAt(studyIdentifier: string, index: int32): ((arg0: ArcInvestigation) => ArcAssay) { - return (inv: ArcInvestigation): ArcAssay => { - const newInv: ArcInvestigation = inv.Copy(); - return newInv.GetAssayAt(studyIdentifier, index); - }; - } - GetAssay(studyIdentifier: string, assayIdentifier: string): ArcAssay { - const this$: ArcInvestigation = this; - const study: ArcStudy = this$.GetStudy(studyIdentifier); - const index: int32 = study.GetAssayIndex(assayIdentifier) | 0; - return study.GetAssayAt(index); - } - static getAssay(studyIdentifier: string, assayIdentifier: string): ((arg0: ArcInvestigation) => ArcAssay) { - return (inv: ArcInvestigation): ArcAssay => { - const newInv: ArcInvestigation = inv.Copy(); - return newInv.GetAssay(studyIdentifier, assayIdentifier); - }; - } - Copy(): ArcInvestigation { - const this$: ArcInvestigation = this; - const newStudies: ArcStudy[] = []; - let enumerator: any = getEnumerator(this$.Studies); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const study: ArcStudy = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const copy: ArcStudy = study.Copy(); - void (newStudies.push(copy)); - } - } - finally { - disposeSafe(enumerator); - } - return new ArcInvestigation(this$.Identifier, unwrap(this$.Title), unwrap(this$.Description), unwrap(this$.SubmissionDate), unwrap(this$.PublicReleaseDate), this$.OntologySourceReferences, this$.Publications, this$.Contacts, newStudies, this$.Comments, this$.Remarks); - } - ToInvestigation(): Investigation { - const this$: ArcInvestigation = this; - const studies: Option> = fromValueWithDefault>(empty(), map_1((a: ArcStudy): Study => a.ToStudy(), toList(this$.Studies))); - return Investigation_create_ZB2B0942(void 0, "isa.investigation.xlsx", isMissingIdentifier(this$.Identifier) ? void 0 : this$.Identifier, this$.Title, this$.Description, this$.SubmissionDate, this$.PublicReleaseDate, void 0, fromValueWithDefault>(empty(), this$.Publications), fromValueWithDefault>(empty(), this$.Contacts), studies, fromValueWithDefault>(empty(), this$.Comments)); - } - static fromInvestigation(i: Investigation): ArcInvestigation { - let identifer: string; - const matchValue: Option = i.Identifier; - identifer = ((matchValue == null) ? createMissingIdentifier() : value_1(matchValue)); - const studies: Option = map_2, ArcStudy[]>((arg_2: FSharpList): ArcStudy[] => { - const arg_1: FSharpList = map_1((arg: Study): ArcStudy => ArcStudy.fromStudy(arg), arg_2); - return Array.from(arg_1); - }, i.Studies); - return ArcInvestigation.create(identifer, i.Title, i.Description, i.SubmissionDate, i.PublicReleaseDate, void 0, i.Publications, i.Contacts, studies, i.Comments); - } -} - -export function ArcInvestigation_$reflection(): TypeInfo { - return class_type("ISA.ArcInvestigation", void 0, ArcInvestigation); -} - -export function ArcInvestigation_$ctor_Z8BBFD6A(identifier: string, title?: string, description?: string, submissionDate?: string, publicReleaseDate?: string, ontologySourceReferences?: FSharpList, publications?: FSharpList, contacts?: FSharpList, studies?: ArcStudy[], comments?: FSharpList, remarks?: FSharpList): ArcInvestigation { - return new ArcInvestigation(identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReferences, publications, contacts, studies, comments, remarks); -} - diff --git a/ts/ISA/ISA/ArcTypes/ArcStudy.ts b/ts/ISA/ISA/ArcTypes/ArcStudy.ts deleted file mode 100644 index 580aae28..00000000 --- a/ts/ISA/ISA/ArcTypes/ArcStudy.ts +++ /dev/null @@ -1,681 +0,0 @@ -import { defaultArg, map as map_2, value, Option, unwrap } from "../../../fable_modules/fable-library-ts/Option.js"; -import { map as map_1, empty, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Publication } from "../JsonTypes/Publication.js"; -import { Person } from "../JsonTypes/Person.js"; -import { OntologyAnnotation } from "../JsonTypes/OntologyAnnotation.js"; -import { ArcTable } from "./ArcTable.js"; -import { ArcAssay } from "./ArcAssay.js"; -import { Factor } from "../JsonTypes/Factor.js"; -import { Comment$ } from "../JsonTypes/Comment.js"; -import { disposeSafe, getEnumerator, equals } from "../../../fable_modules/fable-library-ts/Util.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { toList, removeAt, tryFindIndex, map } from "../../../fable_modules/fable-library-ts/Seq.js"; -import { ArcTables_fromProcesses_Z31821267, ArcTables__get_Tables, ArcTables__GetProcesses, ArcTables__GetRow_Z18115A39, ArcTables__GetRowAt_Z37302880, ArcTables__UpdateRow_Z5E65B4B1, ArcTables__UpdateRowAt_Z596C2D98, ArcTables__RemoveRow_Z18115A39, ArcTables__RemoveRowAt_Z37302880, ArcTables__AddRow_1177C4AF, ArcTables__AddRowAt_Z57F91678, ArcTables__GetColumn_Z18115A39, ArcTables__GetColumnAt_Z37302880, ArcTables__UpdateColumn_Z774BF72A, ArcTables__UpdateColumnAt_Z155350AF, ArcTables__RemoveColumn_Z18115A39, ArcTables__RemoveColumnAt_Z37302880, ArcTables__AddColumn_Z4FC90944, ArcTables__AddColumnAt_6647579B, ArcTables__RenameTable_Z384F8060, ArcTables__RenameTableAt_Z176EF219, ArcTables__MapTable_4E415F2F, ArcTables__MapTableAt_61602D68, ArcTables__RemoveTable_Z721C83C5, ArcTables__RemoveTableAt_Z524259A4, ArcTables__UpdateTable_4976F045, ArcTables__UpdateTableAt_66578202, ArcTables__GetTable_Z721C83C5, ArcTables__GetTableAt_Z524259A4, ArcTables__InitTables_7B28792B, ArcTables__InitTable_3B406CA4, ArcTables__AddTables_3601F24E, ArcTables__AddTable_16F700A1, ArcTables__get_TableNames, ArcTables_$ctor_Z68BECB99, ArcTables__get_Count } from "./ArcTables.js"; -import { CompositeHeader_$union } from "./CompositeHeader.js"; -import { CompositeCell_$union } from "./CompositeCell.js"; -import { CompositeColumn } from "./CompositeColumn.js"; -import { Process } from "../JsonTypes/Process.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { Protocol } from "../JsonTypes/Protocol.js"; -import { getUnits, getCharacteristics, getMaterials, getSamples, getSources, getProtocols } from "../JsonTypes/ProcessSequence.js"; -import { Assay } from "../JsonTypes/Assay.js"; -import { StudyMaterials_get_empty, StudyMaterials_create_Z460D555F, StudyMaterials } from "../JsonTypes/StudyMaterials.js"; -import { Source } from "../JsonTypes/Source.js"; -import { Sample } from "../JsonTypes/Sample.js"; -import { Material } from "../JsonTypes/Material.js"; -import { Study_identifierFromFileName, createMissingIdentifier, Study_fileNameFromIdentifier, isMissingIdentifier } from "./Identifier.js"; -import { Study, Study_create_Z6C8AB268 } from "../JsonTypes/Study.js"; -import { MaterialAttribute } from "../JsonTypes/MaterialAttribute.js"; -import { class_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export class ArcStudy { - readonly submissionDate: Option; - "identifier@25": string; - "Title@": Option; - "Description@": Option; - "SubmissionDate@": Option; - "PublicReleaseDate@": Option; - "Publications@": FSharpList; - "Contacts@": FSharpList; - "StudyDesignDescriptors@": FSharpList; - "Tables@": ArcTable[]; - "Assays@": ArcAssay[]; - "Factors@": FSharpList; - "Comments@": FSharpList; - constructor(identifier: string, title?: string, description?: string, submissionDate?: string, publicReleaseDate?: string, publications?: FSharpList, contacts?: FSharpList, studyDesignDescriptors?: FSharpList, tables?: ArcTable[], assays?: ArcAssay[], factors?: FSharpList, comments?: FSharpList) { - this.submissionDate = submissionDate; - const publications_1: FSharpList = defaultArg>(publications, empty()); - const contacts_1: FSharpList = defaultArg>(contacts, empty()); - const studyDesignDescriptors_1: FSharpList = defaultArg>(studyDesignDescriptors, empty()); - const tables_1: ArcTable[] = defaultArg(tables, []); - const assays_1: ArcAssay[] = defaultArg(assays, []); - const factors_1: FSharpList = defaultArg>(factors, empty()); - const comments_1: FSharpList = defaultArg>(comments, empty()); - this["identifier@25"] = identifier; - this["Title@"] = title; - this["Description@"] = description; - this["SubmissionDate@"] = this.submissionDate; - this["PublicReleaseDate@"] = publicReleaseDate; - this["Publications@"] = publications_1; - this["Contacts@"] = contacts_1; - this["StudyDesignDescriptors@"] = studyDesignDescriptors_1; - this["Tables@"] = tables_1; - this["Assays@"] = assays_1; - this["Factors@"] = factors_1; - this["Comments@"] = comments_1; - } - get Identifier(): string { - const this$: ArcStudy = this; - return this$["identifier@25"]; - } - set Identifier(i: string) { - const this$: ArcStudy = this; - this$["identifier@25"] = i; - } - get Title(): string | undefined { - const __: ArcStudy = this; - return unwrap(__["Title@"]); - } - set Title(v: Option) { - const __: ArcStudy = this; - __["Title@"] = v; - } - get Description(): string | undefined { - const __: ArcStudy = this; - return unwrap(__["Description@"]); - } - set Description(v: Option) { - const __: ArcStudy = this; - __["Description@"] = v; - } - get SubmissionDate(): string | undefined { - const __: ArcStudy = this; - return unwrap(__["SubmissionDate@"]); - } - set SubmissionDate(v: Option) { - const __: ArcStudy = this; - __["SubmissionDate@"] = v; - } - get PublicReleaseDate(): string | undefined { - const __: ArcStudy = this; - return unwrap(__["PublicReleaseDate@"]); - } - set PublicReleaseDate(v: Option) { - const __: ArcStudy = this; - __["PublicReleaseDate@"] = v; - } - get Publications(): FSharpList { - const __: ArcStudy = this; - return __["Publications@"]; - } - set Publications(v: FSharpList) { - const __: ArcStudy = this; - __["Publications@"] = v; - } - get Contacts(): FSharpList { - const __: ArcStudy = this; - return __["Contacts@"]; - } - set Contacts(v: FSharpList) { - const __: ArcStudy = this; - __["Contacts@"] = v; - } - get StudyDesignDescriptors(): FSharpList { - const __: ArcStudy = this; - return __["StudyDesignDescriptors@"]; - } - set StudyDesignDescriptors(v: FSharpList) { - const __: ArcStudy = this; - __["StudyDesignDescriptors@"] = v; - } - get Tables(): ArcTable[] { - const __: ArcStudy = this; - return __["Tables@"]; - } - set Tables(v: ArcTable[]) { - const __: ArcStudy = this; - __["Tables@"] = v; - } - get Assays(): ArcAssay[] { - const __: ArcStudy = this; - return __["Assays@"]; - } - set Assays(v: ArcAssay[]) { - const __: ArcStudy = this; - __["Assays@"] = v; - } - get Factors(): FSharpList { - const __: ArcStudy = this; - return __["Factors@"]; - } - set Factors(v: FSharpList) { - const __: ArcStudy = this; - __["Factors@"] = v; - } - get Comments(): FSharpList { - const __: ArcStudy = this; - return __["Comments@"]; - } - set Comments(v: FSharpList) { - const __: ArcStudy = this; - __["Comments@"] = v; - } - static init(identifier: string): ArcStudy { - return new ArcStudy(identifier); - } - static create(identifier: string, title?: string, description?: string, submissionDate?: string, publicReleaseDate?: string, publications?: FSharpList, contacts?: FSharpList, studyDesignDescriptors?: FSharpList, tables?: ArcTable[], assays?: ArcAssay[], factors?: FSharpList, comments?: FSharpList): ArcStudy { - return new ArcStudy(identifier, unwrap(title), unwrap(description), unwrap(submissionDate), unwrap(publicReleaseDate), unwrap(publications), unwrap(contacts), unwrap(studyDesignDescriptors), unwrap(tables), unwrap(assays), unwrap(factors), unwrap(comments)); - } - static make(identifier: string, title: Option, description: Option, submissionDate: Option, publicReleaseDate: Option, publications: FSharpList, contacts: FSharpList, studyDesignDescriptors: FSharpList, tables: ArcTable[], assays: ArcAssay[], factors: FSharpList, comments: FSharpList): ArcStudy { - return new ArcStudy(identifier, unwrap(title), unwrap(description), unwrap(submissionDate), unwrap(publicReleaseDate), publications, contacts, studyDesignDescriptors, tables, assays, factors, comments); - } - get isEmpty(): boolean { - const this$: ArcStudy = this; - return (((((((((equals(this$.Title, void 0) && equals(this$.Description, void 0)) && equals(this$.SubmissionDate, void 0)) && equals(this$.PublicReleaseDate, void 0)) && equals(this$.Publications, empty())) && equals(this$.Contacts, empty())) && equals(this$.StudyDesignDescriptors, empty())) && (this$.Tables.length === 0)) && (this$.Assays.length === 0)) && equals(this$.Factors, empty())) && equals(this$.Comments, empty()); - } - static get FileName(): string { - return "isa.study.xlsx"; - } - get AssayCount(): int32 { - const this$: ArcStudy = this; - return this$.Assays.length | 0; - } - get AssayIdentifiers(): Iterable { - const this$: ArcStudy = this; - return map((x: ArcAssay): string => x.Identifier, this$.Assays); - } - AddAssay(assay: ArcAssay): void { - const this$: ArcStudy = this; - const assay_1: ArcAssay = assay; - const matchValue: Option = tryFindIndex((x: ArcAssay): boolean => (x.Identifier === assay_1.Identifier), this$.Assays); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create assay with name ${assay_1.Identifier}, as assay names must be unique and assay at index ${value(matchValue)} has the same name.`); - } - void (this$.Assays.push(assay)); - } - static addAssay(assay: ArcAssay): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newStudy: ArcStudy = study.Copy(); - newStudy.AddAssay(assay); - return newStudy; - }; - } - InitAssay(assayName: string): void { - const this$: ArcStudy = this; - const assay: ArcAssay = new ArcAssay(assayName); - this$.AddAssay(assay); - } - static initAssay(assayName: string): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newStudy: ArcStudy = study.Copy(); - newStudy.InitAssay(assayName); - return newStudy; - }; - } - RemoveAssayAt(index: int32): void { - const this$: ArcStudy = this; - this$.Assays.splice(index, 1); - } - static removeAssayAt(index: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newStudy: ArcStudy = study.Copy(); - newStudy.RemoveAssayAt(index); - return newStudy; - }; - } - SetAssayAt(index: int32, assay: ArcAssay): void { - const this$: ArcStudy = this; - const assay_1: ArcAssay = assay; - const matchValue: Option = tryFindIndex((x: ArcAssay): boolean => (x.Identifier === assay_1.Identifier), removeAt(index, this$.Assays)); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create assay with name ${assay_1.Identifier}, as assay names must be unique and assay at index ${value(matchValue)} has the same name.`); - } - this$.Assays[index] = assay; - } - static setAssayAt(index: int32, assay: ArcAssay): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newStudy: ArcStudy = study.Copy(); - newStudy.SetAssayAt(index, assay); - return newStudy; - }; - } - SetAssay(assayIdentifier: string, assay: ArcAssay): void { - const this$: ArcStudy = this; - const index: int32 = this$.GetAssayIndex(assayIdentifier) | 0; - this$.Assays[index] = assay; - } - static setAssay(assayIdentifier: string, assay: ArcAssay): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newStudy: ArcStudy = study.Copy(); - newStudy.SetAssay(assayIdentifier, assay); - return newStudy; - }; - } - GetAssayIndex(assayIdentifier: string): int32 { - const this$: ArcStudy = this; - const index: int32 = this$.Assays.findIndex((a: ArcAssay): boolean => (a.Identifier === assayIdentifier)) | 0; - if (index === -1) { - throw new Error(`Unable to find assay with specified identifier '${assayIdentifier}'!`); - } - return index | 0; - } - static GetAssayIndex(assayIdentifier: string): ((arg0: ArcStudy) => int32) { - return (study: ArcStudy): int32 => study.GetAssayIndex(assayIdentifier); - } - GetAssayAt(index: int32): ArcAssay { - const this$: ArcStudy = this; - return this$.Assays[index]; - } - static getAssayAt(index: int32): ((arg0: ArcStudy) => ArcAssay) { - return (study: ArcStudy): ArcAssay => { - const newStudy: ArcStudy = study.Copy(); - return newStudy.GetAssayAt(index); - }; - } - GetAssay(assayIdentifier: string): ArcAssay { - const this$: ArcStudy = this; - const index: int32 = this$.GetAssayIndex(assayIdentifier) | 0; - return this$.GetAssayAt(index); - } - static getAssay(assayIdentifier: string): ((arg0: ArcStudy) => ArcAssay) { - return (study: ArcStudy): ArcAssay => { - const newStudy: ArcStudy = study.Copy(); - return newStudy.GetAssay(assayIdentifier); - }; - } - get TableCount(): int32 { - const this$: ArcStudy = this; - return ArcTables__get_Count(ArcTables_$ctor_Z68BECB99(this$.Tables)) | 0; - } - get TableNames(): FSharpList { - const this$: ArcStudy = this; - return ArcTables__get_TableNames(ArcTables_$ctor_Z68BECB99(this$.Tables)); - } - AddTable(table: ArcTable, index?: int32): void { - const this$: ArcStudy = this; - ArcTables__AddTable_16F700A1(ArcTables_$ctor_Z68BECB99(this$.Tables), table, unwrap(index)); - } - static addTable(table: ArcTable, index?: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const c: ArcStudy = study.Copy(); - c.AddTable(table, unwrap(index)); - return c; - }; - } - AddTables(tables: Iterable, index?: int32): void { - const this$: ArcStudy = this; - ArcTables__AddTables_3601F24E(ArcTables_$ctor_Z68BECB99(this$.Tables), tables, unwrap(index)); - } - static addTables(tables: Iterable, index?: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const c: ArcStudy = study.Copy(); - c.AddTables(tables, unwrap(index)); - return c; - }; - } - InitTable(tableName: string, index?: int32): void { - const this$: ArcStudy = this; - ArcTables__InitTable_3B406CA4(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, unwrap(index)); - } - static initTable(tableName: string, index?: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const c: ArcStudy = study.Copy(); - c.InitTable(tableName, unwrap(index)); - return c; - }; - } - InitTables(tableNames: Iterable, index?: int32): void { - const this$: ArcStudy = this; - ArcTables__InitTables_7B28792B(ArcTables_$ctor_Z68BECB99(this$.Tables), tableNames, unwrap(index)); - } - static initTables(tableNames: Iterable, index?: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const c: ArcStudy = study.Copy(); - c.InitTables(tableNames, unwrap(index)); - return c; - }; - } - GetTableAt(index: int32): ArcTable { - const this$: ArcStudy = this; - return ArcTables__GetTableAt_Z524259A4(ArcTables_$ctor_Z68BECB99(this$.Tables), index); - } - static getTableAt(index: int32): ((arg0: ArcStudy) => ArcTable) { - return (study: ArcStudy): ArcTable => { - const newAssay: ArcStudy = study.Copy(); - return newAssay.GetTableAt(index); - }; - } - GetTable(name: string): ArcTable { - const this$: ArcStudy = this; - return ArcTables__GetTable_Z721C83C5(ArcTables_$ctor_Z68BECB99(this$.Tables), name); - } - static getTable(name: string): ((arg0: ArcStudy) => ArcTable) { - return (study: ArcStudy): ArcTable => { - const newAssay: ArcStudy = study.Copy(); - return newAssay.GetTable(name); - }; - } - UpdateTableAt(index: int32, table: ArcTable): void { - const this$: ArcStudy = this; - ArcTables__UpdateTableAt_66578202(ArcTables_$ctor_Z68BECB99(this$.Tables), index, table); - } - static updateTableAt(index: int32, table: ArcTable): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.UpdateTableAt(index, table); - return newAssay; - }; - } - UpdateTable(name: string, table: ArcTable): void { - const this$: ArcStudy = this; - ArcTables__UpdateTable_4976F045(ArcTables_$ctor_Z68BECB99(this$.Tables), name, table); - } - static updateTable(name: string, table: ArcTable): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.UpdateTable(name, table); - return newAssay; - }; - } - RemoveTableAt(index: int32): void { - const this$: ArcStudy = this; - ArcTables__RemoveTableAt_Z524259A4(ArcTables_$ctor_Z68BECB99(this$.Tables), index); - } - static removeTableAt(index: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.RemoveTableAt(index); - return newAssay; - }; - } - RemoveTable(name: string): void { - const this$: ArcStudy = this; - ArcTables__RemoveTable_Z721C83C5(ArcTables_$ctor_Z68BECB99(this$.Tables), name); - } - static removeTable(name: string): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.RemoveTable(name); - return newAssay; - }; - } - MapTableAt(index: int32, updateFun: ((arg0: ArcTable) => void)): void { - const this$: ArcStudy = this; - ArcTables__MapTableAt_61602D68(ArcTables_$ctor_Z68BECB99(this$.Tables), index, updateFun); - } - static mapTableAt(index: int32, updateFun: ((arg0: ArcTable) => void)): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.MapTableAt(index, updateFun); - return newAssay; - }; - } - MapTable(name: string, updateFun: ((arg0: ArcTable) => void)): void { - const this$: ArcStudy = this; - ArcTables__MapTable_4E415F2F(ArcTables_$ctor_Z68BECB99(this$.Tables), name, updateFun); - } - static mapTable(name: string, updateFun: ((arg0: ArcTable) => void)): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.MapTable(name, updateFun); - return newAssay; - }; - } - RenameTableAt(index: int32, newName: string): void { - const this$: ArcStudy = this; - ArcTables__RenameTableAt_Z176EF219(ArcTables_$ctor_Z68BECB99(this$.Tables), index, newName); - } - static renameTableAt(index: int32, newName: string): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.RenameTableAt(index, newName); - return newAssay; - }; - } - RenameTable(name: string, newName: string): void { - const this$: ArcStudy = this; - ArcTables__RenameTable_Z384F8060(ArcTables_$ctor_Z68BECB99(this$.Tables), name, newName); - } - static renameTable(name: string, newName: string): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.RenameTable(name, newName); - return newAssay; - }; - } - AddColumnAt(tableIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[], columnIndex?: int32, forceReplace?: boolean): void { - const this$: ArcStudy = this; - ArcTables__AddColumnAt_6647579B(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - } - static addColumnAt(tableIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[], columnIndex?: int32, forceReplace?: boolean): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.AddColumnAt(tableIndex, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - return newAssay; - }; - } - AddColumn(tableName: string, header: CompositeHeader_$union, cells?: CompositeCell_$union[], columnIndex?: int32, forceReplace?: boolean): void { - const this$: ArcStudy = this; - ArcTables__AddColumn_Z4FC90944(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - } - static addColumn(tableName: string, header: CompositeHeader_$union, cells?: CompositeCell_$union[], columnIndex?: int32, forceReplace?: boolean): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.AddColumn(tableName, header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - return newAssay; - }; - } - RemoveColumnAt(tableIndex: int32, columnIndex: int32): void { - const this$: ArcStudy = this; - ArcTables__RemoveColumnAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex); - } - static removeColumnAt(tableIndex: int32, columnIndex: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.RemoveColumnAt(tableIndex, columnIndex); - return newAssay; - }; - } - RemoveColumn(tableName: string, columnIndex: int32): void { - const this$: ArcStudy = this; - ArcTables__RemoveColumn_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex); - } - static removeColumn(tableName: string, columnIndex: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.RemoveColumn(tableName, columnIndex); - return newAssay; - }; - } - UpdateColumnAt(tableIndex: int32, columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): void { - const this$: ArcStudy = this; - ArcTables__UpdateColumnAt_Z155350AF(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex, header, unwrap(cells)); - } - static updateColumnAt(tableIndex: int32, columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.UpdateColumnAt(tableIndex, columnIndex, header, unwrap(cells)); - return newAssay; - }; - } - UpdateColumn(tableName: string, columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): void { - const this$: ArcStudy = this; - ArcTables__UpdateColumn_Z774BF72A(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex, header, unwrap(cells)); - } - static updateColumn(tableName: string, columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.UpdateColumn(tableName, columnIndex, header, unwrap(cells)); - return newAssay; - }; - } - GetColumnAt(tableIndex: int32, columnIndex: int32): CompositeColumn { - const this$: ArcStudy = this; - return ArcTables__GetColumnAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, columnIndex); - } - static getColumnAt(tableIndex: int32, columnIndex: int32): ((arg0: ArcStudy) => CompositeColumn) { - return (study: ArcStudy): CompositeColumn => { - const newAssay: ArcStudy = study.Copy(); - return newAssay.GetColumnAt(tableIndex, columnIndex); - }; - } - GetColumn(tableName: string, columnIndex: int32): CompositeColumn { - const this$: ArcStudy = this; - return ArcTables__GetColumn_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, columnIndex); - } - static getColumn(tableName: string, columnIndex: int32): ((arg0: ArcStudy) => CompositeColumn) { - return (study: ArcStudy): CompositeColumn => { - const newAssay: ArcStudy = study.Copy(); - return newAssay.GetColumn(tableName, columnIndex); - }; - } - AddRowAt(tableIndex: int32, cells?: CompositeCell_$union[], rowIndex?: int32): void { - const this$: ArcStudy = this; - ArcTables__AddRowAt_Z57F91678(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, unwrap(cells), unwrap(rowIndex)); - } - static addRowAt(tableIndex: int32, cells?: CompositeCell_$union[], rowIndex?: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.AddRowAt(tableIndex, unwrap(cells), unwrap(rowIndex)); - return newAssay; - }; - } - AddRow(tableName: string, cells?: CompositeCell_$union[], rowIndex?: int32): void { - const this$: ArcStudy = this; - ArcTables__AddRow_1177C4AF(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, unwrap(cells), unwrap(rowIndex)); - } - static addRow(tableName: string, cells?: CompositeCell_$union[], rowIndex?: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.AddRow(tableName, unwrap(cells), unwrap(rowIndex)); - return newAssay; - }; - } - RemoveRowAt(tableIndex: int32, rowIndex: int32): void { - const this$: ArcStudy = this; - ArcTables__RemoveRowAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex); - } - static removeRowAt(tableIndex: int32, rowIndex: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.RemoveColumnAt(tableIndex, rowIndex); - return newAssay; - }; - } - RemoveRow(tableName: string, rowIndex: int32): void { - const this$: ArcStudy = this; - ArcTables__RemoveRow_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex); - } - static removeRow(tableName: string, rowIndex: int32): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.RemoveRow(tableName, rowIndex); - return newAssay; - }; - } - UpdateRowAt(tableIndex: int32, rowIndex: int32, cells: CompositeCell_$union[]): void { - const this$: ArcStudy = this; - ArcTables__UpdateRowAt_Z596C2D98(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex, cells); - } - static updateRowAt(tableIndex: int32, rowIndex: int32, cells: CompositeCell_$union[]): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.UpdateRowAt(tableIndex, rowIndex, cells); - return newAssay; - }; - } - UpdateRow(tableName: string, rowIndex: int32, cells: CompositeCell_$union[]): void { - const this$: ArcStudy = this; - ArcTables__UpdateRow_Z5E65B4B1(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex, cells); - } - static updateRow(tableName: string, rowIndex: int32, cells: CompositeCell_$union[]): ((arg0: ArcStudy) => ArcStudy) { - return (study: ArcStudy): ArcStudy => { - const newAssay: ArcStudy = study.Copy(); - newAssay.UpdateRow(tableName, rowIndex, cells); - return newAssay; - }; - } - GetRowAt(tableIndex: int32, rowIndex: int32): CompositeCell_$union[] { - const this$: ArcStudy = this; - return ArcTables__GetRowAt_Z37302880(ArcTables_$ctor_Z68BECB99(this$.Tables), tableIndex, rowIndex); - } - static getRowAt(tableIndex: int32, rowIndex: int32): ((arg0: ArcStudy) => CompositeCell_$union[]) { - return (study: ArcStudy): CompositeCell_$union[] => { - const newAssay: ArcStudy = study.Copy(); - return newAssay.GetRowAt(tableIndex, rowIndex); - }; - } - GetRow(tableName: string, rowIndex: int32): CompositeCell_$union[] { - const this$: ArcStudy = this; - return ArcTables__GetRow_Z18115A39(ArcTables_$ctor_Z68BECB99(this$.Tables), tableName, rowIndex); - } - static getRow(tableName: string, rowIndex: int32): ((arg0: ArcStudy) => CompositeCell_$union[]) { - return (study: ArcStudy): CompositeCell_$union[] => { - const newAssay: ArcStudy = study.Copy(); - return newAssay.GetRow(tableName, rowIndex); - }; - } - Copy(): ArcStudy { - const this$: ArcStudy = this; - const newTables: ArcTable[] = []; - const newAssays: ArcAssay[] = []; - let enumerator: any = getEnumerator(this$.Tables); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const table: ArcTable = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const copy: ArcTable = table.Copy(); - void (newTables.push(copy)); - } - } - finally { - disposeSafe(enumerator); - } - let enumerator_1: any = getEnumerator(this$.Assays); - try { - while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) { - const study: ArcAssay = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"](); - const copy_1: ArcAssay = study.Copy(); - void (newAssays.push(copy_1)); - } - } - finally { - disposeSafe(enumerator_1); - } - return new ArcStudy(this$.Identifier, unwrap(this$.Title), unwrap(this$.Description), unwrap(this$.submissionDate), unwrap(this$.PublicReleaseDate), this$.Publications, this$.Contacts, this$.StudyDesignDescriptors, newTables, newAssays, this$.Factors, this$.Comments); - } - ToStudy(): Study { - const this$: ArcStudy = this; - const processSeq: FSharpList = ArcTables__GetProcesses(ArcTables_$ctor_Z68BECB99(this$.Tables)); - const protocols: Option> = fromValueWithDefault>(empty(), getProtocols(processSeq)); - const assays: Option> = fromValueWithDefault>(empty(), map_1((a: ArcAssay): Assay => a.ToAssay(), toList(this$.Assays))); - let studyMaterials: Option; - const v_5: StudyMaterials = StudyMaterials_create_Z460D555F(unwrap(fromValueWithDefault>(empty(), getSources(processSeq))), unwrap(fromValueWithDefault>(empty(), getSamples(processSeq))), unwrap(fromValueWithDefault>(empty(), getMaterials(processSeq)))); - studyMaterials = fromValueWithDefault(StudyMaterials_get_empty(), v_5); - const patternInput: [Option, Option] = isMissingIdentifier(this$.Identifier) ? ([void 0, void 0] as [Option, Option]) : ([this$.Identifier, Study_fileNameFromIdentifier(this$.Identifier)] as [Option, Option]); - return Study_create_Z6C8AB268(void 0, unwrap(patternInput[1]), unwrap(patternInput[0]), unwrap(this$.Title), unwrap(this$.Description), unwrap(this$.SubmissionDate), unwrap(this$.PublicReleaseDate), unwrap(fromValueWithDefault>(empty(), this$.Publications)), unwrap(fromValueWithDefault>(empty(), this$.Contacts)), unwrap(fromValueWithDefault>(empty(), this$.StudyDesignDescriptors)), unwrap(protocols), unwrap(studyMaterials), unwrap(fromValueWithDefault>(empty(), processSeq)), unwrap(assays), unwrap(fromValueWithDefault>(empty(), this$.Factors)), unwrap(fromValueWithDefault>(empty(), getCharacteristics(processSeq))), unwrap(fromValueWithDefault>(empty(), getUnits(processSeq))), unwrap(fromValueWithDefault>(empty(), this$.Comments))); - } - static fromStudy(s: Study): ArcStudy { - const tables: Option = map_2, ArcTable[]>((arg_1: FSharpList): ArcTable[] => ArcTables__get_Tables(ArcTables_fromProcesses_Z31821267(arg_1)), s.ProcessSequence); - let identifer: string; - const matchValue: Option = s.FileName; - identifer = ((matchValue == null) ? createMissingIdentifier() : Study_identifierFromFileName(value(matchValue))); - const assays: Option = map_2, ArcAssay[]>((arg_4: FSharpList): ArcAssay[] => { - const arg_3: FSharpList = map_1((arg_2: Assay): ArcAssay => ArcAssay.fromAssay(arg_2), arg_4); - return Array.from(arg_3); - }, s.Assays); - return ArcStudy.create(identifer, unwrap(s.Title), unwrap(s.Description), unwrap(s.SubmissionDate), unwrap(s.PublicReleaseDate), unwrap(s.Publications), unwrap(s.Contacts), unwrap(s.StudyDesignDescriptors), unwrap(tables), unwrap(assays), unwrap(s.Factors), unwrap(s.Comments)); - } -} - -export function ArcStudy_$reflection(): TypeInfo { - return class_type("ISA.ArcStudy", void 0, ArcStudy); -} - -export function ArcStudy_$ctor_Z337E69A6(identifier: string, title?: string, description?: string, submissionDate?: string, publicReleaseDate?: string, publications?: FSharpList, contacts?: FSharpList, studyDesignDescriptors?: FSharpList, tables?: ArcTable[], assays?: ArcAssay[], factors?: FSharpList, comments?: FSharpList): ArcStudy { - return new ArcStudy(identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, tables, assays, factors, comments); -} - diff --git a/ts/ISA/ISA/ArcTypes/ArcTable.ts b/ts/ISA/ISA/ArcTypes/ArcTable.ts deleted file mode 100644 index 96c2f2e3..00000000 --- a/ts/ISA/ISA/ArcTypes/ArcTable.ts +++ /dev/null @@ -1,604 +0,0 @@ -import { CompositeHeader_$reflection, CompositeHeader_Parameter, CompositeHeader_ProtocolREF, CompositeHeader_ProtocolDescription, CompositeHeader_ProtocolUri, CompositeHeader_ProtocolVersion, CompositeHeader_ProtocolType, CompositeHeader_$union } from "./CompositeHeader.js"; -import { stringHash, compareArrays, safeHash, IDisposable, disposeSafe, IEnumerator, getEnumerator, equals, comparePrimitives, arrayHash, equalArrays, IMap } from "../../../fable_modules/fable-library-ts/Util.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { CompositeCell_$reflection, CompositeCell, CompositeCell_FreeText, CompositeCell_Term, CompositeCell_$union } from "./CompositeCell.js"; -import { Dictionary } from "../../../fable_modules/fable-library-ts/MutableMap.js"; -import { CompositeColumn } from "./CompositeColumn.js"; -import { map as map_2, value as value_9, defaultArg, Option, unwrap } from "../../../fable_modules/fable-library-ts/Option.js"; -import { ProcessParsing_processToRows, ProcessParsing_alignByHeaders, ProcessParsing_getProcessGetter, Unchecked_removeRowCells_withIndexChange, Unchecked_addRow, Unchecked_getEmptyCellForHeader, Unchecked_removeColumnCells_withIndexChange, tryFindDuplicateUniqueInArray, Unchecked_removeColumnCells, Unchecked_removeHeader, Unchecked_fillMissingCells, Unchecked_addColumn, tryFindDuplicateUnique, Unchecked_setCellAt, SanityChecks_validateColumn, SanityChecks_validateRowIndex, SanityChecks_validateColumnIndex, Unchecked_tryGetCellAt, getRowCount, getColumnCount } from "./ArcTableAux.js"; -import { sortBy, forAll2, append, zip, fold, filter, length, singleton, collect, findIndex, toArray, removeAt, map, delay, toList } from "../../../fable_modules/fable-library-ts/Seq.js"; -import { rangeDouble } from "../../../fable_modules/fable-library-ts/Range.js"; -import { collect as collect_1, initialize as initialize_1, singleton as singleton_2, empty, iterate, isEmpty, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { singleton as singleton_1, initialize, sortDescending, iterateIndexed, map as map_1 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { StringBuilder__AppendLine_Z721C83C5, StringBuilder_$ctor } from "../../../fable_modules/fable-library-ts/System.Text.js"; -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { ProcessParameterValue } from "../JsonTypes/ProcessParameterValue.js"; -import { OntologyAnnotation_get_empty, OntologyAnnotation } from "../JsonTypes/OntologyAnnotation.js"; -import { ProtocolParameter_create_2769312B, ProtocolParameter } from "../JsonTypes/ProtocolParameter.js"; -import { ISA_Component__Component_TryGetColumnIndex, ISA_ProtocolParameter__ProtocolParameter_TryGetColumnIndex } from "../JsonTypes/ColumnIndex.js"; -import { Component_create_Z33AADEE0, Component } from "../JsonTypes/Component.js"; -import { Value_$union } from "../JsonTypes/Value.js"; -import { Protocol_get_empty, Protocol_addComponent, Protocol_addParameter, Protocol_setName, Protocol_setDescription, Protocol_setUri, Protocol_setVersion, Protocol_setProtocolType, Protocol } from "../JsonTypes/Protocol.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { toProtocol } from "./CompositeRow.js"; -import { Process } from "../JsonTypes/Process.js"; -import { join } from "../../../fable_modules/fable-library-ts/String.js"; -import { record_type, class_type, tuple_type, int32_type, array_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export class ArcTable extends Record { - readonly Name: string; - readonly Headers: CompositeHeader_$union[]; - readonly Values: IMap<[int32, int32], CompositeCell_$union>; - constructor(Name: string, Headers: CompositeHeader_$union[], Values: IMap<[int32, int32], CompositeCell_$union>) { - super(); - this.Name = Name; - this.Headers = Headers; - this.Values = Values; - } - static create(name: string, headers: CompositeHeader_$union[], values: IMap<[int32, int32], CompositeCell_$union>): ArcTable { - return new ArcTable(name, headers, values); - } - static init(name: string): ArcTable { - return new ArcTable(name, [], new Dictionary<[int32, int32], CompositeCell_$union>([], { - Equals: equalArrays, - GetHashCode: arrayHash, - })); - } - Validate(raiseException?: boolean): boolean { - const this$: ArcTable = this; - let isValid = true; - for (let columnIndex = 0; columnIndex <= (this$.ColumnCount - 1); columnIndex++) { - const column: CompositeColumn = this$.GetColumn(columnIndex); - isValid = column.validate(unwrap(raiseException)); - } - return isValid; - } - static validate(raiseException?: boolean): ((arg0: ArcTable) => boolean) { - return (table: ArcTable): boolean => table.Validate(unwrap(raiseException)); - } - get ColumnCount(): int32 { - const this$: ArcTable = this; - return getColumnCount(this$.Headers) | 0; - } - get RowCount(): int32 { - const this$: ArcTable = this; - return getRowCount(this$.Values) | 0; - } - get Columns(): FSharpList { - const this$: ArcTable = this; - return toList(delay((): Iterable => map((i: int32): CompositeColumn => this$.GetColumn(i), rangeDouble(0, 1, this$.ColumnCount - 1)))); - } - Copy(): ArcTable { - const this$: ArcTable = this; - return ArcTable.create(this$.Name, Array.from(this$.Headers), new Dictionary<[int32, int32], CompositeCell_$union>(this$.Values, { - Equals: equalArrays, - GetHashCode: arrayHash, - })); - } - TryGetCellAt(column: int32, row: int32): Option { - const this$: ArcTable = this; - return Unchecked_tryGetCellAt(column, row, this$.Values); - } - static tryGetCellAt(column: int32, row: int32): ((arg0: ArcTable) => Option) { - return (table: ArcTable): Option => table.TryGetCellAt(column, row); - } - UpdateCellAt(columnIndex: int32, rowIndex: int32, c: CompositeCell_$union): void { - const this$: ArcTable = this; - SanityChecks_validateColumnIndex(columnIndex, this$.ColumnCount, false); - SanityChecks_validateRowIndex(rowIndex, this$.RowCount, false); - SanityChecks_validateColumn(CompositeColumn.create(this$.Headers[columnIndex], [c])); - Unchecked_setCellAt(columnIndex, rowIndex, c, this$.Values); - } - static updateCellAt(columnIndex: int32, rowIndex: int32, cell: CompositeCell_$union): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.UpdateCellAt(columnIndex, rowIndex, cell); - return newTable; - }; - } - UpdateHeader(index: int32, newHeader: CompositeHeader_$union, forceConvertCells?: boolean): void { - const this$: ArcTable = this; - const forceConvertCells_1: boolean = defaultArg(forceConvertCells, false); - SanityChecks_validateColumnIndex(index, this$.ColumnCount, false); - const header: CompositeHeader_$union = newHeader; - const matchValue: Option = tryFindDuplicateUnique(header, removeAt(index, this$.Headers)); - if (matchValue != null) { - throw new Error(`Invalid input. Tried setting unique header \`${header}\`, but header of same type already exists at index ${value_9(matchValue)}.`); - } - const c: CompositeColumn = new CompositeColumn(newHeader, this$.GetColumn(index).Cells); - if (c.validate()) { - let setHeader: any; - setHeader = (this$.Headers[index] = newHeader); - } - else if (forceConvertCells_1) { - const convertedCells: CompositeCell_$union[] = newHeader.IsTermColumn ? map_1((c_1: CompositeCell_$union): CompositeCell_$union => c_1.ToTermCell(), c.Cells) : map_1((c_2: CompositeCell_$union): CompositeCell_$union => c_2.ToFreeTextCell(), c.Cells); - this$.UpdateColumn(index, newHeader, convertedCells); - } - else { - throw new Error("Tried setting header for column with invalid type of cells. Set `forceConvertCells` flag to automatically convert cells into valid CompositeCell type."); - } - } - static updateHeader(index: int32, header: CompositeHeader_$union): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.UpdateHeader(index, header); - return newTable; - }; - } - AddColumn(header: CompositeHeader_$union, cells?: CompositeCell_$union[], index?: int32, forceReplace?: boolean): void { - const this$: ArcTable = this; - const index_1: int32 = defaultArg(index, this$.ColumnCount) | 0; - const cells_1: CompositeCell_$union[] = defaultArg(cells, []); - const forceReplace_1: boolean = defaultArg(forceReplace, false); - SanityChecks_validateColumnIndex(index_1, this$.ColumnCount, true); - SanityChecks_validateColumn(CompositeColumn.create(header, cells_1)); - Unchecked_addColumn(header, cells_1, index_1, forceReplace_1, this$.Headers, this$.Values); - Unchecked_fillMissingCells(this$.Headers, this$.Values); - } - static addColumn(header: CompositeHeader_$union, cells?: CompositeCell_$union[], index?: int32, forceReplace?: boolean): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.AddColumn(header, unwrap(cells), unwrap(index), unwrap(forceReplace)); - return newTable; - }; - } - UpdateColumn(columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): void { - const this$: ArcTable = this; - SanityChecks_validateColumnIndex(columnIndex, this$.ColumnCount, false); - const column: CompositeColumn = CompositeColumn.create(header, unwrap(cells)); - SanityChecks_validateColumn(column); - const header_1: CompositeHeader_$union = column.Header; - const matchValue: Option = tryFindDuplicateUnique(header_1, removeAt(columnIndex, this$.Headers)); - if (matchValue != null) { - throw new Error(`Invalid input. Tried setting unique header \`${header_1}\`, but header of same type already exists at index ${value_9(matchValue)}.`); - } - Unchecked_removeHeader(columnIndex, this$.Headers); - Unchecked_removeColumnCells(columnIndex, this$.Values); - this$.Headers.splice(columnIndex, 0, column.Header); - iterateIndexed((rowIndex: int32, v: CompositeCell_$union): void => { - Unchecked_setCellAt(columnIndex, rowIndex, v, this$.Values); - }, column.Cells); - Unchecked_fillMissingCells(this$.Headers, this$.Values); - } - static updatetColumn(columnIndex: int32, header: CompositeHeader_$union, cells?: CompositeCell_$union[]): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.UpdateColumn(columnIndex, header, unwrap(cells)); - return newTable; - }; - } - InsertColumn(header: CompositeHeader_$union, index: int32, cells?: CompositeCell_$union[]): void { - const this$: ArcTable = this; - this$.AddColumn(header, unwrap(cells), index, false); - } - static insertColumn(header: CompositeHeader_$union, index: int32, cells?: CompositeCell_$union[]): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.InsertColumn(header, index, unwrap(cells)); - return newTable; - }; - } - AppendColumn(header: CompositeHeader_$union, cells?: CompositeCell_$union[]): void { - const this$: ArcTable = this; - this$.AddColumn(header, unwrap(cells), this$.ColumnCount, false); - } - static appendColumn(header: CompositeHeader_$union, cells?: CompositeCell_$union[]): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.AppendColumn(header, unwrap(cells)); - return newTable; - }; - } - AddColumns(columns: CompositeColumn[], index?: int32, forceReplace?: boolean): void { - const this$: ArcTable = this; - let index_1: int32 = defaultArg(index, this$.ColumnCount); - const forceReplace_1: boolean = defaultArg(forceReplace, false); - SanityChecks_validateColumnIndex(index_1, this$.ColumnCount, true); - const duplicates: FSharpList<{ HeaderType: CompositeHeader_$union, Index1: int32, Index2: int32 }> = tryFindDuplicateUniqueInArray(map((x: CompositeColumn): CompositeHeader_$union => x.Header, columns)); - if (!isEmpty(duplicates)) { - const sb: any = StringBuilder_$ctor(); - StringBuilder__AppendLine_Z721C83C5(sb, "Found duplicate unique columns in `columns`."); - iterate<{ HeaderType: CompositeHeader_$union, Index1: int32, Index2: int32 }>((x_1: { HeaderType: CompositeHeader_$union, Index1: int32, Index2: int32 }): void => { - StringBuilder__AppendLine_Z721C83C5(sb, `Duplicate \`${x_1.HeaderType}\` at index ${x_1.Index1} and ${x_1.Index2}.`); - }, duplicates); - throw new Error(toString(sb)); - } - columns.forEach((x_2: CompositeColumn): void => { - SanityChecks_validateColumn(x_2); - }); - columns.forEach((col: CompositeColumn): void => { - const prevHeadersCount: int32 = this$.Headers.length | 0; - Unchecked_addColumn(col.Header, col.Cells, index_1, forceReplace_1, this$.Headers, this$.Values); - if (this$.Headers.length > prevHeadersCount) { - index_1 = ((index_1 + 1) | 0); - } - }); - Unchecked_fillMissingCells(this$.Headers, this$.Values); - } - static addColumns(columns: CompositeColumn[], index?: int32): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.AddColumns(columns, index); - return newTable; - }; - } - RemoveColumn(index: int32): void { - const this$: ArcTable = this; - SanityChecks_validateColumnIndex(index, this$.ColumnCount, false); - const columnCount: int32 = this$.ColumnCount | 0; - Unchecked_removeHeader(index, this$.Headers); - Unchecked_removeColumnCells_withIndexChange(index, columnCount, this$.RowCount, this$.Values); - } - static removeColumn(index: int32): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.RemoveColumn(index); - return newTable; - }; - } - RemoveColumns(indexArr: int32[]): void { - const this$: ArcTable = this; - indexArr.forEach((index: int32): void => { - SanityChecks_validateColumnIndex(index, this$.ColumnCount, false); - }); - const indexArr_1: int32[] = sortDescending(indexArr, { - Compare: comparePrimitives, - }); - indexArr_1.forEach((index_1: int32): void => { - this$.RemoveColumn(index_1); - }); - } - static removeColumns(indexArr: int32[]): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.RemoveColumns(indexArr); - return newTable; - }; - } - GetColumn(columnIndex: int32): CompositeColumn { - const this$: ArcTable = this; - SanityChecks_validateColumnIndex(columnIndex, this$.ColumnCount, false); - const h: CompositeHeader_$union = this$.Headers[columnIndex]; - const cells: CompositeCell_$union[] = toArray(delay((): Iterable => map((i: int32): CompositeCell_$union => value_9(this$.TryGetCellAt(columnIndex, i)), rangeDouble(0, 1, this$.RowCount - 1)))); - return CompositeColumn.create(h, cells); - } - static getColumn(index: int32): ((arg0: ArcTable) => CompositeColumn) { - return (table: ArcTable): CompositeColumn => table.GetColumn(index); - } - GetColumnByHeader(header: CompositeHeader_$union): CompositeColumn { - const this$: ArcTable = this; - const index: int32 = findIndex((x: CompositeHeader_$union): boolean => equals(x, header), this$.Headers) | 0; - return this$.GetColumn(index); - } - AddRow(cells?: CompositeCell_$union[], index?: int32): void { - const this$: ArcTable = this; - const index_1: int32 = defaultArg(index, this$.RowCount) | 0; - const cells_1: CompositeCell_$union[] = (cells == null) ? toArray(delay((): Iterable => collect, CompositeCell_$union>((columnIndex: int32): Iterable => singleton(Unchecked_getEmptyCellForHeader(this$.Headers[columnIndex], Unchecked_tryGetCellAt(columnIndex, 0, this$.Values))), rangeDouble(0, 1, this$.ColumnCount - 1)))) : value_9(cells); - SanityChecks_validateRowIndex(index_1, this$.RowCount, true); - const newCells: Iterable = cells_1; - const columnCount: int32 = this$.ColumnCount | 0; - const newCellsCount: int32 = length(newCells) | 0; - if (columnCount === 0) { - throw new Error("Table contains no columns! Cannot add row to empty table!"); - } - else if (newCellsCount !== columnCount) { - throw new Error(`Cannot add a new row with ${newCellsCount} cells, as the table has ${columnCount} columns.`); - } - for (let columnIndex_1 = 0; columnIndex_1 <= (this$.ColumnCount - 1); columnIndex_1++) { - const h_1: CompositeHeader_$union = this$.Headers[columnIndex_1]; - SanityChecks_validateColumn(CompositeColumn.create(h_1, [cells_1[columnIndex_1]])); - } - Unchecked_addRow(index_1, cells_1, this$.Headers, this$.Values); - } - static addRow(cells?: CompositeCell_$union[], index?: int32): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.AddRow(unwrap(cells), unwrap(index)); - return newTable; - }; - } - UpdateRow(rowIndex: int32, cells: CompositeCell_$union[]): void { - const this$: ArcTable = this; - SanityChecks_validateRowIndex(rowIndex, this$.RowCount, false); - const newCells: Iterable = cells; - const columnCount: int32 = this$.RowCount | 0; - const newCellsCount: int32 = length(newCells) | 0; - if (columnCount === 0) { - throw new Error("Table contains no columns! Cannot add row to empty table!"); - } - else if (newCellsCount !== columnCount) { - throw new Error(`Cannot add a new row with ${newCellsCount} cells, as the table has ${columnCount} columns.`); - } - iterateIndexed((i: int32, cell: CompositeCell_$union): void => { - const h: CompositeHeader_$union = this$.Headers[i]; - SanityChecks_validateColumn(CompositeColumn.create(h, [cell])); - }, cells); - iterateIndexed((columnIndex: int32, cell_1: CompositeCell_$union): void => { - Unchecked_setCellAt(columnIndex, rowIndex, cell_1, this$.Values); - }, cells); - } - static updateRow(rowIndex: int32, cells: CompositeCell_$union[]): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.UpdateRow(rowIndex, cells); - return newTable; - }; - } - AppendRow(cells?: CompositeCell_$union[]): void { - const this$: ArcTable = this; - this$.AddRow(unwrap(cells), this$.RowCount); - } - static appendRow(cells?: CompositeCell_$union[]): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.AppendRow(unwrap(cells)); - return newTable; - }; - } - InsertRow(index: int32, cells?: CompositeCell_$union[]): void { - const this$: ArcTable = this; - this$.AddRow(unwrap(cells), index); - } - static insertRow(index: int32, cells?: CompositeCell_$union[]): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.AddRow(unwrap(cells), index); - return newTable; - }; - } - AddRows(rows: CompositeCell_$union[][], index?: int32): void { - const this$: ArcTable = this; - let index_1: int32 = defaultArg(index, this$.RowCount); - SanityChecks_validateRowIndex(index_1, this$.RowCount, true); - rows.forEach((row: CompositeCell_$union[]): void => { - const newCells: Iterable = row; - const columnCount: int32 = this$.ColumnCount | 0; - const newCellsCount: int32 = length(newCells) | 0; - if (columnCount === 0) { - throw new Error("Table contains no columns! Cannot add row to empty table!"); - } - else if (newCellsCount !== columnCount) { - throw new Error(`Cannot add a new row with ${newCellsCount} cells, as the table has ${columnCount} columns.`); - } - }); - for (let idx = 0; idx <= (rows.length - 1); idx++) { - const row_1: CompositeCell_$union[] = rows[idx]; - for (let columnIndex = 0; columnIndex <= (this$.ColumnCount - 1); columnIndex++) { - const h: CompositeHeader_$union = this$.Headers[columnIndex]; - SanityChecks_validateColumn(CompositeColumn.create(h, [row_1[columnIndex]])); - } - } - rows.forEach((row_2: CompositeCell_$union[]): void => { - Unchecked_addRow(index_1, row_2, this$.Headers, this$.Values); - index_1 = ((index_1 + 1) | 0); - }); - } - static addRows(rows: CompositeCell_$union[][], index?: int32): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.AddRows(rows, unwrap(index)); - return newTable; - }; - } - AddRowsEmpty(rowCount: int32, index?: int32): void { - const this$: ArcTable = this; - const row: CompositeCell_$union[] = toArray(delay((): Iterable => collect, CompositeCell_$union>((columnIndex: int32): Iterable => singleton(Unchecked_getEmptyCellForHeader(this$.Headers[columnIndex], Unchecked_tryGetCellAt(columnIndex, 0, this$.Values))), rangeDouble(0, 1, this$.ColumnCount - 1)))); - const rows: CompositeCell_$union[][] = initialize(rowCount, (_arg: int32): CompositeCell_$union[] => row); - this$.AddRows(rows, unwrap(index)); - } - static addRowsEmpty(rowCount: int32, index?: int32): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.AddRowsEmpty(rowCount, unwrap(index)); - return newTable; - }; - } - RemoveRow(index: int32): void { - const this$: ArcTable = this; - SanityChecks_validateRowIndex(index, this$.RowCount, false); - const removeCells: any = Unchecked_removeRowCells_withIndexChange(index, this$.ColumnCount, this$.RowCount, this$.Values); - } - static removeRow(index: int32): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.RemoveRow(index); - return newTable; - }; - } - RemoveRows(indexArr: int32[]): void { - const this$: ArcTable = this; - indexArr.forEach((index: int32): void => { - SanityChecks_validateRowIndex(index, this$.RowCount, false); - }); - const indexArr_1: int32[] = sortDescending(indexArr, { - Compare: comparePrimitives, - }); - indexArr_1.forEach((index_1: int32): void => { - this$.RemoveRow(index_1); - }); - } - static removeRows(indexArr: int32[]): ((arg0: ArcTable) => ArcTable) { - return (table: ArcTable): ArcTable => { - const newTable: ArcTable = table.Copy(); - newTable.RemoveColumns(indexArr); - return newTable; - }; - } - GetRow(rowIndex: int32): CompositeCell_$union[] { - const this$: ArcTable = this; - SanityChecks_validateRowIndex(rowIndex, this$.RowCount, false); - return toArray(delay((): Iterable => map((columnIndex: int32): CompositeCell_$union => value_9(this$.TryGetCellAt(columnIndex, rowIndex)), rangeDouble(0, 1, this$.ColumnCount - 1)))); - } - static getRow(index: int32): ((arg0: ArcTable) => CompositeCell_$union[]) { - return (table: ArcTable): CompositeCell_$union[] => table.GetRow(index); - } - static insertParameterValue(t: ArcTable, p: ProcessParameterValue): ArcTable { - throw new Error(); - } - static getParameterValues(t: ArcTable): ProcessParameterValue[] { - throw new Error(); - } - AddProtocolTypeColumn(types?: OntologyAnnotation[], index?: int32): void { - const this$: ArcTable = this; - const cells: Option = map_2((array: OntologyAnnotation[]): CompositeCell_$union[] => map_1(CompositeCell_Term, array), types); - this$.AddColumn(CompositeHeader_ProtocolType(), cells, index); - } - AddProtocolVersionColumn(versions?: string[], index?: int32): void { - const this$: ArcTable = this; - const cells: Option = map_2((array: string[]): CompositeCell_$union[] => map_1(CompositeCell_FreeText, array), versions); - this$.AddColumn(CompositeHeader_ProtocolVersion(), cells, index); - } - AddProtocolUriColumn(uris?: string[], index?: int32): void { - const this$: ArcTable = this; - const cells: Option = map_2((array: string[]): CompositeCell_$union[] => map_1(CompositeCell_FreeText, array), uris); - this$.AddColumn(CompositeHeader_ProtocolUri(), cells, index); - } - AddProtocolDescriptionColumn(descriptions?: string[], index?: int32): void { - const this$: ArcTable = this; - const cells: Option = map_2((array: string[]): CompositeCell_$union[] => map_1(CompositeCell_FreeText, array), descriptions); - this$.AddColumn(CompositeHeader_ProtocolDescription(), cells, index); - } - AddProtocolNameColumn(names?: string[], index?: int32): void { - const this$: ArcTable = this; - const cells: Option = map_2((array: string[]): CompositeCell_$union[] => map_1(CompositeCell_FreeText, array), names); - this$.AddColumn(CompositeHeader_ProtocolREF(), cells, index); - } - GetProtocolTypeColumn(): CompositeColumn { - const this$: ArcTable = this; - return this$.GetColumnByHeader(CompositeHeader_ProtocolType()); - } - GetProtocolVersionColumn(): CompositeColumn { - const this$: ArcTable = this; - return this$.GetColumnByHeader(CompositeHeader_ProtocolVersion()); - } - GetProtocolUriColumn(): CompositeColumn { - const this$: ArcTable = this; - return this$.GetColumnByHeader(CompositeHeader_ProtocolUri()); - } - GetProtocolDescriptionColumn(): CompositeColumn { - const this$: ArcTable = this; - return this$.GetColumnByHeader(CompositeHeader_ProtocolDescription()); - } - GetProtocolNameColumn(): CompositeColumn { - const this$: ArcTable = this; - return this$.GetColumnByHeader(CompositeHeader_ProtocolREF()); - } - GetComponentColumns(): CompositeColumn[] { - const this$: ArcTable = this; - return map_1((h_1: CompositeHeader_$union): CompositeColumn => this$.GetColumnByHeader(h_1), toArray(filter((h: CompositeHeader_$union): boolean => h.isComponent, this$.Headers))); - } - static fromProtocol(p: Protocol): ArcTable { - const t: ArcTable = ArcTable.init(defaultArg(p.Name, "")); - const enumerator: IEnumerator = getEnumerator(defaultArg(p.Parameters, empty())); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const pp: ProtocolParameter = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - t.AddColumn(CompositeHeader_Parameter(value_9(pp.ParameterName)), void 0, ISA_ProtocolParameter__ProtocolParameter_TryGetColumnIndex(pp)); - } - } - finally { - disposeSafe(enumerator as IDisposable); - } - const enumerator_1: IEnumerator = getEnumerator(defaultArg(p.Components, empty())); - try { - while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) { - const c: Component = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"](); - const v_1: Option = map_2((arg: Value_$union): CompositeCell_$union[] => singleton_1(CompositeCell.fromValue(arg, unwrap(c.ComponentUnit))), c.ComponentValue); - t.AddColumn(CompositeHeader_Parameter(value_9(c.ComponentType)), v_1, ISA_Component__Component_TryGetColumnIndex(c)); - } - } - finally { - disposeSafe(enumerator_1 as IDisposable); - } - map_2((d: string): void => { - t.AddProtocolDescriptionColumn([d]); - }, p.Description); - map_2((d_1: string): void => { - t.AddProtocolVersionColumn([d_1]); - }, p.Version); - map_2((d_2: OntologyAnnotation): void => { - t.AddProtocolTypeColumn([d_2]); - }, p.ProtocolType); - map_2((d_3: string): void => { - t.AddProtocolUriColumn([d_3]); - }, p.Uri); - map_2((d_4: string): void => { - t.AddProtocolNameColumn([d_4]); - }, p.Name); - return t; - } - GetProtocols(): FSharpList { - const this$: ArcTable = this; - return (this$.RowCount === 0) ? singleton_2(fold((p: Protocol, h: CompositeHeader_$union): Protocol => { - switch (h.tag) { - case /* ProtocolType */ 4: - return Protocol_setProtocolType(p, OntologyAnnotation_get_empty()); - case /* ProtocolVersion */ 7: - return Protocol_setVersion(p, ""); - case /* ProtocolUri */ 6: - return Protocol_setUri(p, ""); - case /* ProtocolDescription */ 5: - return Protocol_setDescription(p, ""); - case /* ProtocolREF */ 8: - return Protocol_setName(p, ""); - case /* Parameter */ 3: - return Protocol_addParameter(ProtocolParameter_create_2769312B(void 0, h.fields[0]), p); - case /* Component */ 0: - return Protocol_addComponent(Component_create_Z33AADEE0(void 0, void 0, void 0, h.fields[0]), p); - default: - return p; - } - }, Protocol_get_empty(), this$.Headers)) : List_distinct(initialize_1(this$.RowCount, (i: int32): Protocol => toProtocol(zip(this$.Headers, this$.GetRow(i)))), { - Equals: equals, - GetHashCode: safeHash, - }); - } - GetProcesses(): FSharpList { - const this$: ArcTable = this; - let getter: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Process)); - const clo: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Process)) = ProcessParsing_getProcessGetter(this$.Name, this$.Headers); - getter = ((arg: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => Process) => { - const clo_1: ((arg0: int32) => Process) = clo(arg); - return clo_1; - }); - return toList(delay((): Iterable => map((i: int32): Process => getter(this$.Values)(i), rangeDouble(0, 1, this$.RowCount - 1)))); - } - static fromProcesses(name: string, ps: FSharpList): ArcTable { - const tupledArg: [CompositeHeader_$union[], IMap<[int32, int32], CompositeCell_$union>] = ProcessParsing_alignByHeaders(collect_1>(ProcessParsing_processToRows, ps)); - return ArcTable.create(name, tupledArg[0], tupledArg[1]); - } - toString(): string { - const this$: ArcTable = this; - return join("\n", toList(delay((): Iterable => append(singleton(`Table: ${this$.Name}`), delay((): Iterable => append(singleton("-------------"), delay((): Iterable => append(singleton(join("\t|\t", map(toString, this$.Headers))), delay((): Iterable => map((rowI: int32): string => join("\t|\t", map(toString, this$.GetRow(rowI))), rangeDouble(0, 1, this$.RowCount - 1))))))))))); - } - Equals(other: any): boolean { - const this$: ArcTable = this; - if (other instanceof ArcTable) { - const table = other as ArcTable; - const sameName: boolean = this$.Name === table.Name; - const h1: CompositeHeader_$union[] = this$.Headers; - const h2: CompositeHeader_$union[] = table.Headers; - const sameHeaderLength: boolean = h1.length === h2.length; - const sameHeaders: boolean = forAll2(equals, h1, h2); - const b1: Iterable<[[int32, int32], CompositeCell_$union]> = sortBy<[[int32, int32], CompositeCell_$union], [int32, int32]>((kv: [[int32, int32], CompositeCell_$union]): [int32, int32] => kv[0], this$.Values, { - Compare: compareArrays, - }); - const b2: Iterable<[[int32, int32], CompositeCell_$union]> = sortBy<[[int32, int32], CompositeCell_$union], [int32, int32]>((kv_1: [[int32, int32], CompositeCell_$union]): [int32, int32] => kv_1[0], table.Values, { - Compare: compareArrays, - }); - return (((sameName && sameHeaderLength) && sameHeaders) && (length<[[int32, int32], CompositeCell_$union]>(b1) === length<[[int32, int32], CompositeCell_$union]>(b2))) && forAll2<[[int32, int32], CompositeCell_$union], [[int32, int32], CompositeCell_$union]>(equals, b1, b2); - } - else { - return false; - } - } - GetHashCode(): int32 { - const this$: ArcTable = this; - return ((stringHash(this$.Name) + fold((state: int32, ele: CompositeHeader_$union): int32 => (state + safeHash(ele)), 0, this$.Headers)) + fold<[[int32, int32], CompositeCell_$union], int32>((state_2: int32, ele_1: [[int32, int32], CompositeCell_$union]): int32 => (state_2 + safeHash(ele_1)), 0, this$.Values)) | 0; - } -} - -export function ArcTable_$reflection(): TypeInfo { - return record_type("ISA.ArcTable", [], ArcTable, () => [["Name", string_type], ["Headers", array_type(CompositeHeader_$reflection())], ["Values", class_type("System.Collections.Generic.Dictionary`2", [tuple_type(int32_type, int32_type), CompositeCell_$reflection()])]]); -} - diff --git a/ts/ISA/ISA/ArcTypes/ArcTableAux.ts b/ts/ISA/ISA/ArcTypes/ArcTableAux.ts deleted file mode 100644 index 83f2f5d2..00000000 --- a/ts/ISA/ISA/ArcTypes/ArcTableAux.ts +++ /dev/null @@ -1,1042 +0,0 @@ -import { getItemFromDict, addToDict } from "../../../fable_modules/fable-library-ts/MapUtil.js"; -import { map as map_2, defaultArg, unwrap, value as value_8, Option, some } from "../../../fable_modules/fable-library-ts/Option.js"; -import { CompositeHeader_ProtocolVersion, CompositeHeader_ProtocolUri, CompositeHeader_ProtocolDescription, CompositeHeader_ProtocolType, CompositeHeader_ProtocolREF, IOType_$union, CompositeHeader_Output, IOType_Source, IOType_ImageFile, IOType_DerivedDataFile, IOType_RawDataFile, IOType_Material, CompositeHeader_Input, IOType_Sample, CompositeHeader_Characteristic, CompositeHeader_Factor, CompositeHeader_Parameter, CompositeHeader_Component, CompositeHeader_$union } from "./CompositeHeader.js"; -import { float64, int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { empty as empty_2, singleton as singleton_1, append, delay, map, tryPick, toList, indexed, initialize, filter, tryFindIndex, maxBy } from "../../../fable_modules/fable-library-ts/Seq.js"; -import { arrayHash, equalArrays, stringHash, int32ToString, IDisposable, IEnumerator, compareArrays, disposeSafe, getEnumerator, compare, equals, IMap, comparePrimitives } from "../../../fable_modules/fable-library-ts/Util.js"; -import { CompositeCell_Unitized, CompositeCell_FreeText, CompositeCell_Term, CompositeCell, CompositeCell_$union } from "./CompositeCell.js"; -import { mapIndexed, pick, exists, zip, append as append_1, sortBy, tryPick as tryPick_1, item, length, map as map_1, ofArray, singleton, choose, ofSeq, empty as empty_1, head, tail as tail_1, isEmpty, FSharpList, cons } from "../../../fable_modules/fable-library-ts/List.js"; -import { CompositeColumn } from "./CompositeColumn.js"; -import { max } from "../../../fable_modules/fable-library-ts/Double.js"; -import { iterateIndexed } from "../../../fable_modules/fable-library-ts/Array.js"; -import { FSharpSet__get_MinimumElement, FSharpSet__get_IsEmpty, difference, FSharpSet, ofSeq as ofSeq_1 } from "../../../fable_modules/fable-library-ts/Set.js"; -import { Value_Name, Value_fromString_Z721C83C5, Value_$union, Value_Ontology } from "../JsonTypes/Value.js"; -import { OntologyAnnotation } from "../JsonTypes/OntologyAnnotation.js"; -import { Component, Component_fromOptions } from "../JsonTypes/Component.js"; -import { ProcessParameterValue, ProcessParameterValue_create_2A3A2A47 } from "../JsonTypes/ProcessParameterValue.js"; -import { ProtocolParameter, ProtocolParameter_create_2769312B } from "../JsonTypes/ProtocolParameter.js"; -import { FactorValue, FactorValue_create_Z54E26173 } from "../JsonTypes/FactorValue.js"; -import { Factor_create_Z3D2B374F } from "../JsonTypes/Factor.js"; -import { toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { MaterialAttributeValue, MaterialAttributeValue_create_163BDE77 } from "../JsonTypes/MaterialAttributeValue.js"; -import { MaterialAttribute_create_2769312B } from "../JsonTypes/MaterialAttribute.js"; -import { ProcessInput_getCharacteristicValues_Z38E7E853, ProcessInput__isMaterial, ProcessInput__isData, ProcessInput_setCharacteristicValues, ProcessInput__get_Name, ProcessInput__isSource, ProcessInput__isSample, ProcessInput_Source, ProcessInput_$union, ProcessInput_createDerivedData_Z721C83C5, ProcessInput_createRawData_Z721C83C5, ProcessInput_createImageFile_Z721C83C5, ProcessInput_createMaterial_ZEED0B34, ProcessInput_createSample_Z445EF6B3, ProcessInput_createSource_Z3083890A } from "../JsonTypes/ProcessInput.js"; -import { remove, printf, toFail } from "../../../fable_modules/fable-library-ts/String.js"; -import { ProcessOutput_getFactorValues_Z4A02997C, ProcessOutput__isMaterial, ProcessOutput__isData, ProcessOutput_setFactorValues, ProcessOutput__get_Name, ProcessOutput__isSample, ProcessOutput_Sample, ProcessOutput_$union, ProcessOutput_createDerivedData_Z721C83C5, ProcessOutput_createRawData_Z721C83C5, ProcessOutput_createImageFile_Z721C83C5, ProcessOutput_createMaterial_ZEED0B34, ProcessOutput_createSample_Z445EF6B3 } from "../JsonTypes/ProcessOutput.js"; -import { Data } from "../JsonTypes/Data.js"; -import { DataFile_$union } from "../JsonTypes/DataFile.js"; -import { tryGetFactorColumnIndex, tryGetCharacteristicColumnIndex, tryGetComponentIndex, tryGetParameterColumnIndex, ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4 } from "../JsonTypes/ColumnIndex.js"; -import { Source_create_Z32235993 } from "../JsonTypes/Source.js"; -import { Sample_create_3A6378D6 } from "../JsonTypes/Sample.js"; -import { mapOrDefault, fromValueWithDefault } from "../OptionExtensions.js"; -import { Protocol, Protocol_make } from "../JsonTypes/Protocol.js"; -import { Process_decomposeName_Z721C83C5, Process, Process_make } from "../JsonTypes/Process.js"; -import { List_groupBy } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { createMissingIdentifier } from "./Identifier.js"; -import { Dictionary } from "../../../fable_modules/fable-library-ts/MutableMap.js"; - -/** - * Returns the dictionary with the binding added to the given dictionary. - * If a binding with the given key already exists in the input dictionary, the existing binding is replaced by the new binding in the result dictionary. - */ -export function Dictionary_addOrUpdateInPlace<$a, $b>(key: $a, value: $b, table: any): any { - if (table.has(key)) { - table.set(key, value); - } - else { - addToDict(table, key, value); - } - return table; -} - -/** - * Lookup an element in the dictionary, returning a Some value if the element is in the domain - * of the dictionary and None if not. - */ -export function Dictionary_tryFind<$a, $b>(key: $a, table: any): Option<$b> { - if (table.has(key)) { - return some(getItemFromDict(table, key)); - } - else { - return void 0; - } -} - -export function getColumnCount(headers: CompositeHeader_$union[]): int32 { - return headers.length; -} - -export function getRowCount(values: IMap<[int32, int32], CompositeCell_$union>): int32 { - if (values.size === 0) { - return 0; - } - else { - return (1 + maxBy<[int32, int32], int32>((tuple: [int32, int32]): int32 => tuple[1], values.keys(), { - Compare: comparePrimitives, - })[1]) | 0; - } -} - -export function $007CIsUniqueExistingHeader$007C_$007C(existingHeaders: Iterable, input: CompositeHeader_$union): Option { - switch (input.tag) { - case /* Parameter */ 3: - case /* Factor */ 2: - case /* Characteristic */ 1: - case /* Component */ 0: - case /* FreeText */ 13: - return void 0; - case /* Output */ 12: - return tryFindIndex((h: CompositeHeader_$union): boolean => (h.tag === /* Output */ 12), existingHeaders); - case /* Input */ 11: - return tryFindIndex((h_1: CompositeHeader_$union): boolean => (h_1.tag === /* Input */ 11), existingHeaders); - default: - return tryFindIndex((h_2: CompositeHeader_$union): boolean => equals(h_2, input), existingHeaders); - } -} - -/** - * Returns the column index of the duplicate unique column in `existingHeaders`. - */ -export function tryFindDuplicateUnique(newHeader: CompositeHeader_$union, existingHeaders: Iterable): Option { - const activePatternResult: Option = $007CIsUniqueExistingHeader$007C_$007C(existingHeaders, newHeader); - if (activePatternResult != null) { - const index: int32 = value_8(activePatternResult) | 0; - return index; - } - else { - return void 0; - } -} - -/** - * Returns the column index of the duplicate unique column in `existingHeaders`. - */ -export function tryFindDuplicateUniqueInArray(existingHeaders: Iterable): FSharpList<{ HeaderType: CompositeHeader_$union, Index1: int32, Index2: int32 }> { - const loop = (i_mut: int32, duplicateList_mut: FSharpList<{ HeaderType: CompositeHeader_$union, Index1: int32, Index2: int32 }>, headerList_mut: FSharpList): FSharpList<{ HeaderType: CompositeHeader_$union, Index1: int32, Index2: int32 }> => { - loop: - while (true) { - const i: int32 = i_mut, duplicateList: FSharpList<{ HeaderType: CompositeHeader_$union, Index1: int32, Index2: int32 }> = duplicateList_mut, headerList: FSharpList = headerList_mut; - let matchResult: int32, header: CompositeHeader_$union, tail: FSharpList; - if (isEmpty(headerList)) { - matchResult = 0; - } - else if (isEmpty(tail_1(headerList))) { - matchResult = 0; - } - else { - matchResult = 1; - header = head(headerList); - tail = tail_1(headerList); - } - switch (matchResult) { - case 0: - return duplicateList; - default: { - const hasDuplicate: Option = tryFindDuplicateUnique(header!, tail!); - i_mut = (i + 1); - duplicateList_mut = ((hasDuplicate != null) ? cons({ - HeaderType: header!, - Index1: i, - Index2: value_8(hasDuplicate), - }, duplicateList) : duplicateList); - headerList_mut = tail!; - continue loop; - } - } - break; - } - }; - return loop(0, empty_1<{ HeaderType: CompositeHeader_$union, Index1: int32, Index2: int32 }>(), ofSeq(filter((x: CompositeHeader_$union): boolean => !x.IsTermColumn, existingHeaders))); -} - -/** - * Checks if given column index is valid for given number of columns. - * - * if `allowAppend` = true => `0 < index <= columnCount` - * - * if `allowAppend` = false => `0 < index < columnCount` - */ -export function SanityChecks_validateColumnIndex(index: int32, columnCount: int32, allowAppend: boolean): void { - let x: int32, y: int32; - if (index < 0) { - throw new Error("Cannot insert CompositeColumn at index < 0."); - } - if ((x = (index | 0), (y = (columnCount | 0), allowAppend ? (compare(x, y) > 0) : (compare(x, y) >= 0)))) { - throw new Error(`Specified index is out of table range! Table contains only ${columnCount} columns.`); - } -} - -/** - * Checks if given index is valid for given number of rows. - * - * if `allowAppend` = true => `0 < index <= rowCount` - * - * if `allowAppend` = false => `0 < index < rowCount` - */ -export function SanityChecks_validateRowIndex(index: int32, rowCount: int32, allowAppend: boolean): void { - let x: int32, y: int32; - if (index < 0) { - throw new Error("Cannot insert CompositeColumn at index < 0."); - } - if ((x = (index | 0), (y = (rowCount | 0), allowAppend ? (compare(x, y) > 0) : (compare(x, y) >= 0)))) { - throw new Error(`Specified index is out of table range! Table contains only ${rowCount} rows.`); - } -} - -export function SanityChecks_validateColumn(column: CompositeColumn): void { - column.validate(true); -} - -export function Unchecked_tryGetCellAt(column: int32, row: int32, cells: IMap<[int32, int32], CompositeCell_$union>): Option { - return Dictionary_tryFind<[int32, int32], CompositeCell_$union>([column, row] as [int32, int32], cells); -} - -export function Unchecked_setCellAt(columnIndex: int32, rowIndex: int32, c: CompositeCell_$union, cells: IMap<[int32, int32], CompositeCell_$union>): void { - Dictionary_addOrUpdateInPlace<[int32, int32], CompositeCell_$union>([columnIndex, rowIndex] as [int32, int32], c, cells); -} - -export function Unchecked_moveCellTo(fromCol: int32, fromRow: int32, toCol: int32, toRow: int32, cells: IMap<[int32, int32], CompositeCell_$union>): void { - const matchValue: Option = Dictionary_tryFind<[int32, int32], CompositeCell_$union>([fromCol, fromRow] as [int32, int32], cells); - if (matchValue == null) { - } - else { - const c: CompositeCell_$union = value_8(matchValue); - cells.delete([fromCol, fromRow] as [int32, int32]); - const value_1: any = Unchecked_setCellAt(toCol, toRow, c, cells); - } -} - -export function Unchecked_removeHeader(index: int32, headers: CompositeHeader_$union[]): void { - headers.splice(index, 1); -} - -/** - * Remove cells of one Column, change index of cells with higher index to index - 1 - */ -export function Unchecked_removeColumnCells(index: int32, cells: IMap<[int32, int32], CompositeCell_$union>): void { - let enumerator: any = getEnumerator(cells); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const activePatternResult: [[int32, int32], CompositeCell_$union] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const c: int32 = activePatternResult[0][0] | 0; - if (c === index) { - cells.delete([c, activePatternResult[0][1]] as [int32, int32]); - } - } - } - finally { - disposeSafe(enumerator); - } -} - -/** - * Remove cells of one Column, change index of cells with higher index to index - 1 - */ -export function Unchecked_removeColumnCells_withIndexChange(index: int32, columnCount: int32, rowCount: int32, cells: IMap<[int32, int32], CompositeCell_$union>): void { - for (let col: int32 = index; col <= (columnCount - 1); col++) { - for (let row = 0; row <= (rowCount - 1); row++) { - if (col === index) { - cells.delete([col, row] as [int32, int32]); - } - else if (col > index) { - Unchecked_moveCellTo(col, row, col - 1, row, cells); - } - } - } -} - -export function Unchecked_removeRowCells(rowIndex: int32, cells: IMap<[int32, int32], CompositeCell_$union>): void { - let enumerator: any = getEnumerator(cells); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const activePatternResult: [[int32, int32], CompositeCell_$union] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - const r: int32 = activePatternResult[0][1] | 0; - if (r === rowIndex) { - cells.delete([activePatternResult[0][0], r] as [int32, int32]); - } - } - } - finally { - disposeSafe(enumerator); - } -} - -/** - * Remove cells of one Row, change index of cells with higher index to index - 1 - */ -export function Unchecked_removeRowCells_withIndexChange(rowIndex: int32, columnCount: int32, rowCount: int32, cells: IMap<[int32, int32], CompositeCell_$union>): void { - for (let row: int32 = rowIndex; row <= (rowCount - 1); row++) { - for (let col = 0; col <= (columnCount - 1); col++) { - if (row === rowIndex) { - cells.delete([col, row] as [int32, int32]); - } - else if (row > rowIndex) { - Unchecked_moveCellTo(col, row, col, row - 1, cells); - } - } - } -} - -/** - * Get an empty cell fitting for related column header. - * - * `columCellOption` is used to decide between `CompositeCell.Term` or `CompositeCell.Unitized`. `columCellOption` can be any other cell in the same column, preferably the first one. - */ -export function Unchecked_getEmptyCellForHeader(header: CompositeHeader_$union, columCellOption: Option): CompositeCell_$union { - const matchValue: boolean = header.IsTermColumn; - if (matchValue) { - let matchResult: int32; - if (columCellOption == null) { - matchResult = 0; - } - else { - switch (value_8(columCellOption).tag) { - case /* Term */ 0: { - matchResult = 0; - break; - } - case /* Unitized */ 2: { - matchResult = 1; - break; - } - default: - matchResult = 2; - } - } - switch (matchResult) { - case 0: - return CompositeCell.emptyTerm; - case 1: - return CompositeCell.emptyUnitized; - default: - throw new Error("[extendBodyCells] This should never happen, IsTermColumn header must be paired with either term or unitized cell."); - } - } - else { - return CompositeCell.emptyFreeText; - } -} - -export function Unchecked_addColumn(newHeader: CompositeHeader_$union, newCells: CompositeCell_$union[], index: int32, forceReplace: boolean, headers: CompositeHeader_$union[], values: IMap<[int32, int32], CompositeCell_$union>): void { - let numberOfNewColumns = 1; - let index_1: int32 = index; - const hasDuplicateUnique: Option = tryFindDuplicateUnique(newHeader, headers); - if (!forceReplace && (hasDuplicateUnique != null)) { - throw new Error(`Invalid new column \`${newHeader}\`. Table already contains header of the same type on index \`${value_8(hasDuplicateUnique)}\``); - } - if (hasDuplicateUnique != null) { - numberOfNewColumns = 0; - index_1 = (value_8(hasDuplicateUnique) | 0); - } - const matchValue: int32 = getColumnCount(headers) | 0; - const matchValue_1: int32 = getRowCount(values) | 0; - const startColCount: int32 = matchValue | 0; - let setNewHeader: any; - if (hasDuplicateUnique != null) { - Unchecked_removeHeader(index_1, headers); - } - setNewHeader = headers.splice(index_1, 0, newHeader); - let increaseColumnIndices: any; - if ((index_1 < startColCount) && (hasDuplicateUnique == null)) { - const lastColumnIndex: int32 = max(startColCount - 1, 0) | 0; - for (let columnIndex: int32 = lastColumnIndex; columnIndex >= index_1; columnIndex--) { - for (let rowIndex = 0; rowIndex <= matchValue_1; rowIndex++) { - Unchecked_moveCellTo(columnIndex, rowIndex, columnIndex + numberOfNewColumns, rowIndex, values); - } - } - } - else { - increaseColumnIndices = void 0; - } - let setNewCells: any; - if (hasDuplicateUnique != null) { - Unchecked_removeColumnCells(index_1, values); - } - setNewCells = iterateIndexed((rowIndex_1: int32, cell: CompositeCell_$union): void => { - Unchecked_setCellAt(index_1, rowIndex_1, cell, values); - }, newCells); -} - -export function Unchecked_fillMissingCells(headers: CompositeHeader_$union[], values: IMap<[int32, int32], CompositeCell_$union>): void { - const rowCount: int32 = getRowCount(values) | 0; - const lastColumnIndex: int32 = (getColumnCount(headers) - 1) | 0; - const keys: any = values.keys(); - for (let columnIndex = 0; columnIndex <= lastColumnIndex; columnIndex++) { - const colKeys: FSharpSet<[int32, int32]> = ofSeq_1<[int32, int32]>(filter<[int32, int32]>((tupledArg: [int32, int32]): boolean => (tupledArg[0] === columnIndex), keys), { - Compare: compareArrays, - }); - const missingKeys: FSharpSet<[int32, int32]> = difference<[int32, int32]>(ofSeq_1<[int32, int32]>(initialize<[int32, int32]>(rowCount, (i: int32): [int32, int32] => ([columnIndex, i] as [int32, int32])), { - Compare: compareArrays, - }), colKeys); - if (!FSharpSet__get_IsEmpty(missingKeys)) { - const empty: CompositeCell_$union = Unchecked_getEmptyCellForHeader(headers[columnIndex], FSharpSet__get_IsEmpty(colKeys) ? void 0 : getItemFromDict(values, FSharpSet__get_MinimumElement(colKeys))); - const enumerator: IEnumerator<[int32, int32]> = getEnumerator(missingKeys); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - const forLoopVar: [int32, int32] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); - Unchecked_setCellAt(forLoopVar[0], forLoopVar[1], empty, values); - } - } - finally { - disposeSafe(enumerator as IDisposable); - } - } - } -} - -export function Unchecked_addRow(index: int32, newCells: CompositeCell_$union[], headers: CompositeHeader_$union[], values: IMap<[int32, int32], CompositeCell_$union>): void { - const rowCount: int32 = getRowCount(values) | 0; - const columnCount: int32 = getColumnCount(headers) | 0; - let increaseRowIndices: any; - if (index < rowCount) { - const lastRowIndex: int32 = max(rowCount - 1, 0) | 0; - for (let rowIndex: int32 = lastRowIndex; rowIndex >= index; rowIndex--) { - for (let columnIndex = 0; columnIndex <= (columnCount - 1); columnIndex++) { - Unchecked_moveCellTo(columnIndex, rowIndex, columnIndex, rowIndex + 1, values); - } - } - } - else { - increaseRowIndices = void 0; - } - const setNewCells: any = iterateIndexed((columnIndex_1: int32, cell: CompositeCell_$union): void => { - Unchecked_setCellAt(columnIndex_1, index, cell, values); - }, newCells); -} - -/** - * Convert a CompositeCell to a ISA Value and Unit tuple. - */ -export function JsonTypes_valueOfCell(value: CompositeCell_$union): [Value_$union, Option] { - switch (value.tag) { - case /* Term */ 0: - return [Value_Ontology(value.fields[0]), void 0] as [Value_$union, Option]; - case /* Unitized */ 2: { - const unit: OntologyAnnotation = value.fields[1]; - return [Value_fromString_Z721C83C5(value.fields[0]), unit] as [Value_$union, Option]; - } - default: - return [Value_fromString_Z721C83C5(value.fields[0]), void 0] as [Value_$union, Option]; - } -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA Component - */ -export function JsonTypes_composeComponent(header: CompositeHeader_$union, value: CompositeCell_$union): Component { - const patternInput: [Value_$union, Option] = JsonTypes_valueOfCell(value); - return Component_fromOptions(patternInput[0], patternInput[1], header.ToTerm()); -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA ProcessParameterValue - */ -export function JsonTypes_composeParameterValue(header: CompositeHeader_$union, value: CompositeCell_$union): ProcessParameterValue { - const patternInput: [Value_$union, Option] = JsonTypes_valueOfCell(value); - return ProcessParameterValue_create_2A3A2A47(ProtocolParameter_create_2769312B(void 0, header.ToTerm()), patternInput[0], unwrap(patternInput[1])); -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA FactorValue - */ -export function JsonTypes_composeFactorValue(header: CompositeHeader_$union, value: CompositeCell_$union): FactorValue { - const patternInput: [Value_$union, Option] = JsonTypes_valueOfCell(value); - return FactorValue_create_Z54E26173(void 0, Factor_create_Z3D2B374F(void 0, toString(header), header.ToTerm()), patternInput[0], unwrap(patternInput[1])); -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA MaterialAttributeValue - */ -export function JsonTypes_composeCharacteristicValue(header: CompositeHeader_$union, value: CompositeCell_$union): MaterialAttributeValue { - const patternInput: [Value_$union, Option] = JsonTypes_valueOfCell(value); - return MaterialAttributeValue_create_163BDE77(void 0, MaterialAttribute_create_2769312B(void 0, header.ToTerm()), patternInput[0], unwrap(patternInput[1])); -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA ProcessInput - */ -export function JsonTypes_composeProcessInput(header: CompositeHeader_$union, value: CompositeCell_$union): ProcessInput_$union { - let matchResult: int32; - if (header.tag === /* Input */ 11) { - switch (header.fields[0].tag) { - case /* Source */ 0: { - matchResult = 0; - break; - } - case /* Sample */ 1: { - matchResult = 1; - break; - } - case /* Material */ 5: { - matchResult = 2; - break; - } - case /* ImageFile */ 4: { - matchResult = 3; - break; - } - case /* RawDataFile */ 2: { - matchResult = 4; - break; - } - case /* DerivedDataFile */ 3: { - matchResult = 5; - break; - } - default: - matchResult = 6; - } - } - else { - matchResult = 6; - } - switch (matchResult) { - case 0: - return ProcessInput_createSource_Z3083890A(toString(value)); - case 1: - return ProcessInput_createSample_Z445EF6B3(toString(value)); - case 2: - return ProcessInput_createMaterial_ZEED0B34(toString(value)); - case 3: - return ProcessInput_createImageFile_Z721C83C5(toString(value)); - case 4: - return ProcessInput_createRawData_Z721C83C5(toString(value)); - case 5: - return ProcessInput_createDerivedData_Z721C83C5(toString(value)); - default: - return toFail(printf("Could not parse input header %O"))(header); - } -} - -/** - * Convert a CompositeHeader and Cell tuple to a ISA ProcessOutput - */ -export function JsonTypes_composeProcessOutput(header: CompositeHeader_$union, value: CompositeCell_$union): ProcessOutput_$union { - let matchResult: int32; - if (header.tag === /* Output */ 12) { - switch (header.fields[0].tag) { - case /* Sample */ 1: { - matchResult = 0; - break; - } - case /* Material */ 5: { - matchResult = 1; - break; - } - case /* ImageFile */ 4: { - matchResult = 2; - break; - } - case /* RawDataFile */ 2: { - matchResult = 3; - break; - } - case /* DerivedDataFile */ 3: { - matchResult = 4; - break; - } - default: - matchResult = 5; - } - } - else { - matchResult = 5; - } - switch (matchResult) { - case 0: - return ProcessOutput_createSample_Z445EF6B3(toString(value)); - case 1: - return ProcessOutput_createMaterial_ZEED0B34(toString(value)); - case 2: - return ProcessOutput_createImageFile_Z721C83C5(toString(value)); - case 3: - return ProcessOutput_createRawData_Z721C83C5(toString(value)); - case 4: - return ProcessOutput_createDerivedData_Z721C83C5(toString(value)); - default: - return toFail(printf("Could not parse output header %O"))(header); - } -} - -/** - * Convert an ISA Value and Unit tuple to a CompositeCell - */ -export function JsonTypes_cellOfValue(value: Option, unit: Option): CompositeCell_$union { - const value_2: Value_$union = defaultArg(value, Value_Name("")); - let matchResult: int32, oa: OntologyAnnotation, text: string, u: OntologyAnnotation, f: float64, u_1: OntologyAnnotation, f_1: float64, i: int32, u_2: OntologyAnnotation, i_1: int32; - switch (value_2.tag) { - case /* Name */ 3: { - if (unit != null) { - if (value_2.fields[0] === "") { - matchResult = 2; - u = value_8(unit); - } - else { - matchResult = 7; - } - } - else { - matchResult = 1; - text = value_2.fields[0]; - } - break; - } - case /* Float */ 2: { - if (unit == null) { - matchResult = 4; - f_1 = value_2.fields[0]; - } - else { - matchResult = 3; - f = value_2.fields[0]; - u_1 = value_8(unit); - } - break; - } - case /* Int */ 1: { - if (unit == null) { - matchResult = 6; - i_1 = value_2.fields[0]; - } - else { - matchResult = 5; - i = value_2.fields[0]; - u_2 = value_8(unit); - } - break; - } - default: - if (unit == null) { - matchResult = 0; - oa = value_2.fields[0]; - } - else { - matchResult = 7; - } - } - switch (matchResult) { - case 0: - return CompositeCell_Term(oa!); - case 1: - return CompositeCell_FreeText(text!); - case 2: - return CompositeCell_Unitized("", u!); - case 3: - return CompositeCell_Unitized(f!.toString(), u_1!); - case 4: - return CompositeCell_FreeText(f_1!.toString()); - case 5: - return CompositeCell_Unitized(int32ToString(i!), u_2!); - case 6: - return CompositeCell_FreeText(int32ToString(i_1!)); - default: - return toFail(printf("Could not parse value %O with unit %O"))(value_2)(unit); - } -} - -/** - * Convert an ISA Component to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeComponent(c: Component): [CompositeHeader_$union, CompositeCell_$union] { - return [CompositeHeader_Component(value_8(c.ComponentType)), JsonTypes_cellOfValue(c.ComponentValue, c.ComponentUnit)] as [CompositeHeader_$union, CompositeCell_$union]; -} - -/** - * Convert an ISA ProcessParameterValue to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeParameterValue(ppv: ProcessParameterValue): [CompositeHeader_$union, CompositeCell_$union] { - return [CompositeHeader_Parameter(value_8(value_8(ppv.Category).ParameterName)), JsonTypes_cellOfValue(ppv.Value, ppv.Unit)] as [CompositeHeader_$union, CompositeCell_$union]; -} - -/** - * Convert an ISA FactorValue to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeFactorValue(fv: FactorValue): [CompositeHeader_$union, CompositeCell_$union] { - return [CompositeHeader_Factor(value_8(value_8(fv.Category).FactorType)), JsonTypes_cellOfValue(fv.Value, fv.Unit)] as [CompositeHeader_$union, CompositeCell_$union]; -} - -/** - * Convert an ISA MaterialAttributeValue to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeCharacteristicValue(cv: MaterialAttributeValue): [CompositeHeader_$union, CompositeCell_$union] { - return [CompositeHeader_Characteristic(value_8(value_8(cv.Category).CharacteristicType)), JsonTypes_cellOfValue(cv.Value, cv.Unit)] as [CompositeHeader_$union, CompositeCell_$union]; -} - -/** - * Convert an ISA ProcessOutput to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeProcessInput(pi: ProcessInput_$union): [CompositeHeader_$union, CompositeCell_$union] { - switch (pi.tag) { - case /* Sample */ 1: - return [CompositeHeader_Input(IOType_Sample()), CompositeCell_FreeText(defaultArg(pi.fields[0].Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - case /* Material */ 3: - return [CompositeHeader_Input(IOType_Material()), CompositeCell_FreeText(defaultArg(pi.fields[0].Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - case /* Data */ 2: { - const d: Data = pi.fields[0]; - const dataType: DataFile_$union = value_8(d.DataType); - switch (dataType.tag) { - case /* RawDataFile */ 0: - return [CompositeHeader_Input(IOType_RawDataFile()), CompositeCell_FreeText(defaultArg(d.Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - case /* DerivedDataFile */ 1: - return [CompositeHeader_Input(IOType_DerivedDataFile()), CompositeCell_FreeText(defaultArg(d.Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - default: - return [CompositeHeader_Input(IOType_ImageFile()), CompositeCell_FreeText(defaultArg(d.Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - } - } - default: - return [CompositeHeader_Input(IOType_Source()), CompositeCell_FreeText(defaultArg(pi.fields[0].Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - } -} - -/** - * Convert an ISA ProcessOutput to a CompositeHeader and Cell tuple - */ -export function JsonTypes_decomposeProcessOutput(po: ProcessOutput_$union): [CompositeHeader_$union, CompositeCell_$union] { - switch (po.tag) { - case /* Material */ 2: - return [CompositeHeader_Output(IOType_Material()), CompositeCell_FreeText(defaultArg(po.fields[0].Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - case /* Data */ 1: { - const d: Data = po.fields[0]; - const dataType: DataFile_$union = value_8(d.DataType); - switch (dataType.tag) { - case /* RawDataFile */ 0: - return [CompositeHeader_Output(IOType_RawDataFile()), CompositeCell_FreeText(defaultArg(d.Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - case /* DerivedDataFile */ 1: - return [CompositeHeader_Output(IOType_DerivedDataFile()), CompositeCell_FreeText(defaultArg(d.Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - default: - return [CompositeHeader_Output(IOType_ImageFile()), CompositeCell_FreeText(defaultArg(d.Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - } - } - default: - return [CompositeHeader_Output(IOType_Sample()), CompositeCell_FreeText(defaultArg(po.fields[0].Name, ""))] as [CompositeHeader_$union, CompositeCell_$union]; - } -} - -/** - * If the headers of a node depict a component, returns a function for parsing the values of the matrix to the values of this component - */ -export function ProcessParsing_tryComponentGetter(generalI: int32, valueI: int32, valueHeader: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Component))> { - if (valueHeader.tag === /* Component */ 0) { - const cat: CompositeHeader_$union = CompositeHeader_Component(ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(valueHeader.fields[0], valueI)); - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => Component) => ((i: int32): Component => JsonTypes_composeComponent(cat, getItemFromDict(matrix, [generalI, i] as [int32, int32]))); - } - else { - return void 0; - } -} - -/** - * If the headers of a node depict a protocolType, returns a function for parsing the values of the matrix to the values of this type - */ -export function ProcessParsing_tryParameterGetter(generalI: int32, valueI: int32, valueHeader: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessParameterValue))> { - if (valueHeader.tag === /* Parameter */ 3) { - const cat: CompositeHeader_$union = CompositeHeader_Parameter(ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(valueHeader.fields[0], valueI)); - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => ProcessParameterValue) => ((i: int32): ProcessParameterValue => JsonTypes_composeParameterValue(cat, getItemFromDict(matrix, [generalI, i] as [int32, int32]))); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryFactorGetter(generalI: int32, valueI: int32, valueHeader: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FactorValue))> { - if (valueHeader.tag === /* Factor */ 2) { - const cat: CompositeHeader_$union = CompositeHeader_Factor(ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(valueHeader.fields[0], valueI)); - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => FactorValue) => ((i: int32): FactorValue => JsonTypes_composeFactorValue(cat, getItemFromDict(matrix, [generalI, i] as [int32, int32]))); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryCharacteristicGetter(generalI: int32, valueI: int32, valueHeader: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => MaterialAttributeValue))> { - if (valueHeader.tag === /* Characteristic */ 1) { - const cat: CompositeHeader_$union = CompositeHeader_Characteristic(ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(valueHeader.fields[0], valueI)); - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => MaterialAttributeValue) => ((i: int32): MaterialAttributeValue => JsonTypes_composeCharacteristicValue(cat, getItemFromDict(matrix, [generalI, i] as [int32, int32]))); - } - else { - return void 0; - } -} - -/** - * If the headers of a node depict a protocolType, returns a function for parsing the values of the matrix to the values of this type - */ -export function ProcessParsing_tryGetProtocolTypeGetter(generalI: int32, header: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => OntologyAnnotation))> { - if (header.tag === /* ProtocolType */ 4) { - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => OntologyAnnotation) => ((i: int32): OntologyAnnotation => getItemFromDict(matrix, [generalI, i] as [int32, int32]).AsTerm); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetProtocolREFGetter(generalI: int32, header: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> { - if (header.tag === /* ProtocolREF */ 8) { - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => string) => ((i: int32): string => getItemFromDict(matrix, [generalI, i] as [int32, int32]).AsFreeText); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetProtocolDescriptionGetter(generalI: int32, header: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> { - if (header.tag === /* ProtocolDescription */ 5) { - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => string) => ((i: int32): string => getItemFromDict(matrix, [generalI, i] as [int32, int32]).AsFreeText); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetProtocolURIGetter(generalI: int32, header: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> { - if (header.tag === /* ProtocolUri */ 6) { - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => string) => ((i: int32): string => getItemFromDict(matrix, [generalI, i] as [int32, int32]).AsFreeText); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetProtocolVersionGetter(generalI: int32, header: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> { - if (header.tag === /* ProtocolVersion */ 7) { - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => string) => ((i: int32): string => getItemFromDict(matrix, [generalI, i] as [int32, int32]).AsFreeText); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetInputGetter(generalI: int32, header: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessInput_$union))> { - if (header.tag === /* Input */ 11) { - const io: IOType_$union = header.fields[0]; - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => ProcessInput_$union) => ((i: int32): ProcessInput_$union => JsonTypes_composeProcessInput(header, getItemFromDict(matrix, [generalI, i] as [int32, int32]))); - } - else { - return void 0; - } -} - -export function ProcessParsing_tryGetOutputGetter(generalI: int32, header: CompositeHeader_$union): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessOutput_$union))> { - if (header.tag === /* Output */ 12) { - const io: IOType_$union = header.fields[0]; - return (matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => ProcessOutput_$union) => ((i: int32): ProcessOutput_$union => JsonTypes_composeProcessOutput(header, getItemFromDict(matrix, [generalI, i] as [int32, int32]))); - } - else { - return void 0; - } -} - -/** - * Given the header sequence of an ArcTable, returns a function for parsing each row of the table to a process - */ -export function ProcessParsing_getProcessGetter(processNameRoot: string, headers: Iterable): ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Process)) { - const headers_1: Iterable<[int32, CompositeHeader_$union]> = indexed(headers); - const valueHeaders: FSharpList<[int32, [int32, CompositeHeader_$union]]> = toList<[int32, [int32, CompositeHeader_$union]]>(indexed<[int32, CompositeHeader_$union]>(filter<[int32, CompositeHeader_$union]>((arg: [int32, CompositeHeader_$union]): boolean => arg[1].IsCvParamColumn, headers_1))); - const charGetters: FSharpList<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => MaterialAttributeValue))> = choose<[int32, [int32, CompositeHeader_$union]], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => MaterialAttributeValue))>((tupledArg: [int32, [int32, CompositeHeader_$union]]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => MaterialAttributeValue))> => { - const _arg: [int32, CompositeHeader_$union] = tupledArg[1]; - return ProcessParsing_tryCharacteristicGetter(_arg[0], tupledArg[0], _arg[1]); - }, valueHeaders); - const factorValueGetters: FSharpList<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FactorValue))> = choose<[int32, [int32, CompositeHeader_$union]], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FactorValue))>((tupledArg_1: [int32, [int32, CompositeHeader_$union]]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FactorValue))> => { - const _arg_1: [int32, CompositeHeader_$union] = tupledArg_1[1]; - return ProcessParsing_tryFactorGetter(_arg_1[0], tupledArg_1[0], _arg_1[1]); - }, valueHeaders); - const parameterValueGetters: FSharpList<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessParameterValue))> = choose<[int32, [int32, CompositeHeader_$union]], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessParameterValue))>((tupledArg_2: [int32, [int32, CompositeHeader_$union]]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessParameterValue))> => { - const _arg_2: [int32, CompositeHeader_$union] = tupledArg_2[1]; - return ProcessParsing_tryParameterGetter(_arg_2[0], tupledArg_2[0], _arg_2[1]); - }, valueHeaders); - const componentGetters: FSharpList<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Component))> = choose<[int32, [int32, CompositeHeader_$union]], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Component))>((tupledArg_3: [int32, [int32, CompositeHeader_$union]]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Component))> => { - const _arg_3: [int32, CompositeHeader_$union] = tupledArg_3[1]; - return ProcessParsing_tryComponentGetter(_arg_3[0], tupledArg_3[0], _arg_3[1]); - }, valueHeaders); - const protocolTypeGetter: Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => OntologyAnnotation))> = tryPick<[int32, CompositeHeader_$union], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => OntologyAnnotation))>((tupledArg_4: [int32, CompositeHeader_$union]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => OntologyAnnotation))> => ProcessParsing_tryGetProtocolTypeGetter(tupledArg_4[0], tupledArg_4[1]), headers_1); - const protocolREFGetter: Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> = tryPick<[int32, CompositeHeader_$union], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))>((tupledArg_5: [int32, CompositeHeader_$union]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> => ProcessParsing_tryGetProtocolREFGetter(tupledArg_5[0], tupledArg_5[1]), headers_1); - const protocolDescriptionGetter: Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> = tryPick<[int32, CompositeHeader_$union], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))>((tupledArg_6: [int32, CompositeHeader_$union]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> => ProcessParsing_tryGetProtocolDescriptionGetter(tupledArg_6[0], tupledArg_6[1]), headers_1); - const protocolURIGetter: Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> = tryPick<[int32, CompositeHeader_$union], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))>((tupledArg_7: [int32, CompositeHeader_$union]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> => ProcessParsing_tryGetProtocolURIGetter(tupledArg_7[0], tupledArg_7[1]), headers_1); - const protocolVersionGetter: Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> = tryPick<[int32, CompositeHeader_$union], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))>((tupledArg_8: [int32, CompositeHeader_$union]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))> => ProcessParsing_tryGetProtocolVersionGetter(tupledArg_8[0], tupledArg_8[1]), headers_1); - let inputGetter_1: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FSharpList)); - const matchValue: Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessInput_$union))> = tryPick<[int32, CompositeHeader_$union], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessInput_$union))>((tupledArg_9: [int32, CompositeHeader_$union]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessInput_$union))> => ProcessParsing_tryGetInputGetter(tupledArg_9[0], tupledArg_9[1]), headers_1); - if (matchValue == null) { - inputGetter_1 = ((matrix_1: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => FSharpList) => ((i_1: int32): FSharpList => singleton(ProcessInput_Source(Source_create_Z32235993(void 0, `${processNameRoot}_Input_${i_1}`, toList(map<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => MaterialAttributeValue)), MaterialAttributeValue>((f_1: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => MaterialAttributeValue))): MaterialAttributeValue => f_1(matrix_1)(i_1), charGetters))))))); - } - else { - const inputGetter: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessInput_$union)) = value_8(matchValue); - inputGetter_1 = ((matrix: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => FSharpList) => ((i: int32): FSharpList => { - const chars: FSharpList = toList(map<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => MaterialAttributeValue)), MaterialAttributeValue>((f: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => MaterialAttributeValue))): MaterialAttributeValue => f(matrix)(i), charGetters)); - const input: ProcessInput_$union = inputGetter(matrix)(i); - return (!(ProcessInput__isSample(input) ? true : ProcessInput__isSource(input)) && !isEmpty(chars)) ? ofArray([input, ProcessInput_createSample_Z445EF6B3(ProcessInput__get_Name(input), chars)]) : singleton(ProcessInput_setCharacteristicValues(chars, input)); - })); - } - let outputGetter_1: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FSharpList)); - const matchValue_1: Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessOutput_$union))> = tryPick<[int32, CompositeHeader_$union], ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessOutput_$union))>((tupledArg_10: [int32, CompositeHeader_$union]): Option<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessOutput_$union))> => ProcessParsing_tryGetOutputGetter(tupledArg_10[0], tupledArg_10[1]), headers_1); - if (matchValue_1 == null) { - outputGetter_1 = ((matrix_3: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => FSharpList) => ((i_3: int32): FSharpList => singleton(ProcessOutput_Sample(Sample_create_3A6378D6(void 0, `${processNameRoot}_Output_${i_3}`, void 0, toList(map<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FactorValue)), FactorValue>((f_3: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FactorValue))): FactorValue => f_3(matrix_3)(i_3), factorValueGetters))))))); - } - else { - const outputGetter: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessOutput_$union)) = value_8(matchValue_1); - outputGetter_1 = ((matrix_2: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => FSharpList) => ((i_2: int32): FSharpList => { - const factors: FSharpList = toList(map<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FactorValue)), FactorValue>((f_2: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => FactorValue))): FactorValue => f_2(matrix_2)(i_2), factorValueGetters)); - const output: ProcessOutput_$union = outputGetter(matrix_2)(i_2); - return (!ProcessOutput__isSample(output) && !isEmpty(factors)) ? ofArray([output, ProcessOutput_createSample_Z445EF6B3(ProcessOutput__get_Name(output), void 0, factors)]) : singleton(ProcessOutput_setFactorValues(factors, output)); - })); - } - return (matrix_4: IMap<[int32, int32], CompositeCell_$union>): ((arg0: int32) => Process) => ((i_4: int32): Process => { - const pn: Option = fromValueWithDefault("", processNameRoot); - const paramvalues: Option> = fromValueWithDefault>(empty_1(), map_1<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessParameterValue)), ProcessParameterValue>((f_4: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => ProcessParameterValue))): ProcessParameterValue => f_4(matrix_4)(i_4), parameterValueGetters)); - const parameters: Option> = map_2, FSharpList>((list_5: FSharpList): FSharpList => map_1((pv: ProcessParameterValue): ProtocolParameter => value_8(pv.Category), list_5), paramvalues); - const protocol: Protocol = Protocol_make(void 0, mapOrDefault) => ((arg0: int32) => string))>(pn, (f_5: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))): string => f_5(matrix_4)(i_4), protocolREFGetter), map_2<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => OntologyAnnotation)), OntologyAnnotation>((f_7: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => OntologyAnnotation))): OntologyAnnotation => f_7(matrix_4)(i_4), protocolTypeGetter), map_2<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string)), string>((f_8: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))): string => f_8(matrix_4)(i_4), protocolDescriptionGetter), map_2<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string)), string>((f_9: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))): string => f_9(matrix_4)(i_4), protocolURIGetter), map_2<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string)), string>((f_10: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => string))): string => f_10(matrix_4)(i_4), protocolVersionGetter), parameters, fromValueWithDefault>(empty_1(), map_1<((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Component)), Component>((f_11: ((arg0: IMap<[int32, int32], CompositeCell_$union>) => ((arg0: int32) => Component))): Component => f_11(matrix_4)(i_4), componentGetters)), void 0); - let patternInput: [FSharpList, FSharpList]; - const inputs: FSharpList = inputGetter_1(matrix_4)(i_4); - const outputs: FSharpList = outputGetter_1(matrix_4)(i_4); - patternInput = (((length(inputs) === 1) && (length(outputs) === 2)) ? ([ofArray([item(0, inputs), item(0, inputs)]), outputs] as [FSharpList, FSharpList]) : (((length(inputs) === 2) && (length(outputs) === 1)) ? ([inputs, ofArray([item(0, outputs), item(0, outputs)])] as [FSharpList, FSharpList]) : ([inputs, outputs] as [FSharpList, FSharpList]))); - return Process_make(void 0, pn, protocol, paramvalues, void 0, void 0, void 0, void 0, patternInput[0], patternInput[1], void 0); - }); -} - -/** - * Groups processes by their name, or by the name of the protocol they execute - * - * Process names are taken from the Worksheet name and numbered: SheetName_1, SheetName_2, etc. - * - * This function decomposes this name into a root name and a number, and groups processes by root name. - */ -export function ProcessParsing_groupProcesses(ps: FSharpList): FSharpList<[string, FSharpList]> { - return List_groupBy((x: Process): string => { - if ((x.Name != null) && (Process_decomposeName_Z721C83C5(value_8(x.Name))[1] != null)) { - return Process_decomposeName_Z721C83C5(value_8(x.Name))[0]; - } - else if ((x.ExecutesProtocol != null) && (value_8(x.ExecutesProtocol).Name != null)) { - return value_8(value_8(x.ExecutesProtocol).Name); - } - else if ((x.Name != null) && (value_8(x.Name).indexOf("_") >= 0)) { - const lastUnderScoreIndex: int32 = value_8(x.Name).lastIndexOf("_") | 0; - return remove(value_8(x.Name), lastUnderScoreIndex); - } - else if ((x.ExecutesProtocol != null) && (value_8(x.ExecutesProtocol).ID != null)) { - return value_8(value_8(x.ExecutesProtocol).ID); - } - else { - return createMissingIdentifier(); - } - }, ps, { - Equals: (x_1: string, y: string): boolean => (x_1 === y), - GetHashCode: stringHash, - }); -} - -export function ProcessParsing_processToRows(p: Process): FSharpList> { - let list_3: FSharpList; - const pvs: FSharpList<[[CompositeHeader_$union, CompositeCell_$union], Option]> = map_1]>((ppv: ProcessParameterValue): [[CompositeHeader_$union, CompositeCell_$union], Option] => ([JsonTypes_decomposeParameterValue(ppv), tryGetParameterColumnIndex(ppv)] as [[CompositeHeader_$union, CompositeCell_$union], Option]), defaultArg(p.ParameterValues, empty_1())); - let components: FSharpList<[[CompositeHeader_$union, CompositeCell_$union], Option]>; - const matchValue: Option = p.ExecutesProtocol; - components = ((matchValue == null) ? empty_1<[[CompositeHeader_$union, CompositeCell_$union], Option]>() : map_1]>((ppv_1: Component): [[CompositeHeader_$union, CompositeCell_$union], Option] => ([JsonTypes_decomposeComponent(ppv_1), tryGetComponentIndex(ppv_1)] as [[CompositeHeader_$union, CompositeCell_$union], Option]), defaultArg(value_8(matchValue).Components, empty_1()))); - let protVals: FSharpList<[CompositeHeader_$union, CompositeCell_$union]>; - const matchValue_1: Option = p.ExecutesProtocol; - if (matchValue_1 == null) { - protVals = empty_1<[CompositeHeader_$union, CompositeCell_$union]>(); - } - else { - const prot_1: Protocol = value_8(matchValue_1); - protVals = toList<[CompositeHeader_$union, CompositeCell_$union]>(delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => append<[CompositeHeader_$union, CompositeCell_$union]>((prot_1.Name != null) ? singleton_1<[CompositeHeader_$union, CompositeCell_$union]>([CompositeHeader_ProtocolREF(), CompositeCell_FreeText(value_8(prot_1.Name))] as [CompositeHeader_$union, CompositeCell_$union]) : empty_2<[CompositeHeader_$union, CompositeCell_$union]>(), delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => append<[CompositeHeader_$union, CompositeCell_$union]>((prot_1.ProtocolType != null) ? singleton_1<[CompositeHeader_$union, CompositeCell_$union]>([CompositeHeader_ProtocolType(), CompositeCell_Term(value_8(prot_1.ProtocolType))] as [CompositeHeader_$union, CompositeCell_$union]) : empty_2<[CompositeHeader_$union, CompositeCell_$union]>(), delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => append<[CompositeHeader_$union, CompositeCell_$union]>((prot_1.Description != null) ? singleton_1<[CompositeHeader_$union, CompositeCell_$union]>([CompositeHeader_ProtocolDescription(), CompositeCell_FreeText(value_8(prot_1.Description))] as [CompositeHeader_$union, CompositeCell_$union]) : empty_2<[CompositeHeader_$union, CompositeCell_$union]>(), delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => append<[CompositeHeader_$union, CompositeCell_$union]>((prot_1.Uri != null) ? singleton_1<[CompositeHeader_$union, CompositeCell_$union]>([CompositeHeader_ProtocolUri(), CompositeCell_FreeText(value_8(prot_1.Uri))] as [CompositeHeader_$union, CompositeCell_$union]) : empty_2<[CompositeHeader_$union, CompositeCell_$union]>(), delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => ((prot_1.Version != null) ? singleton_1<[CompositeHeader_$union, CompositeCell_$union]>([CompositeHeader_ProtocolVersion(), CompositeCell_FreeText(value_8(prot_1.Version))] as [CompositeHeader_$union, CompositeCell_$union]) : empty_2<[CompositeHeader_$union, CompositeCell_$union]>()))))))))))); - } - return map_1<[[string, string], FSharpList<[ProcessInput_$union, ProcessOutput_$union]>], FSharpList<[CompositeHeader_$union, CompositeCell_$union]>>((tupledArg_1: [[string, string], FSharpList<[ProcessInput_$union, ProcessOutput_$union]>]): FSharpList<[CompositeHeader_$union, CompositeCell_$union]> => { - const ios: FSharpList<[ProcessInput_$union, ProcessOutput_$union]> = tupledArg_1[1]; - const inputForCharas: ProcessInput_$union = defaultArg(tryPick_1<[ProcessInput_$union, ProcessOutput_$union], ProcessInput_$union>((tupledArg_2: [ProcessInput_$union, ProcessOutput_$union]): Option => { - const i_2: ProcessInput_$union = tupledArg_2[0]; - if (ProcessInput__isSource(i_2) ? true : ProcessInput__isSample(i_2)) { - return i_2; - } - else { - return void 0; - } - }, ios), head(ios)[0]); - const inputForType: ProcessInput_$union = defaultArg(tryPick_1<[ProcessInput_$union, ProcessOutput_$union], ProcessInput_$union>((tupledArg_3: [ProcessInput_$union, ProcessOutput_$union]): Option => { - const i_3: ProcessInput_$union = tupledArg_3[0]; - if (ProcessInput__isData(i_3) ? true : ProcessInput__isMaterial(i_3)) { - return i_3; - } - else { - return void 0; - } - }, ios), head(ios)[0]); - const chars: FSharpList<[[CompositeHeader_$union, CompositeCell_$union], Option]> = map_1]>((cv: MaterialAttributeValue): [[CompositeHeader_$union, CompositeCell_$union], Option] => ([JsonTypes_decomposeCharacteristicValue(cv), tryGetCharacteristicColumnIndex(cv)] as [[CompositeHeader_$union, CompositeCell_$union], Option]), ProcessInput_getCharacteristicValues_Z38E7E853(inputForCharas)); - const outputForFactors: ProcessOutput_$union = defaultArg(tryPick_1<[ProcessInput_$union, ProcessOutput_$union], ProcessOutput_$union>((tupledArg_4: [ProcessInput_$union, ProcessOutput_$union]): Option => { - const o_4: ProcessOutput_$union = tupledArg_4[1]; - if (ProcessOutput__isSample(o_4)) { - return o_4; - } - else { - return void 0; - } - }, ios), head(ios)[1]); - const outputForType: ProcessOutput_$union = defaultArg(tryPick_1<[ProcessInput_$union, ProcessOutput_$union], ProcessOutput_$union>((tupledArg_5: [ProcessInput_$union, ProcessOutput_$union]): Option => { - const o_5: ProcessOutput_$union = tupledArg_5[1]; - if (ProcessOutput__isData(o_5) ? true : ProcessOutput__isMaterial(o_5)) { - return o_5; - } - else { - return void 0; - } - }, ios), head(ios)[1]); - const vals: FSharpList<[CompositeHeader_$union, CompositeCell_$union]> = map_1<[[CompositeHeader_$union, CompositeCell_$union], Option], [CompositeHeader_$union, CompositeCell_$union]>((tuple_5: [[CompositeHeader_$union, CompositeCell_$union], Option]): [CompositeHeader_$union, CompositeCell_$union] => tuple_5[0], sortBy<[[CompositeHeader_$union, CompositeCell_$union], Option], int32>((arg_2: [[CompositeHeader_$union, CompositeCell_$union], Option]): int32 => defaultArg(arg_2[1], 10000), append_1(chars, append_1(components, append_1(pvs, map_1]>((fv: FactorValue): [[CompositeHeader_$union, CompositeCell_$union], Option] => ([JsonTypes_decomposeFactorValue(fv), tryGetFactorColumnIndex(fv)] as [[CompositeHeader_$union, CompositeCell_$union], Option]), ProcessOutput_getFactorValues_Z4A02997C(outputForFactors))))), { - Compare: comparePrimitives, - })); - return toList<[CompositeHeader_$union, CompositeCell_$union]>(delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => append<[CompositeHeader_$union, CompositeCell_$union]>(singleton_1<[CompositeHeader_$union, CompositeCell_$union]>(JsonTypes_decomposeProcessInput(inputForType)), delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => append<[CompositeHeader_$union, CompositeCell_$union]>(protVals, delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => append<[CompositeHeader_$union, CompositeCell_$union]>(vals, delay<[CompositeHeader_$union, CompositeCell_$union]>((): Iterable<[CompositeHeader_$union, CompositeCell_$union]> => singleton_1<[CompositeHeader_$union, CompositeCell_$union]>(JsonTypes_decomposeProcessOutput(outputForType)))))))))); - }, List_groupBy<[ProcessInput_$union, ProcessOutput_$union], [string, string]>((tupledArg: [ProcessInput_$union, ProcessOutput_$union]): [string, string] => ([ProcessInput__get_Name(tupledArg[0]), ProcessOutput__get_Name(tupledArg[1])] as [string, string]), (list_3 = value_8(p.Outputs), zip(value_8(p.Inputs), list_3)), { - Equals: equalArrays, - GetHashCode: arrayHash, - })); -} - -/** - * Returns true, if two composite headers share the same main header string - */ -export function ProcessParsing_compositeHeaderEqual(ch1: CompositeHeader_$union, ch2: CompositeHeader_$union): boolean { - return toString(ch1) === toString(ch2); -} - -/** - * From a list of rows consisting of headers and values, creates a list of combined headers and the values as a sparse matrix - * - * The values cant be directly taken as they are, as there is no guarantee that the headers are aligned - * - * This function aligns the headers and values by the main header string - */ -export function ProcessParsing_alignByHeaders(rows: FSharpList>): [CompositeHeader_$union[], IMap<[int32, int32], CompositeCell_$union>] { - const headers: CompositeHeader_$union[] = []; - const values: IMap<[int32, int32], CompositeCell_$union> = new Dictionary<[int32, int32], CompositeCell_$union>([], { - Equals: equalArrays, - GetHashCode: arrayHash, - }); - const loop = (colI_mut: int32, rows_2_mut: FSharpList>): [CompositeHeader_$union[], IMap<[int32, int32], CompositeCell_$union>] => { - loop: - while (true) { - const colI: int32 = colI_mut, rows_2: FSharpList> = rows_2_mut; - if (!exists>((arg_1: FSharpList<[CompositeHeader_$union, CompositeCell_$union]>): boolean => !isEmpty(arg_1), rows_2)) { - return [headers, values] as [CompositeHeader_$union[], IMap<[int32, int32], CompositeCell_$union>]; - } - else { - const firstElem: CompositeHeader_$union = pick, [CompositeHeader_$union, CompositeCell_$union]>((l: FSharpList<[CompositeHeader_$union, CompositeCell_$union]>): Option<[CompositeHeader_$union, CompositeCell_$union]> => (isEmpty(l) ? void 0 : head<[CompositeHeader_$union, CompositeCell_$union]>(l)), rows_2)[0]; - void (headers.push(firstElem)); - colI_mut = (colI + 1); - rows_2_mut = mapIndexed, FSharpList<[CompositeHeader_$union, CompositeCell_$union]>>((rowI: int32, l_1: FSharpList<[CompositeHeader_$union, CompositeCell_$union]>): FSharpList<[CompositeHeader_$union, CompositeCell_$union]> => { - if (!isEmpty(l_1)) { - if (ProcessParsing_compositeHeaderEqual(head(l_1)[0], firstElem)) { - addToDict(values, [colI, rowI] as [int32, int32], head(l_1)[1]); - return tail_1(l_1); - } - else { - return l_1; - } - } - else { - return empty_1<[CompositeHeader_$union, CompositeCell_$union]>(); - } - }, rows_2); - continue loop; - } - break; - } - }; - return loop(0, rows); -} - diff --git a/ts/ISA/ISA/ArcTypes/ArcTables.ts b/ts/ISA/ISA/ArcTypes/ArcTables.ts deleted file mode 100644 index 2f6a1d10..00000000 --- a/ts/ISA/ISA/ArcTypes/ArcTables.ts +++ /dev/null @@ -1,283 +0,0 @@ -import { map, delay, toList, length, tryFindIndex } from "../../../fable_modules/fable-library-ts/Seq.js"; -import { ArcTable } from "./ArcTable.js"; -import { unwrap, defaultArg, value, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { IMap, comparePrimitives, stringHash, compare } from "../../../fable_modules/fable-library-ts/Util.js"; -import { distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { FSharpSet__get_IsEmpty, FSharpSet, ofSeq, intersect } from "../../../fable_modules/fable-library-ts/Set.js"; -import { class_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { map as map_1, collect, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { insertRangeInPlace } from "../../../fable_modules/fable-library-ts/Array.js"; -import { CompositeHeader_$union } from "./CompositeHeader.js"; -import { CompositeCell_$union } from "./CompositeCell.js"; -import { CompositeColumn } from "./CompositeColumn.js"; -import { Process } from "../JsonTypes/Process.js"; -import { ProcessParsing_groupProcesses, ProcessParsing_processToRows, ProcessParsing_alignByHeaders } from "./ArcTableAux.js"; - -export function ArcTablesAux_indexByTableName(name: string, tables: ArcTable[]): int32 { - const matchValue: Option = tryFindIndex((t: ArcTable): boolean => (t.Name === name), tables); - if (matchValue == null) { - throw new Error(`Unable to find table with name '${name}'!`); - } - else { - return value(matchValue) | 0; - } -} - -export function ArcTablesAux_SanityChecks_validateSheetIndex(index: int32, allowAppend: boolean, sheets: ArcTable[]): void { - let x: int32, y: int32; - if (index < 0) { - throw new Error("Cannot insert ArcTable at index < 0."); - } - if ((x = (index | 0), (y = (sheets.length | 0), allowAppend ? (compare(x, y) > 0) : (compare(x, y) >= 0)))) { - throw new Error(`Specified index is out of range! Assay contains only ${sheets.length} tables.`); - } -} - -export function ArcTablesAux_SanityChecks_validateNamesUnique(names: Iterable): void { - if (!(length(names) === length(distinct(names, { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })))) { - throw new Error("Cannot add multiple tables with the same name! Table names inside one assay must be unqiue"); - } -} - -export function ArcTablesAux_SanityChecks_validateNewNameUnique(newName: string, existingNames: Iterable): void { - const matchValue: Option = tryFindIndex((x: string): boolean => (x === newName), existingNames); - if (matchValue == null) { - } - else { - throw new Error(`Cannot create table with name ${newName}, as table names must be unique and table at index ${value(matchValue)} has the same name.`); - } -} - -export function ArcTablesAux_SanityChecks_validateNewNamesUnique(newNames: Iterable, existingNames: Iterable): void { - ArcTablesAux_SanityChecks_validateNamesUnique(newNames); - const same: FSharpSet = intersect(ofSeq(newNames, { - Compare: comparePrimitives, - }), ofSeq(existingNames, { - Compare: comparePrimitives, - })); - if (!FSharpSet__get_IsEmpty(same)) { - throw new Error(`Cannot create tables with the names ${same}, as table names must be unique.`); - } -} - -export class ArcTables { - readonly thisTables: ArcTable[]; - constructor(thisTables: ArcTable[]) { - this.thisTables = thisTables; - } -} - -export function ArcTables_$reflection(): TypeInfo { - return class_type("ISA.ArcTables", void 0, ArcTables); -} - -export function ArcTables_$ctor_Z68BECB99(thisTables: ArcTable[]): ArcTables { - return new ArcTables(thisTables); -} - -export function ArcTables__get_Count(this$: ArcTables): int32 { - return this$.thisTables.length; -} - -export function ArcTables__get_TableNames(this$: ArcTables): FSharpList { - return toList(delay((): Iterable => map((s: ArcTable): string => s.Name, this$.thisTables))); -} - -export function ArcTables__get_Tables(this$: ArcTables): ArcTable[] { - return this$.thisTables; -} - -export function ArcTables__get_Item_Z524259A4(this$: ArcTables, index: int32): ArcTable { - return this$.thisTables[index]; -} - -export function ArcTables__AddTable_16F700A1(this$: ArcTables, table: ArcTable, index: Option): void { - const index_1: int32 = defaultArg(index, ArcTables__get_Count(this$)) | 0; - ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNameUnique(table.Name, ArcTables__get_TableNames(this$)); - this$.thisTables.splice(index_1, 0, table); -} - -export function ArcTables__AddTables_3601F24E(this$: ArcTables, tables: Iterable, index: Option): void { - const index_1: int32 = defaultArg(index, ArcTables__get_Count(this$)) | 0; - ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNamesUnique(map((x: ArcTable): string => x.Name, tables), ArcTables__get_TableNames(this$)); - insertRangeInPlace(index_1, tables, this$.thisTables); -} - -export function ArcTables__InitTable_3B406CA4(this$: ArcTables, tableName: string, index: Option): void { - const index_1: int32 = defaultArg(index, ArcTables__get_Count(this$)) | 0; - const table: ArcTable = ArcTable.init(tableName); - ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNameUnique(table.Name, ArcTables__get_TableNames(this$)); - this$.thisTables.splice(index_1, 0, table); -} - -export function ArcTables__InitTables_7B28792B(this$: ArcTables, tableNames: Iterable, index: Option): void { - const index_1: int32 = defaultArg(index, ArcTables__get_Count(this$)) | 0; - const tables: Iterable = map((x: string): ArcTable => ArcTable.init(x), tableNames); - ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNamesUnique(map((x_1: ArcTable): string => x_1.Name, tables), ArcTables__get_TableNames(this$)); - insertRangeInPlace(index_1, tables, this$.thisTables); -} - -export function ArcTables__GetTableAt_Z524259A4(this$: ArcTables, index: int32): ArcTable { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - return this$.thisTables[index]; -} - -export function ArcTables__GetTable_Z721C83C5(this$: ArcTables, name: string): ArcTable { - return ArcTables__GetTableAt_Z524259A4(this$, ArcTablesAux_indexByTableName(name, this$.thisTables)); -} - -export function ArcTables__UpdateTableAt_66578202(this$: ArcTables, index: int32, table: ArcTable): void { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNameUnique(table.Name, ArcTables__get_TableNames(this$)); - this$.thisTables[index] = table; -} - -export function ArcTables__UpdateTable_4976F045(this$: ArcTables, name: string, table: ArcTable): void { - const tupledArg = [ArcTablesAux_indexByTableName(name, this$.thisTables), table] as [int32, ArcTable]; - ArcTables__UpdateTableAt_66578202(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__RemoveTableAt_Z524259A4(this$: ArcTables, index: int32): void { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - this$.thisTables.splice(index, 1); -} - -export function ArcTables__RemoveTable_Z721C83C5(this$: ArcTables, name: string): void { - ArcTables__RemoveTableAt_Z524259A4(this$, ArcTablesAux_indexByTableName(name, this$.thisTables)); -} - -export function ArcTables__MapTableAt_61602D68(this$: ArcTables, index: int32, updateFun: ((arg0: ArcTable) => void)): void { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - updateFun(this$.thisTables[index]); -} - -export function ArcTables__MapTable_4E415F2F(this$: ArcTables, name: string, updateFun: ((arg0: ArcTable) => void)): void { - const tupledArg = [ArcTablesAux_indexByTableName(name, this$.thisTables), updateFun] as [int32, ((arg0: ArcTable) => void)]; - ArcTables__MapTableAt_61602D68(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__RenameTableAt_Z176EF219(this$: ArcTables, index: int32, newName: string): void { - ArcTablesAux_SanityChecks_validateSheetIndex(index, false, this$.thisTables); - ArcTablesAux_SanityChecks_validateNewNameUnique(newName, ArcTables__get_TableNames(this$)); - const table: ArcTable = ArcTables__GetTableAt_Z524259A4(this$, index); - ArcTables__UpdateTableAt_66578202(this$, index, new ArcTable(newName, table.Headers, table.Values)); -} - -export function ArcTables__RenameTable_Z384F8060(this$: ArcTables, name: string, newName: string): void { - const tupledArg = [ArcTablesAux_indexByTableName(name, this$.thisTables), newName] as [int32, string]; - ArcTables__RenameTableAt_Z176EF219(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__AddColumnAt_6647579B(this$: ArcTables, tableIndex: int32, header: CompositeHeader_$union, cells: Option, columnIndex: Option, forceReplace: Option): void { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table: ArcTable): void => { - table.AddColumn(header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); - }); -} - -export function ArcTables__AddColumn_Z4FC90944(this$: ArcTables, tableName: string, header: CompositeHeader_$union, cells: Option, columnIndex: Option, forceReplace: Option): void { - ArcTables__AddColumnAt_6647579B(this$, ArcTablesAux_indexByTableName(tableName, this$.thisTables), header, unwrap(cells), unwrap(columnIndex), unwrap(forceReplace)); -} - -export function ArcTables__RemoveColumnAt_Z37302880(this$: ArcTables, tableIndex: int32, columnIndex: int32): void { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table: ArcTable): void => { - table.RemoveColumn(columnIndex); - }); -} - -export function ArcTables__RemoveColumn_Z18115A39(this$: ArcTables, tableName: string, columnIndex: int32): void { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), columnIndex] as [int32, int32]; - ArcTables__RemoveColumnAt_Z37302880(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__UpdateColumnAt_Z155350AF(this$: ArcTables, tableIndex: int32, columnIndex: int32, header: CompositeHeader_$union, cells: Option): void { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table: ArcTable): void => { - table.UpdateColumn(columnIndex, header, unwrap(cells)); - }); -} - -export function ArcTables__UpdateColumn_Z774BF72A(this$: ArcTables, tableName: string, columnIndex: int32, header: CompositeHeader_$union, cells: Option): void { - ArcTables__UpdateColumnAt_Z155350AF(this$, ArcTablesAux_indexByTableName(tableName, this$.thisTables), columnIndex, header, unwrap(cells)); -} - -export function ArcTables__GetColumnAt_Z37302880(this$: ArcTables, tableIndex: int32, columnIndex: int32): CompositeColumn { - const table: ArcTable = ArcTables__GetTableAt_Z524259A4(this$, tableIndex); - return table.GetColumn(columnIndex); -} - -export function ArcTables__GetColumn_Z18115A39(this$: ArcTables, tableName: string, columnIndex: int32): CompositeColumn { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), columnIndex] as [int32, int32]; - return ArcTables__GetColumnAt_Z37302880(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__AddRowAt_Z57F91678(this$: ArcTables, tableIndex: int32, cells: Option, rowIndex: Option): void { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table: ArcTable): void => { - table.AddRow(unwrap(cells), unwrap(rowIndex)); - }); -} - -export function ArcTables__AddRow_1177C4AF(this$: ArcTables, tableName: string, cells: Option, rowIndex: Option): void { - ArcTables__AddRowAt_Z57F91678(this$, ArcTablesAux_indexByTableName(tableName, this$.thisTables), unwrap(cells), unwrap(rowIndex)); -} - -export function ArcTables__RemoveRowAt_Z37302880(this$: ArcTables, tableIndex: int32, rowIndex: int32): void { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table: ArcTable): void => { - table.RemoveRow(rowIndex); - }); -} - -export function ArcTables__RemoveRow_Z18115A39(this$: ArcTables, tableName: string, rowIndex: int32): void { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), rowIndex] as [int32, int32]; - ArcTables__RemoveRowAt_Z37302880(this$, tupledArg[0], tupledArg[1]); -} - -export function ArcTables__UpdateRowAt_Z596C2D98(this$: ArcTables, tableIndex: int32, rowIndex: int32, cells: CompositeCell_$union[]): void { - ArcTables__MapTableAt_61602D68(this$, tableIndex, (table: ArcTable): void => { - table.UpdateRow(rowIndex, cells); - }); -} - -export function ArcTables__UpdateRow_Z5E65B4B1(this$: ArcTables, tableName: string, rowIndex: int32, cells: CompositeCell_$union[]): void { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), rowIndex, cells] as [int32, int32, CompositeCell_$union[]]; - ArcTables__UpdateRowAt_Z596C2D98(this$, tupledArg[0], tupledArg[1], tupledArg[2]); -} - -export function ArcTables__GetRowAt_Z37302880(this$: ArcTables, tableIndex: int32, rowIndex: int32): CompositeCell_$union[] { - const table: ArcTable = ArcTables__GetTableAt_Z524259A4(this$, tableIndex); - return table.GetRow(rowIndex); -} - -export function ArcTables__GetRow_Z18115A39(this$: ArcTables, tableName: string, rowIndex: int32): CompositeCell_$union[] { - const tupledArg = [ArcTablesAux_indexByTableName(tableName, this$.thisTables), rowIndex] as [int32, int32]; - return ArcTables__GetRowAt_Z37302880(this$, tupledArg[0], tupledArg[1]); -} - -/** - * Return a list of all the processes in all the tables. - */ -export function ArcTables__GetProcesses(this$: ArcTables): FSharpList { - return collect((t: ArcTable): FSharpList => t.GetProcesses(), toList(ArcTables__get_Tables(this$))); -} - -/** - * Create a collection of tables from a list of processes. - * - * For this, the processes are grouped by nameroot ("nameroot_1", "nameroot_2" ...) or exectued protocol if no name exists - * - * Then each group is converted to a table with this nameroot as sheetname - */ -export function ArcTables_fromProcesses_Z31821267(ps: FSharpList): ArcTables { - let arg: FSharpList; - return ArcTables_$ctor_Z68BECB99((arg = map_1<[string, FSharpList], ArcTable>((tupledArg: [string, FSharpList]): ArcTable => { - const tupledArg_1: [CompositeHeader_$union[], IMap<[int32, int32], CompositeCell_$union>] = ProcessParsing_alignByHeaders(collect>(ProcessParsing_processToRows, tupledArg[1])); - return ArcTable.create(tupledArg[0], tupledArg_1[0], tupledArg_1[1]); - }, ProcessParsing_groupProcesses(ps)), Array.from(arg))); -} - diff --git a/ts/ISA/ISA/ArcTypes/CompositeCell.ts b/ts/ISA/ISA/ArcTypes/CompositeCell.ts deleted file mode 100644 index 3f31d5de..00000000 --- a/ts/ISA/ISA/ArcTypes/CompositeCell.ts +++ /dev/null @@ -1,197 +0,0 @@ -import { int32ToString } from "../../../fable_modules/fable-library-ts/Util.js"; -import { float64, int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation__get_NameText, OntologyAnnotation_create_131C8C9D, OntologyAnnotation } from "../JsonTypes/OntologyAnnotation.js"; -import { defaultArg, value as value_1 } from "../../../fable_modules/fable-library-ts/Option.js"; -import { Value_$union } from "../JsonTypes/Value.js"; -import { AnnotationValue_Text } from "../JsonTypes/AnnotationValue.js"; -import { Union } from "../../../fable_modules/fable-library-ts/Types.js"; -import { union_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export type CompositeCell_$union = - | CompositeCell<0> - | CompositeCell<1> - | CompositeCell<2> - -export type CompositeCell_$cases = { - 0: ["Term", [OntologyAnnotation]], - 1: ["FreeText", [string]], - 2: ["Unitized", [string, OntologyAnnotation]] -} - -export function CompositeCell_Term(Item: OntologyAnnotation) { - return new CompositeCell<0>(0, [Item]); -} - -export function CompositeCell_FreeText(Item: string) { - return new CompositeCell<1>(1, [Item]); -} - -export function CompositeCell_Unitized(Item1: string, Item2: OntologyAnnotation) { - return new CompositeCell<2>(2, [Item1, Item2]); -} - -export class CompositeCell extends Union { - constructor(readonly tag: Tag, readonly fields: CompositeCell_$cases[Tag][1]) { - super(); - } - cases() { - return ["Term", "FreeText", "Unitized"]; - } - static fromValue(value: Value_$union, unit?: OntologyAnnotation): CompositeCell_$union { - let matchResult: int32, t: OntologyAnnotation, i: int32, i_1: int32, u: OntologyAnnotation, f: float64, f_1: float64, u_1: OntologyAnnotation, s: string; - switch (value.tag) { - case /* Int */ 1: { - if (unit != null) { - matchResult = 2; - i_1 = value.fields[0]; - u = value_1(unit); - } - else { - matchResult = 1; - i = value.fields[0]; - } - break; - } - case /* Float */ 2: { - if (unit != null) { - matchResult = 4; - f_1 = value.fields[0]; - u_1 = value_1(unit); - } - else { - matchResult = 3; - f = value.fields[0]; - } - break; - } - case /* Name */ 3: { - if (unit == null) { - matchResult = 5; - s = value.fields[0]; - } - else { - matchResult = 6; - } - break; - } - default: - if (unit == null) { - matchResult = 0; - t = value.fields[0]; - } - else { - matchResult = 6; - } - } - switch (matchResult) { - case 0: - return CompositeCell_Term(t!); - case 1: - return CompositeCell_FreeText(int32ToString(i!)); - case 2: - return CompositeCell_Unitized(int32ToString(i_1!), u!); - case 3: - return CompositeCell_FreeText(f!.toString()); - case 4: - return CompositeCell_Unitized(f_1!.toString(), u_1!); - case 5: - return CompositeCell_FreeText(s!); - default: - throw new Error("could not convert value to cell, invalid combination of value and unit"); - } - } - get isUnitized(): boolean { - const this$ = this as CompositeCell_$union; - return this$.tag === /* Unitized */ 2; - } - get isTerm(): boolean { - const this$ = this as CompositeCell_$union; - return this$.tag === /* Term */ 0; - } - get isFreeText(): boolean { - const this$ = this as CompositeCell_$union; - return this$.tag === /* FreeText */ 1; - } - ToUnitizedCell(): CompositeCell_$union { - const this$ = this as CompositeCell_$union; - return (this$.tag === /* FreeText */ 1) ? CompositeCell_Unitized("", OntologyAnnotation_create_131C8C9D(void 0, AnnotationValue_Text(this$.fields[0]))) : ((this$.tag === /* Term */ 0) ? CompositeCell_Unitized("", this$.fields[0]) : this$); - } - ToTermCell(): CompositeCell_$union { - const this$ = this as CompositeCell_$union; - return (this$.tag === /* Unitized */ 2) ? CompositeCell_Term(this$.fields[1]) : ((this$.tag === /* FreeText */ 1) ? CompositeCell_Term(OntologyAnnotation_create_131C8C9D(void 0, AnnotationValue_Text(this$.fields[0]))) : this$); - } - ToFreeTextCell(): CompositeCell_$union { - const this$ = this as CompositeCell_$union; - switch (this$.tag) { - case /* Term */ 0: - return CompositeCell_FreeText(OntologyAnnotation__get_NameText(this$.fields[0])); - case /* Unitized */ 2: { - const v: string = this$.fields[0]; - return CompositeCell_FreeText(OntologyAnnotation__get_NameText(this$.fields[1])); - } - default: - return this$; - } - } - get AsUnitized(): [string, OntologyAnnotation] { - const this$ = this as CompositeCell_$union; - if (this$.tag === /* Unitized */ 2) { - return [this$.fields[0], this$.fields[1]] as [string, OntologyAnnotation]; - } - else { - throw new Error("Not a Unitized cell."); - } - } - get AsTerm(): OntologyAnnotation { - const this$ = this as CompositeCell_$union; - if (this$.tag === /* Term */ 0) { - return this$.fields[0]; - } - else { - throw new Error("Not a Swate TermCell."); - } - } - get AsFreeText(): string { - const this$ = this as CompositeCell_$union; - if (this$.tag === /* FreeText */ 1) { - return this$.fields[0]; - } - else { - throw new Error("Not a Swate TermCell."); - } - } - static createTerm(oa: OntologyAnnotation): CompositeCell_$union { - return CompositeCell_Term(oa); - } - static createTermFromString(name?: string, tsr?: string, tan?: string): CompositeCell_$union { - return CompositeCell_Term(OntologyAnnotation_fromString_Z7D8EB286(name, tsr, tan)); - } - static createUnitized(value: string, oa?: OntologyAnnotation): CompositeCell_$union { - return CompositeCell_Unitized(value, defaultArg(oa, OntologyAnnotation_get_empty())); - } - static createUnitizedFromString(value: string, name?: string, tsr?: string, tan?: string): CompositeCell_$union { - const tupledArg = [value, OntologyAnnotation_fromString_Z7D8EB286(name, tsr, tan)] as [string, OntologyAnnotation]; - return CompositeCell_Unitized(tupledArg[0], tupledArg[1]); - } - static createFreeText(value: string): CompositeCell_$union { - return CompositeCell_FreeText(value); - } - static get emptyTerm(): CompositeCell_$union { - return CompositeCell_Term(OntologyAnnotation_get_empty()); - } - static get emptyFreeText(): CompositeCell_$union { - return CompositeCell_FreeText(""); - } - static get emptyUnitized(): CompositeCell_$union { - return CompositeCell_Unitized("", OntologyAnnotation_get_empty()); - } - toString(): string { - const this$ = this as CompositeCell_$union; - return (this$.tag === /* FreeText */ 1) ? this$.fields[0] : ((this$.tag === /* Unitized */ 2) ? (`${this$.fields[0]} ${OntologyAnnotation__get_NameText(this$.fields[1])}`) : (`Term${OntologyAnnotation__get_NameText(this$.fields[0])}`)); - } -} - -export function CompositeCell_$reflection(): TypeInfo { - return union_type("ISA.CompositeCell", [], CompositeCell, () => [[["Item", OntologyAnnotation_$reflection()]], [["Item", string_type]], [["Item1", string_type], ["Item2", OntologyAnnotation_$reflection()]]]); -} - diff --git a/ts/ISA/ISA/ArcTypes/CompositeColumn.ts b/ts/ISA/ISA/ArcTypes/CompositeColumn.ts deleted file mode 100644 index 9c1cfd86..00000000 --- a/ts/ISA/ISA/ArcTypes/CompositeColumn.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { CompositeHeader_$reflection, CompositeHeader_$union } from "./CompositeHeader.js"; -import { CompositeCell_$reflection, CompositeCell_$union } from "./CompositeCell.js"; -import { min } from "../../../fable_modules/fable-library-ts/Double.js"; -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, array_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export class CompositeColumn extends Record implements IEquatable { - readonly Header: CompositeHeader_$union; - readonly Cells: CompositeCell_$union[]; - constructor(Header: CompositeHeader_$union, Cells: CompositeCell_$union[]) { - super(); - this.Header = Header; - this.Cells = Cells; - } - static create(header: CompositeHeader_$union, cells?: CompositeCell_$union[]): CompositeColumn { - return new CompositeColumn(header, defaultArg(cells, [])); - } - validate(raiseException?: boolean): boolean { - const this$: CompositeColumn = this; - const raiseExeption: boolean = defaultArg(raiseException, false); - const header: CompositeHeader_$union = this$.Header; - const cells: CompositeCell_$union[] = this$.Cells; - if (cells.length === 0) { - return true; - } - else if (header.IsTermColumn && (cells[0].isTerm ? true : cells[0].isUnitized)) { - return true; - } - else if (!header.IsTermColumn && cells[0].isFreeText) { - return true; - } - else { - const c: CompositeCell_$union[] = cells; - if (raiseExeption) { - throw new Error(`Invalid combination of header \`${header}\` and cells \`${c[min(c.length, 3)]}\``); - } - return false; - } - } -} - -export function CompositeColumn_$reflection(): TypeInfo { - return record_type("ISA.CompositeColumn", [], CompositeColumn, () => [["Header", CompositeHeader_$reflection()], ["Cells", array_type(CompositeCell_$reflection())]]); -} - diff --git a/ts/ISA/ISA/ArcTypes/CompositeHeader.ts b/ts/ISA/ISA/ArcTypes/CompositeHeader.ts deleted file mode 100644 index ce8a87c1..00000000 --- a/ts/ISA/ISA/ArcTypes/CompositeHeader.ts +++ /dev/null @@ -1,547 +0,0 @@ -import { Union, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { ActivePatterns_$007CTermColumn$007C_$007C, ActivePatterns_$007CRegex$007C_$007C, tryParseIOTypeHeader } from "../Regex.js"; -import { value, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { union_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation__get_TermAccessionShort, OntologyAnnotation, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation__get_NameText } from "../JsonTypes/OntologyAnnotation.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { ProtocolParameter, ProtocolParameter_create_2769312B } from "../JsonTypes/ProtocolParameter.js"; -import { Factor, Factor_create_Z3D2B374F } from "../JsonTypes/Factor.js"; -import { MaterialAttribute, MaterialAttribute_create_2769312B } from "../JsonTypes/MaterialAttribute.js"; -import { Component, Component_create_Z33AADEE0 } from "../JsonTypes/Component.js"; - -export type IOType_$union = - | IOType<0> - | IOType<1> - | IOType<2> - | IOType<3> - | IOType<4> - | IOType<5> - | IOType<6> - -export type IOType_$cases = { - 0: ["Source", []], - 1: ["Sample", []], - 2: ["RawDataFile", []], - 3: ["DerivedDataFile", []], - 4: ["ImageFile", []], - 5: ["Material", []], - 6: ["FreeText", [string]] -} - -export function IOType_Source() { - return new IOType<0>(0, []); -} - -export function IOType_Sample() { - return new IOType<1>(1, []); -} - -export function IOType_RawDataFile() { - return new IOType<2>(2, []); -} - -export function IOType_DerivedDataFile() { - return new IOType<3>(3, []); -} - -export function IOType_ImageFile() { - return new IOType<4>(4, []); -} - -export function IOType_Material() { - return new IOType<5>(5, []); -} - -export function IOType_FreeText(Item: string) { - return new IOType<6>(6, [Item]); -} - -export class IOType extends Union { - constructor(readonly tag: Tag, readonly fields: IOType_$cases[Tag][1]) { - super(); - } - cases() { - return ["Source", "Sample", "RawDataFile", "DerivedDataFile", "ImageFile", "Material", "FreeText"]; - } - static get All(): IOType_$union[] { - return [IOType_Source(), IOType_Sample(), IOType_RawDataFile(), IOType_DerivedDataFile(), IOType_ImageFile(), IOType_Material()]; - } - get asInput(): string { - const this$ = this as IOType_$union; - const stringCreate = <$a>(x: $a): string => { - let copyOfStruct: $a; - return `Input [${(copyOfStruct = x, toString(copyOfStruct))}]`; - }; - return (this$.tag === /* FreeText */ 6) ? stringCreate(this$.fields[0]) : stringCreate(this$); - } - get asOutput(): string { - const this$ = this as IOType_$union; - const stringCreate = <$a>(x: $a): string => { - let copyOfStruct: $a; - return `Output [${(copyOfStruct = x, toString(copyOfStruct))}]`; - }; - return (this$.tag === /* FreeText */ 6) ? stringCreate(this$.fields[0]) : stringCreate(this$); - } - toString(): string { - const this$ = this as IOType_$union; - return (this$.tag === /* Sample */ 1) ? "Sample Name" : ((this$.tag === /* RawDataFile */ 2) ? "Raw Data File" : ((this$.tag === /* DerivedDataFile */ 3) ? "Derived Data File" : ((this$.tag === /* ImageFile */ 4) ? "Image File" : ((this$.tag === /* Material */ 5) ? "Material" : ((this$.tag === /* FreeText */ 6) ? this$.fields[0] : "Source Name"))))); - } - static ofString(str: string): IOType_$union { - return (str === "Source") ? IOType_Source() : ((str === "Source Name") ? IOType_Source() : ((str === "Sample") ? IOType_Sample() : ((str === "Sample Name") ? IOType_Sample() : ((str === "RawDataFile") ? IOType_RawDataFile() : ((str === "Raw Data File") ? IOType_RawDataFile() : ((str === "DerivedDataFile") ? IOType_DerivedDataFile() : ((str === "Derived Data File") ? IOType_DerivedDataFile() : ((str === "ImageFile") ? IOType_ImageFile() : ((str === "Image File") ? IOType_ImageFile() : ((str === "Material") ? IOType_Material() : IOType_FreeText(str))))))))))); - } - static tryOfHeaderString(str: string): Option { - const matchValue: Option = tryParseIOTypeHeader(str); - if (matchValue == null) { - return void 0; - } - else { - const s: string = value(matchValue); - return IOType.ofString(s); - } - } -} - -export function IOType_$reflection(): TypeInfo { - return union_type("ISA.IOType", [], IOType, () => [[], [], [], [], [], [], [["Item", string_type]]]); -} - -export type CompositeHeader_$union = - | CompositeHeader<0> - | CompositeHeader<1> - | CompositeHeader<2> - | CompositeHeader<3> - | CompositeHeader<4> - | CompositeHeader<5> - | CompositeHeader<6> - | CompositeHeader<7> - | CompositeHeader<8> - | CompositeHeader<9> - | CompositeHeader<10> - | CompositeHeader<11> - | CompositeHeader<12> - | CompositeHeader<13> - -export type CompositeHeader_$cases = { - 0: ["Component", [OntologyAnnotation]], - 1: ["Characteristic", [OntologyAnnotation]], - 2: ["Factor", [OntologyAnnotation]], - 3: ["Parameter", [OntologyAnnotation]], - 4: ["ProtocolType", []], - 5: ["ProtocolDescription", []], - 6: ["ProtocolUri", []], - 7: ["ProtocolVersion", []], - 8: ["ProtocolREF", []], - 9: ["Performer", []], - 10: ["Date", []], - 11: ["Input", [IOType_$union]], - 12: ["Output", [IOType_$union]], - 13: ["FreeText", [string]] -} - -export function CompositeHeader_Component(Item: OntologyAnnotation) { - return new CompositeHeader<0>(0, [Item]); -} - -export function CompositeHeader_Characteristic(Item: OntologyAnnotation) { - return new CompositeHeader<1>(1, [Item]); -} - -export function CompositeHeader_Factor(Item: OntologyAnnotation) { - return new CompositeHeader<2>(2, [Item]); -} - -export function CompositeHeader_Parameter(Item: OntologyAnnotation) { - return new CompositeHeader<3>(3, [Item]); -} - -export function CompositeHeader_ProtocolType() { - return new CompositeHeader<4>(4, []); -} - -export function CompositeHeader_ProtocolDescription() { - return new CompositeHeader<5>(5, []); -} - -export function CompositeHeader_ProtocolUri() { - return new CompositeHeader<6>(6, []); -} - -export function CompositeHeader_ProtocolVersion() { - return new CompositeHeader<7>(7, []); -} - -export function CompositeHeader_ProtocolREF() { - return new CompositeHeader<8>(8, []); -} - -export function CompositeHeader_Performer() { - return new CompositeHeader<9>(9, []); -} - -export function CompositeHeader_Date() { - return new CompositeHeader<10>(10, []); -} - -export function CompositeHeader_Input(Item: IOType_$union) { - return new CompositeHeader<11>(11, [Item]); -} - -export function CompositeHeader_Output(Item: IOType_$union) { - return new CompositeHeader<12>(12, [Item]); -} - -export function CompositeHeader_FreeText(Item: string) { - return new CompositeHeader<13>(13, [Item]); -} - -export class CompositeHeader extends Union { - constructor(readonly tag: Tag, readonly fields: CompositeHeader_$cases[Tag][1]) { - super(); - } - cases() { - return ["Component", "Characteristic", "Factor", "Parameter", "ProtocolType", "ProtocolDescription", "ProtocolUri", "ProtocolVersion", "ProtocolREF", "Performer", "Date", "Input", "Output", "FreeText"]; - } - toString(): string { - const this$ = this as CompositeHeader_$union; - switch (this$.tag) { - case /* Factor */ 2: - return `Factor [${OntologyAnnotation__get_NameText(this$.fields[0])}]`; - case /* Characteristic */ 1: - return `Characteristic [${OntologyAnnotation__get_NameText(this$.fields[0])}]`; - case /* Component */ 0: - return `Component [${OntologyAnnotation__get_NameText(this$.fields[0])}]`; - case /* ProtocolType */ 4: - return "Protocol Type"; - case /* ProtocolREF */ 8: - return "Protocol REF"; - case /* ProtocolDescription */ 5: - return "Protocol Description"; - case /* ProtocolUri */ 6: - return "Protocol Uri"; - case /* ProtocolVersion */ 7: - return "Protocol Version"; - case /* Performer */ 9: - return "Performer"; - case /* Date */ 10: - return "Date"; - case /* Input */ 11: { - const io: IOType_$union = this$.fields[0]; - return io.asInput; - } - case /* Output */ 12: { - const io_1: IOType_$union = this$.fields[0]; - return io_1.asOutput; - } - case /* FreeText */ 13: - return this$.fields[0]; - default: - return `Parameter [${OntologyAnnotation__get_NameText(this$.fields[0])}]`; - } - } - ToTerm(): OntologyAnnotation { - const this$ = this as CompositeHeader_$union; - switch (this$.tag) { - case /* Factor */ 2: - return this$.fields[0]; - case /* Characteristic */ 1: - return this$.fields[0]; - case /* Component */ 0: - return this$.fields[0]; - case /* ProtocolType */ 4: - return OntologyAnnotation_fromString_Z7D8EB286("Protocol Type"); - case /* ProtocolREF */ 8: - return OntologyAnnotation_fromString_Z7D8EB286("Protocol REF"); - case /* ProtocolDescription */ 5: - return OntologyAnnotation_fromString_Z7D8EB286("Protocol Description"); - case /* ProtocolUri */ 6: - return OntologyAnnotation_fromString_Z7D8EB286("Protocol Uri"); - case /* ProtocolVersion */ 7: - return OntologyAnnotation_fromString_Z7D8EB286("Protocol Version"); - case /* Performer */ 9: - return OntologyAnnotation_fromString_Z7D8EB286("Performer"); - case /* Date */ 10: - return OntologyAnnotation_fromString_Z7D8EB286("Date"); - case /* Input */ 11: { - const io: IOType_$union = this$.fields[0]; - return OntologyAnnotation_fromString_Z7D8EB286(io.asInput); - } - case /* Output */ 12: { - const io_1: IOType_$union = this$.fields[0]; - return OntologyAnnotation_fromString_Z7D8EB286(io_1.asOutput); - } - case /* FreeText */ 13: - return OntologyAnnotation_fromString_Z7D8EB286(this$.fields[0]); - default: - return this$.fields[0]; - } - } - static OfHeaderString(str: string): CompositeHeader_$union { - const matchValue: string = str.trim(); - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("Input\\s\\[(?.+)\\]", matchValue); - if (activePatternResult != null) { - const r: any = value(activePatternResult); - const iotype: string = (r.groups && r.groups.iotype) || ""; - return CompositeHeader_Input(IOType.ofString(iotype)); - } - else { - const activePatternResult_1: Option = ActivePatterns_$007CRegex$007C_$007C("Output\\s\\[(?.+)\\]", matchValue); - if (activePatternResult_1 != null) { - const r_1: any = value(activePatternResult_1); - const iotype_1: string = (r_1.groups && r_1.groups.iotype) || ""; - return CompositeHeader_Output(IOType.ofString(iotype_1)); - } - else { - const activePatternResult_2: Option<{ TermColumnType: string, TermName: string }> = ActivePatterns_$007CTermColumn$007C_$007C(matchValue); - if (activePatternResult_2 != null) { - const r_2: { TermColumnType: string, TermName: string } = value(activePatternResult_2); - const matchValue_1: string = r_2.TermColumnType; - switch (matchValue_1) { - case "Parameter": - case "Parameter Value": - return CompositeHeader_Parameter(OntologyAnnotation_fromString_Z7D8EB286(r_2.TermName)); - case "Factor": - case "Factor Value": - return CompositeHeader_Factor(OntologyAnnotation_fromString_Z7D8EB286(r_2.TermName)); - case "Characteristic": - case "Characteristics": - case "Characteristics Value": - return CompositeHeader_Characteristic(OntologyAnnotation_fromString_Z7D8EB286(r_2.TermName)); - case "Component": - return CompositeHeader_Component(OntologyAnnotation_fromString_Z7D8EB286(r_2.TermName)); - default: - return CompositeHeader_FreeText(str); - } - } - else { - return (matchValue === "Date") ? CompositeHeader_Date() : ((matchValue === "Performer") ? CompositeHeader_Performer() : ((matchValue === "Protocol Description") ? CompositeHeader_ProtocolDescription() : ((matchValue === "Protocol Uri") ? CompositeHeader_ProtocolUri() : ((matchValue === "Protocol Version") ? CompositeHeader_ProtocolVersion() : ((matchValue === "Protocol Type") ? CompositeHeader_ProtocolType() : ((matchValue === "Protocol REF") ? CompositeHeader_ProtocolREF() : CompositeHeader_FreeText(matchValue))))))); - } - } - } - } - get IsDeprecated(): boolean { - let s: string, s_1: string, s_2: string, s_3: string; - const this$ = this as CompositeHeader_$union; - let matchResult: int32, s_4: string, s_5: string, s_6: string, s_7: string; - if (this$.tag === /* FreeText */ 13) { - if ((s = this$.fields[0], s.toLocaleLowerCase() === "sample name")) { - matchResult = 0; - s_4 = this$.fields[0]; - } - else if ((s_1 = this$.fields[0], s_1.toLocaleLowerCase() === "source name")) { - matchResult = 1; - s_5 = this$.fields[0]; - } - else if ((s_2 = this$.fields[0], s_2.toLocaleLowerCase() === "data file name")) { - matchResult = 2; - s_6 = this$.fields[0]; - } - else if ((s_3 = this$.fields[0], s_3.toLocaleLowerCase() === "derived data file")) { - matchResult = 3; - s_7 = this$.fields[0]; - } - else { - matchResult = 4; - } - } - else { - matchResult = 4; - } - switch (matchResult) { - case 0: - return true; - case 1: - return true; - case 2: - return true; - case 3: - return true; - default: - return false; - } - } - get IsCvParamColumn(): boolean { - const this$ = this as CompositeHeader_$union; - switch (this$.tag) { - case /* Parameter */ 3: - case /* Factor */ 2: - case /* Characteristic */ 1: - case /* Component */ 0: - return true; - default: - return false; - } - } - get IsTermColumn(): boolean { - const this$ = this as CompositeHeader_$union; - switch (this$.tag) { - case /* Parameter */ 3: - case /* Factor */ 2: - case /* Characteristic */ 1: - case /* Component */ 0: - case /* ProtocolType */ 4: - return true; - default: - return false; - } - } - get IsFeaturedColumn(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* ProtocolType */ 4; - } - get GetFeaturedColumnAccession(): string { - const this$ = this as CompositeHeader_$union; - if (this$.tag === /* ProtocolType */ 4) { - return "DPBO:1000161"; - } - else { - throw new Error(`Tried matching ${this$} in getFeaturedColumnAccession, but is not a featured column.`); - } - } - get GetColumnAccessionShort(): string { - const this$ = this as CompositeHeader_$union; - switch (this$.tag) { - case /* ProtocolType */ 4: - return this$.GetFeaturedColumnAccession; - case /* Parameter */ 3: - return OntologyAnnotation__get_TermAccessionShort(this$.fields[0]); - case /* Factor */ 2: - return OntologyAnnotation__get_TermAccessionShort(this$.fields[0]); - case /* Characteristic */ 1: - return OntologyAnnotation__get_TermAccessionShort(this$.fields[0]); - case /* Component */ 0: - return OntologyAnnotation__get_TermAccessionShort(this$.fields[0]); - default: - throw new Error(`Tried matching ${this$}, but is not a column with an accession.`); - } - } - get IsSingleColumn(): boolean { - const this$ = this as CompositeHeader_$union; - switch (this$.tag) { - case /* FreeText */ 13: - case /* Input */ 11: - case /* Output */ 12: - case /* ProtocolREF */ 8: - case /* ProtocolDescription */ 5: - case /* ProtocolUri */ 6: - case /* ProtocolVersion */ 7: - case /* Performer */ 9: - case /* Date */ 10: - return true; - default: - return false; - } - } - get IsIOType(): boolean { - const this$ = this as CompositeHeader_$union; - let matchResult: int32, io: IOType_$union; - switch (this$.tag) { - case /* Input */ 11: { - matchResult = 0; - io = this$.fields[0]; - break; - } - case /* Output */ 12: { - matchResult = 0; - io = this$.fields[0]; - break; - } - default: - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } - } - get isInput(): boolean { - const this$ = this as CompositeHeader_$union; - if (this$.tag === /* Input */ 11) { - const io: IOType_$union = this$.fields[0]; - return true; - } - else { - return false; - } - } - get isOutput(): boolean { - const this$ = this as CompositeHeader_$union; - if (this$.tag === /* Input */ 11) { - const io: IOType_$union = this$.fields[0]; - return true; - } - else { - return false; - } - } - get isParameter(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* Parameter */ 3; - } - get isFactor(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* Factor */ 2; - } - get isCharacteristic(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* Characteristic */ 1; - } - get isComponent(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* Component */ 0; - } - get isProtocolType(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* ProtocolType */ 4; - } - get isProtocolREF(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* ProtocolREF */ 8; - } - get isProtocolDescription(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* ProtocolDescription */ 5; - } - get isProtocolUri(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* ProtocolUri */ 6; - } - get isProtocolVersion(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* ProtocolVersion */ 7; - } - get isPerformer(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* Performer */ 9; - } - get isDate(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* Date */ 10; - } - get isFreeText(): boolean { - const this$ = this as CompositeHeader_$union; - return this$.tag === /* FreeText */ 13; - } - TryParameter(): Option { - const this$ = this as CompositeHeader_$union; - return (this$.tag === /* Parameter */ 3) ? ProtocolParameter_create_2769312B(void 0, this$.fields[0]) : void 0; - } - TryFactor(): Option { - const this$ = this as CompositeHeader_$union; - return (this$.tag === /* Factor */ 2) ? Factor_create_Z3D2B374F(void 0, void 0, this$.fields[0]) : void 0; - } - TryCharacteristic(): Option { - const this$ = this as CompositeHeader_$union; - return (this$.tag === /* Characteristic */ 1) ? MaterialAttribute_create_2769312B(void 0, this$.fields[0]) : void 0; - } - TryComponent(): Option { - const this$ = this as CompositeHeader_$union; - return (this$.tag === /* Component */ 0) ? Component_create_Z33AADEE0(void 0, void 0, void 0, this$.fields[0]) : void 0; - } -} - -export function CompositeHeader_$reflection(): TypeInfo { - return union_type("ISA.CompositeHeader", [], CompositeHeader, () => [[["Item", OntologyAnnotation_$reflection()]], [["Item", OntologyAnnotation_$reflection()]], [["Item", OntologyAnnotation_$reflection()]], [["Item", OntologyAnnotation_$reflection()]], [], [], [], [], [], [], [], [["Item", IOType_$reflection()]], [["Item", IOType_$reflection()]], [["Item", string_type]]]); -} - diff --git a/ts/ISA/ISA/ArcTypes/CompositeRow.ts b/ts/ISA/ISA/ArcTypes/CompositeRow.ts deleted file mode 100644 index e01f2382..00000000 --- a/ts/ISA/ISA/ArcTypes/CompositeRow.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { fold } from "../../../fable_modules/fable-library-ts/Seq.js"; -import { Protocol_get_empty, Protocol, Protocol_addComponent, Protocol_addParameter, Protocol_setName, Protocol_setDescription, Protocol_setUri, Protocol_setVersion, Protocol_setProtocolType } from "../JsonTypes/Protocol.js"; -import { ProtocolParameter_create_2769312B } from "../JsonTypes/ProtocolParameter.js"; -import { Component_create_Z33AADEE0 } from "../JsonTypes/Component.js"; -import { Value_Ontology, Value_fromString_Z721C83C5 } from "../JsonTypes/Value.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { OntologyAnnotation } from "../JsonTypes/OntologyAnnotation.js"; -import { CompositeCell_$union, CompositeCell } from "./CompositeCell.js"; -import { CompositeHeader_$union, CompositeHeader } from "./CompositeHeader.js"; - -export function toProtocol(row: Iterable<[CompositeHeader_$union, CompositeCell_$union]>): Protocol { - return fold<[CompositeHeader_$union, CompositeCell_$union], Protocol>((p: Protocol, hc: [CompositeHeader_$union, CompositeCell_$union]): Protocol => { - let matchResult: int32, oa: OntologyAnnotation, v: string, v_1: string, v_2: string, v_3: string, oa_1: OntologyAnnotation, oa_2: OntologyAnnotation, unit: OntologyAnnotation, v_4: string, oa_3: OntologyAnnotation, t: OntologyAnnotation; - switch (hc[0].tag) { - case /* ProtocolType */ 4: { - if (hc[1].tag === /* Term */ 0) { - matchResult = 0; - oa = (hc[1] as CompositeCell<0>).fields[0]; - } - else { - matchResult = 8; - } - break; - } - case /* ProtocolVersion */ 7: { - if (hc[1].tag === /* FreeText */ 1) { - matchResult = 1; - v = (hc[1] as CompositeCell<1>).fields[0]; - } - else { - matchResult = 8; - } - break; - } - case /* ProtocolUri */ 6: { - if (hc[1].tag === /* FreeText */ 1) { - matchResult = 2; - v_1 = (hc[1] as CompositeCell<1>).fields[0]; - } - else { - matchResult = 8; - } - break; - } - case /* ProtocolDescription */ 5: { - if (hc[1].tag === /* FreeText */ 1) { - matchResult = 3; - v_2 = (hc[1] as CompositeCell<1>).fields[0]; - } - else { - matchResult = 8; - } - break; - } - case /* ProtocolREF */ 8: { - if (hc[1].tag === /* FreeText */ 1) { - matchResult = 4; - v_3 = (hc[1] as CompositeCell<1>).fields[0]; - } - else { - matchResult = 8; - } - break; - } - case /* Parameter */ 3: { - matchResult = 5; - oa_1 = (hc[0] as CompositeHeader<3>).fields[0]; - break; - } - case /* Component */ 0: { - switch (hc[1].tag) { - case /* Unitized */ 2: { - matchResult = 6; - oa_2 = (hc[0] as CompositeHeader<0>).fields[0]; - unit = (hc[1] as CompositeCell<2>).fields[1]; - v_4 = (hc[1] as CompositeCell<2>).fields[0]; - break; - } - case /* Term */ 0: { - matchResult = 7; - oa_3 = (hc[0] as CompositeHeader<0>).fields[0]; - t = (hc[1] as CompositeCell<0>).fields[0]; - break; - } - default: - matchResult = 8; - } - break; - } - default: - matchResult = 8; - } - switch (matchResult) { - case 0: - return Protocol_setProtocolType(p, oa!); - case 1: - return Protocol_setVersion(p, v!); - case 2: - return Protocol_setUri(p, v_1!); - case 3: - return Protocol_setDescription(p, v_2!); - case 4: - return Protocol_setName(p, v_3!); - case 5: - return Protocol_addParameter(ProtocolParameter_create_2769312B(void 0, oa_1!), p); - case 6: - return Protocol_addComponent(Component_create_Z33AADEE0(void 0, Value_fromString_Z721C83C5(v_4!), unit!, oa_2!), p); - case 7: - return Protocol_addComponent(Component_create_Z33AADEE0(void 0, Value_Ontology(t!), void 0, oa_3!), p); - default: - return p; - } - }, Protocol_get_empty(), row); -} - diff --git a/ts/ISA/ISA/ArcTypes/Identifier.ts b/ts/ISA/ISA/ArcTypes/Identifier.ts deleted file mode 100644 index 8ee1f1f9..00000000 --- a/ts/ISA/ISA/ArcTypes/Identifier.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { match, isMatch } from "../../../fable_modules/fable-library-ts/RegExp.js"; -import { newGuid } from "../../../fable_modules/fable-library-ts/Guid.js"; -import { combineMany } from "../../../FileSystem/Path.js"; - -export function checkValidCharacters(identifier: string): void { - if (!isMatch(/^[a-zA-Z0-9_\- ]+$/gu, identifier)) { - throw new Error("New identifier contains forbidden characters! Allowed characters are: letters, digits, underscore (_), dash (-) and whitespace ( )."); - } -} - -export function createMissingIdentifier(): string { - let copyOfStruct: string; - return "MISSING_IDENTIFIER_" + ((copyOfStruct = newGuid(), copyOfStruct)); -} - -export function isMissingIdentifier(str: string): boolean { - return str.indexOf("MISSING_IDENTIFIER_") === 0; -} - -export function removeMissingIdentifier(str: string): string { - if (str.indexOf("MISSING_IDENTIFIER_") === 0) { - return ""; - } - else { - return str; - } -} - -/** - * On read-in the FileName can be any combination of "assays" (assay folder name), assayIdentifier and "isa.assay.xlsx" (the actual file name). - * - * This functions extracts assayIdentifier from any of these combinations and returns it. - */ -export function Assay_identifierFromFileName(fileName: string): string { - const m: any = match(/^(assays(\/|\\))?(?[a-zA-Z0-9_\- ]+)((\/|\\)isa.assay.xlsx)?$/gu, fileName); - const matchValue: boolean = m != null; - if (matchValue) { - return (m.groups && m.groups.identifier) || ""; - } - else { - throw new Error(`Cannot parse identifier from FileName \`${fileName}\``); - } -} - -/** - * On writing a xlsx file we unify our output to a relative path to ARC root. So: `assays/assayIdentifier/isa.assay.xlsx`. - */ -export function Assay_fileNameFromIdentifier(identifier: string): string { - checkValidCharacters(identifier); - return combineMany(["assays", identifier, "isa.assay.xlsx"]); -} - -/** - * On read-in the FileName can be any combination of "studies" (study folder name), studyIdentifier and "isa.study.xlsx" (the actual file name). - * - * This functions extracts studyIdentifier from any of these combinations and returns it. - */ -export function Study_identifierFromFileName(fileName: string): string { - const m: any = match(/^(studies(\/|\\))?(?[a-zA-Z0-9_\- ]+)((\/|\\)isa.study.xlsx)?$/gu, fileName); - const matchValue: boolean = m != null; - if (matchValue) { - return (m.groups && m.groups.identifier) || ""; - } - else { - throw new Error(`Cannot parse identifier from FileName \`${fileName}\``); - } -} - -/** - * On writing a xlsx file we unify our output to a relative path to ARC root. So: `studies/studyIdentifier/isa.study.xlsx`. - */ -export function Study_fileNameFromIdentifier(identifier: string): string { - checkValidCharacters(identifier); - return combineMany(["studies", identifier, "isa.study.xlsx"]); -} - diff --git a/ts/ISA/ISA/ArcTypes/IdentifierSetters.ts b/ts/ISA/ISA/ArcTypes/IdentifierSetters.ts deleted file mode 100644 index 78e58006..00000000 --- a/ts/ISA/ISA/ArcTypes/IdentifierSetters.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { checkValidCharacters } from "./Identifier.js"; -import { ArcAssay } from "./ArcAssay.js"; -import { ArcStudy } from "./ArcStudy.js"; -import { ArcInvestigation } from "./ArcInvestigation.js"; - -export function setAssayIdentifier(newIdentifier: string, assay: ArcAssay): ArcAssay { - checkValidCharacters(newIdentifier); - assay.Identifier = newIdentifier; - return assay; -} - -export function setStudyIdentifier(newIdentifier: string, study: ArcStudy): ArcStudy { - checkValidCharacters(newIdentifier); - study.Identifier = newIdentifier; - return study; -} - -export function setInvestigationIdentifier(newIdentifier: string, investigation: ArcInvestigation): ArcInvestigation { - checkValidCharacters(newIdentifier); - investigation.Identifier = newIdentifier; - return investigation; -} - diff --git a/ts/ISA/ISA/Builder/Types.ts b/ts/ISA/ISA/Builder/Types.ts deleted file mode 100644 index 678baa37..00000000 --- a/ts/ISA/ISA/Builder/Types.ts +++ /dev/null @@ -1,373 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library-ts/Types.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation } from "../JsonTypes/OntologyAnnotation.js"; -import { list_type, union_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Protocol_get_empty, Protocol } from "../JsonTypes/Protocol.js"; -import { map, defaultArg, value as value_4, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { ProcessParameterValue_$reflection, ProcessParameterValue } from "../JsonTypes/ProcessParameterValue.js"; -import { MaterialAttributeValue_$reflection, MaterialAttributeValue } from "../JsonTypes/MaterialAttributeValue.js"; -import { FactorValue_$reflection, FactorValue } from "../JsonTypes/FactorValue.js"; -import { map as map_1, exists, fold, singleton, empty, append, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { ProtocolParameter } from "../JsonTypes/ProtocolParameter.js"; -import { Process_get_empty, Process } from "../JsonTypes/Process.js"; -import { ProcessInput_$union } from "../JsonTypes/ProcessInput.js"; -import { ProcessOutput_$union } from "../JsonTypes/ProcessOutput.js"; -import { Assay_get_empty, Assay } from "../JsonTypes/Assay.js"; -import { printf, toFail } from "../../../fable_modules/fable-library-ts/String.js"; -import { Study } from "../JsonTypes/Study.js"; - -export type ProtocolTransformation_$union = - | ProtocolTransformation<0> - | ProtocolTransformation<1> - | ProtocolTransformation<2> - -export type ProtocolTransformation_$cases = { - 0: ["AddName", [string]], - 1: ["AddProtocolType", [OntologyAnnotation]], - 2: ["AddDescription", [string]] -} - -export function ProtocolTransformation_AddName(Item: string) { - return new ProtocolTransformation<0>(0, [Item]); -} - -export function ProtocolTransformation_AddProtocolType(Item: OntologyAnnotation) { - return new ProtocolTransformation<1>(1, [Item]); -} - -export function ProtocolTransformation_AddDescription(Item: string) { - return new ProtocolTransformation<2>(2, [Item]); -} - -export class ProtocolTransformation extends Union { - constructor(readonly tag: Tag, readonly fields: ProtocolTransformation_$cases[Tag][1]) { - super(); - } - cases() { - return ["AddName", "AddProtocolType", "AddDescription"]; - } -} - -export function ProtocolTransformation_$reflection(): TypeInfo { - return union_type("ISA.Builder.ProtocolTransformation", [], ProtocolTransformation, () => [[["Item", string_type]], [["Item", OntologyAnnotation_$reflection()]], [["Item", string_type]]]); -} - -export function ProtocolTransformation__Transform_4D8AC666(this$: ProtocolTransformation_$union, p: Protocol): Protocol { - switch (this$.tag) { - case /* AddProtocolType */ 1: - return new Protocol(p.ID, p.Name, this$.fields[0], p.Description, p.Uri, p.Version, p.Parameters, p.Components, p.Comments); - case /* AddDescription */ 2: - return new Protocol(p.ID, p.Name, p.ProtocolType, this$.fields[0], p.Uri, p.Version, p.Parameters, p.Components, p.Comments); - default: - return new Protocol(p.ID, this$.fields[0], p.ProtocolType, p.Description, p.Uri, p.Version, p.Parameters, p.Components, p.Comments); - } -} - -export function ProtocolTransformation__Equals_4D8AC666(this$: ProtocolTransformation_$union, p: Protocol): boolean { - const matchValue: Option = p.Name; - let matchResult: int32, n_1: string, n$0027_1: string; - if (this$.tag === /* AddName */ 0) { - if (matchValue != null) { - if (this$.fields[0] === value_4(matchValue)) { - matchResult = 0; - n_1 = this$.fields[0]; - n$0027_1 = value_4(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } -} - -export type ProcessTransformation_$union = - | ProcessTransformation<0> - | ProcessTransformation<1> - | ProcessTransformation<2> - | ProcessTransformation<3> - | ProcessTransformation<4> - -export type ProcessTransformation_$cases = { - 0: ["AddName", [string]], - 1: ["AddParameter", [ProcessParameterValue]], - 2: ["AddCharacteristic", [MaterialAttributeValue]], - 3: ["AddFactor", [FactorValue]], - 4: ["AddProtocol", [FSharpList]] -} - -export function ProcessTransformation_AddName(Item: string) { - return new ProcessTransformation<0>(0, [Item]); -} - -export function ProcessTransformation_AddParameter(Item: ProcessParameterValue) { - return new ProcessTransformation<1>(1, [Item]); -} - -export function ProcessTransformation_AddCharacteristic(Item: MaterialAttributeValue) { - return new ProcessTransformation<2>(2, [Item]); -} - -export function ProcessTransformation_AddFactor(Item: FactorValue) { - return new ProcessTransformation<3>(3, [Item]); -} - -export function ProcessTransformation_AddProtocol(Item: FSharpList) { - return new ProcessTransformation<4>(4, [Item]); -} - -export class ProcessTransformation extends Union { - constructor(readonly tag: Tag, readonly fields: ProcessTransformation_$cases[Tag][1]) { - super(); - } - cases() { - return ["AddName", "AddParameter", "AddCharacteristic", "AddFactor", "AddProtocol"]; - } -} - -export function ProcessTransformation_$reflection(): TypeInfo { - return union_type("ISA.Builder.ProcessTransformation", [], ProcessTransformation, () => [[["Item", string_type]], [["Item", ProcessParameterValue_$reflection()]], [["Item", MaterialAttributeValue_$reflection()]], [["Item", FactorValue_$reflection()]], [["Item", list_type(ProtocolTransformation_$reflection())]]]); -} - -export function ProcessTransformation__Transform_30EF9E7B(this$: ProcessTransformation_$union, p: Process): Process { - let pro: Protocol; - switch (this$.tag) { - case /* AddParameter */ 1: { - const pv: ProcessParameterValue = this$.fields[0]; - const parameterValues: FSharpList = append(defaultArg(p.ParameterValues, empty()), singleton(pv)); - return new Process(p.ID, p.Name, (pro = defaultArg(p.ExecutesProtocol, Protocol_get_empty()), new Protocol(pro.ID, pro.Name, pro.ProtocolType, pro.Description, pro.Uri, pro.Version, append(defaultArg(pro.Parameters, empty()), singleton(value_4(pv.Category))), pro.Components, pro.Comments)), parameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, p.Outputs, p.Comments); - } - case /* AddCharacteristic */ 2: { - const c: MaterialAttributeValue = this$.fields[0]; - return new Process(p.ID, p.Name, p.ExecutesProtocol, p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, map, FSharpList>((i: FSharpList): FSharpList => i, p.Inputs), p.Outputs, p.Comments); - } - case /* AddFactor */ 3: { - const f: FactorValue = this$.fields[0]; - return new Process(p.ID, p.Name, p.ExecutesProtocol, p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, map, FSharpList>((i_1: FSharpList): FSharpList => i_1, p.Outputs), p.Comments); - } - case /* AddProtocol */ 4: { - const pts: FSharpList = this$.fields[0]; - return new Process(p.ID, p.Name, fold((pro_2: Protocol, trans: ProtocolTransformation_$union): Protocol => ProtocolTransformation__Transform_4D8AC666(trans, pro_2), defaultArg(p.ExecutesProtocol, Protocol_get_empty()), pts), p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, p.Outputs, p.Comments); - } - default: - return new Process(p.ID, this$.fields[0], p.ExecutesProtocol, p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, p.Outputs, p.Comments); - } -} - -export function ProcessTransformation__Equals_30EF9E7B(this$: ProcessTransformation_$union, p: Process): boolean { - const matchValue: Option = p.Name; - let matchResult: int32, n_1: string, n$0027_1: string; - if (this$.tag === /* AddName */ 0) { - if (matchValue != null) { - if (this$.fields[0] === value_4(matchValue)) { - matchResult = 0; - n_1 = this$.fields[0]; - n$0027_1 = value_4(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } -} - -export type AssayTransformation_$union = - | AssayTransformation<0> - | AssayTransformation<1> - | AssayTransformation<2> - | AssayTransformation<3> - | AssayTransformation<4> - -export type AssayTransformation_$cases = { - 0: ["AddFileName", [string]], - 1: ["AddParameter", [ProcessParameterValue]], - 2: ["AddCharacteristic", [MaterialAttributeValue]], - 3: ["AddFactor", [FactorValue]], - 4: ["AddProcess", [FSharpList]] -} - -export function AssayTransformation_AddFileName(Item: string) { - return new AssayTransformation<0>(0, [Item]); -} - -export function AssayTransformation_AddParameter(Item: ProcessParameterValue) { - return new AssayTransformation<1>(1, [Item]); -} - -export function AssayTransformation_AddCharacteristic(Item: MaterialAttributeValue) { - return new AssayTransformation<2>(2, [Item]); -} - -export function AssayTransformation_AddFactor(Item: FactorValue) { - return new AssayTransformation<3>(3, [Item]); -} - -export function AssayTransformation_AddProcess(Item: FSharpList) { - return new AssayTransformation<4>(4, [Item]); -} - -export class AssayTransformation extends Union { - constructor(readonly tag: Tag, readonly fields: AssayTransformation_$cases[Tag][1]) { - super(); - } - cases() { - return ["AddFileName", "AddParameter", "AddCharacteristic", "AddFactor", "AddProcess"]; - } -} - -export function AssayTransformation_$reflection(): TypeInfo { - return union_type("ISA.Builder.AssayTransformation", [], AssayTransformation, () => [[["Item", string_type]], [["Item", ProcessParameterValue_$reflection()]], [["Item", MaterialAttributeValue_$reflection()]], [["Item", FactorValue_$reflection()]], [["Item", list_type(ProcessTransformation_$reflection())]]]); -} - -export function AssayTransformation__Transform_Z269B5B97(this$: AssayTransformation_$union, a: Assay): Assay { - switch (this$.tag) { - case /* AddProcess */ 4: { - const pts: FSharpList = this$.fields[0]; - const processes: FSharpList = defaultArg(a.ProcessSequence, empty()); - return new Assay(a.ID, a.FileName, a.MeasurementType, a.TechnologyType, a.TechnologyPlatform, a.DataFiles, a.Materials, a.CharacteristicCategories, a.UnitCategories, exists((p: Process): boolean => exists((trans: ProcessTransformation_$union): boolean => ProcessTransformation__Equals_30EF9E7B(trans, p), pts), processes) ? map_1((p_1: Process): Process => { - if (exists((trans_1: ProcessTransformation_$union): boolean => ProcessTransformation__Equals_30EF9E7B(trans_1, p_1), pts)) { - return fold((p_2: Process, trans_2: ProcessTransformation_$union): Process => ProcessTransformation__Transform_30EF9E7B(trans_2, p_2), p_1, pts); - } - else { - return p_1; - } - }, processes) : append(processes, singleton(fold((p_3: Process, trans_3: ProcessTransformation_$union): Process => ProcessTransformation__Transform_30EF9E7B(trans_3, p_3), Process_get_empty(), pts))), a.Comments); - } - case /* AddFileName */ 0: - return new Assay(a.ID, this$.fields[0], a.MeasurementType, a.TechnologyType, a.TechnologyPlatform, a.DataFiles, a.Materials, a.CharacteristicCategories, a.UnitCategories, a.ProcessSequence, a.Comments); - default: - return toFail(printf("Builder failed: Case %O Not implemented"))(this$); - } -} - -export function AssayTransformation__Equals_Z269B5B97(this$: AssayTransformation_$union, a: Assay): boolean { - const matchValue: Option = a.FileName; - let matchResult: int32, n_1: string, n$0027_1: string; - if (this$.tag === /* AddFileName */ 0) { - if (matchValue != null) { - if (this$.fields[0] === value_4(matchValue)) { - matchResult = 0; - n_1 = this$.fields[0]; - n$0027_1 = value_4(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } -} - -export type StudyTransformation_$union = - | StudyTransformation<0> - | StudyTransformation<1> - | StudyTransformation<2> - | StudyTransformation<3> - | StudyTransformation<4> - -export type StudyTransformation_$cases = { - 0: ["AddParameter", [ProcessParameterValue]], - 1: ["AddCharacteristic", [MaterialAttributeValue]], - 2: ["AddFactor", [FactorValue]], - 3: ["AddProcess", [FSharpList]], - 4: ["AddAssay", [FSharpList]] -} - -export function StudyTransformation_AddParameter(Item: ProcessParameterValue) { - return new StudyTransformation<0>(0, [Item]); -} - -export function StudyTransformation_AddCharacteristic(Item: MaterialAttributeValue) { - return new StudyTransformation<1>(1, [Item]); -} - -export function StudyTransformation_AddFactor(Item: FactorValue) { - return new StudyTransformation<2>(2, [Item]); -} - -export function StudyTransformation_AddProcess(Item: FSharpList) { - return new StudyTransformation<3>(3, [Item]); -} - -export function StudyTransformation_AddAssay(Item: FSharpList) { - return new StudyTransformation<4>(4, [Item]); -} - -export class StudyTransformation extends Union { - constructor(readonly tag: Tag, readonly fields: StudyTransformation_$cases[Tag][1]) { - super(); - } - cases() { - return ["AddParameter", "AddCharacteristic", "AddFactor", "AddProcess", "AddAssay"]; - } -} - -export function StudyTransformation_$reflection(): TypeInfo { - return union_type("ISA.Builder.StudyTransformation", [], StudyTransformation, () => [[["Item", ProcessParameterValue_$reflection()]], [["Item", MaterialAttributeValue_$reflection()]], [["Item", FactorValue_$reflection()]], [["Item", list_type(ProcessTransformation_$reflection())]], [["Item", list_type(AssayTransformation_$reflection())]]]); -} - -export function StudyTransformation__Transform_Z27CB2981(this$: StudyTransformation_$union, s: Study): Study { - switch (this$.tag) { - case /* AddProcess */ 3: { - const pts: FSharpList = this$.fields[0]; - const processes: FSharpList = defaultArg(s.ProcessSequence, empty()); - return new Study(s.ID, s.FileName, s.Identifier, s.Title, s.Description, s.SubmissionDate, s.PublicReleaseDate, s.Publications, s.Contacts, s.StudyDesignDescriptors, s.Protocols, s.Materials, exists((p: Process): boolean => exists((trans: ProcessTransformation_$union): boolean => ProcessTransformation__Equals_30EF9E7B(trans, p), pts), processes) ? map_1((p_1: Process): Process => { - if (exists((trans_1: ProcessTransformation_$union): boolean => ProcessTransformation__Equals_30EF9E7B(trans_1, p_1), pts)) { - return fold((p_2: Process, trans_2: ProcessTransformation_$union): Process => ProcessTransformation__Transform_30EF9E7B(trans_2, p_2), p_1, pts); - } - else { - return p_1; - } - }, processes) : append(processes, singleton(fold((p_3: Process, trans_3: ProcessTransformation_$union): Process => ProcessTransformation__Transform_30EF9E7B(trans_3, p_3), Process_get_empty(), pts))), s.Assays, s.Factors, s.CharacteristicCategories, s.UnitCategories, s.Comments); - } - case /* AddAssay */ 4: { - const ats: FSharpList = this$.fields[0]; - const assays: FSharpList = defaultArg(s.Assays, empty()); - return new Study(s.ID, s.FileName, s.Identifier, s.Title, s.Description, s.SubmissionDate, s.PublicReleaseDate, s.Publications, s.Contacts, s.StudyDesignDescriptors, s.Protocols, s.Materials, s.ProcessSequence, exists((a: Assay): boolean => exists((trans_4: AssayTransformation_$union): boolean => AssayTransformation__Equals_Z269B5B97(trans_4, a), ats), assays) ? map_1((a_1: Assay): Assay => { - if (exists((trans_5: AssayTransformation_$union): boolean => AssayTransformation__Equals_Z269B5B97(trans_5, a_1), ats)) { - return fold((a_2: Assay, trans_6: AssayTransformation_$union): Assay => AssayTransformation__Transform_Z269B5B97(trans_6, a_2), a_1, ats); - } - else { - return a_1; - } - }, assays) : append(assays, singleton(fold((a_3: Assay, trans_7: AssayTransformation_$union): Assay => AssayTransformation__Transform_Z269B5B97(trans_7, a_3), Assay_get_empty(), ats))), s.Factors, s.CharacteristicCategories, s.UnitCategories, s.Comments); - } - default: - return toFail(printf("Builder failed: Case %O Not implemented"))(this$); - } -} - diff --git a/ts/ISA/ISA/Fable.ts b/ts/ISA/ISA/Fable.ts deleted file mode 100644 index 377ee3f8..00000000 --- a/ts/ISA/ISA/Fable.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { toString } from "../../fable_modules/fable-library-ts/Types.js"; -import { FSharpList, append } from "../../fable_modules/fable-library-ts/List.js"; -import { append as append_1 } from "../../fable_modules/fable-library-ts/Array.js"; -import { Array_distinct, List_distinct } from "../../fable_modules/fable-library-ts/Seq2.js"; -import { structuralHash, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; - -export function isMap_generic<$a>(l1: $a): boolean { - let copyOfStruct: $a; - return ((copyOfStruct = l1, toString(copyOfStruct))).indexOf("map [") === 0; -} - -export function isList_generic<$a>(l1: $a): boolean { - let s: string; - let copyOfStruct: $a = l1; - s = toString(copyOfStruct); - if (s.indexOf("[") === 0) { - return !(s.indexOf("seq [") === 0); - } - else { - return false; - } -} - -export function append_generic<$a, $b>(l1: $a, l2: $b): $a { - if (l2 == null) { - return l1; - } - else if (isList_generic<$a>(l1)) { - return append(l1, l2); - } - else { - return append_1(l1, l2); - } -} - -export function distinct_generic<$a, $b>(l1: $a): FSharpList { - if (isList_generic<$a>(l1)) { - return List_distinct(l1, { - Equals: equals, - GetHashCode: structuralHash, - }); - } - else { - return Array_distinct(l1, { - Equals: equals, - GetHashCode: structuralHash, - }); - } -} - diff --git a/ts/ISA/ISA/JsonTypes/AnnotationValue.ts b/ts/ISA/ISA/JsonTypes/AnnotationValue.ts deleted file mode 100644 index 212baf8a..00000000 --- a/ts/ISA/ISA/JsonTypes/AnnotationValue.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library-ts/Types.js"; -import { parse as parse_1, int32, float64 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { union_type, int32_type, float64_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { parse } from "../../../fable_modules/fable-library-ts/Double.js"; -import { int32ToString } from "../../../fable_modules/fable-library-ts/Util.js"; - -export type AnnotationValue_$union = - | AnnotationValue<0> - | AnnotationValue<1> - | AnnotationValue<2> - -export type AnnotationValue_$cases = { - 0: ["Text", [string]], - 1: ["Float", [float64]], - 2: ["Int", [int32]] -} - -export function AnnotationValue_Text(Item: string) { - return new AnnotationValue<0>(0, [Item]); -} - -export function AnnotationValue_Float(Item: float64) { - return new AnnotationValue<1>(1, [Item]); -} - -export function AnnotationValue_Int(Item: int32) { - return new AnnotationValue<2>(2, [Item]); -} - -export class AnnotationValue extends Union { - constructor(readonly tag: Tag, readonly fields: AnnotationValue_$cases[Tag][1]) { - super(); - } - cases() { - return ["Text", "Float", "Int"]; - } -} - -export function AnnotationValue_$reflection(): TypeInfo { - return union_type("ISA.AnnotationValue", [], AnnotationValue, () => [[["Item", string_type]], [["Item", float64_type]], [["Item", int32_type]]]); -} - -export function AnnotationValue_get_empty(): AnnotationValue_$union { - return AnnotationValue_Text(""); -} - -/** - * Create a ISAJson Annotation value from a ISATab string entry - */ -export function AnnotationValue_fromString_Z721C83C5(s: string): AnnotationValue_$union { - try { - return AnnotationValue_Int(parse_1(s, 511, false, 32)); - } - catch (matchValue: any) { - try { - return AnnotationValue_Float(parse(s)); - } - catch (matchValue_1: any) { - return AnnotationValue_Text(s); - } - } -} - -/** - * Get a ISATab string Annotation Name from a ISAJson object - */ -export function AnnotationValue_toString_Z3C00A204(v: AnnotationValue_$union): string { - switch (v.tag) { - case /* Int */ 2: - return int32ToString(v.fields[0]); - case /* Float */ 1: { - const f: float64 = v.fields[0]; - return f.toString(); - } - default: - return v.fields[0]; - } -} - diff --git a/ts/ISA/ISA/JsonTypes/Assay.ts b/ts/ISA/ISA/JsonTypes/Assay.ts deleted file mode 100644 index 42d92212..00000000 --- a/ts/ISA/ISA/JsonTypes/Assay.ts +++ /dev/null @@ -1,642 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { map as map_1, value as value_4, defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { empty, filter, map, singleton, append, exists, tryFind, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Data_$reflection, Data } from "./Data.js"; -import { AssayMaterials_get_empty, AssayMaterials_make, AssayMaterials_$reflection, AssayMaterials } from "./AssayMaterials.js"; -import { MaterialAttribute_$reflection, MaterialAttribute } from "./MaterialAttribute.js"; -import { Process_$reflection, Process } from "./Process.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { safeHash, structuralHash, IMap, equals, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Update_UpdateOptions_UpdateByExistingAppendLists, Update_UpdateOptions_$union } from "../Update.js"; -import { map2 as map2_2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Dict_tryFind, Dict_ofSeqWithMerge, Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { fromValueWithDefault, mapDefault } from "../OptionExtensions.js"; -import { updateProtocols, getProtocols, getFactors, getOutputsWithFactorBy, getOutputsWithCharacteristicBy, getInputsWithCharacteristicBy, getParameters, getOutputsWithParameterBy, getInputsWithParameterBy, getMaterials, getSamples, getSources, getCharacteristics, getUnits, getData } from "./ProcessSequence.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { Source } from "./Source.js"; -import { Sample_$reflection, Sample } from "./Sample.js"; -import { Material_$reflection, Material } from "./Material.js"; -import { ProcessInput_$union } from "./ProcessInput.js"; -import { ProcessParameterValue } from "./ProcessParameterValue.js"; -import { ProtocolParameter } from "./ProtocolParameter.js"; -import { ProcessOutput_$union } from "./ProcessOutput.js"; -import { MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { FactorValue } from "./FactorValue.js"; -import { Factor } from "./Factor.js"; -import { Protocol } from "./Protocol.js"; -import { toFail } from "../../../fable_modules/fable-library-ts/String.js"; - -export class Assay extends Record implements IEquatable { - readonly ID: Option; - readonly FileName: Option; - readonly MeasurementType: Option; - readonly TechnologyType: Option; - readonly TechnologyPlatform: Option; - readonly DataFiles: Option>; - readonly Materials: Option; - readonly CharacteristicCategories: Option>; - readonly UnitCategories: Option>; - readonly ProcessSequence: Option>; - readonly Comments: Option>; - constructor(ID: Option, FileName: Option, MeasurementType: Option, TechnologyType: Option, TechnologyPlatform: Option, DataFiles: Option>, Materials: Option, CharacteristicCategories: Option>, UnitCategories: Option>, ProcessSequence: Option>, Comments: Option>) { - super(); - this.ID = ID; - this.FileName = FileName; - this.MeasurementType = MeasurementType; - this.TechnologyType = TechnologyType; - this.TechnologyPlatform = TechnologyPlatform; - this.DataFiles = DataFiles; - this.Materials = Materials; - this.CharacteristicCategories = CharacteristicCategories; - this.UnitCategories = UnitCategories; - this.ProcessSequence = ProcessSequence; - this.Comments = Comments; - } -} - -export function Assay_$reflection(): TypeInfo { - return record_type("ISA.Assay", [], Assay, () => [["ID", option_type(string_type)], ["FileName", option_type(string_type)], ["MeasurementType", option_type(OntologyAnnotation_$reflection())], ["TechnologyType", option_type(OntologyAnnotation_$reflection())], ["TechnologyPlatform", option_type(string_type)], ["DataFiles", option_type(list_type(Data_$reflection()))], ["Materials", option_type(AssayMaterials_$reflection())], ["CharacteristicCategories", option_type(list_type(MaterialAttribute_$reflection()))], ["UnitCategories", option_type(list_type(OntologyAnnotation_$reflection()))], ["ProcessSequence", option_type(list_type(Process_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Assay_make(id: Option, fileName: Option, measurementType: Option, technologyType: Option, technologyPlatform: Option, dataFiles: Option>, materials: Option, characteristicCategories: Option>, unitCategories: Option>, processSequence: Option>, comments: Option>): Assay { - return new Assay(id, fileName, measurementType, technologyType, technologyPlatform, dataFiles, materials, characteristicCategories, unitCategories, processSequence, comments); -} - -export function Assay_create_ABF59A4(Id?: string, FileName?: string, MeasurementType?: OntologyAnnotation, TechnologyType?: OntologyAnnotation, TechnologyPlatform?: string, DataFiles?: FSharpList, Materials?: AssayMaterials, CharacteristicCategories?: FSharpList, UnitCategories?: FSharpList, ProcessSequence?: FSharpList, Comments?: FSharpList): Assay { - return Assay_make(Id, FileName, MeasurementType, TechnologyType, TechnologyPlatform, DataFiles, Materials, CharacteristicCategories, UnitCategories, ProcessSequence, Comments); -} - -export function Assay_get_empty(): Assay { - return Assay_create_ABF59A4(); -} - -/** - * If an assay with the given identfier exists in the list, returns it - */ -export function Assay_tryGetByFileName(fileName: string, assays: FSharpList): Option { - return tryFind((a: Assay): boolean => equals(a.FileName, fileName), assays); -} - -/** - * If an assay with the given identfier exists in the list, returns true - */ -export function Assay_existsByFileName(fileName: string, assays: FSharpList): boolean { - return exists((a: Assay): boolean => equals(a.FileName, fileName), assays); -} - -/** - * Adds the given assay to the assays - */ -export function Assay_add(assays: FSharpList, assay: Assay): FSharpList { - return append(assays, singleton(assay)); -} - -/** - * Updates all assays for which the predicate returns true with the given assays values - */ -export function Assay_updateBy(predicate: ((arg0: Assay) => boolean), updateOption: Update_UpdateOptions_$union, assay: Assay, assays: FSharpList): FSharpList { - if (exists(predicate, assays)) { - return map((a: Assay): Assay => { - if (predicate(a)) { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: Assay = a; - const recordType_2: Assay = assay; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Assay_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Assay; - case /* UpdateByExisting */ 1: - return makeRecord(Assay_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Assay; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Assay_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Assay; - default: - return recordType_2; - } - } - else { - return a; - } - }, assays); - } - else { - return assays; - } -} - -/** - * If an assay with the same fileName as the given assay exists in the study exists, updates it with the given assay values - */ -export function Assay_updateByFileName(updateOption: Update_UpdateOptions_$union, assay: Assay, assays: FSharpList): FSharpList { - return Assay_updateBy((a: Assay): boolean => equals(a.FileName, assay.FileName), updateOption, assay, assays); -} - -/** - * Updates all assays with the same name as the given assay with its values - */ -export function Assay_removeByFileName(fileName: string, assays: FSharpList): FSharpList { - return filter((a: Assay): boolean => !equals(a.FileName, fileName), assays); -} - -/** - * Returns comments of an assay - */ -export function Assay_getComments_Z269B5B97(assay: Assay): Option> { - return assay.Comments; -} - -/** - * Applies function f on comments of an assay - */ -export function Assay_mapComments(f: ((arg0: FSharpList) => FSharpList), assay: Assay): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, mapDefault>(empty(), f, assay.Comments)); -} - -/** - * Replaces comments of an assay by given comment list - */ -export function Assay_setComments(assay: Assay, comments: FSharpList): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, comments); -} - -/** - * Returns data files of an assay - */ -export function Assay_getData_Z269B5B97(assay: Assay): FSharpList { - const processSequenceData: FSharpList = getData(defaultArg(assay.ProcessSequence, empty())); - const updateOptions: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping = (d: Data): Option => d.Name; - const list1: FSharpList = defaultArg(assay.DataFiles, empty()); - const list2: FSharpList = processSequenceData; - try { - const map1: IMap, Data> = Dict_ofSeqWithMerge>((arg: Data, arg_1: Data): Data => { - const this$: Update_UpdateOptions_$union = updateOptions; - const recordType_1: Data = arg; - const recordType_2: Data = arg_1; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Data_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Data; - case /* UpdateByExisting */ 1: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Data; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Data; - default: - return recordType_2; - } - }, map, Data]>((v: Data): [Option, Data] => ([mapping(v), v] as [Option, Data]), list1)); - const map2: IMap, Data> = Dict_ofSeqWithMerge>((arg_2: Data, arg_3: Data): Data => { - const this$_1: Update_UpdateOptions_$union = updateOptions; - const recordType_1_1: Data = arg_2; - const recordType_2_1: Data = arg_3; - switch (this$_1.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Data_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Data; - case /* UpdateByExisting */ 1: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Data; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Data; - default: - return recordType_2_1; - } - }, map, Data]>((v_1: Data): [Option, Data] => ([mapping(v_1), v_1] as [Option, Data]), list2)); - return map, Data>((k: Option): Data => { - const matchValue: Option = Dict_tryFind, Data>(k, map1); - const matchValue_1: Option = Dict_tryFind, Data>(k, map2); - if (matchValue == null) { - if (matchValue_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1: Data = value_4(matchValue_1); - return v2_1; - } - } - else if (matchValue_1 == null) { - const v1_1: Data = value_4(matchValue); - return v1_1; - } - else { - const v1: Data = value_4(matchValue); - const v2: Data = value_4(matchValue_1); - const this$_2: Update_UpdateOptions_$union = updateOptions; - const recordType_1_2: Data = v1; - const recordType_2_2: Data = v2; - switch (this$_2.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Data_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Data; - case /* UpdateByExisting */ 1: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Data; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Data_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Data; - default: - return recordType_2_2; - } - } - }, List_distinct>(append>(map>(mapping, list1), map>(mapping, list2)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err: any) { - throw new Error(`Could not mergeUpdate ${"Data"} list: -${err.message}`); - } -} - -/** - * Applies function f on data files of an assay - */ -export function Assay_mapData(f: ((arg0: FSharpList) => FSharpList), assay: Assay): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, mapDefault>(empty(), f, assay.DataFiles), assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces data files of an assay by given data file list - */ -export function Assay_setData(assay: Assay, dataFiles: FSharpList): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, dataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns unit categories of an assay - */ -export function Assay_getUnitCategories_Z269B5B97(assay: Assay): FSharpList { - return List_distinct(append(getUnits(defaultArg(assay.ProcessSequence, empty())), defaultArg(assay.UnitCategories, empty())), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Applies function f on unit categories of an assay - */ -export function Assay_mapUnitCategories(f: ((arg0: FSharpList) => FSharpList), assay: Assay): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, mapDefault>(empty(), f, assay.UnitCategories), assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces unit categories of an assay by given unit categorie list - */ -export function Assay_setUnitCategories(assay: Assay, unitCategories: FSharpList): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, unitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns characteristic categories of an assay - */ -export function Assay_getCharacteristics_Z269B5B97(assay: Assay): FSharpList { - return List_distinct(append(getCharacteristics(defaultArg(assay.ProcessSequence, empty())), defaultArg(assay.CharacteristicCategories, empty())), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Applies function f on characteristic categories of an assay - */ -export function Assay_mapCharacteristics(f: ((arg0: FSharpList) => FSharpList), assay: Assay): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, mapDefault>(empty(), f, assay.CharacteristicCategories), assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces characteristic categories of an assay by given characteristic categorie list - */ -export function Assay_setCharacteristics(assay: Assay, characteristics: FSharpList): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, characteristics, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns measurement type of an assay - */ -export function Assay_getMeasurementType_Z269B5B97(assay: Assay): Option { - return assay.MeasurementType; -} - -/** - * Applies function f on measurement type of an assay - */ -export function Assay_mapMeasurementType(f: ((arg0: OntologyAnnotation) => OntologyAnnotation), assay: Assay): Assay { - return new Assay(assay.ID, assay.FileName, map_1(f, assay.MeasurementType), assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces measurement type of an assay by given measurement type - */ -export function Assay_setMeasurementType(assay: Assay, measurementType: OntologyAnnotation): Assay { - return new Assay(assay.ID, assay.FileName, measurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns technology type of an assay - */ -export function Assay_getTechnologyType_Z269B5B97(assay: Assay): Option { - return assay.TechnologyType; -} - -/** - * Applies function f on technology type of an assay - */ -export function Assay_mapTechnologyType(f: ((arg0: OntologyAnnotation) => OntologyAnnotation), assay: Assay): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, map_1(f, assay.TechnologyType), assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces technology type of an assay by given technology type - */ -export function Assay_setTechnologyType(assay: Assay, technologyType: OntologyAnnotation): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, technologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Returns processes of an assay - */ -export function Assay_getProcesses_Z269B5B97(assay: Assay): FSharpList { - return defaultArg(assay.ProcessSequence, empty()); -} - -/** - * Applies function f on processes of an assay - */ -export function Assay_mapProcesses(f: ((arg0: FSharpList) => FSharpList), assay: Assay): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, mapDefault>(empty(), f, assay.ProcessSequence), assay.Comments); -} - -/** - * Replaces processes of an assay by given processe list - */ -export function Assay_setProcesses(assay: Assay, processes: FSharpList): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, assay.Materials, assay.CharacteristicCategories, assay.UnitCategories, processes, assay.Comments); -} - -export function Assay_getSources_Z269B5B97(assay: Assay): FSharpList { - return getSources(Assay_getProcesses_Z269B5B97(assay)); -} - -export function Assay_getSamples_Z269B5B97(assay: Assay): FSharpList { - return getSamples(Assay_getProcesses_Z269B5B97(assay)); -} - -/** - * Returns materials of an assay - */ -export function Assay_getMaterials_Z269B5B97(assay: Assay): AssayMaterials { - const processSequenceMaterials: FSharpList = getMaterials(defaultArg(assay.ProcessSequence, empty())); - const processSequenceSamples: FSharpList = getSamples(defaultArg(assay.ProcessSequence, empty())); - const matchValue: Option = assay.Materials; - if (matchValue == null) { - return AssayMaterials_make(fromValueWithDefault>(empty(), processSequenceSamples), fromValueWithDefault>(empty(), processSequenceMaterials)); - } - else { - const mat: AssayMaterials = value_4(matchValue); - let samples: FSharpList; - const updateOptions: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping = (s: Sample): Option => s.Name; - const list1: FSharpList = defaultArg(mat.Samples, empty()); - const list2: FSharpList = processSequenceSamples; - try { - const map1: IMap, Sample> = Dict_ofSeqWithMerge>((arg: Sample, arg_1: Sample): Sample => { - const this$: Update_UpdateOptions_$union = updateOptions; - const recordType_1: Sample = arg; - const recordType_2: Sample = arg_1; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Sample; - default: - return recordType_2; - } - }, map, Sample]>((v: Sample): [Option, Sample] => ([mapping(v), v] as [Option, Sample]), list1)); - const map2: IMap, Sample> = Dict_ofSeqWithMerge>((arg_2: Sample, arg_3: Sample): Sample => { - const this$_1: Update_UpdateOptions_$union = updateOptions; - const recordType_1_1: Sample = arg_2; - const recordType_2_1: Sample = arg_3; - switch (this$_1.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Sample; - default: - return recordType_2_1; - } - }, map, Sample]>((v_1: Sample): [Option, Sample] => ([mapping(v_1), v_1] as [Option, Sample]), list2)); - samples = map, Sample>((k: Option): Sample => { - const matchValue_1: Option = Dict_tryFind, Sample>(k, map1); - const matchValue_1_1: Option = Dict_tryFind, Sample>(k, map2); - if (matchValue_1 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1: Sample = value_4(matchValue_1_1); - return v2_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1: Sample = value_4(matchValue_1); - return v1_1; - } - else { - const v1: Sample = value_4(matchValue_1); - const v2: Sample = value_4(matchValue_1_1); - const this$_2: Update_UpdateOptions_$union = updateOptions; - const recordType_1_2: Sample = v1; - const recordType_2_2: Sample = v2; - switch (this$_2.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Sample; - default: - return recordType_2_2; - } - } - }, List_distinct>(append>(map>(mapping, list1), map>(mapping, list2)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err: any) { - throw new Error(`Could not mergeUpdate ${"Sample"} list: -${err.message}`); - } - let materials: FSharpList; - const updateOptions_1: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_5 = (m: Material): Option => m.Name; - const list1_1: FSharpList = defaultArg(mat.OtherMaterials, empty()); - const list2_1: FSharpList = processSequenceMaterials; - try { - const map1_1: IMap, Material> = Dict_ofSeqWithMerge>((arg_6: Material, arg_1_1: Material): Material => { - const this$_3: Update_UpdateOptions_$union = updateOptions_1; - const recordType_1_3: Material = arg_6; - const recordType_2_3: Material = arg_1_1; - switch (this$_3.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Material; - default: - return recordType_2_3; - } - }, map, Material]>((v_2: Material): [Option, Material] => ([mapping_5(v_2), v_2] as [Option, Material]), list1_1)); - const map2_1: IMap, Material> = Dict_ofSeqWithMerge>((arg_2_1: Material, arg_3_1: Material): Material => { - const this$_4: Update_UpdateOptions_$union = updateOptions_1; - const recordType_1_4: Material = arg_2_1; - const recordType_2_4: Material = arg_3_1; - switch (this$_4.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Material; - default: - return recordType_2_4; - } - }, map, Material]>((v_1_1: Material): [Option, Material] => ([mapping_5(v_1_1), v_1_1] as [Option, Material]), list2_1)); - materials = map, Material>((k_1: Option): Material => { - const matchValue_3: Option = Dict_tryFind, Material>(k_1, map1_1); - const matchValue_1_2: Option = Dict_tryFind, Material>(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_2 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1: Material = value_4(matchValue_1_2); - return v2_1_1; - } - } - else if (matchValue_1_2 == null) { - const v1_1_1: Material = value_4(matchValue_3); - return v1_1_1; - } - else { - const v1_2: Material = value_4(matchValue_3); - const v2_2: Material = value_4(matchValue_1_2); - const this$_5: Update_UpdateOptions_$union = updateOptions_1; - const recordType_1_5: Material = v1_2; - const recordType_2_5: Material = v2_2; - switch (this$_5.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Material; - default: - return recordType_2_5; - } - } - }, List_distinct>(append>(map>(mapping_5, list1_1), map>(mapping_5, list2_1)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err_1: any) { - throw new Error(`Could not mergeUpdate ${"Material"} list: -${err_1.message}`); - } - return AssayMaterials_make(fromValueWithDefault>(empty(), samples), fromValueWithDefault>(empty(), materials)); - } -} - -/** - * Applies function f on materials of an assay - */ -export function Assay_mapMaterials(f: ((arg0: AssayMaterials) => AssayMaterials), assay: Assay): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, map_1(f, assay.Materials), assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * Replaces materials of an assay by given assay materials - */ -export function Assay_setMaterials(assay: Assay, materials: AssayMaterials): Assay { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, assay.DataFiles, materials, assay.CharacteristicCategories, assay.UnitCategories, assay.ProcessSequence, assay.Comments); -} - -/** - * If the assay contains a process implementing the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function Assay_getInputsWithParameterBy(predicate: ((arg0: ProtocolParameter) => boolean), assay: Assay): Option> { - return map_1, FSharpList<[ProcessInput_$union, ProcessParameterValue]>>((processSequence: FSharpList): FSharpList<[ProcessInput_$union, ProcessParameterValue]> => getInputsWithParameterBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * If the assay contains a process implementing the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function Assay_getOutputsWithParameterBy(predicate: ((arg0: ProtocolParameter) => boolean), assay: Assay): Option> { - return map_1, FSharpList<[ProcessOutput_$union, ProcessParameterValue]>>((processSequence: FSharpList): FSharpList<[ProcessOutput_$union, ProcessParameterValue]> => getOutputsWithParameterBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * Returns the parameters implemented by the processes contained in this assay - */ -export function Assay_getParameters_Z269B5B97(assay: Assay): Option> { - return map_1, FSharpList>(getParameters, assay.ProcessSequence); -} - -/** - * If the assay contains a process implementing the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function Assay_getInputsWithCharacteristicBy(predicate: ((arg0: MaterialAttribute) => boolean), assay: Assay): Option> { - return map_1, FSharpList<[ProcessInput_$union, MaterialAttributeValue]>>((processSequence: FSharpList): FSharpList<[ProcessInput_$union, MaterialAttributeValue]> => getInputsWithCharacteristicBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * If the assay contains a process implementing the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function Assay_getOutputsWithCharacteristicBy(predicate: ((arg0: MaterialAttribute) => boolean), assay: Assay): Option> { - return map_1, FSharpList<[ProcessOutput_$union, MaterialAttributeValue]>>((processSequence: FSharpList): FSharpList<[ProcessOutput_$union, MaterialAttributeValue]> => getOutputsWithCharacteristicBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * If the assay contains a process implementing the given factor, return the list of output files together with their according factor values of this factor - */ -export function Assay_getOutputsWithFactorBy(predicate: ((arg0: Factor) => boolean), assay: Assay): Option> { - return map_1, FSharpList<[ProcessOutput_$union, FactorValue]>>((processSequence: FSharpList): FSharpList<[ProcessOutput_$union, FactorValue]> => getOutputsWithFactorBy(predicate, processSequence), assay.ProcessSequence); -} - -/** - * Returns the factors implemented by the processes contained in this assay - */ -export function Assay_getFactors_Z269B5B97(assay: Assay): FSharpList { - return getFactors(defaultArg(assay.ProcessSequence, empty())); -} - -/** - * Returns the protocols implemented by the processes contained in this assay - */ -export function Assay_getProtocols_Z269B5B97(assay: Assay): FSharpList { - return getProtocols(defaultArg(assay.ProcessSequence, empty())); -} - -export function Assay_update_Z269B5B97(assay: Assay): Assay { - let v_1: AssayMaterials; - try { - return new Assay(assay.ID, assay.FileName, assay.MeasurementType, assay.TechnologyType, assay.TechnologyPlatform, fromValueWithDefault>(empty(), Assay_getData_Z269B5B97(assay)), (v_1 = Assay_getMaterials_Z269B5B97(assay), fromValueWithDefault(AssayMaterials_get_empty(), v_1)), fromValueWithDefault>(empty(), Assay_getCharacteristics_Z269B5B97(assay)), fromValueWithDefault>(empty(), Assay_getUnitCategories_Z269B5B97(assay)), assay.ProcessSequence, assay.Comments); - } - catch (err: any) { - return toFail(`Could not update assay ${assay.FileName}: -${err.message}`); - } -} - -export function Assay_updateProtocols(protocols: FSharpList, assay: Assay): Assay { - try { - return Assay_mapProcesses((processSequence: FSharpList): FSharpList => updateProtocols(protocols, processSequence), assay); - } - catch (err: any) { - return toFail(`Could not update assay protocols ${assay.FileName}: -${err.message}`); - } -} - diff --git a/ts/ISA/ISA/JsonTypes/AssayMaterials.ts b/ts/ISA/ISA/JsonTypes/AssayMaterials.ts deleted file mode 100644 index a46064bf..00000000 --- a/ts/ISA/ISA/JsonTypes/AssayMaterials.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { empty, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Sample_$reflection, Sample } from "./Sample.js"; -import { Material_$reflection, Material } from "./Material.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, option_type, list_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export class AssayMaterials extends Record implements IEquatable { - readonly Samples: Option>; - readonly OtherMaterials: Option>; - constructor(Samples: Option>, OtherMaterials: Option>) { - super(); - this.Samples = Samples; - this.OtherMaterials = OtherMaterials; - } -} - -export function AssayMaterials_$reflection(): TypeInfo { - return record_type("ISA.AssayMaterials", [], AssayMaterials, () => [["Samples", option_type(list_type(Sample_$reflection()))], ["OtherMaterials", option_type(list_type(Material_$reflection()))]]); -} - -export function AssayMaterials_make(samples: Option>, otherMaterials: Option>): AssayMaterials { - return new AssayMaterials(samples, otherMaterials); -} - -export function AssayMaterials_create_1CB3546D(Samples?: FSharpList, OtherMaterials?: FSharpList): AssayMaterials { - return AssayMaterials_make(Samples, OtherMaterials); -} - -export function AssayMaterials_get_empty(): AssayMaterials { - return AssayMaterials_create_1CB3546D(); -} - -export function AssayMaterials_getMaterials_E3447B1(am: AssayMaterials): FSharpList { - return defaultArg(am.OtherMaterials, empty()); -} - -export function AssayMaterials_getSamples_E3447B1(am: AssayMaterials): FSharpList { - return defaultArg(am.Samples, empty()); -} - diff --git a/ts/ISA/ISA/JsonTypes/ColumnIndex.ts b/ts/ISA/ISA/JsonTypes/ColumnIndex.ts deleted file mode 100644 index 9444d005..00000000 --- a/ts/ISA/ISA/JsonTypes/ColumnIndex.ts +++ /dev/null @@ -1,248 +0,0 @@ -import { tryParse, int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { FSharpRef } from "../../../fable_modules/fable-library-ts/Types.js"; -import { value, bind, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { Comment$, Comment_fromString } from "./Comment.js"; -import { int32ToString } from "../../../fable_modules/fable-library-ts/Util.js"; -import { tryItem } from "./CommentList.js"; -import { cons, singleton, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; -import { ProtocolParameter_fromString_703AFBF9, ProtocolParameter } from "./ProtocolParameter.js"; -import { ProcessParameterValue } from "./ProcessParameterValue.js"; -import { Factor_fromString_Z5D76503E, Factor } from "./Factor.js"; -import { FactorValue } from "./FactorValue.js"; -import { MaterialAttribute_fromString_703AFBF9, MaterialAttribute } from "./MaterialAttribute.js"; -import { MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { Component_fromString_55205B02, Component } from "./Component.js"; - -function tryInt(str: string): Option { - let matchValue: [boolean, int32]; - let outArg = 0; - matchValue = ([tryParse(str, 511, false, 32, new FSharpRef((): int32 => outArg, (v: int32): void => { - outArg = (v | 0); - })), outArg] as [boolean, int32]); - if (matchValue[0]) { - return matchValue[1]; - } - else { - return void 0; - } -} - -export const orderName = "ColumnIndex"; - -export function createOrderComment(index: int32): Comment$ { - return Comment_fromString(orderName, int32ToString(index)); -} - -export function tryGetIndex(comments: FSharpList): Option { - return bind(tryInt, tryItem(orderName, comments)); -} - -export function setOntologyAnnotationIndex(i: int32, oa: OntologyAnnotation): OntologyAnnotation { - let matchValue: Option>, cs: FSharpList; - return new OntologyAnnotation(oa.ID, oa.Name, oa.TermSourceREF, oa.LocalID, oa.TermAccessionNumber, (matchValue = oa.Comments, (matchValue == null) ? singleton(createOrderComment(i)) : ((cs = value(matchValue), cons(createOrderComment(i), cs))))); -} - -export function tryGetOntologyAnnotationIndex(oa: OntologyAnnotation): Option { - return bind, int32>(tryGetIndex, oa.Comments); -} - -export function tryGetParameterIndex(param: ProtocolParameter): Option { - return bind((oa: OntologyAnnotation): Option => bind, int32>(tryGetIndex, oa.Comments), param.ParameterName); -} - -export function tryGetParameterColumnIndex(paramValue: ProcessParameterValue): Option { - return bind(tryGetParameterIndex, paramValue.Category); -} - -export function tryGetFactorIndex(factor: Factor): Option { - return bind((oa: OntologyAnnotation): Option => bind, int32>(tryGetIndex, oa.Comments), factor.FactorType); -} - -export function tryGetFactorColumnIndex(factorValue: FactorValue): Option { - return bind(tryGetFactorIndex, factorValue.Category); -} - -export function tryGetCharacteristicIndex(characteristic: MaterialAttribute): Option { - return bind((oa: OntologyAnnotation): Option => bind, int32>(tryGetIndex, oa.Comments), characteristic.CharacteristicType); -} - -export function tryGetCharacteristicColumnIndex(characteristicValue: MaterialAttributeValue): Option { - return bind(tryGetCharacteristicIndex, characteristicValue.Category); -} - -export function tryGetComponentIndex(comp: Component): Option { - return bind((oa: OntologyAnnotation): Option => bind, int32>(tryGetIndex, oa.Comments), comp.ComponentType); -} - -/** - * Create a ISAJson Factor from ISATab string entries - */ -export function ISA_OntologyAnnotation__OntologyAnnotation_fromStringWithColumnIndex_Static(name: string, term: string, source: string, accession: string, valueIndex: int32): Factor { - return Factor_fromString_Z5D76503E(name, term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_getColumnIndex_Static_2FC95D30(f: OntologyAnnotation): int32 { - return value(tryGetOntologyAnnotationIndex(f)); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_GetColumnIndex(this$: OntologyAnnotation): int32 { - return value(tryGetOntologyAnnotationIndex(this$)); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_tryGetColumnIndex_Static_2FC95D30(f: OntologyAnnotation): Option { - return tryGetOntologyAnnotationIndex(f); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_TryGetColumnIndex(this$: OntologyAnnotation): Option { - return tryGetOntologyAnnotationIndex(this$); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_setColumnIndex_Static(i: int32, oa: OntologyAnnotation): OntologyAnnotation { - return setOntologyAnnotationIndex(i, oa); -} - -export function ISA_OntologyAnnotation__OntologyAnnotation_SetColumnIndex_Z524259A4(this$: OntologyAnnotation, i: int32): OntologyAnnotation { - return setOntologyAnnotationIndex(i, this$); -} - -/** - * Create a ISAJson Factor from ISATab string entries - */ -export function ISA_Factor__Factor_fromStringWithColumnIndex_Static(name: string, term: string, source: string, accession: string, valueIndex: int32): Factor { - return Factor_fromString_Z5D76503E(name, term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_Factor__Factor_getColumnIndex_Static_E353FDD(f: Factor): int32 { - return value(tryGetFactorIndex(f)); -} - -export function ISA_Factor__Factor_GetColumnIndex(this$: Factor): int32 { - return value(tryGetFactorIndex(this$)); -} - -export function ISA_Factor__Factor_tryGetColumnIndex_Static_E353FDD(f: Factor): Option { - return tryGetFactorIndex(f); -} - -export function ISA_Factor__Factor_TryGetColumnIndex(this$: Factor): Option { - return tryGetFactorIndex(this$); -} - -export function ISA_FactorValue__FactorValue_getColumnIndex_Static_2A4175B6(f: FactorValue): int32 { - return value(tryGetFactorColumnIndex(f)); -} - -export function ISA_FactorValue__FactorValue_GetColumnIndex(this$: FactorValue): int32 { - return value(tryGetFactorColumnIndex(this$)); -} - -export function ISA_FactorValue__FactorValue_tryGetColumnIndex_Static_2A4175B6(f: FactorValue): Option { - return tryGetFactorColumnIndex(f); -} - -export function ISA_FactorValue__FactorValue_TryGetColumnIndex(this$: FactorValue): Option { - return tryGetFactorColumnIndex(this$); -} - -/** - * Create a ISAJson characteristic from ISATab string entries - */ -export function ISA_MaterialAttribute__MaterialAttribute_fromStringWithColumnIndex_Static(term: string, source: string, accession: string, valueIndex: int32): MaterialAttribute { - return MaterialAttribute_fromString_703AFBF9(term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_MaterialAttribute__MaterialAttribute_getColumnIndex_Static_Z6476E859(m: MaterialAttribute): int32 { - return value(tryGetCharacteristicIndex(m)); -} - -export function ISA_MaterialAttribute__MaterialAttribute_GetColumnIndex(this$: MaterialAttribute): int32 { - return value(tryGetCharacteristicIndex(this$)); -} - -export function ISA_MaterialAttribute__MaterialAttribute_tryGetColumnIndex_Static_Z6476E859(m: MaterialAttribute): Option { - return tryGetCharacteristicIndex(m); -} - -export function ISA_MaterialAttribute__MaterialAttribute_TryGetColumnIndex(this$: MaterialAttribute): Option { - return tryGetCharacteristicIndex(this$); -} - -export function ISA_MaterialAttributeValue__MaterialAttributeValue_getColumnIndex_Static_6A64994C(m: MaterialAttributeValue): int32 { - return value(tryGetCharacteristicColumnIndex(m)); -} - -export function ISA_MaterialAttributeValue__MaterialAttributeValue_GetColumnIndex(this$: MaterialAttributeValue): int32 { - return value(tryGetCharacteristicColumnIndex(this$)); -} - -export function ISA_MaterialAttributeValue__MaterialAttributeValue_tryGetColumnIndex_Static_6A64994C(m: MaterialAttributeValue): Option { - return tryGetCharacteristicColumnIndex(m); -} - -export function ISA_MaterialAttributeValue__MaterialAttributeValue_TryGetColumnIndex(this$: MaterialAttributeValue): Option { - return tryGetCharacteristicColumnIndex(this$); -} - -/** - * Create a ISAJson parameter from ISATab string entries - */ -export function ISA_ProtocolParameter__ProtocolParameter_fromStringWithColumnIndex_Static(term: string, source: string, accession: string, valueIndex: int32): ProtocolParameter { - return ProtocolParameter_fromString_703AFBF9(term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_ProtocolParameter__ProtocolParameter_getColumnIndex_Static_2762A46F(p: ProtocolParameter): int32 { - return value(tryGetParameterIndex(p)); -} - -export function ISA_ProtocolParameter__ProtocolParameter_GetColumnIndex(this$: ProtocolParameter): int32 { - return value(tryGetParameterIndex(this$)); -} - -export function ISA_ProtocolParameter__ProtocolParameter_tryGetColumnIndex_Static_2762A46F(p: ProtocolParameter): Option { - return tryGetParameterIndex(p); -} - -export function ISA_ProtocolParameter__ProtocolParameter_TryGetColumnIndex(this$: ProtocolParameter): Option { - return tryGetParameterIndex(this$); -} - -export function ISA_ProcessParameterValue__ProcessParameterValue_getColumnIndex_Static_39585819(p: ProcessParameterValue): int32 { - return value(tryGetParameterColumnIndex(p)); -} - -export function ISA_ProcessParameterValue__ProcessParameterValue_GetColumnIndex(this$: ProcessParameterValue): int32 { - return value(tryGetParameterColumnIndex(this$)); -} - -export function ISA_ProcessParameterValue__ProcessParameterValue_tryGetColumnIndex_Static_39585819(p: ProcessParameterValue): Option { - return tryGetParameterColumnIndex(p); -} - -export function ISA_ProcessParameterValue__ProcessParameterValue_TryGetColumnIndex(this$: ProcessParameterValue): Option { - return tryGetParameterColumnIndex(this$); -} - -/** - * Create a ISAJson Factor from ISATab string entries - */ -export function ISA_Component__Component_fromStringWithColumnIndex_Static(name: string, term: string, source: string, accession: string, valueIndex: int32): Component { - return Component_fromString_55205B02(name, term, source, accession, singleton(createOrderComment(valueIndex))); -} - -export function ISA_Component__Component_getColumnIndex_Static_Z7E9B32A1(f: Component): int32 { - return value(tryGetComponentIndex(f)); -} - -export function ISA_Component__Component_GetColumnIndex(this$: Component): int32 { - return value(tryGetComponentIndex(this$)); -} - -export function ISA_Component__Component_tryGetColumnIndex_Static_Z7E9B32A1(f: Component): Option { - return tryGetComponentIndex(f); -} - -export function ISA_Component__Component_TryGetColumnIndex(this$: Component): Option { - return tryGetComponentIndex(this$); -} - diff --git a/ts/ISA/ISA/JsonTypes/Comment.ts b/ts/ISA/ISA/JsonTypes/Comment.ts deleted file mode 100644 index f2f9dc44..00000000 --- a/ts/ISA/ISA/JsonTypes/Comment.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { IComparable, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { int32_type, record_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; - -export class Comment$ extends Record implements IEquatable, IComparable { - readonly ID: Option; - readonly Name: Option; - readonly Value: Option; - constructor(ID: Option, Name: Option, Value: Option) { - super(); - this.ID = ID; - this.Name = Name; - this.Value = Value; - } -} - -export function Comment$_$reflection(): TypeInfo { - return record_type("ISA.Comment", [], Comment$, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["Value", option_type(string_type)]]); -} - -export function Comment_make(id: Option, name: Option, value: Option): Comment$ { - return new Comment$(id, name, value); -} - -export function Comment_create_250E0578(Id?: string, Name?: string, Value?: string): Comment$ { - return Comment_make(Id, Name, Value); -} - -export function Comment_fromString(name: string, value: string): Comment$ { - return Comment_create_250E0578(void 0, name, value); -} - -export function Comment_toString_6AAB8F23(comment: Comment$): [string, string] { - return [defaultArg(comment.Name, ""), defaultArg(comment.Value, "")] as [string, string]; -} - -export class Remark extends Record implements IEquatable, IComparable { - readonly Line: int32; - readonly Value: string; - constructor(Line: int32, Value: string) { - super(); - this.Line = (Line | 0); - this.Value = Value; - } -} - -export function Remark_$reflection(): TypeInfo { - return record_type("ISA.Remark", [], Remark, () => [["Line", int32_type], ["Value", string_type]]); -} - -export function Remark_make(line: int32, value: string): Remark { - return new Remark(line, value); -} - -export function Remark_create_Z176EF219(line: int32, value: string): Remark { - return Remark_make(line, value); -} - -export function Remark_toTuple_Z2023CF4E(remark: Remark): [int32, string] { - return [remark.Line, remark.Value] as [int32, string]; -} - diff --git a/ts/ISA/ISA/JsonTypes/CommentList.ts b/ts/ISA/ISA/JsonTypes/CommentList.ts deleted file mode 100644 index 76e81c92..00000000 --- a/ts/ISA/ISA/JsonTypes/CommentList.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { filter, map, singleton, append, choose, exists, FSharpList, tryPick } from "../../../fable_modules/fable-library-ts/List.js"; -import { value, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { Comment$ } from "./Comment.js"; -import { FSharpMap, ofList } from "../../../fable_modules/fable-library-ts/Map.js"; -import { equals, comparePrimitives } from "../../../fable_modules/fable-library-ts/Util.js"; - -/** - * If a comment with the given key exists in the list, return its value, else return None - */ -export function tryItem(key: string, comments: FSharpList): Option { - return tryPick((c: Comment$): Option => { - const matchValue: Option = c.Name; - let matchResult: int32, n_1: string; - if (matchValue != null) { - if (value(matchValue) === key) { - matchResult = 0; - n_1 = value(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return c.Value; - default: - return void 0; - } - }, comments); -} - -/** - * Returns true, if the key exists in the list - */ -export function containsKey(key: string, comments: FSharpList): boolean { - return exists((c: Comment$): boolean => { - const matchValue: Option = c.Name; - let matchResult: int32, n_1: string; - if (matchValue != null) { - if (value(matchValue) === key) { - matchResult = 0; - n_1 = value(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } - }, comments); -} - -/** - * If a comment with the given key exists in the list, return its value - */ -export function item(key: string, comments: FSharpList): string { - return value(tryItem(key, comments)); -} - -/** - * Create a map of comment keys to comment values - */ -export function toMap(comments: FSharpList): FSharpMap> { - return ofList>(choose]>((c: Comment$): Option<[string, Option]> => { - const matchValue: Option = c.Name; - if (matchValue != null) { - return [value(matchValue), c.Value] as [string, Option]; - } - else { - return void 0; - } - }, comments), { - Compare: comparePrimitives, - }); -} - -/** - * Adds the given comment to the comment list - */ -export function add(comment: Comment$, comments: FSharpList): FSharpList { - return append(comments, singleton(comment)); -} - -/** - * Add the given comment to the comment list if it doesnt exist, else replace it - */ -export function set$(comment: Comment$, comments: FSharpList): FSharpList { - if (containsKey(value(comment.Name), comments)) { - return map((c: Comment$): Comment$ => { - if (equals(c.Name, comment.Name)) { - return comment; - } - else { - return c; - } - }, comments); - } - else { - return append(comments, singleton(comment)); - } -} - -/** - * Returns a new comment list where comments with the given key are filtered out - */ -export function dropByKey(key: string, comments: FSharpList): FSharpList { - return filter((c: Comment$): boolean => { - const matchValue: Option = c.Name; - let matchResult: int32, n_1: string; - if (matchValue != null) { - if (value(matchValue) === key) { - matchResult = 0; - n_1 = value(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return false; - default: - return true; - } - }, comments); -} - diff --git a/ts/ISA/ISA/JsonTypes/Component.ts b/ts/ISA/ISA/JsonTypes/Component.ts deleted file mode 100644 index 83af8e4d..00000000 --- a/ts/ISA/ISA/JsonTypes/Component.ts +++ /dev/null @@ -1,161 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { map, defaultArg, unwrap, value as value_2, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { Value_Name, Value_Ontology, Value_fromString_Z721C83C5, Value__get_Text, Value as Value_1, Value_$reflection, Value_$union } from "./Value.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_fromTermAnnotation_Z721C83C5, OntologyAnnotation__get_TermAccessionShort, OntologyAnnotation__get_NameText, OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { create, match } from "../../../fable_modules/fable-library-ts/RegExp.js"; -import { AnnotationValue_Text } from "./AnnotationValue.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Comment$ } from "./Comment.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; - -export class Component extends Record implements IEquatable { - readonly ComponentName: Option; - readonly ComponentValue: Option; - readonly ComponentUnit: Option; - readonly ComponentType: Option; - constructor(ComponentName: Option, ComponentValue: Option, ComponentUnit: Option, ComponentType: Option) { - super(); - this.ComponentName = ComponentName; - this.ComponentValue = ComponentValue; - this.ComponentUnit = ComponentUnit; - this.ComponentType = ComponentType; - } -} - -export function Component_$reflection(): TypeInfo { - return record_type("ISA.Component", [], Component, () => [["ComponentName", option_type(string_type)], ["ComponentValue", option_type(Value_$reflection())], ["ComponentUnit", option_type(OntologyAnnotation_$reflection())], ["ComponentType", option_type(OntologyAnnotation_$reflection())]]); -} - -export function Component_make(name: Option, value: Option, unit: Option, componentType: Option): Component { - return new Component(name, value, unit, componentType); -} - -export function Component_create_Z33AADEE0(Name?: string, Value?: Value_$union, Unit?: OntologyAnnotation, ComponentType?: OntologyAnnotation): Component { - return Component_make(Name, Value, Unit, ComponentType); -} - -export function Component_get_empty(): Component { - return Component_create_Z33AADEE0(); -} - -/** - * This function creates a string containing full isa term triplet information about the component - * - * Components do not have enough fields in ISA-JSON to include all existing ontology term information. - * This function allows us, to add the same information as `Parameter`, `Characteristics`.., to `Component`. - * Without this string composition we loose the ontology information for the header value. - */ -export function Component_composeName(value: Option, unit: Option): string { - if (value == null) { - return ""; - } - else if (value_2(value).tag === /* Ontology */ 0) { - const oa: OntologyAnnotation = (value_2(value) as Value_1<0>).fields[0]; - return `${OntologyAnnotation__get_NameText(oa)} (${OntologyAnnotation__get_TermAccessionShort(oa)})`; - } - else if (unit != null) { - const u: OntologyAnnotation = value_2(unit); - const v_1: Value_$union = value_2(value); - return `${Value__get_Text(v_1)} ${OntologyAnnotation__get_NameText(u)} (${OntologyAnnotation__get_TermAccessionShort(u)})`; - } - else { - const v: Value_$union = value_2(value); - return `${Value__get_Text(v)}`; - } -} - -/** - * This function parses the given Component header string format into the ISA-JSON Component type - * - * Components do not have enough fields in ISA-JSON to include all existing ontology term information. - * This function allows us, to add the same information as `Parameter`, `Characteristics`.., to `Component`. - * Without this string composition we loose the ontology information for the header value. - */ -export function Component_decomposeName_Z721C83C5(name: string): [Value_$union, Option] { - const r: any = match(create("(?[^\\(]+) \\((?[^(]*:[^)]*)\\)"), name); - const unitr: any = match(create("(?[\\d\\.]+) (?.+) \\((?[^(]*:[^)]*)\\)"), name); - if (unitr != null) { - const oa: OntologyAnnotation = OntologyAnnotation_fromTermAnnotation_Z721C83C5((unitr.groups && unitr.groups.ontology) || ""); - return [Value_fromString_Z721C83C5((unitr.groups && unitr.groups.value) || ""), new OntologyAnnotation(oa.ID, AnnotationValue_Text((unitr.groups && unitr.groups.unit) || ""), oa.TermSourceREF, oa.LocalID, oa.TermAccessionNumber, oa.Comments)] as [Value_$union, Option]; - } - else if (r != null) { - const oa_1: OntologyAnnotation = OntologyAnnotation_fromTermAnnotation_Z721C83C5((r.groups && r.groups.ontology) || ""); - return [Value_Ontology(new OntologyAnnotation(oa_1.ID, AnnotationValue_Text(Value__get_Text(Value_fromString_Z721C83C5((r.groups && r.groups.value) || ""))), oa_1.TermSourceREF, oa_1.LocalID, oa_1.TermAccessionNumber, oa_1.Comments)), void 0] as [Value_$union, Option]; - } - else { - return [Value_Name(name), void 0] as [Value_$union, Option]; - } -} - -/** - * Create a ISAJson Component from ISATab string entries - */ -export function Component_fromString_55205B02(name?: string, term?: string, source?: string, accession?: string, comments?: FSharpList): Component { - let cType: Option; - const v: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(unwrap(term), unwrap(source), unwrap(accession), unwrap(comments)); - cType = fromValueWithDefault(OntologyAnnotation_get_empty(), v); - if (name == null) { - return Component_make(void 0, void 0, void 0, cType); - } - else { - const patternInput: [Value_$union, Option] = Component_decomposeName_Z721C83C5(value_2(name)); - return Component_make(name, fromValueWithDefault(Value_Name(""), patternInput[0]), patternInput[1], cType); - } -} - -export function Component_fromOptions(value: Option, unit: Option, header: Option): Component { - return Component_make(fromValueWithDefault("", Component_composeName(value, unit)), value, unit, header); -} - -/** - * Get ISATab string entries from an ISAJson Component object - */ -export function Component_toString_Z7E9B32A1(c: Component): [string, { TermAccessionNumber: string, TermName: string, TermSourceREF: string }] { - let oa: { TermAccessionNumber: string, TermName: string, TermSourceREF: string }; - const value: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = { - TermAccessionNumber: "", - TermName: "", - TermSourceREF: "", - }; - oa = defaultArg(map(OntologyAnnotation_toString_473B9D79, c.ComponentType), value); - return [defaultArg(c.ComponentName, ""), oa] as [string, { TermAccessionNumber: string, TermName: string, TermSourceREF: string }]; -} - -export function Component__get_NameText(this$: Component): string { - return defaultArg(map(OntologyAnnotation__get_NameText, this$.ComponentType), ""); -} - -/** - * Returns the ontology of the category of the Value as string - */ -export function Component__get_UnitText(this$: Component): string { - return defaultArg(map(OntologyAnnotation__get_NameText, this$.ComponentUnit), ""); -} - -export function Component__get_ValueText(this$: Component): string { - return defaultArg(map(Value__get_Text, this$.ComponentValue), ""); -} - -export function Component__get_ValueWithUnitText(this$: Component): string { - const unit: Option = map(OntologyAnnotation__get_NameText, this$.ComponentUnit); - const v: string = Component__get_ValueText(this$); - if (unit == null) { - return v; - } - else { - const u: string = value_2(unit); - return toText(printf("%s %s"))(v)(u); - } -} - -export function Component__MapCategory_65D42856(this$: Component, f: ((arg0: OntologyAnnotation) => OntologyAnnotation)): Component { - return new Component(this$.ComponentName, this$.ComponentValue, this$.ComponentUnit, map(f, this$.ComponentType)); -} - -export function Component__SetCategory_2FC95D30(this$: Component, c: OntologyAnnotation): Component { - return new Component(this$.ComponentName, this$.ComponentValue, this$.ComponentUnit, c); -} - diff --git a/ts/ISA/ISA/JsonTypes/Data.ts b/ts/ISA/ISA/JsonTypes/Data.ts deleted file mode 100644 index 9e32f7dc..00000000 --- a/ts/ISA/ISA/JsonTypes/Data.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { defaultArg, value as value_1, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { DataFile_$reflection, DataFile__get_AsString, DataFile_$union } from "./DataFile.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; -import { FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { IComparable, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { IISAPrintable } from "../Printer.js"; -import { record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export class Data extends Record implements IEquatable, IComparable, IISAPrintable { - readonly ID: Option; - readonly Name: Option; - readonly DataType: Option; - readonly Comments: Option>; - constructor(ID: Option, Name: Option, DataType: Option, Comments: Option>) { - super(); - this.ID = ID; - this.Name = Name; - this.DataType = DataType; - this.Comments = Comments; - } - Print(): string { - const this$: Data = this; - return toString(this$); - } - PrintCompact(): string { - const this$: Data = this; - const matchValue: Option = this$.DataType; - if (matchValue == null) { - const arg_2: string = Data__get_NameAsString(this$); - return toText(printf("%s"))(arg_2); - } - else { - const t: DataFile_$union = value_1(matchValue); - const arg: string = Data__get_NameAsString(this$); - const arg_1: string = DataFile__get_AsString(t); - return toText(printf("%s [%s]"))(arg)(arg_1); - } - } -} - -export function Data_$reflection(): TypeInfo { - return record_type("ISA.Data", [], Data, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["DataType", option_type(DataFile_$reflection())], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Data_make(id: Option, name: Option, dataType: Option, comments: Option>): Data { - return new Data(id, name, dataType, comments); -} - -export function Data_create_Z748D099(Id?: string, Name?: string, DataType?: DataFile_$union, Comments?: FSharpList): Data { - return Data_make(Id, Name, DataType, Comments); -} - -export function Data_get_empty(): Data { - return Data_create_Z748D099(); -} - -export function Data__get_NameAsString(this$: Data): string { - return defaultArg(this$.Name, ""); -} - diff --git a/ts/ISA/ISA/JsonTypes/DataFile.ts b/ts/ISA/ISA/JsonTypes/DataFile.ts deleted file mode 100644 index 3d9602e1..00000000 --- a/ts/ISA/ISA/JsonTypes/DataFile.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library-ts/Types.js"; -import { union_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export type DataFile_$union = - | DataFile<0> - | DataFile<1> - | DataFile<2> - -export type DataFile_$cases = { - 0: ["RawDataFile", []], - 1: ["DerivedDataFile", []], - 2: ["ImageFile", []] -} - -export function DataFile_RawDataFile() { - return new DataFile<0>(0, []); -} - -export function DataFile_DerivedDataFile() { - return new DataFile<1>(1, []); -} - -export function DataFile_ImageFile() { - return new DataFile<2>(2, []); -} - -export class DataFile extends Union { - constructor(readonly tag: Tag, readonly fields: DataFile_$cases[Tag][1]) { - super(); - } - cases() { - return ["RawDataFile", "DerivedDataFile", "ImageFile"]; - } -} - -export function DataFile_$reflection(): TypeInfo { - return union_type("ISA.DataFile", [], DataFile, () => [[], [], []]); -} - -export function DataFile_get_RawDataFileJson(): string { - return "Raw Data File"; -} - -export function DataFile_get_DerivedDataFileJson(): string { - return "Derived Data File"; -} - -export function DataFile_get_ImageFileJson(): string { - return "Image File"; -} - -export function DataFile__get_AsString(this$: DataFile_$union): string { - switch (this$.tag) { - case /* DerivedDataFile */ 1: - return "DerivedDataFileJson"; - case /* ImageFile */ 2: - return "ImageFileJson"; - default: - return "RawDataFileJson"; - } -} - -export function DataFile__get_IsDerivedData(this$: DataFile_$union): boolean { - if (this$.tag === /* DerivedDataFile */ 1) { - return true; - } - else { - return false; - } -} - -export function DataFile__get_IsRawData(this$: DataFile_$union): boolean { - if (this$.tag === /* RawDataFile */ 0) { - return true; - } - else { - return false; - } -} - -export function DataFile__get_IsImage(this$: DataFile_$union): boolean { - if (this$.tag === /* ImageFile */ 2) { - return true; - } - else { - return false; - } -} - diff --git a/ts/ISA/ISA/JsonTypes/Factor.ts b/ts/ISA/ISA/JsonTypes/Factor.ts deleted file mode 100644 index 32e57763..00000000 --- a/ts/ISA/ISA/JsonTypes/Factor.ts +++ /dev/null @@ -1,203 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { map, defaultArg, unwrap, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { filter, map as map_1, singleton, append, exists, tryFind, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { equals, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { IISAPrintable } from "../Printer.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { Update_UpdateOptions_$union } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; - -export class Factor extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly Name: Option; - readonly FactorType: Option; - readonly Comments: Option>; - constructor(ID: Option, Name: Option, FactorType: Option, Comments: Option>) { - super(); - this.ID = ID; - this.Name = Name; - this.FactorType = FactorType; - this.Comments = Comments; - } - Print(): string { - const this$: Factor = this; - return toString(this$); - } - PrintCompact(): string { - const this$: Factor = this; - return "OA " + Factor__get_NameText(this$); - } -} - -export function Factor_$reflection(): TypeInfo { - return record_type("ISA.Factor", [], Factor, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["FactorType", option_type(OntologyAnnotation_$reflection())], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Factor_make(id: Option, name: Option, factorType: Option, comments: Option>): Factor { - return new Factor(id, name, factorType, comments); -} - -export function Factor_create_Z3D2B374F(Id?: string, Name?: string, FactorType?: OntologyAnnotation, Comments?: FSharpList): Factor { - return Factor_make(Id, Name, FactorType, Comments); -} - -export function Factor_get_empty(): Factor { - return Factor_create_Z3D2B374F(); -} - -/** - * Create a ISAJson Factor from ISATab string entries - */ -export function Factor_fromString_Z5D76503E(name: string, term: string, source: string, accession: string, comments?: FSharpList): Factor { - const oa: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(term, source, accession, unwrap(comments)); - return Factor_make(void 0, fromValueWithDefault("", name), fromValueWithDefault(OntologyAnnotation_get_empty(), oa), void 0); -} - -/** - * Get ISATab string entries from an ISAJson Factor object - */ -export function Factor_toString_E353FDD(factor: Factor): { TermAccessionNumber: string, TermName: string, TermSourceREF: string } { - const value: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = { - TermAccessionNumber: "", - TermName: "", - TermSourceREF: "", - }; - return defaultArg(map(OntologyAnnotation_toString_473B9D79, factor.FactorType), value); -} - -export function Factor__get_NameText(this$: Factor): string { - return defaultArg(this$.Name, ""); -} - -export function Factor__MapCategory_65D42856(this$: Factor, f: ((arg0: OntologyAnnotation) => OntologyAnnotation)): Factor { - return new Factor(this$.ID, this$.Name, map(f, this$.FactorType), this$.Comments); -} - -export function Factor__SetCategory_2FC95D30(this$: Factor, c: OntologyAnnotation): Factor { - return new Factor(this$.ID, this$.Name, c, this$.Comments); -} - -/** - * If a factor with the given name exists in the list, returns it - */ -export function Factor_tryGetByName(name: string, factors: FSharpList): Option { - return tryFind((f: Factor): boolean => equals(f.Name, name), factors); -} - -/** - * If a factor with the given name exists in the list exists, returns true - */ -export function Factor_existsByName(name: string, factors: FSharpList): boolean { - return exists((f: Factor): boolean => equals(f.Name, name), factors); -} - -/** - * adds the given factor to the factors - */ -export function Factor_add(factors: FSharpList, factor: Factor): FSharpList { - return append(factors, singleton(factor)); -} - -/** - * Updates all factors for which the predicate returns true with the given factor values - */ -export function Factor_updateBy(predicate: ((arg0: Factor) => boolean), updateOption: Update_UpdateOptions_$union, factor: Factor, factors: FSharpList): FSharpList { - if (exists(predicate, factors)) { - return map_1((f: Factor): Factor => { - if (predicate(f)) { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: Factor = f; - const recordType_2: Factor = factor; - return (this$.tag === /* UpdateAllAppendLists */ 2) ? (makeRecord(Factor_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Factor) : ((this$.tag === /* UpdateByExisting */ 1) ? (makeRecord(Factor_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Factor) : ((this$.tag === /* UpdateByExistingAppendLists */ 3) ? (makeRecord(Factor_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Factor) : recordType_2)); - } - else { - return f; - } - }, factors); - } - else { - return factors; - } -} - -/** - * Updates all factors with the same name as the given factor with its values - */ -export function Factor_updateByName(updateOption: Update_UpdateOptions_$union, factor: Factor, factors: FSharpList): FSharpList { - return Factor_updateBy((f: Factor): boolean => equals(f.Name, factor.Name), updateOption, factor, factors); -} - -/** - * If a factor with the given name exists in the list, removes it - */ -export function Factor_removeByName(name: string, factors: FSharpList): FSharpList { - return filter((f: Factor): boolean => !equals(f.Name, name), factors); -} - -/** - * Returns comments of a factor - */ -export function Factor_getComments_E353FDD(factor: Factor): Option> { - return factor.Comments; -} - -/** - * Applies function f on comments of a factor - */ -export function Factor_mapComments(f: ((arg0: FSharpList) => FSharpList), factor: Factor): Factor { - return new Factor(factor.ID, factor.Name, factor.FactorType, map, FSharpList>(f, factor.Comments)); -} - -/** - * Replaces comments of a factor by given comment list - */ -export function Factor_setComments(factor: Factor, comments: FSharpList): Factor { - return new Factor(factor.ID, factor.Name, factor.FactorType, comments); -} - -/** - * Returns factor type of a factor - */ -export function Factor_getFactorType_E353FDD(factor: Factor): Option { - return factor.FactorType; -} - -/** - * Applies function f on factor type of a factor - */ -export function Factor_mapFactorType(f: ((arg0: OntologyAnnotation) => OntologyAnnotation), factor: Factor): Factor { - return new Factor(factor.ID, factor.Name, map(f, factor.FactorType), factor.Comments); -} - -/** - * Replaces factor type of a factor by given factor type - */ -export function Factor_setFactorType(factor: Factor, factorType: OntologyAnnotation): Factor { - return new Factor(factor.ID, factor.Name, factorType, factor.Comments); -} - -/** - * Returns the name of the factor as string if it exists - */ -export function Factor_tryGetName_E353FDD(f: Factor): Option { - return f.Name; -} - -/** - * Returns the name of the factor as string - */ -export function Factor_getNameAsString_E353FDD(f: Factor): string { - return Factor__get_NameText(f); -} - -/** - * Returns true if the given name matches the name of the factor - */ -export function Factor_nameEqualsString(name: string, f: Factor): boolean { - return Factor__get_NameText(f) === name; -} - diff --git a/ts/ISA/ISA/JsonTypes/FactorValue.ts b/ts/ISA/ISA/JsonTypes/FactorValue.ts deleted file mode 100644 index 29160809..00000000 --- a/ts/ISA/ISA/JsonTypes/FactorValue.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { defaultArg, value as value_3, Option, map } from "../../../fable_modules/fable-library-ts/Option.js"; -import { Factor__SetCategory_2FC95D30, Factor_create_Z3D2B374F, Factor__MapCategory_65D42856, Factor_$reflection, Factor, Factor__get_NameText } from "./Factor.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation, OntologyAnnotation__get_NameText } from "./OntologyAnnotation.js"; -import { IISAPrintable } from "../Printer.js"; -import { Value_$reflection, Value_$union } from "./Value.js"; -import { int32ToString, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { float64 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; - -export class FactorValue extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly Category: Option; - readonly Value: Option; - readonly Unit: Option; - constructor(ID: Option, Category: Option, Value: Option, Unit: Option) { - super(); - this.ID = ID; - this.Category = Category; - this.Value = Value; - this.Unit = Unit; - } - Print(): string { - const this$: FactorValue = this; - return toString(this$); - } - PrintCompact(): string { - let value_2: string, category_2: string, category_1: string, value_1: string; - const this$: FactorValue = this; - const category: Option = map(Factor__get_NameText, this$.Category); - const unit: Option = map(OntologyAnnotation__get_NameText, this$.Unit); - const value: Option = map((v: Value_$union): string => { - const s: string = (v as IISAPrintable).PrintCompact(); - if (unit == null) { - return s; - } - else { - return (s + " ") + value_3(unit); - } - }, this$.Value); - return (category == null) ? ((value == null) ? "" : ((value_2 = value_3(value), value_2))) : ((value == null) ? ((category_2 = value_3(category), (category_2 + ":") + "No Value")) : ((category_1 = value_3(category), (value_1 = value_3(value), (category_1 + ":") + value_1)))); - } -} - -export function FactorValue_$reflection(): TypeInfo { - return record_type("ISA.FactorValue", [], FactorValue, () => [["ID", option_type(string_type)], ["Category", option_type(Factor_$reflection())], ["Value", option_type(Value_$reflection())], ["Unit", option_type(OntologyAnnotation_$reflection())]]); -} - -export function FactorValue_make(id: Option, category: Option, value: Option, unit: Option): FactorValue { - return new FactorValue(id, category, value, unit); -} - -export function FactorValue_create_Z54E26173(Id?: string, Category?: Factor, Value?: Value_$union, Unit?: OntologyAnnotation): FactorValue { - return FactorValue_make(Id, Category, Value, Unit); -} - -export function FactorValue_get_empty(): FactorValue { - return FactorValue_create_Z54E26173(); -} - -export function FactorValue__get_ValueText(this$: FactorValue): string { - return defaultArg(map((oa: Value_$union): string => { - switch (oa.tag) { - case /* Float */ 2: { - const f: float64 = oa.fields[0]; - return f.toString(); - } - case /* Int */ 1: - return int32ToString(oa.fields[0]); - case /* Name */ 3: - return oa.fields[0]; - default: - return OntologyAnnotation__get_NameText(oa.fields[0]); - } - }, this$.Value), ""); -} - -export function FactorValue__get_ValueWithUnitText(this$: FactorValue): string { - const unit: Option = map(OntologyAnnotation__get_NameText, this$.Unit); - const v: string = FactorValue__get_ValueText(this$); - if (unit == null) { - return v; - } - else { - const u: string = value_3(unit); - return toText(printf("%s %s"))(v)(u); - } -} - -export function FactorValue__get_NameText(this$: FactorValue): string { - return defaultArg(map(Factor__get_NameText, this$.Category), ""); -} - -export function FactorValue__MapCategory_65D42856(this$: FactorValue, f: ((arg0: OntologyAnnotation) => OntologyAnnotation)): FactorValue { - return new FactorValue(this$.ID, map((p: Factor): Factor => Factor__MapCategory_65D42856(p, f), this$.Category), this$.Value, this$.Unit); -} - -export function FactorValue__SetCategory_2FC95D30(this$: FactorValue, c: OntologyAnnotation): FactorValue { - let matchValue: Option; - return new FactorValue(this$.ID, (matchValue = this$.Category, (matchValue == null) ? Factor_create_Z3D2B374F(void 0, void 0, c) : Factor__SetCategory_2FC95D30(value_3(matchValue), c)), this$.Value, this$.Unit); -} - -/** - * Returns the name of the factor value as string - */ -export function FactorValue_getNameAsString_2A4175B6(fv: FactorValue): string { - return FactorValue__get_NameText(fv); -} - -/** - * Returns true if the given name matches the name of the factor value - */ -export function FactorValue_nameEqualsString(name: string, fv: FactorValue): boolean { - return FactorValue__get_NameText(fv) === name; -} - diff --git a/ts/ISA/ISA/JsonTypes/Investigation.ts b/ts/ISA/ISA/JsonTypes/Investigation.ts deleted file mode 100644 index 1973c764..00000000 --- a/ts/ISA/ISA/JsonTypes/Investigation.ts +++ /dev/null @@ -1,219 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { map, defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { map as map_1, empty, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologySourceReference_$reflection, OntologySourceReference } from "./OntologySourceReference.js"; -import { Publication_$reflection, Publication } from "./Publication.js"; -import { Person_$reflection, Person } from "./Person.js"; -import { Study_update_Z27CB2981, Study_$reflection, Study } from "./Study.js"; -import { Remark_$reflection, Comment$_$reflection, Remark, Comment$ } from "./Comment.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { mapDefault } from "../OptionExtensions.js"; -import { Update_UpdateOptions_$union } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { toFail } from "../../../fable_modules/fable-library-ts/String.js"; - -export class Investigation extends Record implements IEquatable { - readonly ID: Option; - readonly FileName: Option; - readonly Identifier: Option; - readonly Title: Option; - readonly Description: Option; - readonly SubmissionDate: Option; - readonly PublicReleaseDate: Option; - readonly OntologySourceReferences: Option>; - readonly Publications: Option>; - readonly Contacts: Option>; - readonly Studies: Option>; - readonly Comments: Option>; - readonly Remarks: FSharpList; - constructor(ID: Option, FileName: Option, Identifier: Option, Title: Option, Description: Option, SubmissionDate: Option, PublicReleaseDate: Option, OntologySourceReferences: Option>, Publications: Option>, Contacts: Option>, Studies: Option>, Comments: Option>, Remarks: FSharpList) { - super(); - this.ID = ID; - this.FileName = FileName; - this.Identifier = Identifier; - this.Title = Title; - this.Description = Description; - this.SubmissionDate = SubmissionDate; - this.PublicReleaseDate = PublicReleaseDate; - this.OntologySourceReferences = OntologySourceReferences; - this.Publications = Publications; - this.Contacts = Contacts; - this.Studies = Studies; - this.Comments = Comments; - this.Remarks = Remarks; - } -} - -export function Investigation_$reflection(): TypeInfo { - return record_type("ISA.Investigation", [], Investigation, () => [["ID", option_type(string_type)], ["FileName", option_type(string_type)], ["Identifier", option_type(string_type)], ["Title", option_type(string_type)], ["Description", option_type(string_type)], ["SubmissionDate", option_type(string_type)], ["PublicReleaseDate", option_type(string_type)], ["OntologySourceReferences", option_type(list_type(OntologySourceReference_$reflection()))], ["Publications", option_type(list_type(Publication_$reflection()))], ["Contacts", option_type(list_type(Person_$reflection()))], ["Studies", option_type(list_type(Study_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))], ["Remarks", list_type(Remark_$reflection())]]); -} - -export function Investigation_make(id: Option, filename: Option, identifier: Option, title: Option, description: Option, submissionDate: Option, publicReleaseDate: Option, ontologySourceReference: Option>, publications: Option>, contacts: Option>, studies: Option>, comments: Option>, remarks: FSharpList): Investigation { - return new Investigation(id, filename, identifier, title, description, submissionDate, publicReleaseDate, ontologySourceReference, publications, contacts, studies, comments, remarks); -} - -export function Investigation_create_ZB2B0942(Id?: string, FileName?: string, Identifier?: string, Title?: string, Description?: string, SubmissionDate?: string, PublicReleaseDate?: string, OntologySourceReferences?: FSharpList, Publications?: FSharpList, Contacts?: FSharpList, Studies?: FSharpList, Comments?: FSharpList, Remarks?: FSharpList): Investigation { - return Investigation_make(Id, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, OntologySourceReferences, Publications, Contacts, Studies, Comments, defaultArg(Remarks, empty())); -} - -export function Investigation_get_empty(): Investigation { - return Investigation_create_ZB2B0942(); -} - -/** - * Returns contacts of an investigation - */ -export function Investigation_getContacts_5997CE50(investigation: Investigation): Option> { - return investigation.Contacts; -} - -/** - * Applies function f on person of an investigation - */ -export function Investigation_mapContacts(f: ((arg0: FSharpList) => FSharpList), investigation: Investigation): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, mapDefault>(empty(), f, investigation.Contacts), investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Replaces persons of an investigation with the given person list - */ -export function Investigation_setContacts(investigation: Investigation, persons: FSharpList): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, persons, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Returns publications of an investigation - */ -export function Investigation_getPublications_5997CE50(investigation: Investigation): Option> { - return investigation.Publications; -} - -/** - * Applies function f on publications of an investigation - */ -export function Investigation_mapPublications(f: ((arg0: FSharpList) => FSharpList), investigation: Investigation): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, mapDefault>(empty(), f, investigation.Publications), investigation.Contacts, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Replaces publications of an investigation with the given publication list - */ -export function Investigation_setPublications(investigation: Investigation, publications: FSharpList): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, publications, investigation.Contacts, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Returns ontology source ref of an investigation - */ -export function Investigation_getOntologies_5997CE50(investigation: Investigation): Option> { - return investigation.OntologySourceReferences; -} - -/** - * Applies function f on ontology source ref of an investigation - */ -export function Investigation_mapOntologies(f: ((arg0: FSharpList) => FSharpList), investigation: Investigation): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, mapDefault>(empty(), f, investigation.OntologySourceReferences), investigation.Publications, investigation.Contacts, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Replaces ontology source ref of an investigation with the given ontology source ref list - */ -export function Investigation_setOntologies(investigation: Investigation, ontologies: FSharpList): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, ontologies, investigation.Publications, investigation.Contacts, investigation.Studies, investigation.Comments, investigation.Remarks); -} - -/** - * Returns studies of an investigation - */ -export function Investigation_getStudies_5997CE50(investigation: Investigation): FSharpList { - return defaultArg(investigation.Studies, empty()); -} - -/** - * Applies function f on studies of an investigation - */ -export function Investigation_mapStudies(f: ((arg0: FSharpList) => FSharpList), investigation: Investigation): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, mapDefault>(empty(), f, investigation.Studies), investigation.Comments, investigation.Remarks); -} - -/** - * Replaces studies of an investigation with the given study list - */ -export function Investigation_setStudies(investigation: Investigation, studies: FSharpList): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, studies, investigation.Comments, investigation.Remarks); -} - -/** - * Returns comments of an investigation - */ -export function Investigation_getComments_5997CE50(investigation: Investigation): Option> { - return investigation.Comments; -} - -/** - * Applies function f on comments of an investigation - */ -export function Investigation_mapComments(f: ((arg0: FSharpList) => FSharpList), investigation: Investigation): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, investigation.Studies, mapDefault>(empty(), f, investigation.Comments), investigation.Remarks); -} - -/** - * Replaces comments of an investigation with the given comment list - */ -export function Investigation_setComments(investigation: Investigation, comments: FSharpList): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, investigation.Studies, comments, investigation.Remarks); -} - -/** - * Returns remarks of an investigation - */ -export function Investigation_getRemarks_5997CE50(investigation: Investigation): FSharpList { - return investigation.Remarks; -} - -/** - * Applies function f on remarks of an investigation - */ -export function Investigation_mapRemarks(f: ((arg0: FSharpList) => FSharpList), investigation: Investigation): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, investigation.Studies, investigation.Comments, f(investigation.Remarks)); -} - -/** - * Replaces remarks of an investigation with the given remark list - */ -export function Investigation_setRemarks(investigation: Investigation, remarks: FSharpList): Investigation { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, investigation.Studies, investigation.Comments, remarks); -} - -/** - * Update the investigation with the values of the given newInvestigation - */ -export function Investigation_updateBy(updateOption: Update_UpdateOptions_$union, investigation: Investigation, newInvestigation: Investigation): Investigation { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: Investigation = investigation; - const recordType_2: Investigation = newInvestigation; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Investigation_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Investigation; - case /* UpdateByExisting */ 1: - return makeRecord(Investigation_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Investigation; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Investigation_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Investigation; - default: - return recordType_2; - } -} - -export function Investigation_update_5997CE50(investigation: Investigation): Investigation { - try { - return new Investigation(investigation.ID, investigation.FileName, investigation.Identifier, investigation.Title, investigation.Description, investigation.SubmissionDate, investigation.PublicReleaseDate, investigation.OntologySourceReferences, investigation.Publications, investigation.Contacts, map, FSharpList>((list: FSharpList): FSharpList => map_1(Study_update_Z27CB2981, list), investigation.Studies), investigation.Comments, investigation.Remarks); - } - catch (err: any) { - return toFail(`Could not update investigation ${investigation.Identifier}: -${err.message}`); - } -} - diff --git a/ts/ISA/ISA/JsonTypes/Material.ts b/ts/ISA/ISA/JsonTypes/Material.ts deleted file mode 100644 index 11ba5f89..00000000 --- a/ts/ISA/ISA/JsonTypes/Material.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { choose, FSharpList, empty, length } from "../../../fable_modules/fable-library-ts/List.js"; -import { value as value_1, Option, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { MaterialAttributeValue_$reflection, MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { MaterialType_$reflection, MaterialType__get_AsString, MaterialType_$union } from "./MaterialType.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { IISAPrintable } from "../Printer.js"; -import { record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; - -export class Material extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly Name: Option; - readonly MaterialType: Option; - readonly Characteristics: Option>; - readonly DerivesFrom: Option>; - constructor(ID: Option, Name: Option, MaterialType: Option, Characteristics: Option>, DerivesFrom: Option>) { - super(); - this.ID = ID; - this.Name = Name; - this.MaterialType = MaterialType; - this.Characteristics = Characteristics; - this.DerivesFrom = DerivesFrom; - } - Print(): string { - const this$: Material = this; - return toString(this$); - } - PrintCompact(): string { - const this$: Material = this; - const chars: int32 = length(defaultArg(this$.Characteristics, empty())) | 0; - const matchValue: Option = this$.MaterialType; - if (matchValue == null) { - const arg_3: string = Material__get_NameText(this$); - return toText(printf("%s [%i characteristics]"))(arg_3)(chars); - } - else { - const t: MaterialType_$union = value_1(matchValue); - const arg: string = Material__get_NameText(this$); - const arg_1: string = MaterialType__get_AsString(t); - return toText(printf("%s [%s; %i characteristics]"))(arg)(arg_1)(chars); - } - } -} - -export function Material_$reflection(): TypeInfo { - return record_type("ISA.Material", [], Material, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["MaterialType", option_type(MaterialType_$reflection())], ["Characteristics", option_type(list_type(MaterialAttributeValue_$reflection()))], ["DerivesFrom", option_type(list_type(Material_$reflection()))]]); -} - -export function Material_make(id: Option, name: Option, materialType: Option, characteristics: Option>, derivesFrom: Option>): Material { - return new Material(id, name, materialType, characteristics, derivesFrom); -} - -export function Material_create_76090C97(Id?: string, Name?: string, MaterialType?: MaterialType_$union, Characteristics?: FSharpList, DerivesFrom?: FSharpList): Material { - return Material_make(Id, Name, MaterialType, Characteristics, DerivesFrom); -} - -export function Material_get_empty(): Material { - return Material_create_76090C97(); -} - -export function Material__get_NameText(this$: Material): string { - return defaultArg(this$.Name, ""); -} - -export function Material_getUnits_43A4149B(m: Material): FSharpList { - return choose((c: MaterialAttributeValue): Option => c.Unit, defaultArg(m.Characteristics, empty())); -} - -export function Material_setCharacteristicValues(values: FSharpList, m: Material): Material { - return new Material(m.ID, m.Name, m.MaterialType, values, m.DerivesFrom); -} - diff --git a/ts/ISA/ISA/JsonTypes/MaterialAttribute.ts b/ts/ISA/ISA/JsonTypes/MaterialAttribute.ts deleted file mode 100644 index 59cb60ce..00000000 --- a/ts/ISA/ISA/JsonTypes/MaterialAttribute.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { bind, map, defaultArg, unwrap, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { OntologyAnnotation__get_TryNameText, OntologyAnnotation__get_NameText, OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { IISAPrintable } from "../Printer.js"; -import { record_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Comment$ } from "./Comment.js"; - -export class MaterialAttribute extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly CharacteristicType: Option; - constructor(ID: Option, CharacteristicType: Option) { - super(); - this.ID = ID; - this.CharacteristicType = CharacteristicType; - } - Print(): string { - const this$: MaterialAttribute = this; - return toString(this$); - } - PrintCompact(): string { - const this$: MaterialAttribute = this; - return "OA " + MaterialAttribute__get_NameText(this$); - } -} - -export function MaterialAttribute_$reflection(): TypeInfo { - return record_type("ISA.MaterialAttribute", [], MaterialAttribute, () => [["ID", option_type(string_type)], ["CharacteristicType", option_type(OntologyAnnotation_$reflection())]]); -} - -export function MaterialAttribute_make(id: Option, characteristicType: Option): MaterialAttribute { - return new MaterialAttribute(id, characteristicType); -} - -export function MaterialAttribute_create_2769312B(Id?: string, CharacteristicType?: OntologyAnnotation): MaterialAttribute { - return MaterialAttribute_make(Id, CharacteristicType); -} - -export function MaterialAttribute_get_empty(): MaterialAttribute { - return MaterialAttribute_create_2769312B(); -} - -/** - * Create a ISAJson MaterialAttribute from ISATab string entries - */ -export function MaterialAttribute_fromString_703AFBF9(term: string, source: string, accession: string, comments?: FSharpList): MaterialAttribute { - const oa: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(term, source, accession, unwrap(comments)); - return MaterialAttribute_make(void 0, fromValueWithDefault(OntologyAnnotation_get_empty(), oa)); -} - -/** - * Get ISATab string entries from an ISAJson MaterialAttribute object - */ -export function MaterialAttribute_toString_Z6476E859(ma: MaterialAttribute): { TermAccessionNumber: string, TermName: string, TermSourceREF: string } { - const value: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = { - TermAccessionNumber: "", - TermName: "", - TermSourceREF: "", - }; - return defaultArg(map(OntologyAnnotation_toString_473B9D79, ma.CharacteristicType), value); -} - -/** - * Returns the name of the characteristic as string - */ -export function MaterialAttribute__get_NameText(this$: MaterialAttribute): string { - return defaultArg(map(OntologyAnnotation__get_NameText, this$.CharacteristicType), ""); -} - -/** - * Returns the name of the characteristic as string - */ -export function MaterialAttribute__get_TryNameText(this$: MaterialAttribute): Option { - return bind(OntologyAnnotation__get_TryNameText, this$.CharacteristicType); -} - -export function MaterialAttribute__MapCategory_65D42856(this$: MaterialAttribute, f: ((arg0: OntologyAnnotation) => OntologyAnnotation)): MaterialAttribute { - return new MaterialAttribute(this$.ID, map(f, this$.CharacteristicType)); -} - -export function MaterialAttribute__SetCategory_2FC95D30(this$: MaterialAttribute, c: OntologyAnnotation): MaterialAttribute { - return new MaterialAttribute(this$.ID, c); -} - -/** - * Returns the name of the characteristic as string if it exists - */ -export function MaterialAttribute_tryGetNameText_Z6476E859(ma: MaterialAttribute): string { - return MaterialAttribute__get_NameText(ma); -} - -/** - * Returns the name of the characteristic as string - */ -export function MaterialAttribute_getNameText_Z6476E859(ma: MaterialAttribute): Option { - return MaterialAttribute__get_TryNameText(ma); -} - -/** - * Returns true if the given name matches the name of the characteristic - */ -export function MaterialAttribute_nameEqualsString(name: string, ma: MaterialAttribute): boolean { - return MaterialAttribute__get_NameText(ma) === name; -} - diff --git a/ts/ISA/ISA/JsonTypes/MaterialAttributeValue.ts b/ts/ISA/ISA/JsonTypes/MaterialAttributeValue.ts deleted file mode 100644 index 58920f80..00000000 --- a/ts/ISA/ISA/JsonTypes/MaterialAttributeValue.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { bind, defaultArg, value as value_3, Option, map } from "../../../fable_modules/fable-library-ts/Option.js"; -import { MaterialAttribute__SetCategory_2FC95D30, MaterialAttribute_create_2769312B, MaterialAttribute__MapCategory_65D42856, MaterialAttribute__get_TryNameText, MaterialAttribute_$reflection, MaterialAttribute, MaterialAttribute__get_NameText } from "./MaterialAttribute.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation, OntologyAnnotation__get_NameText } from "./OntologyAnnotation.js"; -import { IISAPrintable } from "../Printer.js"; -import { Value_$reflection, Value_$union } from "./Value.js"; -import { int32ToString, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { float64 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; - -export class MaterialAttributeValue extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly Category: Option; - readonly Value: Option; - readonly Unit: Option; - constructor(ID: Option, Category: Option, Value: Option, Unit: Option) { - super(); - this.ID = ID; - this.Category = Category; - this.Value = Value; - this.Unit = Unit; - } - Print(): string { - const this$: MaterialAttributeValue = this; - return toString(this$); - } - PrintCompact(): string { - let value_2: string, category_2: string, category_1: string, value_1: string; - const this$: MaterialAttributeValue = this; - const category: Option = map(MaterialAttribute__get_NameText, this$.Category); - const unit: Option = map(OntologyAnnotation__get_NameText, this$.Unit); - const value: Option = map((v: Value_$union): string => { - const s: string = (v as IISAPrintable).PrintCompact(); - if (unit == null) { - return s; - } - else { - return (s + " ") + value_3(unit); - } - }, this$.Value); - return (category == null) ? ((value == null) ? "" : ((value_2 = value_3(value), value_2))) : ((value == null) ? ((category_2 = value_3(category), (category_2 + ":") + "No Value")) : ((category_1 = value_3(category), (value_1 = value_3(value), (category_1 + ":") + value_1)))); - } -} - -export function MaterialAttributeValue_$reflection(): TypeInfo { - return record_type("ISA.MaterialAttributeValue", [], MaterialAttributeValue, () => [["ID", option_type(string_type)], ["Category", option_type(MaterialAttribute_$reflection())], ["Value", option_type(Value_$reflection())], ["Unit", option_type(OntologyAnnotation_$reflection())]]); -} - -export function MaterialAttributeValue_make(id: Option, category: Option, value: Option, unit: Option): MaterialAttributeValue { - return new MaterialAttributeValue(id, category, value, unit); -} - -export function MaterialAttributeValue_create_163BDE77(Id?: string, Category?: MaterialAttribute, Value?: Value_$union, Unit?: OntologyAnnotation): MaterialAttributeValue { - return MaterialAttributeValue_make(Id, Category, Value, Unit); -} - -export function MaterialAttributeValue_get_empty(): MaterialAttributeValue { - return MaterialAttributeValue_create_163BDE77(); -} - -/** - * Returns the name of the category as string - */ -export function MaterialAttributeValue__get_NameText(this$: MaterialAttributeValue): string { - return defaultArg(map(MaterialAttribute__get_NameText, this$.Category), ""); -} - -/** - * Returns the name of the category as string - */ -export function MaterialAttributeValue__get_TryNameText(this$: MaterialAttributeValue): Option { - return bind(MaterialAttribute__get_TryNameText, this$.Category); -} - -export function MaterialAttributeValue__get_ValueText(this$: MaterialAttributeValue): string { - return defaultArg(map((oa: Value_$union): string => { - switch (oa.tag) { - case /* Float */ 2: { - const f: float64 = oa.fields[0]; - return f.toString(); - } - case /* Int */ 1: - return int32ToString(oa.fields[0]); - case /* Name */ 3: - return oa.fields[0]; - default: - return OntologyAnnotation__get_NameText(oa.fields[0]); - } - }, this$.Value), ""); -} - -export function MaterialAttributeValue__get_ValueWithUnitText(this$: MaterialAttributeValue): string { - const unit: Option = map(OntologyAnnotation__get_NameText, this$.Unit); - const v: string = MaterialAttributeValue__get_ValueText(this$); - if (unit == null) { - return v; - } - else { - const u: string = value_3(unit); - return toText(printf("%s %s"))(v)(u); - } -} - -export function MaterialAttributeValue__MapCategory_65D42856(this$: MaterialAttributeValue, f: ((arg0: OntologyAnnotation) => OntologyAnnotation)): MaterialAttributeValue { - return new MaterialAttributeValue(this$.ID, map((p: MaterialAttribute): MaterialAttribute => MaterialAttribute__MapCategory_65D42856(p, f), this$.Category), this$.Value, this$.Unit); -} - -export function MaterialAttributeValue__SetCategory_2FC95D30(this$: MaterialAttributeValue, c: OntologyAnnotation): MaterialAttributeValue { - let matchValue: Option; - return new MaterialAttributeValue(this$.ID, (matchValue = this$.Category, (matchValue == null) ? MaterialAttribute_create_2769312B(void 0, c) : MaterialAttribute__SetCategory_2FC95D30(value_3(matchValue), c)), this$.Value, this$.Unit); -} - -/** - * Returns the name of the characteristic value as string if it exists - */ -export function MaterialAttributeValue_tryGetNameText_6A64994C(mv: MaterialAttributeValue): Option { - return MaterialAttributeValue__get_TryNameText(mv); -} - -/** - * Returns the name of the characteristic value as string - */ -export function MaterialAttributeValue_getNameAsString_6A64994C(mv: MaterialAttributeValue): Option { - return MaterialAttributeValue__get_TryNameText(mv); -} - -/** - * Returns true if the given name matches the name of the characteristic value - */ -export function MaterialAttributeValue_nameEqualsString(name: string, mv: MaterialAttributeValue): boolean { - return MaterialAttributeValue__get_NameText(mv) === name; -} - diff --git a/ts/ISA/ISA/JsonTypes/MaterialType.ts b/ts/ISA/ISA/JsonTypes/MaterialType.ts deleted file mode 100644 index 5c09c472..00000000 --- a/ts/ISA/ISA/JsonTypes/MaterialType.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Union } from "../../../fable_modules/fable-library-ts/Types.js"; -import { union_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export type MaterialType_$union = - | MaterialType<0> - | MaterialType<1> - -export type MaterialType_$cases = { - 0: ["ExtractName", []], - 1: ["LabeledExtractName", []] -} - -export function MaterialType_ExtractName() { - return new MaterialType<0>(0, []); -} - -export function MaterialType_LabeledExtractName() { - return new MaterialType<1>(1, []); -} - -export class MaterialType extends Union { - constructor(readonly tag: Tag, readonly fields: MaterialType_$cases[Tag][1]) { - super(); - } - cases() { - return ["ExtractName", "LabeledExtractName"]; - } -} - -export function MaterialType_$reflection(): TypeInfo { - return union_type("ISA.MaterialType", [], MaterialType, () => [[], []]); -} - -export function MaterialType_create_Z721C83C5(t: string): MaterialType_$union { - switch (t) { - case "Extract Name": - return MaterialType_ExtractName(); - case "Labeled Extract Name": - return MaterialType_LabeledExtractName(); - default: - throw new Error("No other value than \"Extract Name\" or \"Labeled Extract Name\" allowed for materialtype"); - } -} - -/** - * Returns the type of the MaterialType - */ -export function MaterialType__get_AsString(this$: MaterialType_$union): string { - if (this$.tag === /* LabeledExtractName */ 1) { - return "Labeled Extract"; - } - else { - return "Extract"; - } -} - diff --git a/ts/ISA/ISA/JsonTypes/OntologyAnnotation.ts b/ts/ISA/ISA/JsonTypes/OntologyAnnotation.ts deleted file mode 100644 index 9c442e23..00000000 --- a/ts/ISA/ISA/JsonTypes/OntologyAnnotation.ts +++ /dev/null @@ -1,354 +0,0 @@ -import { equals, int32ToString, IEquatable, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; -import { float64, int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { value as value_4, map, defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { AnnotationValue_toString_Z3C00A204, AnnotationValue_fromString_Z721C83C5, AnnotationValue_$reflection, AnnotationValue_$union } from "./AnnotationValue.js"; -import { empty, filter, map as map_1, singleton, append, exists, tryFind, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { IISAPrintable } from "../Printer.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { ActivePatterns_$007CRegex$007C_$007C, tryParseTermAnnotation, ActivePatterns_$007CTermAnnotation$007C_$007C } from "../Regex.js"; -import { Update_UpdateOptions_$union } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { mapDefault } from "../OptionExtensions.js"; - -export class OntologyAnnotation extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly Name: Option; - readonly TermSourceREF: Option; - readonly LocalID: Option; - readonly TermAccessionNumber: Option; - readonly Comments: Option>; - constructor(ID: Option, Name: Option, TermSourceREF: Option, LocalID: Option, TermAccessionNumber: Option, Comments: Option>) { - super(); - this.ID = ID; - this.Name = Name; - this.TermSourceREF = TermSourceREF; - this.LocalID = LocalID; - this.TermAccessionNumber = TermAccessionNumber; - this.Comments = Comments; - } - Equals(other: any): boolean { - const this$: OntologyAnnotation = this; - if (other instanceof OntologyAnnotation) { - const oa: OntologyAnnotation = other; - return this$["System.IEquatable`1.Equals2B595"](oa); - } - else if (typeof other === "string") { - const s: string = other; - return ((OntologyAnnotation__get_NameText(this$) === s) ? true : (OntologyAnnotation__get_TermAccessionShort(this$) === s)) ? true : (OntologyAnnotation__get_TermAccessionOntobeeUrl(this$) === s); - } - else { - return false; - } - } - GetHashCode(): int32 { - const this$: OntologyAnnotation = this; - return stringHash(OntologyAnnotation__get_NameText(this$) + OntologyAnnotation__get_TermAccessionShort(this$)) | 0; - } - Print(): string { - const this$: OntologyAnnotation = this; - return toString(this$); - } - PrintCompact(): string { - const this$: OntologyAnnotation = this; - return "OA " + OntologyAnnotation__get_NameText(this$); - } - "System.IEquatable`1.Equals2B595"(other: OntologyAnnotation): boolean { - const this$: OntologyAnnotation = this; - return ((this$.TermAccessionNumber != null) && (other.TermAccessionNumber != null)) ? ((OntologyAnnotation__get_TermAccessionShort(other) === OntologyAnnotation__get_TermAccessionShort(this$)) ? true : (OntologyAnnotation__get_TermAccessionOntobeeUrl(other) === OntologyAnnotation__get_TermAccessionOntobeeUrl(this$))) : (((this$.Name != null) && (other.Name != null)) ? (OntologyAnnotation__get_NameText(other) === OntologyAnnotation__get_NameText(this$)) : ((((this$.TermAccessionNumber == null) && (other.TermAccessionNumber == null)) && (this$.Name == null)) && (other.Name == null))); - } -} - -export function OntologyAnnotation_$reflection(): TypeInfo { - return record_type("ISA.OntologyAnnotation", [], OntologyAnnotation, () => [["ID", option_type(string_type)], ["Name", option_type(AnnotationValue_$reflection())], ["TermSourceREF", option_type(string_type)], ["LocalID", option_type(string_type)], ["TermAccessionNumber", option_type(string_type)], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function OntologyAnnotation_make(id: Option, name: Option, termSourceREF: Option, localID: Option, termAccessionNumber: Option, comments: Option>): OntologyAnnotation { - return new OntologyAnnotation(id, name, termSourceREF, localID, termAccessionNumber, comments); -} - -/** - * This function creates the type exactly as given. If you want a more streamlined approach use `OntologyAnnotation.fromString`. - */ -export function OntologyAnnotation_create_131C8C9D(Id?: string, Name?: AnnotationValue_$union, TermSourceREF?: string, LocalID?: string, TermAccessionNumber?: string, Comments?: FSharpList): OntologyAnnotation { - return OntologyAnnotation_make(Id, Name, TermSourceREF, LocalID, TermAccessionNumber, Comments); -} - -export function OntologyAnnotation_get_empty(): OntologyAnnotation { - return OntologyAnnotation_create_131C8C9D(); -} - -/** - * Returns the name of the ontology as string - */ -export function OntologyAnnotation__get_NameText(this$: OntologyAnnotation): string { - return defaultArg(map((av: AnnotationValue_$union): string => { - switch (av.tag) { - case /* Float */ 1: { - const f: float64 = av.fields[0]; - return f.toString(); - } - case /* Int */ 2: - return int32ToString(av.fields[0]); - default: - return av.fields[0]; - } - }, this$.Name), ""); -} - -/** - * Returns the name of the ontology as string - */ -export function OntologyAnnotation__get_TryNameText(this$: OntologyAnnotation): Option { - return map((av: AnnotationValue_$union): string => { - switch (av.tag) { - case /* Float */ 1: { - const f: float64 = av.fields[0]; - return f.toString(); - } - case /* Int */ 2: - return int32ToString(av.fields[0]); - default: - return av.fields[0]; - } - }, this$.Name); -} - -/** - * Returns the term source of the ontology as string - */ -export function OntologyAnnotation__get_TermSourceREFString(this$: OntologyAnnotation): string { - return defaultArg(this$.TermSourceREF, ""); -} - -/** - * Returns the term accession number of the ontology as string - */ -export function OntologyAnnotation__get_TermAccessionString(this$: OntologyAnnotation): string { - return defaultArg(this$.TermAccessionNumber, ""); -} - -/** - * Create a path in form of `http://purl.obolibrary.org/obo/MS_1000121` from it's Term Accession Source `MS` and Local Term Accession Number `1000121`. - */ -export function OntologyAnnotation_createUriAnnotation(termSourceRef: string, localTAN: string): string { - return `${"http://purl.obolibrary.org/obo/"}${termSourceRef}_${localTAN}`; -} - -/** - * Create a ISAJson Ontology Annotation value from ISATab string entries, will try to reduce `termAccessionNumber` with regex matching. - * - * Exmp. 1: http://purl.obolibrary.org/obo/GO_000001 --> GO:000001 - */ -export function OntologyAnnotation_fromString_Z7D8EB286(term?: string, tsr?: string, tan?: string, comments?: FSharpList): OntologyAnnotation { - let activePatternResult: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }>, tan_1: { LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }; - const patternInput: [Option, Option] = (tan != null) ? ((activePatternResult = ActivePatterns_$007CTermAnnotation$007C_$007C(value_4(tan)), (activePatternResult != null) ? ((tan_1 = value_4(activePatternResult), [(tsr != null) ? tsr : tan_1.TermSourceREF, tan_1.LocalTAN] as [Option, Option])) : ([tsr, void 0] as [Option, Option]))) : ([tsr, void 0] as [Option, Option]); - return OntologyAnnotation_make(void 0, map(AnnotationValue_fromString_Z721C83C5, term), patternInput[0], patternInput[1], tan, comments); -} - -/** - * Will always be created without `OntologyAnnotion.Name` - */ -export function OntologyAnnotation_fromTermAnnotation_Z721C83C5(termAnnotation: string): OntologyAnnotation { - const r: { LocalTAN: string, TermSourceREF: string } = value_4(tryParseTermAnnotation(termAnnotation)); - return OntologyAnnotation_fromString_Z7D8EB286("", r.TermSourceREF, (r.TermSourceREF + ":") + r.LocalTAN); -} - -/** - * Parses any value in `TermAccessionString` to term accession format "termsourceref:localtan". Exmp.: "MS:000001". - * - * If `TermAccessionString` cannot be parsed to this format, returns empty string! - */ -export function OntologyAnnotation__get_TermAccessionShort(this$: OntologyAnnotation): string { - const matchValue: Option = this$.TermSourceREF; - const matchValue_1: Option = this$.LocalID; - let matchResult: int32, id: string, tsr: string; - if (matchValue != null) { - if (matchValue_1 != null) { - matchResult = 0; - id = value_4(matchValue_1); - tsr = value_4(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return `${tsr!}:${id!}`; - default: - return ""; - } -} - -export function OntologyAnnotation__get_TermAccessionOntobeeUrl(this$: OntologyAnnotation): string { - const matchValue: Option = this$.TermSourceREF; - const matchValue_1: Option = this$.LocalID; - let matchResult: int32, id: string, tsr: string; - if (matchValue != null) { - if (matchValue_1 != null) { - matchResult = 0; - id = value_4(matchValue_1); - tsr = value_4(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return OntologyAnnotation_createUriAnnotation(tsr!, id!); - default: - return ""; - } -} - -export function OntologyAnnotation__get_TermAccessionAndOntobeeUrlIfShort(this$: OntologyAnnotation): string { - const matchValue: Option = this$.TermAccessionNumber; - if (matchValue != null) { - const tan: string = value_4(matchValue); - if (ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", tan) != null) { - return OntologyAnnotation__get_TermAccessionOntobeeUrl(this$); - } - else { - return tan; - } - } - else { - return ""; - } -} - -/** - * Get a ISATab string entries from an ISAJson Ontology Annotation object (name,source,accession) - * - * `asOntobeePurlUrl`: option to return term accession in Ontobee purl-url format (`http://purl.obolibrary.org/obo/MS_1000121`) - */ -export function OntologyAnnotation_toString_473B9D79(oa: OntologyAnnotation, asOntobeePurlUrlIfShort?: boolean): { TermAccessionNumber: string, TermName: string, TermSourceREF: string } { - let url: string; - const asOntobeePurlUrlIfShort_1: boolean = defaultArg(asOntobeePurlUrlIfShort, false); - const TermName: string = defaultArg(map(AnnotationValue_toString_Z3C00A204, oa.Name), ""); - const TermSourceREF: string = defaultArg(oa.TermSourceREF, ""); - return { - TermAccessionNumber: asOntobeePurlUrlIfShort_1 ? ((url = OntologyAnnotation__get_TermAccessionAndOntobeeUrlIfShort(oa), (url === "") ? defaultArg(oa.TermAccessionNumber, "") : url)) : defaultArg(oa.TermAccessionNumber, ""), - TermName: TermName, - TermSourceREF: TermSourceREF, - }; -} - -/** - * Returns the name of the ontology as string if it has a name - */ -export function OntologyAnnotation_tryGetNameText_2FC95D30(oa: OntologyAnnotation): Option { - return OntologyAnnotation__get_TryNameText(oa); -} - -/** - * Returns the name of the ontology as string if it has a name - */ -export function OntologyAnnotation_getNameText_2FC95D30(oa: OntologyAnnotation): string { - return OntologyAnnotation__get_NameText(oa); -} - -/** - * Returns true if the given name matches the name of the ontology annotation - */ -export function OntologyAnnotation_nameEqualsString(name: string, oa: OntologyAnnotation): boolean { - return OntologyAnnotation__get_NameText(oa) === name; -} - -/** - * If an ontology annotation with the given annotation value exists in the list, returns it - */ -export function OntologyAnnotation_tryGetByName(name: AnnotationValue_$union, annotations: FSharpList): Option { - return tryFind((d: OntologyAnnotation): boolean => equals(d.Name, name), annotations); -} - -/** - * If a ontology annotation with the given annotation value exists in the list, returns true - */ -export function OntologyAnnotation_existsByName(name: AnnotationValue_$union, annotations: FSharpList): boolean { - return exists((d: OntologyAnnotation): boolean => equals(d.Name, name), annotations); -} - -/** - * Adds the given ontology annotation to the Study.StudyDesignDescriptors - */ -export function OntologyAnnotation_add(onotolgyAnnotations: FSharpList, onotolgyAnnotation: OntologyAnnotation): FSharpList { - return append(onotolgyAnnotations, singleton(onotolgyAnnotation)); -} - -/** - * Updates all ontology annotations for which the predicate returns true with the given ontology annotations values - */ -export function OntologyAnnotation_updateBy(predicate: ((arg0: OntologyAnnotation) => boolean), updateOption: Update_UpdateOptions_$union, design: OntologyAnnotation, annotations: FSharpList): FSharpList { - if (exists(predicate, annotations)) { - return map_1((d: OntologyAnnotation): OntologyAnnotation => { - if (predicate(d)) { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: OntologyAnnotation = d; - const recordType_2: OntologyAnnotation = design; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(OntologyAnnotation_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as OntologyAnnotation; - case /* UpdateByExisting */ 1: - return makeRecord(OntologyAnnotation_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as OntologyAnnotation; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(OntologyAnnotation_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as OntologyAnnotation; - default: - return recordType_2; - } - } - else { - return d; - } - }, annotations); - } - else { - return annotations; - } -} - -/** - * If an ontology annotation with the same annotation value as the given annotation value exists in the list, updates it with the given ontology annotation - */ -export function OntologyAnnotation_updateByName(updateOption: Update_UpdateOptions_$union, design: OntologyAnnotation, annotations: FSharpList): FSharpList { - return OntologyAnnotation_updateBy((f: OntologyAnnotation): boolean => equals(f.Name, design.Name), updateOption, design, annotations); -} - -/** - * If a ontology annotation with the annotation value exists in the list, removes it - */ -export function OntologyAnnotation_removeByName(name: AnnotationValue_$union, annotations: FSharpList): FSharpList { - return filter((d: OntologyAnnotation): boolean => !equals(d.Name, name), annotations); -} - -/** - * Returns comments of a ontology annotation - */ -export function OntologyAnnotation_getComments_2FC95D30(annotation: OntologyAnnotation): Option> { - return annotation.Comments; -} - -/** - * Applies function f on comments of a ontology annotation - */ -export function OntologyAnnotation_mapComments(f: ((arg0: FSharpList) => FSharpList), annotation: OntologyAnnotation): OntologyAnnotation { - return new OntologyAnnotation(annotation.ID, annotation.Name, annotation.TermSourceREF, annotation.LocalID, annotation.TermAccessionNumber, mapDefault>(empty(), f, annotation.Comments)); -} - -/** - * Replaces comments of a ontology annotation by given comment list - */ -export function OntologyAnnotation_setComments(annotation: OntologyAnnotation, comments: FSharpList): OntologyAnnotation { - return new OntologyAnnotation(annotation.ID, annotation.Name, annotation.TermSourceREF, annotation.LocalID, annotation.TermAccessionNumber, comments); -} - diff --git a/ts/ISA/ISA/JsonTypes/OntologySourceReference.ts b/ts/ISA/ISA/JsonTypes/OntologySourceReference.ts deleted file mode 100644 index 4ed6c138..00000000 --- a/ts/ISA/ISA/JsonTypes/OntologySourceReference.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { empty, filter, map, singleton, append, exists, tryFind, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { equals, IComparable, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Update_UpdateOptions_$union } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { mapDefault } from "../OptionExtensions.js"; - -export class OntologySourceReference extends Record implements IEquatable, IComparable { - readonly Description: Option; - readonly File: Option; - readonly Name: Option; - readonly Version: Option; - readonly Comments: Option>; - constructor(Description: Option, File: Option, Name: Option, Version: Option, Comments: Option>) { - super(); - this.Description = Description; - this.File = File; - this.Name = Name; - this.Version = Version; - this.Comments = Comments; - } -} - -export function OntologySourceReference_$reflection(): TypeInfo { - return record_type("ISA.OntologySourceReference", [], OntologySourceReference, () => [["Description", option_type(string_type)], ["File", option_type(string_type)], ["Name", option_type(string_type)], ["Version", option_type(string_type)], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function OntologySourceReference_make(description: Option, file: Option, name: Option, version: Option, comments: Option>): OntologySourceReference { - return new OntologySourceReference(description, file, name, version, comments); -} - -export function OntologySourceReference_create_55205B02(Description?: string, File?: string, Name?: string, Version?: string, Comments?: FSharpList): OntologySourceReference { - return OntologySourceReference_make(Description, File, Name, Version, Comments); -} - -export function OntologySourceReference_get_empty(): OntologySourceReference { - return OntologySourceReference_create_55205B02(); -} - -/** - * If an ontology source reference with the given name exists in the list, returns it - */ -export function OntologySourceReference_tryGetByName(name: string, ontologies: FSharpList): Option { - return tryFind((t: OntologySourceReference): boolean => equals(t.Name, name), ontologies); -} - -/** - * If an ontology source reference with the given name exists in the list, returns true - */ -export function OntologySourceReference_existsByName(name: string, ontologies: FSharpList): boolean { - return exists((t: OntologySourceReference): boolean => equals(t.Name, name), ontologies); -} - -/** - * Adds the given ontology source reference to the investigation - */ -export function OntologySourceReference_add(ontologySourceReference: OntologySourceReference, ontologies: FSharpList): FSharpList { - return append(ontologies, singleton(ontologySourceReference)); -} - -/** - * Updates all ontology source references for which the predicate returns true with the given ontology source reference values - */ -export function OntologySourceReference_updateBy(predicate: ((arg0: OntologySourceReference) => boolean), updateOption: Update_UpdateOptions_$union, ontologySourceReference: OntologySourceReference, ontologies: FSharpList): FSharpList { - if (exists(predicate, ontologies)) { - return map((t: OntologySourceReference): OntologySourceReference => { - if (predicate(t)) { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: OntologySourceReference = t; - const recordType_2: OntologySourceReference = ontologySourceReference; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(OntologySourceReference_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as OntologySourceReference; - case /* UpdateByExisting */ 1: - return makeRecord(OntologySourceReference_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as OntologySourceReference; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(OntologySourceReference_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as OntologySourceReference; - default: - return recordType_2; - } - } - else { - return t; - } - }, ontologies); - } - else { - return ontologies; - } -} - -/** - * If an ontology source reference with the same name as the given name exists in the investigation, updates it with the given ontology source reference - */ -export function OntologySourceReference_updateByName(updateOption: Update_UpdateOptions_$union, ontologySourceReference: OntologySourceReference, ontologies: FSharpList): FSharpList { - return OntologySourceReference_updateBy((t: OntologySourceReference): boolean => equals(t.Name, ontologySourceReference.Name), updateOption, ontologySourceReference, ontologies); -} - -/** - * If a ontology source reference with the given name exists in the list, removes it - */ -export function OntologySourceReference_removeByName(name: string, ontologies: FSharpList): FSharpList { - return filter((t: OntologySourceReference): boolean => !equals(t.Name, name), ontologies); -} - -/** - * Returns comments of ontology source ref - */ -export function OntologySourceReference_getComments_Z68D7813F(ontology: OntologySourceReference): Option> { - return ontology.Comments; -} - -/** - * Applies function f on comments in ontology source ref - */ -export function OntologySourceReference_mapComments(f: ((arg0: FSharpList) => FSharpList), ontology: OntologySourceReference): OntologySourceReference { - return new OntologySourceReference(ontology.Description, ontology.File, ontology.Name, ontology.Version, mapDefault>(empty(), f, ontology.Comments)); -} - -/** - * Replaces comments in ontology source ref by given comment list - */ -export function OntologySourceReference_setComments(ontology: OntologySourceReference, comments: FSharpList): OntologySourceReference { - return new OntologySourceReference(ontology.Description, ontology.File, ontology.Name, ontology.Version, comments); -} - diff --git a/ts/ISA/ISA/JsonTypes/Person.ts b/ts/ISA/ISA/JsonTypes/Person.ts deleted file mode 100644 index e1e41ee5..00000000 --- a/ts/ISA/ISA/JsonTypes/Person.ts +++ /dev/null @@ -1,168 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { empty, filter, map, singleton, append, exists, tryFind, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { equals, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Update_UpdateOptions_$union } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { mapDefault } from "../OptionExtensions.js"; - -export class Person extends Record implements IEquatable { - readonly ID: Option; - readonly LastName: Option; - readonly FirstName: Option; - readonly MidInitials: Option; - readonly EMail: Option; - readonly Phone: Option; - readonly Fax: Option; - readonly Address: Option; - readonly Affiliation: Option; - readonly Roles: Option>; - readonly Comments: Option>; - constructor(ID: Option, LastName: Option, FirstName: Option, MidInitials: Option, EMail: Option, Phone: Option, Fax: Option, Address: Option, Affiliation: Option, Roles: Option>, Comments: Option>) { - super(); - this.ID = ID; - this.LastName = LastName; - this.FirstName = FirstName; - this.MidInitials = MidInitials; - this.EMail = EMail; - this.Phone = Phone; - this.Fax = Fax; - this.Address = Address; - this.Affiliation = Affiliation; - this.Roles = Roles; - this.Comments = Comments; - } -} - -export function Person_$reflection(): TypeInfo { - return record_type("ISA.Person", [], Person, () => [["ID", option_type(string_type)], ["LastName", option_type(string_type)], ["FirstName", option_type(string_type)], ["MidInitials", option_type(string_type)], ["EMail", option_type(string_type)], ["Phone", option_type(string_type)], ["Fax", option_type(string_type)], ["Address", option_type(string_type)], ["Affiliation", option_type(string_type)], ["Roles", option_type(list_type(OntologyAnnotation_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Person_make(id: Option, lastName: Option, firstName: Option, midInitials: Option, email: Option, phone: Option, fax: Option, address: Option, affiliation: Option, roles: Option>, comments: Option>): Person { - return new Person(id, lastName, firstName, midInitials, email, phone, fax, address, affiliation, roles, comments); -} - -export function Person_create_28E835CB(Id?: string, LastName?: string, FirstName?: string, MidInitials?: string, Email?: string, Phone?: string, Fax?: string, Address?: string, Affiliation?: string, Roles?: FSharpList, Comments?: FSharpList): Person { - return Person_make(Id, LastName, FirstName, MidInitials, Email, Phone, Fax, Address, Affiliation, Roles, Comments); -} - -export function Person_get_empty(): Person { - return Person_create_28E835CB(); -} - -export function Person_tryGetByFullName(firstName: string, midInitials: string, lastName: string, persons: FSharpList): Option { - return tryFind((p: Person): boolean => ((midInitials === "") ? (equals(p.FirstName, firstName) && equals(p.LastName, lastName)) : ((equals(p.FirstName, firstName) && equals(p.MidInitials, midInitials)) && equals(p.LastName, lastName))), persons); -} - -/** - * If an person with the given FirstName, MidInitials and LastName exists in the list, returns true - */ -export function Person_existsByFullName(firstName: string, midInitials: string, lastName: string, persons: FSharpList): boolean { - return exists((p: Person): boolean => ((midInitials === "") ? (equals(p.FirstName, firstName) && equals(p.LastName, lastName)) : ((equals(p.FirstName, firstName) && equals(p.MidInitials, midInitials)) && equals(p.LastName, lastName))), persons); -} - -/** - * adds the given person to the persons - */ -export function Person_add(persons: FSharpList, person: Person): FSharpList { - return append(persons, singleton(person)); -} - -/** - * Updates all persons for which the predicate returns true with the given person values - */ -export function Person_updateBy(predicate: ((arg0: Person) => boolean), updateOption: Update_UpdateOptions_$union, person: Person, persons: FSharpList): FSharpList { - if (exists(predicate, persons)) { - return map((p: Person): Person => { - if (predicate(p)) { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: Person = p; - const recordType_2: Person = person; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Person_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Person; - case /* UpdateByExisting */ 1: - return makeRecord(Person_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Person; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Person_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Person; - default: - return recordType_2; - } - } - else { - return p; - } - }, persons); - } - else { - return persons; - } -} - -/** - * Updates all persons with the same FirstName, MidInitials and LastName as the given person with its values - */ -export function Person_updateByFullName(updateOption: Update_UpdateOptions_$union, person: Person, persons: FSharpList): FSharpList { - return Person_updateBy((p: Person): boolean => { - if (equals(p.FirstName, person.FirstName) && equals(p.MidInitials, person.MidInitials)) { - return equals(p.LastName, person.LastName); - } - else { - return false; - } - }, updateOption, person, persons); -} - -/** - * If a person with the given FirstName, MidInitials and LastName exists in the list, removes it - */ -export function Person_removeByFullName(firstName: string, midInitials: string, lastName: string, persons: FSharpList): FSharpList { - return filter((p: Person): boolean => ((midInitials === "") ? !(equals(p.FirstName, firstName) && equals(p.LastName, lastName)) : !((equals(p.FirstName, firstName) && equals(p.MidInitials, midInitials)) && equals(p.LastName, lastName))), persons); -} - -/** - * Returns roles of a person - */ -export function Person_getRoles_Z2DD38D1B(person: Person): Option> { - return person.Roles; -} - -/** - * Applies function f on roles of a person - */ -export function Person_mapRoles(f: ((arg0: FSharpList) => FSharpList), person: Person): Person { - return new Person(person.ID, person.LastName, person.FirstName, person.MidInitials, person.EMail, person.Phone, person.Fax, person.Address, person.Affiliation, mapDefault>(empty(), f, person.Roles), person.Comments); -} - -/** - * Replaces roles of a person with the given roles - */ -export function Person_setRoles(person: Person, roles: FSharpList): Person { - return new Person(person.ID, person.LastName, person.FirstName, person.MidInitials, person.EMail, person.Phone, person.Fax, person.Address, person.Affiliation, roles, person.Comments); -} - -/** - * Returns comments of a person - */ -export function Person_getComments_Z2DD38D1B(person: Person): Option> { - return person.Comments; -} - -/** - * Applies function f on comments of a person - */ -export function Person_mapComments(f: ((arg0: FSharpList) => FSharpList), person: Person): Person { - return new Person(person.ID, person.LastName, person.FirstName, person.MidInitials, person.EMail, person.Phone, person.Fax, person.Address, person.Affiliation, person.Roles, mapDefault>(empty(), f, person.Comments)); -} - -/** - * Replaces comments of a person by given comment list - */ -export function Person_setComments(person: Person, comments: FSharpList): Person { - return new Person(person.ID, person.LastName, person.FirstName, person.MidInitials, person.EMail, person.Phone, person.Fax, person.Address, person.Affiliation, person.Roles, comments); -} - diff --git a/ts/ISA/ISA/JsonTypes/Process.ts b/ts/ISA/ISA/JsonTypes/Process.ts deleted file mode 100644 index 3d38344a..00000000 --- a/ts/ISA/ISA/JsonTypes/Process.ts +++ /dev/null @@ -1,423 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { zip, tryPick, map as map_1, tryFind, append, collect, choose, FSharpList, empty, length } from "../../../fable_modules/fable-library-ts/List.js"; -import { map, value as value_4, bind, Option, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { ProcessInput_tryMaterial_Z38E7E853, ProcessInput_trySample_Z38E7E853, ProcessInput_tryData_Z38E7E853, ProcessInput_trySource_Z38E7E853, ProcessInput_tryGetCharacteristicValues_Z38E7E853, ProcessInput_$reflection, ProcessInput_$union } from "./ProcessInput.js"; -import { parse, int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { ProcessOutput_tryGetFactorValues_Z4A02997C, ProcessOutput_tryGetCharacteristicValues_Z4A02997C, ProcessOutput_$reflection, ProcessOutput_$union } from "./ProcessOutput.js"; -import { ProcessParameterValue_$reflection, ProcessParameterValue } from "./ProcessParameterValue.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; -import { Protocol_$reflection, Protocol } from "./Protocol.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { safeHash, equals, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { IISAPrintable } from "../Printer.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { create, match } from "../../../fable_modules/fable-library-ts/RegExp.js"; -import { ProtocolParameter_get_empty, ProtocolParameter } from "./ProtocolParameter.js"; -import { MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { MaterialAttribute } from "./MaterialAttribute.js"; -import { FactorValue } from "./FactorValue.js"; -import { Factor } from "./Factor.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { Source } from "./Source.js"; -import { Data } from "./Data.js"; -import { Sample } from "./Sample.js"; -import { Material } from "./Material.js"; -import { Update_UpdateOptions_$union, Update_UpdateOptions_UpdateByExistingAppendLists } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; - -export class Process extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly Name: Option; - readonly ExecutesProtocol: Option; - readonly ParameterValues: Option>; - readonly Performer: Option; - readonly Date: Option; - readonly PreviousProcess: Option; - readonly NextProcess: Option; - readonly Inputs: Option>; - readonly Outputs: Option>; - readonly Comments: Option>; - constructor(ID: Option, Name: Option, ExecutesProtocol: Option, ParameterValues: Option>, Performer: Option, Date$: Option, PreviousProcess: Option, NextProcess: Option, Inputs: Option>, Outputs: Option>, Comments: Option>) { - super(); - this.ID = ID; - this.Name = Name; - this.ExecutesProtocol = ExecutesProtocol; - this.ParameterValues = ParameterValues; - this.Performer = Performer; - this.Date = Date$; - this.PreviousProcess = PreviousProcess; - this.NextProcess = NextProcess; - this.Inputs = Inputs; - this.Outputs = Outputs; - this.Comments = Comments; - } - Print(): string { - const this$: Process = this; - return toString(this$); - } - PrintCompact(): string { - const this$: Process = this; - const inputCount: int32 = length(defaultArg(this$.Inputs, empty())) | 0; - const outputCount: int32 = length(defaultArg(this$.Outputs, empty())) | 0; - const paramCount: int32 = length(defaultArg(this$.ParameterValues, empty())) | 0; - const name: string = defaultArg(this$.Name, "Unnamed Process"); - return toText(printf("%s [%i Inputs -> %i Params -> %i Outputs]"))(name)(inputCount)(paramCount)(outputCount); - } -} - -export function Process_$reflection(): TypeInfo { - return record_type("ISA.Process", [], Process, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["ExecutesProtocol", option_type(Protocol_$reflection())], ["ParameterValues", option_type(list_type(ProcessParameterValue_$reflection()))], ["Performer", option_type(string_type)], ["Date", option_type(string_type)], ["PreviousProcess", option_type(Process_$reflection())], ["NextProcess", option_type(Process_$reflection())], ["Inputs", option_type(list_type(ProcessInput_$reflection()))], ["Outputs", option_type(list_type(ProcessOutput_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Process_make(id: Option, name: Option, executesProtocol: Option, parameterValues: Option>, performer: Option, date: Option, previousProcess: Option, nextProcess: Option, inputs: Option>, outputs: Option>, comments: Option>): Process { - return new Process(id, name, executesProtocol, parameterValues, performer, date, previousProcess, nextProcess, inputs, outputs, comments); -} - -export function Process_create_236DF576(Id?: string, Name?: string, ExecutesProtocol?: Protocol, ParameterValues?: FSharpList, Performer?: string, Date$?: string, PreviousProcess?: Process, NextProcess?: Process, Inputs?: FSharpList, Outputs?: FSharpList, Comments?: FSharpList): Process { - return Process_make(Id, Name, ExecutesProtocol, ParameterValues, Performer, Date$, PreviousProcess, NextProcess, Inputs, Outputs, Comments); -} - -export function Process_get_empty(): Process { - return Process_create_236DF576(); -} - -export function Process_composeName(processNameRoot: string, i: int32): string { - return `${processNameRoot}_${i}`; -} - -export function Process_decomposeName_Z721C83C5(name: string): [string, Option] { - const r: any = match(create("(?.+)_(?\\d+)"), name); - if (r != null) { - return [(r.groups && r.groups.name) || "", parse((r.groups && r.groups.num) || "", 511, false, 32)] as [string, Option]; - } - else { - return [name, void 0] as [string, Option]; - } -} - -/** - * Returns the name of the protocol the given process executes - */ -export function Process_tryGetProtocolName_30EF9E7B(p: Process): Option { - return bind((p_1: Protocol): Option => p_1.Name, p.ExecutesProtocol); -} - -/** - * Returns the name of the protocol the given process executes - */ -export function Process_getProtocolName_30EF9E7B(p: Process): string { - return value_4(bind((p_1: Protocol): Option => p_1.Name, p.ExecutesProtocol)); -} - -/** - * Returns the parameter values describing the process - */ -export function Process_getParameterValues_30EF9E7B(p: Process): FSharpList { - return defaultArg(p.ParameterValues, empty()); -} - -/** - * Returns the parameters describing the process - */ -export function Process_getParameters_30EF9E7B(p: Process): FSharpList { - return choose((pv: ProcessParameterValue): Option => pv.Category, Process_getParameterValues_30EF9E7B(p)); -} - -/** - * Returns the characteristics describing the inputs of the process - */ -export function Process_getInputCharacteristicValues_30EF9E7B(p: Process): FSharpList { - const matchValue: Option> = p.Inputs; - if (matchValue == null) { - return empty(); - } - else { - return List_distinct(collect((inp: ProcessInput_$union): FSharpList => defaultArg(ProcessInput_tryGetCharacteristicValues_Z38E7E853(inp), empty()), value_4(matchValue)), { - Equals: equals, - GetHashCode: safeHash, - }); - } -} - -/** - * Returns the characteristics describing the outputs of the process - */ -export function Process_getOutputCharacteristicValues_30EF9E7B(p: Process): FSharpList { - const matchValue: Option> = p.Outputs; - if (matchValue == null) { - return empty(); - } - else { - return List_distinct(collect((out: ProcessOutput_$union): FSharpList => defaultArg(ProcessOutput_tryGetCharacteristicValues_Z4A02997C(out), empty()), value_4(matchValue)), { - Equals: equals, - GetHashCode: safeHash, - }); - } -} - -/** - * Returns the characteristic values describing the inputs and outputs of the process - */ -export function Process_getCharacteristicValues_30EF9E7B(p: Process): FSharpList { - return List_distinct(append(Process_getInputCharacteristicValues_30EF9E7B(p), Process_getOutputCharacteristicValues_30EF9E7B(p)), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the characteristics describing the inputs and outputs of the process - */ -export function Process_getCharacteristics_30EF9E7B(p: Process): FSharpList { - return List_distinct(choose((cv: MaterialAttributeValue): Option => cv.Category, Process_getCharacteristicValues_30EF9E7B(p)), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the factor values of the samples of the process - */ -export function Process_getFactorValues_30EF9E7B(p: Process): FSharpList { - return List_distinct(collect((arg_1: ProcessOutput_$union): FSharpList => defaultArg(ProcessOutput_tryGetFactorValues_Z4A02997C(arg_1), empty()), defaultArg(p.Outputs, empty())), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the factors of the samples of the process - */ -export function Process_getFactors_30EF9E7B(p: Process): FSharpList { - return List_distinct(choose((fv: FactorValue): Option => fv.Category, Process_getFactorValues_30EF9E7B(p)), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the units of the process - */ -export function Process_getUnits_30EF9E7B(p: Process): FSharpList { - return append(choose((cv: MaterialAttributeValue): Option => cv.Unit, Process_getCharacteristicValues_30EF9E7B(p)), append(choose((pv: ProcessParameterValue): Option => pv.Unit, Process_getParameterValues_30EF9E7B(p)), choose((fv: FactorValue): Option => fv.Unit, Process_getFactorValues_30EF9E7B(p)))); -} - -/** - * If the process implements the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function Process_tryGetInputsWithParameterBy(predicate: ((arg0: ProtocolParameter) => boolean), p: Process): Option> { - const matchValue: Option> = p.ParameterValues; - if (matchValue == null) { - return void 0; - } - else { - const matchValue_1: Option = tryFind((pv: ProcessParameterValue): boolean => predicate(defaultArg(pv.Category, ProtocolParameter_get_empty())), value_4(matchValue)); - if (matchValue_1 == null) { - return void 0; - } - else { - const paramValue: ProcessParameterValue = value_4(matchValue_1); - return map, FSharpList<[ProcessInput_$union, ProcessParameterValue]>>((list_1: FSharpList): FSharpList<[ProcessInput_$union, ProcessParameterValue]> => map_1((i: ProcessInput_$union): [ProcessInput_$union, ProcessParameterValue] => ([i, paramValue] as [ProcessInput_$union, ProcessParameterValue]), list_1), p.Inputs); - } - } -} - -/** - * If the process implements the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function Process_tryGetOutputsWithParameterBy(predicate: ((arg0: ProtocolParameter) => boolean), p: Process): Option> { - const matchValue: Option> = p.ParameterValues; - if (matchValue == null) { - return void 0; - } - else { - const matchValue_1: Option = tryFind((pv: ProcessParameterValue): boolean => predicate(defaultArg(pv.Category, ProtocolParameter_get_empty())), value_4(matchValue)); - if (matchValue_1 == null) { - return void 0; - } - else { - const paramValue: ProcessParameterValue = value_4(matchValue_1); - return map, FSharpList<[ProcessOutput_$union, ProcessParameterValue]>>((list_1: FSharpList): FSharpList<[ProcessOutput_$union, ProcessParameterValue]> => map_1((i: ProcessOutput_$union): [ProcessOutput_$union, ProcessParameterValue] => ([i, paramValue] as [ProcessOutput_$union, ProcessParameterValue]), list_1), p.Outputs); - } - } -} - -/** - * If the process implements the given characteristic, return the list of input files together with their according characteristic values of this characteristic - */ -export function Process_tryGetInputsWithCharacteristicBy(predicate: ((arg0: MaterialAttribute) => boolean), p: Process): Option> { - const matchValue: Option> = p.Inputs; - if (matchValue == null) { - return void 0; - } - else { - return fromValueWithDefault>(empty<[ProcessInput_$union, MaterialAttributeValue]>(), choose((i: ProcessInput_$union): Option<[ProcessInput_$union, MaterialAttributeValue]> => tryPick((mv: MaterialAttributeValue): Option<[ProcessInput_$union, MaterialAttributeValue]> => { - const matchValue_1: Option = mv.Category; - let matchResult: int32, m_1: MaterialAttribute; - if (matchValue_1 != null) { - if (predicate(value_4(matchValue_1))) { - matchResult = 0; - m_1 = value_4(matchValue_1); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return [i, mv] as [ProcessInput_$union, MaterialAttributeValue]; - default: - return void 0; - } - }, defaultArg(ProcessInput_tryGetCharacteristicValues_Z38E7E853(i), empty())), value_4(matchValue))); - } -} - -/** - * If the process implements the given characteristic, return the list of output files together with their according characteristic values of this characteristic - */ -export function Process_tryGetOutputsWithCharacteristicBy(predicate: ((arg0: MaterialAttribute) => boolean), p: Process): Option> { - const matchValue: Option> = p.Inputs; - const matchValue_1: Option> = p.Outputs; - let matchResult: int32, is: FSharpList, os: FSharpList; - if (matchValue != null) { - if (matchValue_1 != null) { - matchResult = 0; - is = value_4(matchValue); - os = value_4(matchValue_1); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return fromValueWithDefault>(empty<[ProcessOutput_$union, MaterialAttributeValue]>(), choose<[ProcessInput_$union, ProcessOutput_$union], [ProcessOutput_$union, MaterialAttributeValue]>((tupledArg: [ProcessInput_$union, ProcessOutput_$union]): Option<[ProcessOutput_$union, MaterialAttributeValue]> => tryPick((mv: MaterialAttributeValue): Option<[ProcessOutput_$union, MaterialAttributeValue]> => { - const matchValue_3: Option = mv.Category; - let matchResult_1: int32, m_1: MaterialAttribute; - if (matchValue_3 != null) { - if (predicate(value_4(matchValue_3))) { - matchResult_1 = 0; - m_1 = value_4(matchValue_3); - } - else { - matchResult_1 = 1; - } - } - else { - matchResult_1 = 1; - } - switch (matchResult_1) { - case 0: - return [tupledArg[1], mv] as [ProcessOutput_$union, MaterialAttributeValue]; - default: - return void 0; - } - }, defaultArg(ProcessInput_tryGetCharacteristicValues_Z38E7E853(tupledArg[0]), empty())), zip(is!, os!))); - default: - return void 0; - } -} - -/** - * If the process implements the given factor, return the list of output files together with their according factor values of this factor - */ -export function Process_tryGetOutputsWithFactorBy(predicate: ((arg0: Factor) => boolean), p: Process): Option> { - const matchValue: Option> = p.Outputs; - if (matchValue == null) { - return void 0; - } - else { - return fromValueWithDefault>(empty<[ProcessOutput_$union, FactorValue]>(), choose((o: ProcessOutput_$union): Option<[ProcessOutput_$union, FactorValue]> => tryPick((mv: FactorValue): Option<[ProcessOutput_$union, FactorValue]> => { - const matchValue_1: Option = mv.Category; - let matchResult: int32, m_1: Factor; - if (matchValue_1 != null) { - if (predicate(value_4(matchValue_1))) { - matchResult = 0; - m_1 = value_4(matchValue_1); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return [o, mv] as [ProcessOutput_$union, FactorValue]; - default: - return void 0; - } - }, defaultArg(ProcessOutput_tryGetFactorValues_Z4A02997C(o), empty())), value_4(matchValue))); - } -} - -export function Process_getSources_30EF9E7B(p: Process): FSharpList { - return List_distinct(choose(ProcessInput_trySource_Z38E7E853, defaultArg(p.Inputs, empty())), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function Process_getData_30EF9E7B(p: Process): FSharpList { - return List_distinct(append(choose(ProcessInput_tryData_Z38E7E853, defaultArg(p.Inputs, empty())), choose(ProcessInput_tryData_Z38E7E853, defaultArg(p.Inputs, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function Process_getSamples_30EF9E7B(p: Process): FSharpList { - return List_distinct(append(choose(ProcessInput_trySample_Z38E7E853, defaultArg(p.Inputs, empty())), choose(ProcessInput_trySample_Z38E7E853, defaultArg(p.Inputs, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function Process_getMaterials_30EF9E7B(p: Process): FSharpList { - return List_distinct(append(choose(ProcessInput_tryMaterial_Z38E7E853, defaultArg(p.Inputs, empty())), choose(ProcessInput_tryMaterial_Z38E7E853, defaultArg(p.Inputs, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function Process_updateProtocol(referenceProtocols: FSharpList, p: Process): Process { - let this$: Update_UpdateOptions_$union, recordType_1: Protocol, recordType_2: Protocol; - const matchValue: Option = p.ExecutesProtocol; - let matchResult: int32, protocol_1: Protocol; - if (matchValue != null) { - if (value_4(matchValue).Name != null) { - matchResult = 0; - protocol_1 = value_4(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: { - const matchValue_1: Option = tryFind((prot: Protocol): boolean => (value_4(prot.Name) === defaultArg(protocol_1!.Name, "")), referenceProtocols); - if (matchValue_1 != null) { - return new Process(p.ID, p.Name, (this$ = Update_UpdateOptions_UpdateByExistingAppendLists(), (recordType_1 = protocol_1!, (recordType_2 = value_4(matchValue_1), (this$.tag === /* UpdateAllAppendLists */ 2) ? (makeRecord(Protocol_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol) : ((this$.tag === /* UpdateByExisting */ 1) ? (makeRecord(Protocol_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol) : ((this$.tag === /* UpdateByExistingAppendLists */ 3) ? (makeRecord(Protocol_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol) : recordType_2))))), p.ParameterValues, p.Performer, p.Date, p.PreviousProcess, p.NextProcess, p.Inputs, p.Outputs, p.Comments); - } - else { - return p; - } - } - default: - return p; - } -} - diff --git a/ts/ISA/ISA/JsonTypes/ProcessInput.ts b/ts/ISA/ISA/JsonTypes/ProcessInput.ts deleted file mode 100644 index 451f6dce..00000000 --- a/ts/ISA/ISA/JsonTypes/ProcessInput.ts +++ /dev/null @@ -1,333 +0,0 @@ -import { Union, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { Source_create_Z32235993, Source_getUnits_Z220A6393, Source_setCharacteristicValues, Source_get_empty, Source_$reflection, Source } from "./Source.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; -import { Material_create_76090C97, Material_getUnits_43A4149B, Material_setCharacteristicValues, Material_$reflection, Material } from "./Material.js"; -import { Data_create_Z748D099, Data_$reflection, Data } from "./Data.js"; -import { Sample_create_3A6378D6, Sample_getUnits_Z23050B6A, Sample_setCharacteristicValues, Sample_$reflection, Sample } from "./Sample.js"; -import { IISAPrintable } from "../Printer.js"; -import { union_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { unwrap, map, defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { empty, choose, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { MaterialAttribute } from "./MaterialAttribute.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; -import { FactorValue } from "./FactorValue.js"; -import { DataFile_DerivedDataFile, DataFile_RawDataFile, DataFile_ImageFile } from "./DataFile.js"; - -export type ProcessInput_$union = - | ProcessInput<0> - | ProcessInput<1> - | ProcessInput<2> - | ProcessInput<3> - -export type ProcessInput_$cases = { - 0: ["Source", [Source]], - 1: ["Sample", [Sample]], - 2: ["Data", [Data]], - 3: ["Material", [Material]] -} - -export function ProcessInput_Source(Item: Source) { - return new ProcessInput<0>(0, [Item]); -} - -export function ProcessInput_Sample(Item: Sample) { - return new ProcessInput<1>(1, [Item]); -} - -export function ProcessInput_Data(Item: Data) { - return new ProcessInput<2>(2, [Item]); -} - -export function ProcessInput_Material(Item: Material) { - return new ProcessInput<3>(3, [Item]); -} - -export class ProcessInput extends Union implements IISAPrintable { - constructor(readonly tag: Tag, readonly fields: ProcessInput_$cases[Tag][1]) { - super(); - } - cases() { - return ["Source", "Sample", "Data", "Material"]; - } - Print(): string { - const this$ = this as ProcessInput_$union; - return toString(this$); - } - PrintCompact(): string { - const this$ = this as ProcessInput_$union; - switch (this$.tag) { - case /* Source */ 0: { - const s_1: Source = this$.fields[0]; - const arg_1: string = s_1.PrintCompact(); - return toText(printf("Source {%s}"))(arg_1); - } - case /* Material */ 3: { - const m: Material = this$.fields[0]; - const arg_2: string = m.PrintCompact(); - return toText(printf("Material {%s}"))(arg_2); - } - case /* Data */ 2: { - const d: Data = this$.fields[0]; - const arg_3: string = d.PrintCompact(); - return toText(printf("Data {%s}"))(arg_3); - } - default: { - const s: Sample = this$.fields[0]; - const arg: string = s.PrintCompact(); - return toText(printf("Sample {%s}"))(arg); - } - } - } -} - -export function ProcessInput_$reflection(): TypeInfo { - return union_type("ISA.ProcessInput", [], ProcessInput, () => [[["Item", Source_$reflection()]], [["Item", Sample_$reflection()]], [["Item", Data_$reflection()]], [["Item", Material_$reflection()]]]); -} - -export function ProcessInput__get_TryName(this$: ProcessInput_$union): Option { - switch (this$.tag) { - case /* Source */ 0: - return this$.fields[0].Name; - case /* Material */ 3: - return this$.fields[0].Name; - case /* Data */ 2: - return this$.fields[0].Name; - default: - return this$.fields[0].Name; - } -} - -export function ProcessInput__get_Name(this$: ProcessInput_$union): string { - return defaultArg(ProcessInput__get_TryName(this$), ""); -} - -export function ProcessInput_get_Default(): ProcessInput_$union { - return ProcessInput_Source(Source_get_empty()); -} - -/** - * Returns name of processInput - */ -export function ProcessInput_tryGetName_Z38E7E853(pi: ProcessInput_$union): Option { - return ProcessInput__get_TryName(pi); -} - -/** - * Returns name of processInput - */ -export function ProcessInput_getName_Z38E7E853(pi: ProcessInput_$union): string { - return ProcessInput__get_Name(pi); -} - -/** - * Returns true, if given name equals name of processInput - */ -export function ProcessInput_nameEquals(name: string, pi: ProcessInput_$union): boolean { - return ProcessInput__get_Name(pi) === name; -} - -/** - * Returns true, if Process Input is Sample - */ -export function ProcessInput_isSample_Z38E7E853(pi: ProcessInput_$union): boolean { - if (pi.tag === /* Sample */ 1) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Input is Source - */ -export function ProcessInput_isSource_Z38E7E853(pi: ProcessInput_$union): boolean { - if (pi.tag === /* Source */ 0) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Input is Data - */ -export function ProcessInput_isData_Z38E7E853(pi: ProcessInput_$union): boolean { - if (pi.tag === /* Data */ 2) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Input is Material - */ -export function ProcessInput_isMaterial_Z38E7E853(pi: ProcessInput_$union): boolean { - if (pi.tag === /* Material */ 3) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Input is Source - */ -export function ProcessInput__isSource(this$: ProcessInput_$union): boolean { - return ProcessInput_isSource_Z38E7E853(this$); -} - -/** - * Returns true, if Process Input is Sample - */ -export function ProcessInput__isSample(this$: ProcessInput_$union): boolean { - return ProcessInput_isSample_Z38E7E853(this$); -} - -/** - * Returns true, if Process Input is Data - */ -export function ProcessInput__isData(this$: ProcessInput_$union): boolean { - return ProcessInput_isData_Z38E7E853(this$); -} - -/** - * Returns true, if Process Input is Material - */ -export function ProcessInput__isMaterial(this$: ProcessInput_$union): boolean { - return ProcessInput_isMaterial_Z38E7E853(this$); -} - -/** - * If given process input is a sample, returns it, else returns None - */ -export function ProcessInput_trySample_Z38E7E853(pi: ProcessInput_$union): Option { - if (pi.tag === /* Sample */ 1) { - return pi.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process input is a source, returns it, else returns None - */ -export function ProcessInput_trySource_Z38E7E853(pi: ProcessInput_$union): Option { - if (pi.tag === /* Source */ 0) { - return pi.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process input is a data, returns it, else returns None - */ -export function ProcessInput_tryData_Z38E7E853(pi: ProcessInput_$union): Option { - if (pi.tag === /* Data */ 2) { - return pi.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process input is a material, returns it, else returns None - */ -export function ProcessInput_tryMaterial_Z38E7E853(pi: ProcessInput_$union): Option { - if (pi.tag === /* Material */ 3) { - return pi.fields[0]; - } - else { - return void 0; - } -} - -export function ProcessInput_setCharacteristicValues(characteristics: FSharpList, pi: ProcessInput_$union): ProcessInput_$union { - switch (pi.tag) { - case /* Source */ 0: - return ProcessInput_Source(Source_setCharacteristicValues(characteristics, pi.fields[0])); - case /* Material */ 3: - return ProcessInput_Material(Material_setCharacteristicValues(characteristics, pi.fields[0])); - case /* Data */ 2: - return pi; - default: - return ProcessInput_Sample(Sample_setCharacteristicValues(characteristics, pi.fields[0])); - } -} - -/** - * If given process input contains characteristics, returns them - */ -export function ProcessInput_tryGetCharacteristicValues_Z38E7E853(pi: ProcessInput_$union): Option> { - switch (pi.tag) { - case /* Source */ 0: - return pi.fields[0].Characteristics; - case /* Material */ 3: - return pi.fields[0].Characteristics; - case /* Data */ 2: - return void 0; - default: - return pi.fields[0].Characteristics; - } -} - -/** - * If given process input contains characteristics, returns them - */ -export function ProcessInput_tryGetCharacteristics_Z38E7E853(pi: ProcessInput_$union): Option> { - return map, FSharpList>((list: FSharpList): FSharpList => choose((c: MaterialAttributeValue): Option => c.Category, list), ProcessInput_tryGetCharacteristicValues_Z38E7E853(pi)); -} - -export function ProcessInput_getCharacteristicValues_Z38E7E853(pi: ProcessInput_$union): FSharpList { - return defaultArg(ProcessInput_tryGetCharacteristicValues_Z38E7E853(pi), empty()); -} - -/** - * If given process output contains units, returns them - */ -export function ProcessInput_getUnits_Z38E7E853(pi: ProcessInput_$union): FSharpList { - switch (pi.tag) { - case /* Sample */ 1: - return Sample_getUnits_Z23050B6A(pi.fields[0]); - case /* Material */ 3: - return Material_getUnits_43A4149B(pi.fields[0]); - case /* Data */ 2: - return empty(); - default: - return Source_getUnits_Z220A6393(pi.fields[0]); - } -} - -export function ProcessInput_createSource_Z3083890A(name: string, characteristics?: FSharpList): ProcessInput_$union { - return ProcessInput_Source(Source_create_Z32235993(void 0, name, unwrap(characteristics))); -} - -export function ProcessInput_createSample_Z445EF6B3(name: string, characteristics?: FSharpList, factors?: FSharpList, derivesFrom?: FSharpList): ProcessInput_$union { - return ProcessInput_Sample(Sample_create_3A6378D6(void 0, name, unwrap(characteristics), unwrap(factors), unwrap(derivesFrom))); -} - -export function ProcessInput_createMaterial_ZEED0B34(name: string, characteristics?: FSharpList, derivesFrom?: FSharpList): ProcessInput_$union { - return ProcessInput_Material(Material_create_76090C97(void 0, name, void 0, unwrap(characteristics), unwrap(derivesFrom))); -} - -export function ProcessInput_createImageFile_Z721C83C5(name: string): ProcessInput_$union { - return ProcessInput_Data(Data_create_Z748D099(void 0, name, DataFile_ImageFile())); -} - -export function ProcessInput_createRawData_Z721C83C5(name: string): ProcessInput_$union { - return ProcessInput_Data(Data_create_Z748D099(void 0, name, DataFile_RawDataFile())); -} - -export function ProcessInput_createDerivedData_Z721C83C5(name: string): ProcessInput_$union { - return ProcessInput_Data(Data_create_Z748D099(void 0, name, DataFile_DerivedDataFile())); -} - diff --git a/ts/ISA/ISA/JsonTypes/ProcessOutput.ts b/ts/ISA/ISA/JsonTypes/ProcessOutput.ts deleted file mode 100644 index d45f5094..00000000 --- a/ts/ISA/ISA/JsonTypes/ProcessOutput.ts +++ /dev/null @@ -1,293 +0,0 @@ -import { Union, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { Material_create_76090C97, Material_getUnits_43A4149B, Material_$reflection, Material } from "./Material.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; -import { Data_create_Z748D099, Data_$reflection, Data } from "./Data.js"; -import { Sample_create_3A6378D6, Sample_getUnits_Z23050B6A, Sample_setFactorValues, Sample_get_empty, Sample_$reflection, Sample } from "./Sample.js"; -import { IISAPrintable } from "../Printer.js"; -import { union_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { unwrap, map, defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { empty, choose, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { MaterialAttribute } from "./MaterialAttribute.js"; -import { FactorValue } from "./FactorValue.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; -import { Source } from "./Source.js"; -import { DataFile_DerivedDataFile, DataFile_RawDataFile, DataFile_ImageFile } from "./DataFile.js"; - -export type ProcessOutput_$union = - | ProcessOutput<0> - | ProcessOutput<1> - | ProcessOutput<2> - -export type ProcessOutput_$cases = { - 0: ["Sample", [Sample]], - 1: ["Data", [Data]], - 2: ["Material", [Material]] -} - -export function ProcessOutput_Sample(Item: Sample) { - return new ProcessOutput<0>(0, [Item]); -} - -export function ProcessOutput_Data(Item: Data) { - return new ProcessOutput<1>(1, [Item]); -} - -export function ProcessOutput_Material(Item: Material) { - return new ProcessOutput<2>(2, [Item]); -} - -export class ProcessOutput extends Union implements IISAPrintable { - constructor(readonly tag: Tag, readonly fields: ProcessOutput_$cases[Tag][1]) { - super(); - } - cases() { - return ["Sample", "Data", "Material"]; - } - Print(): string { - const this$ = this as ProcessOutput_$union; - return toString(this$); - } - PrintCompact(): string { - const this$ = this as ProcessOutput_$union; - switch (this$.tag) { - case /* Material */ 2: { - const m: Material = this$.fields[0]; - const arg_1: string = m.PrintCompact(); - return toText(printf("Material {%s}"))(arg_1); - } - case /* Data */ 1: { - const d: Data = this$.fields[0]; - const arg_2: string = d.PrintCompact(); - return toText(printf("Data {%s}"))(arg_2); - } - default: { - const s: Sample = this$.fields[0]; - const arg: string = s.PrintCompact(); - return toText(printf("Sample {%s}"))(arg); - } - } - } -} - -export function ProcessOutput_$reflection(): TypeInfo { - return union_type("ISA.ProcessOutput", [], ProcessOutput, () => [[["Item", Sample_$reflection()]], [["Item", Data_$reflection()]], [["Item", Material_$reflection()]]]); -} - -export function ProcessOutput__get_TryName(this$: ProcessOutput_$union): Option { - switch (this$.tag) { - case /* Material */ 2: - return this$.fields[0].Name; - case /* Data */ 1: - return this$.fields[0].Name; - default: - return this$.fields[0].Name; - } -} - -export function ProcessOutput__get_Name(this$: ProcessOutput_$union): string { - return defaultArg(ProcessOutput__get_TryName(this$), ""); -} - -export function ProcessOutput_get_Default(): ProcessOutput_$union { - return ProcessOutput_Sample(Sample_get_empty()); -} - -/** - * Returns name of processOutput - */ -export function ProcessOutput_tryGetName_Z4A02997C(po: ProcessOutput_$union): Option { - return ProcessOutput__get_TryName(po); -} - -/** - * Returns name of processInput - */ -export function ProcessOutput_getName_Z4A02997C(po: ProcessOutput_$union): string { - return ProcessOutput__get_Name(po); -} - -/** - * Returns true, if given name equals name of processOutput - */ -export function ProcessOutput_nameEquals(name: string, po: ProcessOutput_$union): boolean { - return ProcessOutput__get_Name(po) === name; -} - -/** - * Returns true, if Process Output is Sample - */ -export function ProcessOutput_isSample_Z4A02997C(po: ProcessOutput_$union): boolean { - if (po.tag === /* Sample */ 0) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Output is Data - */ -export function ProcessOutput_isData_Z4A02997C(po: ProcessOutput_$union): boolean { - if (po.tag === /* Data */ 1) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Output is Material - */ -export function ProcessOutput_isMaterial_Z4A02997C(po: ProcessOutput_$union): boolean { - if (po.tag === /* Material */ 2) { - return true; - } - else { - return false; - } -} - -/** - * Returns true, if Process Output is Sample - */ -export function ProcessOutput__isSample(this$: ProcessOutput_$union): boolean { - return ProcessOutput_isSample_Z4A02997C(this$); -} - -/** - * Returns true, if Process Output is Data - */ -export function ProcessOutput__isData(this$: ProcessOutput_$union): boolean { - return ProcessOutput_isData_Z4A02997C(this$); -} - -/** - * Returns true, if Process Output is Material - */ -export function ProcessOutput__isMaterial(this$: ProcessOutput_$union): boolean { - return ProcessOutput_isMaterial_Z4A02997C(this$); -} - -/** - * If given process output is a sample, returns it, else returns None - */ -export function ProcessOutput_trySample_Z4A02997C(po: ProcessOutput_$union): Option { - if (po.tag === /* Sample */ 0) { - return po.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process output is a data, returns it, else returns None - */ -export function ProcessOutput_tryData_Z4A02997C(po: ProcessOutput_$union): Option { - if (po.tag === /* Data */ 1) { - return po.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process output is a material, returns it, else returns None - */ -export function ProcessOutput_tryMaterial_Z4A02997C(po: ProcessOutput_$union): Option { - if (po.tag === /* Material */ 2) { - return po.fields[0]; - } - else { - return void 0; - } -} - -/** - * If given process output contains characteristics, returns them - */ -export function ProcessOutput_tryGetCharacteristicValues_Z4A02997C(po: ProcessOutput_$union): Option> { - switch (po.tag) { - case /* Material */ 2: - return po.fields[0].Characteristics; - case /* Data */ 1: - return void 0; - default: - return po.fields[0].Characteristics; - } -} - -/** - * If given process output contains characteristics, returns them - */ -export function ProcessOutput_tryGetCharacteristics_Z4A02997C(po: ProcessOutput_$union): Option> { - return map, FSharpList>((list: FSharpList): FSharpList => choose((c: MaterialAttributeValue): Option => c.Category, list), ProcessOutput_tryGetCharacteristicValues_Z4A02997C(po)); -} - -/** - * If given process output contains factors, returns them - */ -export function ProcessOutput_tryGetFactorValues_Z4A02997C(po: ProcessOutput_$union): Option> { - switch (po.tag) { - case /* Material */ 2: - return void 0; - case /* Data */ 1: - return void 0; - default: - return po.fields[0].FactorValues; - } -} - -export function ProcessOutput_setFactorValues(values: FSharpList, po: ProcessOutput_$union): ProcessOutput_$union { - switch (po.tag) { - case /* Material */ 2: - return po; - case /* Data */ 1: - return po; - default: - return ProcessOutput_Sample(Sample_setFactorValues(values, po.fields[0])); - } -} - -export function ProcessOutput_getFactorValues_Z4A02997C(po: ProcessOutput_$union): FSharpList { - return defaultArg(ProcessOutput_tryGetFactorValues_Z4A02997C(po), empty()); -} - -/** - * If given process output contains units, returns them - */ -export function ProcessOutput_getUnits_Z4A02997C(po: ProcessOutput_$union): FSharpList { - switch (po.tag) { - case /* Material */ 2: - return Material_getUnits_43A4149B(po.fields[0]); - case /* Data */ 1: - return empty(); - default: - return Sample_getUnits_Z23050B6A(po.fields[0]); - } -} - -export function ProcessOutput_createSample_Z445EF6B3(name: string, characteristics?: FSharpList, factors?: FSharpList, derivesFrom?: FSharpList): ProcessOutput_$union { - return ProcessOutput_Sample(Sample_create_3A6378D6(void 0, name, unwrap(characteristics), unwrap(factors), unwrap(derivesFrom))); -} - -export function ProcessOutput_createMaterial_ZEED0B34(name: string, characteristics?: FSharpList, derivesFrom?: FSharpList): ProcessOutput_$union { - return ProcessOutput_Material(Material_create_76090C97(void 0, name, void 0, unwrap(characteristics), unwrap(derivesFrom))); -} - -export function ProcessOutput_createImageFile_Z721C83C5(name: string): ProcessOutput_$union { - return ProcessOutput_Data(Data_create_Z748D099(void 0, name, DataFile_ImageFile())); -} - -export function ProcessOutput_createRawData_Z721C83C5(name: string): ProcessOutput_$union { - return ProcessOutput_Data(Data_create_Z748D099(void 0, name, DataFile_RawDataFile())); -} - -export function ProcessOutput_createDerivedData_Z721C83C5(name: string): ProcessOutput_$union { - return ProcessOutput_Data(Data_create_Z748D099(void 0, name, DataFile_DerivedDataFile())); -} - diff --git a/ts/ISA/ISA/JsonTypes/ProcessParameterValue.ts b/ts/ISA/ISA/JsonTypes/ProcessParameterValue.ts deleted file mode 100644 index 2af7aa52..00000000 --- a/ts/ISA/ISA/JsonTypes/ProcessParameterValue.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { bind, defaultArg, value as value_3, Option, map } from "../../../fable_modules/fable-library-ts/Option.js"; -import { ProtocolParameter__SetCategory_2FC95D30, ProtocolParameter_create_2769312B, ProtocolParameter__MapCategory_65D42856, ProtocolParameter__get_TryNameText, ProtocolParameter_$reflection, ProtocolParameter, ProtocolParameter__get_NameText } from "./ProtocolParameter.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation, OntologyAnnotation__get_NameText } from "./OntologyAnnotation.js"; -import { IISAPrintable } from "../Printer.js"; -import { Value_$reflection, Value_$union } from "./Value.js"; -import { int32ToString, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, option_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { float64 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; - -export class ProcessParameterValue extends Record implements IEquatable, IISAPrintable { - readonly Category: Option; - readonly Value: Option; - readonly Unit: Option; - constructor(Category: Option, Value: Option, Unit: Option) { - super(); - this.Category = Category; - this.Value = Value; - this.Unit = Unit; - } - Print(): string { - const this$: ProcessParameterValue = this; - return toString(this$); - } - PrintCompact(): string { - let value_2: string, category_2: string, category_1: string, value_1: string; - const this$: ProcessParameterValue = this; - const category: Option = map(ProtocolParameter__get_NameText, this$.Category); - const unit: Option = map(OntologyAnnotation__get_NameText, this$.Unit); - const value: Option = map((v: Value_$union): string => { - const s: string = (v as IISAPrintable).PrintCompact(); - if (unit == null) { - return s; - } - else { - return (s + " ") + value_3(unit); - } - }, this$.Value); - return (category == null) ? ((value == null) ? "" : ((value_2 = value_3(value), value_2))) : ((value == null) ? ((category_2 = value_3(category), (category_2 + ":") + "No Value")) : ((category_1 = value_3(category), (value_1 = value_3(value), (category_1 + ":") + value_1)))); - } -} - -export function ProcessParameterValue_$reflection(): TypeInfo { - return record_type("ISA.ProcessParameterValue", [], ProcessParameterValue, () => [["Category", option_type(ProtocolParameter_$reflection())], ["Value", option_type(Value_$reflection())], ["Unit", option_type(OntologyAnnotation_$reflection())]]); -} - -export function ProcessParameterValue_make(category: Option, value: Option, unit: Option): ProcessParameterValue { - return new ProcessParameterValue(category, value, unit); -} - -export function ProcessParameterValue_create_2A3A2A47(Category?: ProtocolParameter, Value?: Value_$union, Unit?: OntologyAnnotation): ProcessParameterValue { - return ProcessParameterValue_make(Category, Value, Unit); -} - -export function ProcessParameterValue_get_empty(): ProcessParameterValue { - return ProcessParameterValue_create_2A3A2A47(); -} - -/** - * Returns the name of the category as string - */ -export function ProcessParameterValue__get_NameText(this$: ProcessParameterValue): string { - return defaultArg(map(ProtocolParameter__get_NameText, this$.Category), ""); -} - -/** - * Returns the name of the category as string - */ -export function ProcessParameterValue__get_TryNameText(this$: ProcessParameterValue): Option { - return bind(ProtocolParameter__get_TryNameText, this$.Category); -} - -export function ProcessParameterValue__get_ValueText(this$: ProcessParameterValue): string { - return defaultArg(map((oa: Value_$union): string => { - switch (oa.tag) { - case /* Float */ 2: { - const f: float64 = oa.fields[0]; - return f.toString(); - } - case /* Int */ 1: - return int32ToString(oa.fields[0]); - case /* Name */ 3: - return oa.fields[0]; - default: - return OntologyAnnotation__get_NameText(oa.fields[0]); - } - }, this$.Value), ""); -} - -export function ProcessParameterValue__get_ValueWithUnitText(this$: ProcessParameterValue): string { - const unit: Option = map(OntologyAnnotation__get_NameText, this$.Unit); - const v: string = ProcessParameterValue__get_ValueText(this$); - if (unit == null) { - return v; - } - else { - const u: string = value_3(unit); - return toText(printf("%s %s"))(v)(u); - } -} - -export function ProcessParameterValue__MapCategory_65D42856(this$: ProcessParameterValue, f: ((arg0: OntologyAnnotation) => OntologyAnnotation)): ProcessParameterValue { - return new ProcessParameterValue(map((p: ProtocolParameter): ProtocolParameter => ProtocolParameter__MapCategory_65D42856(p, f), this$.Category), this$.Value, this$.Unit); -} - -export function ProcessParameterValue__SetCategory_2FC95D30(this$: ProcessParameterValue, c: OntologyAnnotation): ProcessParameterValue { - let matchValue: Option; - return new ProcessParameterValue((matchValue = this$.Category, (matchValue == null) ? ProtocolParameter_create_2769312B(void 0, c) : ProtocolParameter__SetCategory_2FC95D30(value_3(matchValue), c)), this$.Value, this$.Unit); -} - -/** - * Returns the name of the paramater value as string if it exists - */ -export function ProcessParameterValue_tryGetNameText_39585819(pv: ProcessParameterValue): Option { - return ProcessParameterValue__get_TryNameText(pv); -} - -/** - * Returns the name of the paramater value as string - */ -export function ProcessParameterValue_getNameText_39585819(pv: ProcessParameterValue): string { - return ProcessParameterValue__get_NameText(pv); -} - -/** - * Returns true if the given name matches the name of the parameter value - */ -export function ProcessParameterValue_nameEqualsString(name: string, pv: ProcessParameterValue): boolean { - return ProcessParameterValue__get_NameText(pv) === name; -} - -export function ProcessParameterValue_getCategory_39585819(pv: ProcessParameterValue): Option { - return pv.Category; -} - diff --git a/ts/ISA/ISA/JsonTypes/ProcessSequence.ts b/ts/ISA/ISA/JsonTypes/ProcessSequence.ts deleted file mode 100644 index 465f3ddf..00000000 --- a/ts/ISA/ISA/JsonTypes/ProcessSequence.ts +++ /dev/null @@ -1,268 +0,0 @@ -import { List_groupBy, List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { singleton, zip, map, empty, collect, concat, filter, FSharpList, choose } from "../../../fable_modules/fable-library-ts/List.js"; -import { defaultArg, value as value_3, Option, bind } from "../../../fable_modules/fable-library-ts/Option.js"; -import { Protocol } from "./Protocol.js"; -import { Process_updateProtocol, Process_getMaterials_30EF9E7B, Process_getSamples_30EF9E7B, Process_getSources_30EF9E7B, Process_getData_30EF9E7B, Process_getUnits_30EF9E7B, Process_getFactors_30EF9E7B, Process_tryGetOutputsWithFactorBy, Process_tryGetOutputsWithCharacteristicBy, Process_tryGetInputsWithCharacteristicBy, Process_getCharacteristics_30EF9E7B, Process_getParameters_30EF9E7B, Process_tryGetOutputsWithParameterBy, Process_tryGetInputsWithParameterBy, Process } from "./Process.js"; -import { arrayHash, equalArrays, comparePrimitives, safeHash, equals, stringHash } from "../../../fable_modules/fable-library-ts/Util.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { ProcessInput__get_Name, ProcessInput_getName_Z38E7E853, ProcessInput_$union } from "./ProcessInput.js"; -import { ProcessParameterValue } from "./ProcessParameterValue.js"; -import { ProtocolParameter } from "./ProtocolParameter.js"; -import { ProcessOutput__get_Name, ProcessOutput_getName_Z4A02997C, ProcessOutput_$union } from "./ProcessOutput.js"; -import { MaterialAttribute } from "./MaterialAttribute.js"; -import { MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { FactorValue } from "./FactorValue.js"; -import { Factor } from "./Factor.js"; -import { FSharpSet__Contains, FSharpSet, ofList } from "../../../fable_modules/fable-library-ts/Set.js"; -import { FSharpMap__TryFind, FSharpMap, ofList as ofList_1 } from "../../../fable_modules/fable-library-ts/Map.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; -import { Data } from "./Data.js"; -import { Source } from "./Source.js"; -import { Sample } from "./Sample.js"; -import { Material } from "./Material.js"; - -/** - * Returns the names of the protocols the given processes impelement - */ -export function getProtocolNames(processSequence: FSharpList): FSharpList { - return List_distinct(choose((p: Process): Option => bind((protocol: Protocol): Option => protocol.Name, p.ExecutesProtocol), processSequence), { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - }); -} - -/** - * Returns the protocols the given processes impelement - */ -export function getProtocols(processSequence: FSharpList): FSharpList { - return List_distinct(choose((p: Process): Option => p.ExecutesProtocol, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns a list of the processes, containing only the ones executing a protocol for which the predicate returns true - */ -export function filterByProtocolBy(predicate: ((arg0: Protocol) => boolean), processSequence: FSharpList): FSharpList { - return filter((p: Process): boolean => { - const matchValue: Option = p.ExecutesProtocol; - let matchResult: int32, protocol_1: Protocol; - if (matchValue != null) { - if (predicate(value_3(matchValue))) { - matchResult = 0; - protocol_1 = value_3(matchValue); - } - else { - matchResult = 1; - } - } - else { - matchResult = 1; - } - switch (matchResult) { - case 0: - return true; - default: - return false; - } - }, processSequence); -} - -/** - * Returns a list of the processes, containing only the ones executing a protocol with the given name - */ -export function filterByProtocolName(protocolName: string, processSequence: FSharpList): FSharpList { - return filterByProtocolBy((p: Protocol): boolean => equals(p.Name, protocolName), processSequence); -} - -/** - * If the processes contain a process implementing the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function getInputsWithParameterBy(predicate: ((arg0: ProtocolParameter) => boolean), processSequence: FSharpList): FSharpList<[ProcessInput_$union, ProcessParameterValue]> { - return concat<[ProcessInput_$union, ProcessParameterValue]>(choose>((arg_1: Process): Option> => Process_tryGetInputsWithParameterBy(predicate, arg_1), processSequence)); -} - -/** - * If the processes contain a process implementing the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function getOutputsWithParameterBy(predicate: ((arg0: ProtocolParameter) => boolean), processSequence: FSharpList): FSharpList<[ProcessOutput_$union, ProcessParameterValue]> { - return concat<[ProcessOutput_$union, ProcessParameterValue]>(choose>((arg_1: Process): Option> => Process_tryGetOutputsWithParameterBy(predicate, arg_1), processSequence)); -} - -/** - * Returns the parameters implemented by the processes contained in these processes - */ -export function getParameters(processSequence: FSharpList): FSharpList { - return List_distinct(collect(Process_getParameters_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the characteristics describing the inputs and outputs of the processssequence - */ -export function getCharacteristics(processSequence: FSharpList): FSharpList { - return List_distinct(collect(Process_getCharacteristics_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * If the processes contain a process implementing the given parameter, return the list of input files together with their according parameter values of this parameter - */ -export function getInputsWithCharacteristicBy(predicate: ((arg0: MaterialAttribute) => boolean), processSequence: FSharpList): FSharpList<[ProcessInput_$union, MaterialAttributeValue]> { - return concat<[ProcessInput_$union, MaterialAttributeValue]>(choose>((arg_1: Process): Option> => Process_tryGetInputsWithCharacteristicBy(predicate, arg_1), processSequence)); -} - -/** - * If the processes contain a process implementing the given parameter, return the list of output files together with their according parameter values of this parameter - */ -export function getOutputsWithCharacteristicBy(predicate: ((arg0: MaterialAttribute) => boolean), processSequence: FSharpList): FSharpList<[ProcessOutput_$union, MaterialAttributeValue]> { - return concat<[ProcessOutput_$union, MaterialAttributeValue]>(choose>((arg_1: Process): Option> => Process_tryGetOutputsWithCharacteristicBy(predicate, arg_1), processSequence)); -} - -/** - * If the processes contain a process implementing the given factor, return the list of output files together with their according factor values of this factor - */ -export function getOutputsWithFactorBy(predicate: ((arg0: Factor) => boolean), processSequence: FSharpList): FSharpList<[ProcessOutput_$union, FactorValue]> { - return concat<[ProcessOutput_$union, FactorValue]>(choose>((arg_1: Process): Option> => Process_tryGetOutputsWithFactorBy(predicate, arg_1), processSequence)); -} - -/** - * Returns the factors implemented by the processes contained in these processes - */ -export function getFactors(processSequence: FSharpList): FSharpList { - return List_distinct(collect(Process_getFactors_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the initial inputs final outputs of the processSequence, to which no processPoints - */ -export function getRootInputs(processSequence: FSharpList): FSharpList { - const inputs: FSharpList = collect((p: Process): FSharpList => defaultArg(p.Inputs, empty()), processSequence); - const outputs: FSharpSet = ofList(collect((p_1: Process): FSharpList => map(ProcessOutput_getName_Z4A02997C, defaultArg(p_1.Outputs, empty())), processSequence), { - Compare: comparePrimitives, - }); - return filter((i: ProcessInput_$union): boolean => !FSharpSet__Contains(outputs, ProcessInput_getName_Z38E7E853(i)), inputs); -} - -/** - * Returns the final outputs of the processSequence, which point to no further nodes - */ -export function getFinalOutputs(processSequence: FSharpList): FSharpList { - const inputs: FSharpSet = ofList(collect((p: Process): FSharpList => map(ProcessInput_getName_Z38E7E853, defaultArg(p.Inputs, empty())), processSequence), { - Compare: comparePrimitives, - }); - return filter((o: ProcessOutput_$union): boolean => !FSharpSet__Contains(inputs, ProcessOutput_getName_Z4A02997C(o)), collect((p_1: Process): FSharpList => defaultArg(p_1.Outputs, empty()), processSequence)); -} - -/** - * Returns the initial inputs final outputs of the processSequence, to which no processPoints - */ -export function getRootInputOf(processSequence: FSharpList, sample: string): FSharpList { - const mappings: FSharpMap> = ofList_1>(map<[string, FSharpList<[string, string]>], [string, FSharpList]>((tupledArg: [string, FSharpList<[string, string]>]): [string, FSharpList] => ([tupledArg[0], map<[string, string], string>((tuple_1: [string, string]): string => tuple_1[1], tupledArg[1])] as [string, FSharpList]), List_groupBy<[string, string], string>((tuple: [string, string]): string => tuple[0], collect((p: Process): FSharpList<[string, string]> => List_distinct<[string, string]>(zip(map(ProcessOutput__get_Name, value_3(p.Outputs)), map(ProcessInput__get_Name, value_3(p.Inputs))), { - Equals: equalArrays, - GetHashCode: arrayHash, - }), processSequence), { - Equals: (x_1: string, y_1: string): boolean => (x_1 === y_1), - GetHashCode: stringHash, - })), { - Compare: comparePrimitives, - }); - const loop = (lastState_mut: FSharpList, state_mut: FSharpList): FSharpList => { - loop: - while (true) { - const lastState: FSharpList = lastState_mut, state: FSharpList = state_mut; - if (equals(lastState, state)) { - return state; - } - else { - lastState_mut = state; - state_mut = collect((s: string): FSharpList => defaultArg(FSharpMap__TryFind(mappings, s), singleton(s)), state); - continue loop; - } - break; - } - }; - return loop(empty(), singleton(sample)); -} - -/** - * Returns the final outputs of the processSequence, which point to no further nodes - */ -export function getFinalOutputsOf(processSequence: FSharpList, sample: string): FSharpList { - const mappings: FSharpMap> = ofList_1>(map<[string, FSharpList<[string, string]>], [string, FSharpList]>((tupledArg: [string, FSharpList<[string, string]>]): [string, FSharpList] => ([tupledArg[0], map<[string, string], string>((tuple_1: [string, string]): string => tuple_1[1], tupledArg[1])] as [string, FSharpList]), List_groupBy<[string, string], string>((tuple: [string, string]): string => tuple[0], collect((p: Process): FSharpList<[string, string]> => List_distinct<[string, string]>(zip(map(ProcessInput__get_Name, value_3(p.Inputs)), map(ProcessOutput__get_Name, value_3(p.Outputs))), { - Equals: equalArrays, - GetHashCode: arrayHash, - }), processSequence), { - Equals: (x_1: string, y_1: string): boolean => (x_1 === y_1), - GetHashCode: stringHash, - })), { - Compare: comparePrimitives, - }); - const loop = (lastState_mut: FSharpList, state_mut: FSharpList): FSharpList => { - loop: - while (true) { - const lastState: FSharpList = lastState_mut, state: FSharpList = state_mut; - if (equals(lastState, state)) { - return state; - } - else { - lastState_mut = state; - state_mut = collect((s: string): FSharpList => defaultArg(FSharpMap__TryFind(mappings, s), singleton(s)), state); - continue loop; - } - break; - } - }; - return loop(empty(), singleton(sample)); -} - -export function getUnits(processSequence: FSharpList): FSharpList { - return List_distinct(collect(Process_getUnits_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns the data the given processes contain - */ -export function getData(processSequence: FSharpList): FSharpList { - return List_distinct(collect(Process_getData_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function getSources(processSequence: FSharpList): FSharpList { - return List_distinct(collect(Process_getSources_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function getSamples(processSequence: FSharpList): FSharpList { - return List_distinct(collect(Process_getSamples_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function getMaterials(processSequence: FSharpList): FSharpList { - return List_distinct(collect(Process_getMaterials_30EF9E7B, processSequence), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -export function updateProtocols(protocols: FSharpList, processSequence: FSharpList): FSharpList { - return map((arg_1: Process): Process => Process_updateProtocol(protocols, arg_1), processSequence); -} - diff --git a/ts/ISA/ISA/JsonTypes/Protocol.ts b/ts/ISA/ISA/JsonTypes/Protocol.ts deleted file mode 100644 index b7b26678..00000000 --- a/ts/ISA/ISA/JsonTypes/Protocol.ts +++ /dev/null @@ -1,287 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { defaultArg, map as map_1, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { empty, filter, map, singleton, append, exists, tryFind, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { ProtocolParameter_$reflection, ProtocolParameter } from "./ProtocolParameter.js"; -import { Component_$reflection, Component } from "./Component.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { equals, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Update_UpdateOptions_$union } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; - -export class Protocol extends Record implements IEquatable { - readonly ID: Option; - readonly Name: Option; - readonly ProtocolType: Option; - readonly Description: Option; - readonly Uri: Option; - readonly Version: Option; - readonly Parameters: Option>; - readonly Components: Option>; - readonly Comments: Option>; - constructor(ID: Option, Name: Option, ProtocolType: Option, Description: Option, Uri: Option, Version: Option, Parameters: Option>, Components: Option>, Comments: Option>) { - super(); - this.ID = ID; - this.Name = Name; - this.ProtocolType = ProtocolType; - this.Description = Description; - this.Uri = Uri; - this.Version = Version; - this.Parameters = Parameters; - this.Components = Components; - this.Comments = Comments; - } -} - -export function Protocol_$reflection(): TypeInfo { - return record_type("ISA.Protocol", [], Protocol, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["ProtocolType", option_type(OntologyAnnotation_$reflection())], ["Description", option_type(string_type)], ["Uri", option_type(string_type)], ["Version", option_type(string_type)], ["Parameters", option_type(list_type(ProtocolParameter_$reflection()))], ["Components", option_type(list_type(Component_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Protocol_make(id: Option, name: Option, protocolType: Option, description: Option, uri: Option, version: Option, parameters: Option>, components: Option>, comments: Option>): Protocol { - return new Protocol(id, name, protocolType, description, uri, version, parameters, components, comments); -} - -export function Protocol_create_Z4D717767(Id?: string, Name?: string, ProtocolType?: OntologyAnnotation, Description?: string, Uri?: string, Version?: string, Parameters?: FSharpList, Components?: FSharpList, Comments?: FSharpList): Protocol { - return Protocol_make(Id, Name, ProtocolType, Description, Uri, Version, Parameters, Components, Comments); -} - -export function Protocol_get_empty(): Protocol { - return Protocol_create_Z4D717767(); -} - -/** - * If a protocol with the given identfier exists in the list, returns it - */ -export function Protocol_tryGetByName(name: string, protocols: FSharpList): Option { - return tryFind((p: Protocol): boolean => equals(p.Name, name), protocols); -} - -/** - * If a protocol with the given name exists in the list exists, returns true - */ -export function Protocol_existsByName(name: string, protocols: FSharpList): boolean { - return exists((p: Protocol): boolean => equals(p.Name, name), protocols); -} - -/** - * Adds the given protocol to the protocols - */ -export function Protocol_add(protocols: FSharpList, protocol: Protocol): FSharpList { - return append(protocols, singleton(protocol)); -} - -/** - * Updates all protocols for which the predicate returns true with the given protocol values - */ -export function Protocol_updateBy(predicate: ((arg0: Protocol) => boolean), updateOption: Update_UpdateOptions_$union, protocol: Protocol, protocols: FSharpList): FSharpList { - if (exists(predicate, protocols)) { - return map((p: Protocol): Protocol => { - if (predicate(p)) { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: Protocol = p; - const recordType_2: Protocol = protocol; - return (this$.tag === /* UpdateAllAppendLists */ 2) ? (makeRecord(Protocol_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol) : ((this$.tag === /* UpdateByExisting */ 1) ? (makeRecord(Protocol_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol) : ((this$.tag === /* UpdateByExistingAppendLists */ 3) ? (makeRecord(Protocol_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol) : recordType_2)); - } - else { - return p; - } - }, protocols); - } - else { - return protocols; - } -} - -/** - * Updates all protocols with the same name as the given protocol with its values - */ -export function Protocol_updateByName(updateOption: Update_UpdateOptions_$union, protocol: Protocol, protocols: FSharpList): FSharpList { - return Protocol_updateBy((p: Protocol): boolean => equals(p.Name, protocol.Name), updateOption, protocol, protocols); -} - -/** - * If a protocol with the given name exists in the list, removes it - */ -export function Protocol_removeByName(name: string, protocols: FSharpList): FSharpList { - return filter((p: Protocol): boolean => !equals(p.Name, name), protocols); -} - -/** - * Returns comments of a protocol - */ -export function Protocol_getComments_4D8AC666(protocol: Protocol): Option> { - return protocol.Comments; -} - -/** - * Applies function f on comments of a protocol - */ -export function Protocol_mapComments(f: ((arg0: FSharpList) => FSharpList), protocol: Protocol): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, map_1, FSharpList>(f, protocol.Comments)); -} - -/** - * Replaces comments of a protocol by given comment list - */ -export function Protocol_setComments(protocol: Protocol, comments: FSharpList): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, comments); -} - -/** - * Returns protocol type of a protocol - */ -export function Protocol_getProtocolType_4D8AC666(protocol: Protocol): Option { - return protocol.ProtocolType; -} - -/** - * Applies function f on protocol type of a protocol - */ -export function Protocol_mapProtocolType(f: ((arg0: OntologyAnnotation) => OntologyAnnotation), protocol: Protocol): Protocol { - return new Protocol(protocol.ID, protocol.Name, map_1(f, protocol.ProtocolType), protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol type of a protocol by given protocol type - */ -export function Protocol_setProtocolType(protocol: Protocol, protocolType: OntologyAnnotation): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Returns protocol version of a protocol - */ -export function Protocol_getVersion_4D8AC666(protocol: Protocol): Option { - return protocol.Version; -} - -/** - * Applies function f on protocol version of a protocol - */ -export function Protocol_mapVersion(f: ((arg0: string) => string), protocol: Protocol): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, map_1(f, protocol.Version), protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol version of a protocol by given protocol version - */ -export function Protocol_setVersion(protocol: Protocol, version: string): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Protocol Name - * Returns protocol name of a protocol - */ -export function Protocol_getName_4D8AC666(protocol: Protocol): Option { - return protocol.Name; -} - -/** - * Applies function f on protocol name of a protocol - */ -export function Protocol_mapName(f: ((arg0: string) => string), protocol: Protocol): Protocol { - return new Protocol(protocol.ID, map_1(f, protocol.Name), protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol name of a protocol by given protocol name - */ -export function Protocol_setName(protocol: Protocol, name: string): Protocol { - return new Protocol(protocol.ID, name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Returns protocol description of a protocol - */ -export function Protocol_getDescription_4D8AC666(protocol: Protocol): Option { - return protocol.Description; -} - -/** - * Applies function f on protocol description of a protocol - */ -export function Protocol_mapDescription(f: ((arg0: string) => string), protocol: Protocol): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, map_1(f, protocol.Description), protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol description of a protocol by given protocol description - */ -export function Protocol_setDescription(protocol: Protocol, description: string): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, description, protocol.Uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Returns protocol URI of a protocol - */ -export function Protocol_getUri_4D8AC666(protocol: Protocol): Option { - return protocol.Uri; -} - -/** - * Applies function f on protocol URI of a protocol - */ -export function Protocol_mapUri(f: ((arg0: string) => string), protocol: Protocol): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, map_1(f, protocol.Uri), protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol URI of a protocol by given protocol URI - */ -export function Protocol_setUri(protocol: Protocol, uri: string): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, uri, protocol.Version, protocol.Parameters, protocol.Components, protocol.Comments); -} - -/** - * Returns components of a protocol - */ -export function Protocol_getComponents_4D8AC666(protocol: Protocol): Option> { - return protocol.Components; -} - -/** - * Applies function f on components of a protocol - */ -export function Protocol_mapComponents(f: ((arg0: FSharpList) => FSharpList), protocol: Protocol): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, map_1, FSharpList>(f, protocol.Components), protocol.Comments); -} - -/** - * Replaces components of a protocol by given component list - */ -export function Protocol_setComponents(protocol: Protocol, components: FSharpList): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, protocol.Parameters, components, protocol.Comments); -} - -export function Protocol_addComponent(comp: Component, protocol: Protocol): Protocol { - return Protocol_setComponents(protocol, append(defaultArg(protocol.Components, empty()), singleton(comp))); -} - -/** - * Returns protocol parameters of a protocol - */ -export function Protocol_getParameters_4D8AC666(protocol: Protocol): Option> { - return protocol.Parameters; -} - -/** - * Applies function f on protocol parameters of a protocol - */ -export function Protocol_mapParameters(f: ((arg0: FSharpList) => FSharpList), protocol: Protocol): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, map_1, FSharpList>(f, protocol.Parameters), protocol.Components, protocol.Comments); -} - -/** - * Replaces protocol parameters of a protocol by given protocol parameter list - */ -export function Protocol_setParameters(protocol: Protocol, parameters: FSharpList): Protocol { - return new Protocol(protocol.ID, protocol.Name, protocol.ProtocolType, protocol.Description, protocol.Uri, protocol.Version, parameters, protocol.Components, protocol.Comments); -} - -export function Protocol_addParameter(parameter: ProtocolParameter, protocol: Protocol): Protocol { - return Protocol_setParameters(protocol, append(defaultArg(protocol.Parameters, empty()), singleton(parameter))); -} - diff --git a/ts/ISA/ISA/JsonTypes/ProtocolParameter.ts b/ts/ISA/ISA/JsonTypes/ProtocolParameter.ts deleted file mode 100644 index de8c79ba..00000000 --- a/ts/ISA/ISA/JsonTypes/ProtocolParameter.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { bind, map, defaultArg, unwrap, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { OntologyAnnotation__get_TryNameText, OntologyAnnotation__get_NameText, OntologyAnnotation_toString_473B9D79, OntologyAnnotation_get_empty, OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { IISAPrintable } from "../Printer.js"; -import { record_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { fromValueWithDefault } from "../OptionExtensions.js"; -import { FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Comment$ } from "./Comment.js"; - -export class ProtocolParameter extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly ParameterName: Option; - constructor(ID: Option, ParameterName: Option) { - super(); - this.ID = ID; - this.ParameterName = ParameterName; - } - Print(): string { - const this$: ProtocolParameter = this; - return toString(this$); - } - PrintCompact(): string { - const this$: ProtocolParameter = this; - return "OA " + ProtocolParameter__get_NameText(this$); - } -} - -export function ProtocolParameter_$reflection(): TypeInfo { - return record_type("ISA.ProtocolParameter", [], ProtocolParameter, () => [["ID", option_type(string_type)], ["ParameterName", option_type(OntologyAnnotation_$reflection())]]); -} - -export function ProtocolParameter_make(id: Option, parameterName: Option): ProtocolParameter { - return new ProtocolParameter(id, parameterName); -} - -export function ProtocolParameter_create_2769312B(Id?: string, ParameterName?: OntologyAnnotation): ProtocolParameter { - return ProtocolParameter_make(Id, ParameterName); -} - -export function ProtocolParameter_get_empty(): ProtocolParameter { - return ProtocolParameter_create_2769312B(); -} - -/** - * Create a ISAJson Protocol Parameter from ISATab string entries - */ -export function ProtocolParameter_fromString_703AFBF9(term: string, source: string, accession: string, comments?: FSharpList): ProtocolParameter { - const oa: OntologyAnnotation = OntologyAnnotation_fromString_Z7D8EB286(term, source, accession, unwrap(comments)); - return ProtocolParameter_make(void 0, fromValueWithDefault(OntologyAnnotation_get_empty(), oa)); -} - -/** - * Get ISATab string entries from an ISAJson ProtocolParameter object (name,source,accession) - */ -export function ProtocolParameter_toString_2762A46F(pp: ProtocolParameter): { TermAccessionNumber: string, TermName: string, TermSourceREF: string } { - const value: { TermAccessionNumber: string, TermName: string, TermSourceREF: string } = { - TermAccessionNumber: "", - TermName: "", - TermSourceREF: "", - }; - return defaultArg(map(OntologyAnnotation_toString_473B9D79, pp.ParameterName), value); -} - -/** - * Returns the name of the parameter as string - */ -export function ProtocolParameter__get_NameText(this$: ProtocolParameter): string { - return defaultArg(map(OntologyAnnotation__get_NameText, this$.ParameterName), ""); -} - -/** - * Returns the name of the parameter as string - */ -export function ProtocolParameter__get_TryNameText(this$: ProtocolParameter): Option { - return bind(OntologyAnnotation__get_TryNameText, this$.ParameterName); -} - -export function ProtocolParameter__MapCategory_65D42856(this$: ProtocolParameter, f: ((arg0: OntologyAnnotation) => OntologyAnnotation)): ProtocolParameter { - return new ProtocolParameter(this$.ID, map(f, this$.ParameterName)); -} - -export function ProtocolParameter__SetCategory_2FC95D30(this$: ProtocolParameter, c: OntologyAnnotation): ProtocolParameter { - return new ProtocolParameter(this$.ID, c); -} - -/** - * Returns the name of the paramater as string if it exists - */ -export function ProtocolParameter_tryGetNameText_2762A46F(pp: ProtocolParameter): Option { - return ProtocolParameter__get_TryNameText(pp); -} - -/** - * Returns the name of the paramater as string - */ -export function ProtocolParameter_getNameText_2762A46F(pp: ProtocolParameter): string { - return defaultArg(ProtocolParameter_tryGetNameText_2762A46F(pp), ""); -} - -/** - * Returns true if the given name matches the name of the parameter - */ -export function ProtocolParameter_nameEqualsString(name: string, pp: ProtocolParameter): boolean { - return ProtocolParameter__get_NameText(pp) === name; -} - diff --git a/ts/ISA/ISA/JsonTypes/Publication.ts b/ts/ISA/ISA/JsonTypes/Publication.ts deleted file mode 100644 index 3e7b2587..00000000 --- a/ts/ISA/ISA/JsonTypes/Publication.ts +++ /dev/null @@ -1,176 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { map as map_1, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { empty, filter, map, tryFind, exists, singleton, append, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { equals, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Update_UpdateOptions_$union } from "../Update.js"; -import { map2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { mapDefault } from "../OptionExtensions.js"; - -export class Publication extends Record implements IEquatable { - readonly PubMedID: Option; - readonly DOI: Option; - readonly Authors: Option; - readonly Title: Option; - readonly Status: Option; - readonly Comments: Option>; - constructor(PubMedID: Option, DOI: Option, Authors: Option, Title: Option, Status: Option, Comments: Option>) { - super(); - this.PubMedID = PubMedID; - this.DOI = DOI; - this.Authors = Authors; - this.Title = Title; - this.Status = Status; - this.Comments = Comments; - } -} - -export function Publication_$reflection(): TypeInfo { - return record_type("ISA.Publication", [], Publication, () => [["PubMedID", option_type(string_type)], ["DOI", option_type(string_type)], ["Authors", option_type(string_type)], ["Title", option_type(string_type)], ["Status", option_type(OntologyAnnotation_$reflection())], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Publication_make(pubMedID: Option, doi: Option, authors: Option, title: Option, status: Option, comments: Option>): Publication { - return new Publication(pubMedID, doi, authors, title, status, comments); -} - -export function Publication_create_Z3E55064F(PubMedID?: string, Doi?: string, Authors?: string, Title?: string, Status?: OntologyAnnotation, Comments?: FSharpList): Publication { - return Publication_make(PubMedID, Doi, Authors, Title, Status, Comments); -} - -export function Publication_get_empty(): Publication { - return Publication_create_Z3E55064F(); -} - -/** - * Adds the given publication to the publications - */ -export function Publication_add(publications: FSharpList, publication: Publication): FSharpList { - return append(publications, singleton(publication)); -} - -/** - * Returns true, if a publication with the given doi exists in the investigation - */ -export function Publication_existsByDoi(doi: string, publications: FSharpList): boolean { - return exists((p: Publication): boolean => equals(p.DOI, doi), publications); -} - -/** - * Returns true, if a publication with the given pubmedID exists in the investigation - */ -export function Publication_existsByPubMedID(pubMedID: string, publications: FSharpList): boolean { - return exists((p: Publication): boolean => equals(p.PubMedID, pubMedID), publications); -} - -/** - * If a publication with the given doi exists in the investigation, returns it - */ -export function Publication_tryGetByDoi(doi: string, publications: FSharpList): Option { - return tryFind((publication: Publication): boolean => equals(publication.DOI, doi), publications); -} - -/** - * Updates all publications for which the predicate returns true with the given publication values - */ -export function Publication_updateBy(predicate: ((arg0: Publication) => boolean), updateOption: Update_UpdateOptions_$union, publication: Publication, publications: FSharpList): FSharpList { - if (exists(predicate, publications)) { - return map((p: Publication): Publication => { - if (predicate(p)) { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: Publication = p; - const recordType_2: Publication = publication; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Publication_$reflection(), map2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Publication; - case /* UpdateByExisting */ 1: - return makeRecord(Publication_$reflection(), map2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Publication; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Publication_$reflection(), map2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Publication; - default: - return recordType_2; - } - } - else { - return p; - } - }, publications); - } - else { - return publications; - } -} - -/** - * Updates all protocols with the same DOI as the given publication with its values - */ -export function Publication_updateByDOI(updateOption: Update_UpdateOptions_$union, publication: Publication, publications: FSharpList): FSharpList { - return Publication_updateBy((p: Publication): boolean => equals(p.DOI, publication.DOI), updateOption, publication, publications); -} - -/** - * Updates all protocols with the same pubMedID as the given publication with its values - */ -export function Publication_updateByPubMedID(updateOption: Update_UpdateOptions_$union, publication: Publication, publications: FSharpList): FSharpList { - return Publication_updateBy((p: Publication): boolean => equals(p.PubMedID, publication.PubMedID), updateOption, publication, publications); -} - -/** - * If a publication with the given doi exists in the investigation, removes it from the investigation - */ -export function Publication_removeByDoi(doi: string, publications: FSharpList): FSharpList { - return filter((p: Publication): boolean => !equals(p.DOI, doi), publications); -} - -/** - * If a publication with the given pubMedID exists in the investigation, removes it - */ -export function Publication_removeByPubMedID(pubMedID: string, publications: FSharpList): FSharpList { - return filter((p: Publication): boolean => !equals(p.PubMedID, pubMedID), publications); -} - -/** - * Status - * Returns publication status of a publication - */ -export function Publication_getStatus_Z3C2FFBB4(publication: Publication): Option { - return publication.Status; -} - -/** - * Applies function f on publication status of a publication - */ -export function Publication_mapStatus(f: ((arg0: OntologyAnnotation) => OntologyAnnotation), publication: Publication): Publication { - return new Publication(publication.PubMedID, publication.DOI, publication.Authors, publication.Title, map_1(f, publication.Status), publication.Comments); -} - -/** - * Replaces publication status of a publication by given publication status - */ -export function Publication_setStatus(publication: Publication, status: OntologyAnnotation): Publication { - return new Publication(publication.PubMedID, publication.DOI, publication.Authors, publication.Title, status, publication.Comments); -} - -/** - * Returns comments of a protocol - */ -export function Publication_getComments_Z3C2FFBB4(publication: Publication): Option> { - return publication.Comments; -} - -/** - * Applies function f on comments of a protocol - */ -export function Publication_mapComments(f: ((arg0: FSharpList) => FSharpList), publication: Publication): Publication { - return new Publication(publication.PubMedID, publication.DOI, publication.Authors, publication.Title, publication.Status, mapDefault>(empty(), f, publication.Comments)); -} - -/** - * Replaces comments of a protocol by given comment list - */ -export function Publication_setComments(publication: Publication, comments: FSharpList): Publication { - return new Publication(publication.PubMedID, publication.DOI, publication.Authors, publication.Title, publication.Status, comments); -} - diff --git a/ts/ISA/ISA/JsonTypes/Sample.ts b/ts/ISA/ISA/JsonTypes/Sample.ts deleted file mode 100644 index 51960703..00000000 --- a/ts/ISA/ISA/JsonTypes/Sample.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { append, choose, FSharpList, empty, length } from "../../../fable_modules/fable-library-ts/List.js"; -import { Option, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { MaterialAttributeValue_$reflection, MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { FactorValue_$reflection, FactorValue } from "./FactorValue.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; -import { Source_$reflection, Source } from "./Source.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { IISAPrintable } from "../Printer.js"; -import { record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; - -export class Sample extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly Name: Option; - readonly Characteristics: Option>; - readonly FactorValues: Option>; - readonly DerivesFrom: Option>; - constructor(ID: Option, Name: Option, Characteristics: Option>, FactorValues: Option>, DerivesFrom: Option>) { - super(); - this.ID = ID; - this.Name = Name; - this.Characteristics = Characteristics; - this.FactorValues = FactorValues; - this.DerivesFrom = DerivesFrom; - } - Print(): string { - const this$: Sample = this; - return toString(this$); - } - PrintCompact(): string { - const this$: Sample = this; - const chars: int32 = length(defaultArg(this$.Characteristics, empty())) | 0; - const facts: int32 = length(defaultArg(this$.FactorValues, empty())) | 0; - const arg: string = Sample__get_NameAsString(this$); - return toText(printf("%s [%i characteristics; %i factors]"))(arg)(chars)(facts); - } -} - -export function Sample_$reflection(): TypeInfo { - return record_type("ISA.Sample", [], Sample, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["Characteristics", option_type(list_type(MaterialAttributeValue_$reflection()))], ["FactorValues", option_type(list_type(FactorValue_$reflection()))], ["DerivesFrom", option_type(list_type(Source_$reflection()))]]); -} - -export function Sample_make(id: Option, name: Option, characteristics: Option>, factorValues: Option>, derivesFrom: Option>): Sample { - return new Sample(id, name, characteristics, factorValues, derivesFrom); -} - -export function Sample_create_3A6378D6(Id?: string, Name?: string, Characteristics?: FSharpList, FactorValues?: FSharpList, DerivesFrom?: FSharpList): Sample { - return Sample_make(Id, Name, Characteristics, FactorValues, DerivesFrom); -} - -export function Sample_get_empty(): Sample { - return Sample_create_3A6378D6(); -} - -export function Sample__get_NameAsString(this$: Sample): string { - return defaultArg(this$.Name, ""); -} - -export function Sample_getCharacteristicUnits_Z23050B6A(s: Sample): FSharpList { - return choose((c: MaterialAttributeValue): Option => c.Unit, defaultArg(s.Characteristics, empty())); -} - -export function Sample_getFactorUnits_Z23050B6A(s: Sample): FSharpList { - return choose((c: FactorValue): Option => c.Unit, defaultArg(s.FactorValues, empty())); -} - -export function Sample_getUnits_Z23050B6A(s: Sample): FSharpList { - return append(Sample_getCharacteristicUnits_Z23050B6A(s), Sample_getFactorUnits_Z23050B6A(s)); -} - -export function Sample_setCharacteristicValues(values: FSharpList, s: Sample): Sample { - return new Sample(s.ID, s.Name, values, s.FactorValues, s.DerivesFrom); -} - -export function Sample_setFactorValues(values: FSharpList, s: Sample): Sample { - return new Sample(s.ID, s.Name, s.Characteristics, values, s.DerivesFrom); -} - diff --git a/ts/ISA/ISA/JsonTypes/Source.ts b/ts/ISA/ISA/JsonTypes/Source.ts deleted file mode 100644 index 43488b6c..00000000 --- a/ts/ISA/ISA/JsonTypes/Source.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Record, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { choose, FSharpList, empty, length } from "../../../fable_modules/fable-library-ts/List.js"; -import { Option, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { MaterialAttributeValue_$reflection, MaterialAttributeValue } from "./MaterialAttributeValue.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { IISAPrintable } from "../Printer.js"; -import { record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { OntologyAnnotation } from "./OntologyAnnotation.js"; - -export class Source extends Record implements IEquatable, IISAPrintable { - readonly ID: Option; - readonly Name: Option; - readonly Characteristics: Option>; - constructor(ID: Option, Name: Option, Characteristics: Option>) { - super(); - this.ID = ID; - this.Name = Name; - this.Characteristics = Characteristics; - } - Print(): string { - const this$: Source = this; - return toString(this$); - } - PrintCompact(): string { - const this$: Source = this; - const l: int32 = length(defaultArg(this$.Characteristics, empty())) | 0; - const arg: string = Source__get_NameAsString(this$); - return toText(printf("%s [%i characteristics]"))(arg)(l); - } -} - -export function Source_$reflection(): TypeInfo { - return record_type("ISA.Source", [], Source, () => [["ID", option_type(string_type)], ["Name", option_type(string_type)], ["Characteristics", option_type(list_type(MaterialAttributeValue_$reflection()))]]); -} - -export function Source_make(id: Option, name: Option, characteristics: Option>): Source { - return new Source(id, name, characteristics); -} - -export function Source_create_Z32235993(Id?: string, Name?: string, Characteristics?: FSharpList): Source { - return Source_make(Id, Name, Characteristics); -} - -export function Source_get_empty(): Source { - return Source_create_Z32235993(); -} - -export function Source__get_NameAsString(this$: Source): string { - return defaultArg(this$.Name, ""); -} - -export function Source_getUnits_Z220A6393(m: Source): FSharpList { - return choose((c: MaterialAttributeValue): Option => c.Unit, defaultArg(m.Characteristics, empty())); -} - -export function Source_setCharacteristicValues(values: FSharpList, m: Source): Source { - return new Source(m.ID, m.Name, values); -} - diff --git a/ts/ISA/ISA/JsonTypes/Study.ts b/ts/ISA/ISA/JsonTypes/Study.ts deleted file mode 100644 index a961ee98..00000000 --- a/ts/ISA/ISA/JsonTypes/Study.ts +++ /dev/null @@ -1,962 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { map as map_1, value as value_3, defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { collect, empty, filter, map, singleton, append, exists, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Publication_$reflection, Publication } from "./Publication.js"; -import { Person_$reflection, Person } from "./Person.js"; -import { OntologyAnnotation_$reflection, OntologyAnnotation } from "./OntologyAnnotation.js"; -import { Protocol_$reflection, Protocol } from "./Protocol.js"; -import { StudyMaterials_get_empty, StudyMaterials_make, StudyMaterials_$reflection, StudyMaterials } from "./StudyMaterials.js"; -import { Process_$reflection, Process } from "./Process.js"; -import { Assay_update_Z269B5B97, Assay_updateProtocols, Assay_getMaterials_Z269B5B97, Assay_getSamples_Z269B5B97, Assay_getSources_Z269B5B97, Assay_getUnitCategories_Z269B5B97, Assay_getFactors_Z269B5B97, Assay_getCharacteristics_Z269B5B97, Assay_getProtocols_Z269B5B97, Assay_$reflection, Assay } from "./Assay.js"; -import { Factor_$reflection, Factor } from "./Factor.js"; -import { MaterialAttribute_$reflection, MaterialAttribute } from "./MaterialAttribute.js"; -import { Comment$_$reflection, Comment$ } from "./Comment.js"; -import { stringHash, safeHash, structuralHash, IMap, equals, IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { getRecordFields, makeRecord, record_type, list_type, option_type, string_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { Update_UpdateOptions_UpdateByExistingAppendLists, Update_UpdateOptions_$union } from "../Update.js"; -import { map2 as map2_2 } from "../../../fable_modules/fable-library-ts/Array.js"; -import { Dict_tryFind, Dict_ofSeqWithMerge, Update_updateOnlyByExistingAppend, Update_updateOnlyByExisting, Update_updateAppend } from "../Update.js"; -import { fromValueWithDefault, mapDefault } from "../OptionExtensions.js"; -import { updateProtocols, getMaterials, getSamples, getSources, getUnits, getFactors, getCharacteristics, getProtocols } from "./ProcessSequence.js"; -import { List_distinct } from "../../../fable_modules/fable-library-ts/Seq2.js"; -import { int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { Source_$reflection, Source } from "./Source.js"; -import { Sample_$reflection, Sample } from "./Sample.js"; -import { Material_$reflection, Material } from "./Material.js"; -import { AssayMaterials_getMaterials_E3447B1 } from "./AssayMaterials.js"; -import { toFail } from "../../../fable_modules/fable-library-ts/String.js"; - -export class Study extends Record implements IEquatable { - readonly ID: Option; - readonly FileName: Option; - readonly Identifier: Option; - readonly Title: Option; - readonly Description: Option; - readonly SubmissionDate: Option; - readonly PublicReleaseDate: Option; - readonly Publications: Option>; - readonly Contacts: Option>; - readonly StudyDesignDescriptors: Option>; - readonly Protocols: Option>; - readonly Materials: Option; - readonly ProcessSequence: Option>; - readonly Assays: Option>; - readonly Factors: Option>; - readonly CharacteristicCategories: Option>; - readonly UnitCategories: Option>; - readonly Comments: Option>; - constructor(ID: Option, FileName: Option, Identifier: Option, Title: Option, Description: Option, SubmissionDate: Option, PublicReleaseDate: Option, Publications: Option>, Contacts: Option>, StudyDesignDescriptors: Option>, Protocols: Option>, Materials: Option, ProcessSequence: Option>, Assays: Option>, Factors: Option>, CharacteristicCategories: Option>, UnitCategories: Option>, Comments: Option>) { - super(); - this.ID = ID; - this.FileName = FileName; - this.Identifier = Identifier; - this.Title = Title; - this.Description = Description; - this.SubmissionDate = SubmissionDate; - this.PublicReleaseDate = PublicReleaseDate; - this.Publications = Publications; - this.Contacts = Contacts; - this.StudyDesignDescriptors = StudyDesignDescriptors; - this.Protocols = Protocols; - this.Materials = Materials; - this.ProcessSequence = ProcessSequence; - this.Assays = Assays; - this.Factors = Factors; - this.CharacteristicCategories = CharacteristicCategories; - this.UnitCategories = UnitCategories; - this.Comments = Comments; - } -} - -export function Study_$reflection(): TypeInfo { - return record_type("ISA.Study", [], Study, () => [["ID", option_type(string_type)], ["FileName", option_type(string_type)], ["Identifier", option_type(string_type)], ["Title", option_type(string_type)], ["Description", option_type(string_type)], ["SubmissionDate", option_type(string_type)], ["PublicReleaseDate", option_type(string_type)], ["Publications", option_type(list_type(Publication_$reflection()))], ["Contacts", option_type(list_type(Person_$reflection()))], ["StudyDesignDescriptors", option_type(list_type(OntologyAnnotation_$reflection()))], ["Protocols", option_type(list_type(Protocol_$reflection()))], ["Materials", option_type(StudyMaterials_$reflection())], ["ProcessSequence", option_type(list_type(Process_$reflection()))], ["Assays", option_type(list_type(Assay_$reflection()))], ["Factors", option_type(list_type(Factor_$reflection()))], ["CharacteristicCategories", option_type(list_type(MaterialAttribute_$reflection()))], ["UnitCategories", option_type(list_type(OntologyAnnotation_$reflection()))], ["Comments", option_type(list_type(Comment$_$reflection()))]]); -} - -export function Study_make(id: Option, filename: Option, identifier: Option, title: Option, description: Option, submissionDate: Option, publicReleaseDate: Option, publications: Option>, contacts: Option>, studyDesignDescriptors: Option>, protocols: Option>, materials: Option, processSequence: Option>, assays: Option>, factors: Option>, characteristicCategories: Option>, unitCategories: Option>, comments: Option>): Study { - return new Study(id, filename, identifier, title, description, submissionDate, publicReleaseDate, publications, contacts, studyDesignDescriptors, protocols, materials, processSequence, assays, factors, characteristicCategories, unitCategories, comments); -} - -export function Study_create_Z6C8AB268(Id?: string, FileName?: string, Identifier?: string, Title?: string, Description?: string, SubmissionDate?: string, PublicReleaseDate?: string, Publications?: FSharpList, Contacts?: FSharpList, StudyDesignDescriptors?: FSharpList, Protocols?: FSharpList, Materials?: StudyMaterials, ProcessSequence?: FSharpList, Assays?: FSharpList, Factors?: FSharpList, CharacteristicCategories?: FSharpList, UnitCategories?: FSharpList, Comments?: FSharpList): Study { - return Study_make(Id, FileName, Identifier, Title, Description, SubmissionDate, PublicReleaseDate, Publications, Contacts, StudyDesignDescriptors, Protocols, Materials, ProcessSequence, Assays, Factors, CharacteristicCategories, UnitCategories, Comments); -} - -export function Study_get_empty(): Study { - return Study_create_Z6C8AB268(); -} - -/** - * If an study with the given identfier exists in the list, returns true - */ -export function Study_existsByIdentifier(identifier: string, studies: FSharpList): boolean { - return exists((s: Study): boolean => equals(s.Identifier, identifier), studies); -} - -/** - * Adds the given study to the studies - */ -export function Study_add(studies: FSharpList, study: Study): FSharpList { - return append(studies, singleton(study)); -} - -/** - * Updates all studies for which the predicate returns true with the given study values - */ -export function Study_updateBy(predicate: ((arg0: Study) => boolean), updateOption: Update_UpdateOptions_$union, study: Study, studies: FSharpList): FSharpList { - if (exists(predicate, studies)) { - return map((a: Study): Study => { - if (predicate(a)) { - const this$: Update_UpdateOptions_$union = updateOption; - const recordType_1: Study = a; - const recordType_2: Study = study; - return (this$.tag === /* UpdateAllAppendLists */ 2) ? (makeRecord(Study_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Study) : ((this$.tag === /* UpdateByExisting */ 1) ? (makeRecord(Study_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Study) : ((this$.tag === /* UpdateByExistingAppendLists */ 3) ? (makeRecord(Study_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Study) : recordType_2)); - } - else { - return a; - } - }, studies); - } - else { - return studies; - } -} - -/** - * Updates all studies with the same identifier as the given study with its values - */ -export function Study_updateByIdentifier(updateOption: Update_UpdateOptions_$union, study: Study, studies: FSharpList): FSharpList { - return Study_updateBy((s: Study): boolean => equals(s.Identifier, study.Identifier), updateOption, study, studies); -} - -/** - * If a study with the given identifier exists in the list, removes it - */ -export function Study_removeByIdentifier(identifier: string, studies: FSharpList): FSharpList { - return filter((s: Study): boolean => !equals(s.Identifier, identifier), studies); -} - -/** - * Returns assays of a study - */ -export function Study_getAssays_Z27CB2981(study: Study): FSharpList { - return defaultArg(study.Assays, empty()); -} - -/** - * Applies function f to the assays of a study - */ -export function Study_mapAssays(f: ((arg0: FSharpList) => FSharpList), study: Study): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, mapDefault>(empty(), f, study.Assays), study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces study assays with the given assay list - */ -export function Study_setAssays(study: Study, assays: FSharpList): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Applies function f to the factors of a study - */ -export function Study_mapFactors(f: ((arg0: FSharpList) => FSharpList), study: Study): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, mapDefault>(empty(), f, study.Factors), study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces study factors with the given assay list - */ -export function Study_setFactors(study: Study, factors: FSharpList): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Applies function f to the protocols of a study - */ -export function Study_mapProtocols(f: ((arg0: FSharpList) => FSharpList), study: Study): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, mapDefault>(empty(), f, study.Protocols), study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces study protocols with the given assay list - */ -export function Study_setProtocols(study: Study, protocols: FSharpList): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Returns all contacts of a study - */ -export function Study_getContacts_Z27CB2981(study: Study): FSharpList { - return defaultArg(study.Contacts, empty()); -} - -/** - * Applies function f to contacts of a study - */ -export function Study_mapContacts(f: ((arg0: FSharpList) => FSharpList), study: Study): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, mapDefault>(empty(), f, study.Contacts), study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces contacts of a study with the given person list - */ -export function Study_setContacts(study: Study, persons: FSharpList): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, persons, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Returns publications of a study - */ -export function Study_getPublications_Z27CB2981(study: Study): FSharpList { - return defaultArg(study.Publications, empty()); -} - -/** - * Applies function f to publications of the study - */ -export function Study_mapPublications(f: ((arg0: FSharpList) => FSharpList), study: Study): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, mapDefault>(empty(), f, study.Publications), study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces publications of a study with the given publication list - */ -export function Study_setPublications(study: Study, publications: FSharpList): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, publications, study.Contacts, study.StudyDesignDescriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Returns study design descriptors of a study - */ -export function Study_getDescriptors_Z27CB2981(study: Study): FSharpList { - return defaultArg(study.StudyDesignDescriptors, empty()); -} - -/** - * Applies function f to to study design descriptors of a study - */ -export function Study_mapDescriptors(f: ((arg0: FSharpList) => FSharpList), study: Study): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, mapDefault>(empty(), f, study.StudyDesignDescriptors), study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Replaces study design descriptors with the given ontology annotation list - */ -export function Study_setDescriptors(study: Study, descriptors: FSharpList): Study { - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, descriptors, study.Protocols, study.Materials, study.ProcessSequence, study.Assays, study.Factors, study.CharacteristicCategories, study.UnitCategories, study.Comments); -} - -/** - * Returns processSequence of study - */ -export function Study_getProcesses_Z27CB2981(study: Study): FSharpList { - return defaultArg(study.ProcessSequence, empty()); -} - -/** - * Returns protocols of a study - */ -export function Study_getProtocols_Z27CB2981(study: Study): FSharpList { - const processSequenceProtocols: FSharpList = getProtocols(Study_getProcesses_Z27CB2981(study)); - const assaysProtocols: FSharpList = collect(Assay_getProtocols_Z269B5B97, Study_getAssays_Z27CB2981(study)); - const updateOptions_2: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_6 = (p_1: Protocol): Option => p_1.Name; - const list1_1: FSharpList = defaultArg(study.Protocols, empty()); - let list2_1: FSharpList; - const updateOptions: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_1 = (p: Protocol): Option => p.Name; - const list1: FSharpList = assaysProtocols; - const list2: FSharpList = processSequenceProtocols; - try { - const map1: IMap, Protocol> = Dict_ofSeqWithMerge>((arg_1: Protocol, arg_1_1: Protocol): Protocol => { - const this$: Update_UpdateOptions_$union = updateOptions; - const recordType_1: Protocol = arg_1; - const recordType_2: Protocol = arg_1_1; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol; - case /* UpdateByExisting */ 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Protocol; - default: - return recordType_2; - } - }, map, Protocol]>((v: Protocol): [Option, Protocol] => ([mapping_1(v), v] as [Option, Protocol]), list1)); - const map2: IMap, Protocol> = Dict_ofSeqWithMerge>((arg_2: Protocol, arg_3: Protocol): Protocol => { - const this$_1: Update_UpdateOptions_$union = updateOptions; - const recordType_1_1: Protocol = arg_2; - const recordType_2_1: Protocol = arg_3; - switch (this$_1.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Protocol; - case /* UpdateByExisting */ 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Protocol; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Protocol; - default: - return recordType_2_1; - } - }, map, Protocol]>((v_1: Protocol): [Option, Protocol] => ([mapping_1(v_1), v_1] as [Option, Protocol]), list2)); - list2_1 = map, Protocol>((k: Option): Protocol => { - const matchValue: Option = Dict_tryFind, Protocol>(k, map1); - const matchValue_1: Option = Dict_tryFind, Protocol>(k, map2); - if (matchValue == null) { - if (matchValue_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1: Protocol = value_3(matchValue_1); - return v2_1; - } - } - else if (matchValue_1 == null) { - const v1_1: Protocol = value_3(matchValue); - return v1_1; - } - else { - const v1: Protocol = value_3(matchValue); - const v2: Protocol = value_3(matchValue_1); - const this$_2: Update_UpdateOptions_$union = updateOptions; - const recordType_1_2: Protocol = v1; - const recordType_2_2: Protocol = v2; - switch (this$_2.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Protocol; - case /* UpdateByExisting */ 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Protocol; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Protocol; - default: - return recordType_2_2; - } - } - }, List_distinct>(append>(map>(mapping_1, list1), map>(mapping_1, list2)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err: any) { - throw new Error(`Could not mergeUpdate ${"Protocol"} list: -${err.message}`); - } - try { - const map1_1: IMap, Protocol> = Dict_ofSeqWithMerge>((arg_6: Protocol, arg_1_2: Protocol): Protocol => { - const this$_3: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_3: Protocol = arg_6; - const recordType_2_3: Protocol = arg_1_2; - switch (this$_3.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Protocol; - case /* UpdateByExisting */ 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Protocol; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Protocol; - default: - return recordType_2_3; - } - }, map, Protocol]>((v_2: Protocol): [Option, Protocol] => ([mapping_6(v_2), v_2] as [Option, Protocol]), list1_1)); - const map2_1: IMap, Protocol> = Dict_ofSeqWithMerge>((arg_2_1: Protocol, arg_3_1: Protocol): Protocol => { - const this$_4: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_4: Protocol = arg_2_1; - const recordType_2_4: Protocol = arg_3_1; - switch (this$_4.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Protocol; - case /* UpdateByExisting */ 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Protocol; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Protocol; - default: - return recordType_2_4; - } - }, map, Protocol]>((v_1_1: Protocol): [Option, Protocol] => ([mapping_6(v_1_1), v_1_1] as [Option, Protocol]), list2_1)); - return map, Protocol>((k_1: Option): Protocol => { - const matchValue_3: Option = Dict_tryFind, Protocol>(k_1, map1_1); - const matchValue_1_1: Option = Dict_tryFind, Protocol>(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1: Protocol = value_3(matchValue_1_1); - return v2_1_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1_1: Protocol = value_3(matchValue_3); - return v1_1_1; - } - else { - const v1_2: Protocol = value_3(matchValue_3); - const v2_2: Protocol = value_3(matchValue_1_1); - const this$_5: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_5: Protocol = v1_2; - const recordType_2_5: Protocol = v2_2; - switch (this$_5.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Protocol; - case /* UpdateByExisting */ 1: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Protocol; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Protocol_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Protocol; - default: - return recordType_2_5; - } - } - }, List_distinct>(append>(map>(mapping_6, list1_1), map>(mapping_6, list2_1)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err_1: any) { - throw new Error(`Could not mergeUpdate ${"Protocol"} list: -${err_1.message}`); - } -} - -/** - * Returns Characteristics of the study - */ -export function Study_getCharacteristics_Z27CB2981(study: Study): FSharpList { - return List_distinct(append(getCharacteristics(Study_getProcesses_Z27CB2981(study)), append(collect(Assay_getCharacteristics_Z269B5B97, Study_getAssays_Z27CB2981(study)), defaultArg(study.CharacteristicCategories, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns factors of the study - */ -export function Study_getFactors_Z27CB2981(study: Study): FSharpList { - return List_distinct(append(getFactors(Study_getProcesses_Z27CB2981(study)), append(collect(Assay_getFactors_Z269B5B97, Study_getAssays_Z27CB2981(study)), defaultArg(study.Factors, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns unit categories of the study - */ -export function Study_getUnitCategories_Z27CB2981(study: Study): FSharpList { - return List_distinct(append(getUnits(Study_getProcesses_Z27CB2981(study)), append(collect(Assay_getUnitCategories_Z269B5B97, Study_getAssays_Z27CB2981(study)), defaultArg(study.UnitCategories, empty()))), { - Equals: equals, - GetHashCode: safeHash, - }); -} - -/** - * Returns sources of the study - */ -export function Study_getSources_Z27CB2981(study: Study): FSharpList { - const processSequenceSources: FSharpList = getSources(Study_getProcesses_Z27CB2981(study)); - const assaysSources: FSharpList = collect(Assay_getSources_Z269B5B97, Study_getAssays_Z27CB2981(study)); - const updateOptions_2: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_6 = (s_2: Source): string => defaultArg(s_2.Name, ""); - let list1_1: FSharpList; - const matchValue: Option = study.Materials; - list1_1 = ((matchValue == null) ? empty() : defaultArg(value_3(matchValue).Sources, empty())); - let list2_1: FSharpList; - const updateOptions: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_1 = (s: Source): string => defaultArg(s.Name, ""); - const list1: FSharpList = assaysSources; - const list2: FSharpList = processSequenceSources; - try { - const map1: IMap = Dict_ofSeqWithMerge((arg_1: Source, arg_1_1: Source): Source => { - const this$: Update_UpdateOptions_$union = updateOptions; - const recordType_1: Source = arg_1; - const recordType_2: Source = arg_1_1; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Source; - case /* UpdateByExisting */ 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Source; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Source; - default: - return recordType_2; - } - }, map((v: Source): [string, Source] => ([mapping_1(v), v] as [string, Source]), list1)); - const map2: IMap = Dict_ofSeqWithMerge((arg_2: Source, arg_3: Source): Source => { - const this$_1: Update_UpdateOptions_$union = updateOptions; - const recordType_1_1: Source = arg_2; - const recordType_2_1: Source = arg_3; - switch (this$_1.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Source; - case /* UpdateByExisting */ 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Source; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Source; - default: - return recordType_2_1; - } - }, map((v_1: Source): [string, Source] => ([mapping_1(v_1), v_1] as [string, Source]), list2)); - list2_1 = map((k: string): Source => { - const matchValue_1: Option = Dict_tryFind(k, map1); - const matchValue_1_1: Option = Dict_tryFind(k, map2); - if (matchValue_1 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1: Source = value_3(matchValue_1_1); - return v2_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1: Source = value_3(matchValue_1); - return v1_1; - } - else { - const v1: Source = value_3(matchValue_1); - const v2: Source = value_3(matchValue_1_1); - const this$_2: Update_UpdateOptions_$union = updateOptions; - const recordType_1_2: Source = v1; - const recordType_2_2: Source = v2; - switch (this$_2.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Source; - case /* UpdateByExisting */ 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Source; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Source; - default: - return recordType_2_2; - } - } - }, List_distinct(append(map(mapping_1, list1), map(mapping_1, list2)), { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })); - } - catch (err: any) { - throw new Error(`Could not mergeUpdate ${"Source"} list: -${err.message}`); - } - try { - const map1_1: IMap = Dict_ofSeqWithMerge((arg_6: Source, arg_1_2: Source): Source => { - const this$_3: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_3: Source = arg_6; - const recordType_2_3: Source = arg_1_2; - switch (this$_3.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Source; - case /* UpdateByExisting */ 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Source; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Source; - default: - return recordType_2_3; - } - }, map((v_2: Source): [string, Source] => ([mapping_6(v_2), v_2] as [string, Source]), list1_1)); - const map2_1: IMap = Dict_ofSeqWithMerge((arg_2_1: Source, arg_3_1: Source): Source => { - const this$_4: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_4: Source = arg_2_1; - const recordType_2_4: Source = arg_3_1; - switch (this$_4.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Source; - case /* UpdateByExisting */ 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Source; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Source; - default: - return recordType_2_4; - } - }, map((v_1_1: Source): [string, Source] => ([mapping_6(v_1_1), v_1_1] as [string, Source]), list2_1)); - return map((k_1: string): Source => { - const matchValue_3: Option = Dict_tryFind(k_1, map1_1); - const matchValue_1_2: Option = Dict_tryFind(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_2 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1: Source = value_3(matchValue_1_2); - return v2_1_1; - } - } - else if (matchValue_1_2 == null) { - const v1_1_1: Source = value_3(matchValue_3); - return v1_1_1; - } - else { - const v1_2: Source = value_3(matchValue_3); - const v2_2: Source = value_3(matchValue_1_2); - const this$_5: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_5: Source = v1_2; - const recordType_2_5: Source = v2_2; - switch (this$_5.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Source_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Source; - case /* UpdateByExisting */ 1: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Source; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Source_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Source; - default: - return recordType_2_5; - } - } - }, List_distinct(append(map(mapping_6, list1_1), map(mapping_6, list2_1)), { - Equals: (x_1: string, y_1: string): boolean => (x_1 === y_1), - GetHashCode: stringHash, - })); - } - catch (err_1: any) { - throw new Error(`Could not mergeUpdate ${"Source"} list: -${err_1.message}`); - } -} - -/** - * Returns sources of the study - */ -export function Study_getSamples_Z27CB2981(study: Study): FSharpList { - const processSequenceSamples: FSharpList = getSamples(Study_getProcesses_Z27CB2981(study)); - const assaysSamples: FSharpList = collect(Assay_getSamples_Z269B5B97, Study_getAssays_Z27CB2981(study)); - const updateOptions_2: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_6 = (s_2: Sample): string => defaultArg(s_2.Name, ""); - let list1_1: FSharpList; - const matchValue: Option = study.Materials; - list1_1 = ((matchValue == null) ? empty() : defaultArg(value_3(matchValue).Samples, empty())); - let list2_1: FSharpList; - const updateOptions: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_1 = (s: Sample): string => defaultArg(s.Name, ""); - const list1: FSharpList = assaysSamples; - const list2: FSharpList = processSequenceSamples; - try { - const map1: IMap = Dict_ofSeqWithMerge((arg_1: Sample, arg_1_1: Sample): Sample => { - const this$: Update_UpdateOptions_$union = updateOptions; - const recordType_1: Sample = arg_1; - const recordType_2: Sample = arg_1_1; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Sample; - default: - return recordType_2; - } - }, map((v: Sample): [string, Sample] => ([mapping_1(v), v] as [string, Sample]), list1)); - const map2: IMap = Dict_ofSeqWithMerge((arg_2: Sample, arg_3: Sample): Sample => { - const this$_1: Update_UpdateOptions_$union = updateOptions; - const recordType_1_1: Sample = arg_2; - const recordType_2_1: Sample = arg_3; - switch (this$_1.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Sample; - default: - return recordType_2_1; - } - }, map((v_1: Sample): [string, Sample] => ([mapping_1(v_1), v_1] as [string, Sample]), list2)); - list2_1 = map((k: string): Sample => { - const matchValue_1: Option = Dict_tryFind(k, map1); - const matchValue_1_1: Option = Dict_tryFind(k, map2); - if (matchValue_1 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1: Sample = value_3(matchValue_1_1); - return v2_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1: Sample = value_3(matchValue_1); - return v1_1; - } - else { - const v1: Sample = value_3(matchValue_1); - const v2: Sample = value_3(matchValue_1_1); - const this$_2: Update_UpdateOptions_$union = updateOptions; - const recordType_1_2: Sample = v1; - const recordType_2_2: Sample = v2; - switch (this$_2.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Sample; - default: - return recordType_2_2; - } - } - }, List_distinct(append(map(mapping_1, list1), map(mapping_1, list2)), { - Equals: (x: string, y: string): boolean => (x === y), - GetHashCode: stringHash, - })); - } - catch (err: any) { - throw new Error(`Could not mergeUpdate ${"Sample"} list: -${err.message}`); - } - try { - const map1_1: IMap = Dict_ofSeqWithMerge((arg_6: Sample, arg_1_2: Sample): Sample => { - const this$_3: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_3: Sample = arg_6; - const recordType_2_3: Sample = arg_1_2; - switch (this$_3.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Sample; - default: - return recordType_2_3; - } - }, map((v_2: Sample): [string, Sample] => ([mapping_6(v_2), v_2] as [string, Sample]), list1_1)); - const map2_1: IMap = Dict_ofSeqWithMerge((arg_2_1: Sample, arg_3_1: Sample): Sample => { - const this$_4: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_4: Sample = arg_2_1; - const recordType_2_4: Sample = arg_3_1; - switch (this$_4.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Sample; - default: - return recordType_2_4; - } - }, map((v_1_1: Sample): [string, Sample] => ([mapping_6(v_1_1), v_1_1] as [string, Sample]), list2_1)); - return map((k_1: string): Sample => { - const matchValue_3: Option = Dict_tryFind(k_1, map1_1); - const matchValue_1_2: Option = Dict_tryFind(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_2 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1: Sample = value_3(matchValue_1_2); - return v2_1_1; - } - } - else if (matchValue_1_2 == null) { - const v1_1_1: Sample = value_3(matchValue_3); - return v1_1_1; - } - else { - const v1_2: Sample = value_3(matchValue_3); - const v2_2: Sample = value_3(matchValue_1_2); - const this$_5: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_5: Sample = v1_2; - const recordType_2_5: Sample = v2_2; - switch (this$_5.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Sample_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Sample; - case /* UpdateByExisting */ 1: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Sample; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Sample_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Sample; - default: - return recordType_2_5; - } - } - }, List_distinct(append(map(mapping_6, list1_1), map(mapping_6, list2_1)), { - Equals: (x_1: string, y_1: string): boolean => (x_1 === y_1), - GetHashCode: stringHash, - })); - } - catch (err_1: any) { - throw new Error(`Could not mergeUpdate ${"Sample"} list: -${err_1.message}`); - } -} - -/** - * Returns materials of the study - */ -export function Study_getMaterials_Z27CB2981(study: Study): StudyMaterials { - const processSequenceMaterials: FSharpList = getMaterials(Study_getProcesses_Z27CB2981(study)); - const assaysMaterials: FSharpList = collect((arg_2: Assay): FSharpList => AssayMaterials_getMaterials_E3447B1(Assay_getMaterials_Z269B5B97(arg_2)), Study_getAssays_Z27CB2981(study)); - let materials: FSharpList; - const updateOptions_2: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_6 = (s_2: Material): Option => s_2.Name; - let list1_1: FSharpList; - const matchValue: Option = study.Materials; - list1_1 = ((matchValue == null) ? empty() : defaultArg(value_3(matchValue).OtherMaterials, empty())); - let list2_1: FSharpList; - const updateOptions: Update_UpdateOptions_$union = Update_UpdateOptions_UpdateByExistingAppendLists(); - const mapping_1 = (s: Material): Option => s.Name; - const list1: FSharpList = assaysMaterials; - const list2: FSharpList = processSequenceMaterials; - try { - const map1: IMap, Material> = Dict_ofSeqWithMerge>((arg_3: Material, arg_1_1: Material): Material => { - const this$: Update_UpdateOptions_$union = updateOptions; - const recordType_1: Material = arg_3; - const recordType_2: Material = arg_1_1; - switch (this$.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1), getRecordFields(recordType_2))) as Material; - default: - return recordType_2; - } - }, map, Material]>((v: Material): [Option, Material] => ([mapping_1(v), v] as [Option, Material]), list1)); - const map2: IMap, Material> = Dict_ofSeqWithMerge>((arg_2_1: Material, arg_3_1: Material): Material => { - const this$_1: Update_UpdateOptions_$union = updateOptions; - const recordType_1_1: Material = arg_2_1; - const recordType_2_1: Material = arg_3_1; - switch (this$_1.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_1), getRecordFields(recordType_2_1))) as Material; - default: - return recordType_2_1; - } - }, map, Material]>((v_1: Material): [Option, Material] => ([mapping_1(v_1), v_1] as [Option, Material]), list2)); - list2_1 = map, Material>((k: Option): Material => { - const matchValue_1: Option = Dict_tryFind, Material>(k, map1); - const matchValue_1_1: Option = Dict_tryFind, Material>(k, map2); - if (matchValue_1 == null) { - if (matchValue_1_1 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1: Material = value_3(matchValue_1_1); - return v2_1; - } - } - else if (matchValue_1_1 == null) { - const v1_1: Material = value_3(matchValue_1); - return v1_1; - } - else { - const v1: Material = value_3(matchValue_1); - const v2: Material = value_3(matchValue_1_1); - const this$_2: Update_UpdateOptions_$union = updateOptions; - const recordType_1_2: Material = v1; - const recordType_2_2: Material = v2; - switch (this$_2.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_2), getRecordFields(recordType_2_2))) as Material; - default: - return recordType_2_2; - } - } - }, List_distinct>(append>(map>(mapping_1, list1), map>(mapping_1, list2)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err: any) { - throw new Error(`Could not mergeUpdate ${"Material"} list: -${err.message}`); - } - try { - const map1_1: IMap, Material> = Dict_ofSeqWithMerge>((arg_6: Material, arg_1_2: Material): Material => { - const this$_3: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_3: Material = arg_6; - const recordType_2_3: Material = arg_1_2; - switch (this$_3.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_3), getRecordFields(recordType_2_3))) as Material; - default: - return recordType_2_3; - } - }, map, Material]>((v_2: Material): [Option, Material] => ([mapping_6(v_2), v_2] as [Option, Material]), list1_1)); - const map2_1: IMap, Material> = Dict_ofSeqWithMerge>((arg_2_2: Material, arg_3_2: Material): Material => { - const this$_4: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_4: Material = arg_2_2; - const recordType_2_4: Material = arg_3_2; - switch (this$_4.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_4), getRecordFields(recordType_2_4))) as Material; - default: - return recordType_2_4; - } - }, map, Material]>((v_1_1: Material): [Option, Material] => ([mapping_6(v_1_1), v_1_1] as [Option, Material]), list2_1)); - materials = map, Material>((k_1: Option): Material => { - const matchValue_3: Option = Dict_tryFind, Material>(k_1, map1_1); - const matchValue_1_2: Option = Dict_tryFind, Material>(k_1, map2_1); - if (matchValue_3 == null) { - if (matchValue_1_2 == null) { - throw new Error("If this fails, then I don\'t know how to program"); - } - else { - const v2_1_1: Material = value_3(matchValue_1_2); - return v2_1_1; - } - } - else if (matchValue_1_2 == null) { - const v1_1_1: Material = value_3(matchValue_3); - return v1_1_1; - } - else { - const v1_2: Material = value_3(matchValue_3); - const v2_2: Material = value_3(matchValue_1_2); - const this$_5: Update_UpdateOptions_$union = updateOptions_2; - const recordType_1_5: Material = v1_2; - const recordType_2_5: Material = v2_2; - switch (this$_5.tag) { - case /* UpdateAllAppendLists */ 2: - return makeRecord(Material_$reflection(), map2_2(Update_updateAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Material; - case /* UpdateByExisting */ 1: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExisting, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Material; - case /* UpdateByExistingAppendLists */ 3: - return makeRecord(Material_$reflection(), map2_2(Update_updateOnlyByExistingAppend, getRecordFields(recordType_1_5), getRecordFields(recordType_2_5))) as Material; - default: - return recordType_2_5; - } - } - }, List_distinct>(append>(map>(mapping_6, list1_1), map>(mapping_6, list2_1)), { - Equals: equals, - GetHashCode: structuralHash, - })); - } - catch (err_1: any) { - throw new Error(`Could not mergeUpdate ${"Material"} list: -${err_1.message}`); - } - const sources: FSharpList = Study_getSources_Z27CB2981(study); - const samples: FSharpList = Study_getSamples_Z27CB2981(study); - return StudyMaterials_make(fromValueWithDefault>(empty(), sources), fromValueWithDefault>(empty(), samples), fromValueWithDefault>(empty(), materials)); -} - -export function Study_update_Z27CB2981(study: Study): Study { - try { - const protocols: FSharpList = Study_getProtocols_Z27CB2981(study); - let Materials: Option; - const v: StudyMaterials = Study_getMaterials_Z27CB2981(study); - Materials = fromValueWithDefault(StudyMaterials_get_empty(), v); - const Assays: Option> = map_1, FSharpList>((list: FSharpList): FSharpList => map((arg_3: Assay): Assay => ((arg_2: Assay): Assay => Assay_updateProtocols(protocols, arg_2))(Assay_update_Z269B5B97(arg_3)), list), study.Assays); - const Protocols: Option> = fromValueWithDefault>(empty(), protocols); - const Factors: Option> = fromValueWithDefault>(empty(), Study_getFactors_Z27CB2981(study)); - const CharacteristicCategories: Option> = fromValueWithDefault>(empty(), Study_getCharacteristics_Z27CB2981(study)); - const UnitCategories: Option> = fromValueWithDefault>(empty(), Study_getUnitCategories_Z27CB2981(study)); - return new Study(study.ID, study.FileName, study.Identifier, study.Title, study.Description, study.SubmissionDate, study.PublicReleaseDate, study.Publications, study.Contacts, study.StudyDesignDescriptors, Protocols, Materials, map_1, FSharpList>((processSequence: FSharpList): FSharpList => updateProtocols(protocols, processSequence), study.ProcessSequence), Assays, Factors, CharacteristicCategories, UnitCategories, study.Comments); - } - catch (err: any) { - return toFail(`Could not update study ${study.Identifier}: -${err.message}`); - } -} - diff --git a/ts/ISA/ISA/JsonTypes/StudyMaterials.ts b/ts/ISA/ISA/JsonTypes/StudyMaterials.ts deleted file mode 100644 index 8d61a838..00000000 --- a/ts/ISA/ISA/JsonTypes/StudyMaterials.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Record } from "../../../fable_modules/fable-library-ts/Types.js"; -import { defaultArg, Option } from "../../../fable_modules/fable-library-ts/Option.js"; -import { empty, FSharpList } from "../../../fable_modules/fable-library-ts/List.js"; -import { Source_$reflection, Source } from "./Source.js"; -import { Sample_$reflection, Sample } from "./Sample.js"; -import { Material_$reflection, Material } from "./Material.js"; -import { IEquatable } from "../../../fable_modules/fable-library-ts/Util.js"; -import { record_type, option_type, list_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; - -export class StudyMaterials extends Record implements IEquatable { - readonly Sources: Option>; - readonly Samples: Option>; - readonly OtherMaterials: Option>; - constructor(Sources: Option>, Samples: Option>, OtherMaterials: Option>) { - super(); - this.Sources = Sources; - this.Samples = Samples; - this.OtherMaterials = OtherMaterials; - } -} - -export function StudyMaterials_$reflection(): TypeInfo { - return record_type("ISA.StudyMaterials", [], StudyMaterials, () => [["Sources", option_type(list_type(Source_$reflection()))], ["Samples", option_type(list_type(Sample_$reflection()))], ["OtherMaterials", option_type(list_type(Material_$reflection()))]]); -} - -export function StudyMaterials_make(sources: Option>, samples: Option>, otherMaterials: Option>): StudyMaterials { - return new StudyMaterials(sources, samples, otherMaterials); -} - -export function StudyMaterials_create_Z460D555F(Sources?: FSharpList, Samples?: FSharpList, OtherMaterials?: FSharpList): StudyMaterials { - return StudyMaterials_make(Sources, Samples, OtherMaterials); -} - -export function StudyMaterials_get_empty(): StudyMaterials { - return StudyMaterials_create_Z460D555F(); -} - -export function StudyMaterials_getMaterials_6A1922E7(am: StudyMaterials): FSharpList { - return defaultArg(am.OtherMaterials, empty()); -} - -export function StudyMaterials_getSamples_6A1922E7(am: StudyMaterials): FSharpList { - return defaultArg(am.Samples, empty()); -} - -export function StudyMaterials_getSources_6A1922E7(am: StudyMaterials): FSharpList { - return defaultArg(am.Sources, empty()); -} - diff --git a/ts/ISA/ISA/JsonTypes/URI.ts b/ts/ISA/ISA/JsonTypes/URI.ts deleted file mode 100644 index 2b8ed2ff..00000000 --- a/ts/ISA/ISA/JsonTypes/URI.ts +++ /dev/null @@ -1,19 +0,0 @@ - -/** - * Create a ISAJson URI from a ISATab string entry - * - * This is a placeholder function. It has currently no function, but as soon as it is implemented it will already be placed at all relevant code locations. - */ -export function URIModule_fromString(s: string): string { - return s; -} - -/** - * Create a ISATab string entry from a ISAJson URI - * - * This is a placeholder function. It has currently no function, but as soon as it is implemented it will already be placed at all relevant code locations. - */ -export function URIModule_toString(s: string): string { - return s; -} - diff --git a/ts/ISA/ISA/JsonTypes/Value.ts b/ts/ISA/ISA/JsonTypes/Value.ts deleted file mode 100644 index a06d5833..00000000 --- a/ts/ISA/ISA/JsonTypes/Value.ts +++ /dev/null @@ -1,256 +0,0 @@ -import { Union, toString } from "../../../fable_modules/fable-library-ts/Types.js"; -import { parse as parse_1, float64, int32 } from "../../../fable_modules/fable-library-ts/Int32.js"; -import { printf, toText } from "../../../fable_modules/fable-library-ts/String.js"; -import { OntologyAnnotation_fromString_Z7D8EB286, OntologyAnnotation_$reflection, OntologyAnnotation, OntologyAnnotation__get_NameText } from "./OntologyAnnotation.js"; -import { IISAPrintable } from "../Printer.js"; -import { union_type, string_type, float64_type, int32_type, TypeInfo } from "../../../fable_modules/fable-library-ts/Reflection.js"; -import { parse } from "../../../fable_modules/fable-library-ts/Double.js"; -import { map, Option, value as value_2, defaultArg } from "../../../fable_modules/fable-library-ts/Option.js"; -import { int32ToString } from "../../../fable_modules/fable-library-ts/Util.js"; -import { AnnotationValue_$union, AnnotationValue_toString_Z3C00A204 } from "./AnnotationValue.js"; - -export type Value_$union = - | Value<0> - | Value<1> - | Value<2> - | Value<3> - -export type Value_$cases = { - 0: ["Ontology", [OntologyAnnotation]], - 1: ["Int", [int32]], - 2: ["Float", [float64]], - 3: ["Name", [string]] -} - -export function Value_Ontology(Item: OntologyAnnotation) { - return new Value<0>(0, [Item]); -} - -export function Value_Int(Item: int32) { - return new Value<1>(1, [Item]); -} - -export function Value_Float(Item: float64) { - return new Value<2>(2, [Item]); -} - -export function Value_Name(Item: string) { - return new Value<3>(3, [Item]); -} - -export class Value extends Union implements IISAPrintable { - constructor(readonly tag: Tag, readonly fields: Value_$cases[Tag][1]) { - super(); - } - cases() { - return ["Ontology", "Int", "Float", "Name"]; - } - Print(): string { - const this$ = this as Value_$union; - return toString(this$); - } - PrintCompact(): string { - const this$ = this as Value_$union; - switch (this$.tag) { - case /* Int */ 1: { - const i: int32 = this$.fields[0] | 0; - return toText(printf("%i"))(i); - } - case /* Float */ 2: { - const f: float64 = this$.fields[0]; - return toText(printf("%f"))(f); - } - case /* Name */ 3: - return this$.fields[0]; - default: - return OntologyAnnotation__get_NameText(this$.fields[0]); - } - } -} - -export function Value_$reflection(): TypeInfo { - return union_type("ISA.Value", [], Value, () => [[["Item", OntologyAnnotation_$reflection()]], [["Item", int32_type]], [["Item", float64_type]], [["Item", string_type]]]); -} - -export function Value_fromString_Z721C83C5(value: string): Value_$union { - try { - return Value_Int(parse_1(value, 511, false, 32)); - } - catch (matchValue: any) { - try { - return Value_Float(parse(value)); - } - catch (matchValue_1: any) { - return Value_Name(value); - } - } -} - -export function Value_fromOptions(value: Option, termSource: Option, termAccesssion: Option): Option { - let matchResult: int32, value_1: string; - if (value == null) { - if (termSource == null) { - if (termAccesssion == null) { - matchResult = 1; - } - else { - matchResult = 2; - } - } - else { - matchResult = 2; - } - } - else if (termSource == null) { - if (termAccesssion == null) { - matchResult = 0; - value_1 = value_2(value); - } - else { - matchResult = 2; - } - } - else { - matchResult = 2; - } - switch (matchResult) { - case 0: - return (() => { - try { - return Value_Int(parse_1(value_1!, 511, false, 32)); - } - catch (matchValue_1: any) { - try { - return Value_Float(parse(value_1!)); - } - catch (matchValue_2: any) { - return Value_Name(value_1!); - } - } - })(); - case 1: - return void 0; - default: - return Value_Ontology(OntologyAnnotation_fromString_Z7D8EB286(defaultArg(value, ""), termSource, termAccesssion)); - } -} - -export function Value_toOptions_Z277CD705(value: Value_$union): [Option, Option, Option] { - switch (value.tag) { - case /* Int */ 1: - return [int32ToString(value.fields[0]), void 0, void 0] as [Option, Option, Option]; - case /* Float */ 2: { - const f: float64 = value.fields[0]; - return [f.toString(), void 0, void 0] as [Option, Option, Option]; - } - case /* Name */ 3: - return [value.fields[0], void 0, void 0] as [Option, Option, Option]; - default: { - const oa: OntologyAnnotation = value.fields[0]; - return [map(AnnotationValue_toString_Z3C00A204, oa.Name), oa.TermAccessionNumber, oa.TermSourceREF] as [Option, Option, Option]; - } - } -} - -export function Value__get_Text(this$: Value_$union): string { - switch (this$.tag) { - case /* Float */ 2: { - const f: float64 = this$.fields[0]; - return f.toString(); - } - case /* Int */ 1: - return int32ToString(this$.fields[0]); - case /* Name */ 3: - return this$.fields[0]; - default: - return OntologyAnnotation__get_NameText(this$.fields[0]); - } -} - -export function Value__AsName(this$: Value_$union): string { - if (this$.tag === /* Name */ 3) { - return this$.fields[0]; - } - else { - throw new Error(`Value ${this$} is not of case name`); - } -} - -export function Value__AsInt(this$: Value_$union): int32 { - if (this$.tag === /* Int */ 1) { - return this$.fields[0] | 0; - } - else { - throw new Error(`Value ${this$} is not of case int`); - } -} - -export function Value__AsFloat(this$: Value_$union): float64 { - if (this$.tag === /* Float */ 2) { - return this$.fields[0]; - } - else { - throw new Error(`Value ${this$} is not of case float`); - } -} - -export function Value__AsOntology(this$: Value_$union): OntologyAnnotation { - if (this$.tag === /* Ontology */ 0) { - return this$.fields[0]; - } - else { - throw new Error(`Value ${this$} is not of case ontology`); - } -} - -export function Value__get_IsAnOntology(this$: Value_$union): boolean { - if (this$.tag === /* Ontology */ 0) { - const oa: OntologyAnnotation = this$.fields[0]; - return true; - } - else { - return false; - } -} - -export function Value__get_IsNumerical(this$: Value_$union): boolean { - switch (this$.tag) { - case /* Int */ 1: - case /* Float */ 2: - return true; - default: - return false; - } -} - -export function Value__get_IsAnInt(this$: Value_$union): boolean { - if (this$.tag === /* Int */ 1) { - return true; - } - else { - return false; - } -} - -export function Value__get_IsAFloat(this$: Value_$union): boolean { - if (this$.tag === /* Float */ 2) { - return true; - } - else { - return false; - } -} - -export function Value__get_IsAText(this$: Value_$union): boolean { - if (this$.tag === /* Name */ 3) { - return true; - } - else { - return false; - } -} - -export function Value_getText_Z277CD705(v: Value_$union): string { - return Value__get_Text(v); -} - diff --git a/ts/ISA/ISA/OptionExtensions.ts b/ts/ISA/ISA/OptionExtensions.ts deleted file mode 100644 index 68dd0487..00000000 --- a/ts/ISA/ISA/OptionExtensions.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { value, Option, some } from "../../fable_modules/fable-library-ts/Option.js"; - -/** - * If the value matches the default, a None is returned, else a Some is returned - */ -export function fromValueWithDefault<$a>(d: $a, v: $a): Option<$a> { - if (equals(d, v)) { - return void 0; - } - else { - return some(v); - } -} - -/** - * Applies the function f on the value of the option if it exists, else applies it on the default value. If the result value matches the default, a None is returned - */ -export function mapDefault(d: T, f: ((arg0: T) => T), o: Option): Option { - return fromValueWithDefault(d, (o == null) ? f(d) : f(value(o))); -} - -/** - * Applies the function f on the value of the option if it exists, else returns the default value. - */ -export function mapOrDefault(d: Option, f: ((arg0: U) => T), o: Option): Option { - if (o == null) { - return d; - } - else { - return some(f(value(o))); - } -} - diff --git a/ts/ISA/ISA/Printer.ts b/ts/ISA/ISA/Printer.ts deleted file mode 100644 index c1fc68d8..00000000 --- a/ts/ISA/ISA/Printer.ts +++ /dev/null @@ -1,6 +0,0 @@ - -export interface IISAPrintable { - Print(): string, - PrintCompact(): string -} - diff --git a/ts/ISA/ISA/Regex.ts b/ts/ISA/ISA/Regex.ts deleted file mode 100644 index 7a6cd70d..00000000 --- a/ts/ISA/ISA/Regex.ts +++ /dev/null @@ -1,512 +0,0 @@ -import { create, match } from "../../fable_modules/fable-library-ts/RegExp.js"; -import { map, some, value as value_1, Option } from "../../fable_modules/fable-library-ts/Option.js"; -import { parse, int32 } from "../../fable_modules/fable-library-ts/Int32.js"; - -/** - * Matches, if the input string matches the given regex pattern. - */ -export function ActivePatterns_$007CRegex$007C_$007C(pattern: string, input: string): Option { - const m: any = match(create(pattern), input.trim()); - if (m != null) { - return m; - } - else { - return void 0; - } -} - -/** - * Matches any column header starting with some text, followed by one whitespace and a term name inside squared brackets. - */ -export function ActivePatterns_$007CTermColumn$007C_$007C(input: string): Option<{ TermColumnType: string, TermName: string }> { - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("(?.+)\\s\\[(?.+)\\]", input); - if (activePatternResult != null) { - const r: any = value_1(activePatternResult); - return { - TermColumnType: (r.groups && r.groups.termcolumntype) || "", - TermName: (r.groups && r.groups.termname) || "", - }; - } - else { - return void 0; - } -} - -/** - * Matches a "Unit" column header. - */ -export function ActivePatterns_$007CUnitColumnHeader$007C_$007C(input: string): Option { - if (ActivePatterns_$007CRegex$007C_$007C("Unit", input) != null) { - return some(void 0); - } - else { - return void 0; - } -} - -/** - * Matches a "Parameter [Term]" or "Parameter Value [Term]" column header and returns the Term string. - */ -export function ActivePatterns_$007CParameterColumnHeader$007C_$007C(input: string): Option { - const activePatternResult: Option<{ TermColumnType: string, TermName: string }> = ActivePatterns_$007CTermColumn$007C_$007C(input); - if (activePatternResult != null) { - const r: { TermColumnType: string, TermName: string } = value_1(activePatternResult); - const matchValue: string = r.TermColumnType; - switch (matchValue) { - case "Parameter": - case "Parameter Value": - return r.TermName; - default: - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a "Factor [Term]" or "Factor Value [Term]" column header and returns the Term string. - */ -export function ActivePatterns_$007CFactorColumnHeader$007C_$007C(input: string): Option { - const activePatternResult: Option<{ TermColumnType: string, TermName: string }> = ActivePatterns_$007CTermColumn$007C_$007C(input); - if (activePatternResult != null) { - const r: { TermColumnType: string, TermName: string } = value_1(activePatternResult); - const matchValue: string = r.TermColumnType; - switch (matchValue) { - case "Factor": - case "Factor Value": - return r.TermName; - default: - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a "Characteristic [Term]" or "Characteristics [Term]" or "Characteristics Value [Term]" column header and returns the Term string. - */ -export function ActivePatterns_$007CCharacteristicColumnHeader$007C_$007C(input: string): Option { - const activePatternResult: Option<{ TermColumnType: string, TermName: string }> = ActivePatterns_$007CTermColumn$007C_$007C(input); - if (activePatternResult != null) { - const r: { TermColumnType: string, TermName: string } = value_1(activePatternResult); - const matchValue: string = r.TermColumnType; - switch (matchValue) { - case "Characteristic": - case "Characteristics": - case "Characteristics Value": - return r.TermName; - default: - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a short term string and returns the term source ref and the annotation number strings. - * - * Example: "MS:1003022" --> term source ref: "MS"; annotation number: "1003022" - */ -export function ActivePatterns_$007CTermAnnotationShort$007C_$007C(input: string): Option<{ LocalTAN: string, TermSourceREF: string }> { - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", input); - if (activePatternResult != null) { - const value: any = value_1(activePatternResult); - const termsourceref: string = (value.groups && value.groups.termsourceref) || ""; - return { - LocalTAN: (value.groups && value.groups.localtan) || "", - TermSourceREF: termsourceref, - }; - } - else { - return void 0; - } -} - -/** - * Matches a term string (either short or URI) and returns the term source ref and the annotation number strings. - * - * Example 1: "MS:1003022" --> term source ref: "MS"; annotation number: "1003022" - * - * Example 2: "http://purl.obolibrary.org/obo/MS_1003022" --> term source ref: "MS"; annotation number: "1003022" - */ -export function ActivePatterns_$007CTermAnnotation$007C_$007C(input: string): Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> { - let matchResult: int32, value: any; - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", input); - if (activePatternResult != null) { - matchResult = 0; - value = value_1(activePatternResult); - } - else { - const activePatternResult_1: Option = ActivePatterns_$007CRegex$007C_$007C("http://purl.obolibrary.org/obo/(?\\w+?)_(?\\w+)", input); - if (activePatternResult_1 != null) { - matchResult = 0; - value = value_1(activePatternResult_1); - } - else { - const activePatternResult_2: Option = ActivePatterns_$007CRegex$007C_$007C(".*\\/(?\\w+?)[:_](?\\w+)", input); - if (activePatternResult_2 != null) { - matchResult = 0; - value = value_1(activePatternResult_2); - } - else { - matchResult = 1; - } - } - } - switch (matchResult) { - case 0: { - const termsourceref: string = (value!.groups && value!.groups.termsourceref) || ""; - return { - LocalTAN: (value!.groups && value!.groups.localtan) || "", - TermAccessionNumber: input, - TermSourceREF: termsourceref, - }; - } - default: - return void 0; - } -} - -/** - * Matches a "Term Source REF (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. - * - * Example: "Term Source REF (MS:1003022)" --> term source ref: "MS"; annotation number: "1003022" - */ -export function ActivePatterns_$007CTSRColumnHeader$007C_$007C(input: string): Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> { - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("Term Source REF\\s\\((?.+)\\)", input); - if (activePatternResult != null) { - const r: any = value_1(activePatternResult); - const matchValue: string = (r.groups && r.groups.id) || ""; - const activePatternResult_1: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTermAnnotation$007C_$007C(matchValue); - if (activePatternResult_1 != null) { - const r_1: { LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string } = value_1(activePatternResult_1); - return r_1; - } - else { - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a "Term Accession Number (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. - * - * Example: "Term Accession Number (MS:1003022)" --> term source ref: "MS"; annotation number: "1003022" - */ -export function ActivePatterns_$007CTANColumnHeader$007C_$007C(input: string): Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> { - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("Term Accession Number\\s\\((?.+)\\)", input); - if (activePatternResult != null) { - const r: any = value_1(activePatternResult); - const matchValue: string = (r.groups && r.groups.id) || ""; - const activePatternResult_1: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTermAnnotation$007C_$007C(matchValue); - if (activePatternResult_1 != null) { - const r_1: { LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string } = value_1(activePatternResult_1); - return r_1; - } - else { - return void 0; - } - } - else { - return void 0; - } -} - -/** - * Matches a "Input [InputType]" column header and returns the InputType as string. - */ -export function ActivePatterns_$007CInputColumnHeader$007C_$007C(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("Input\\s\\[(?.+)\\]", input); - if (activePatternResult != null) { - const r: any = value_1(activePatternResult); - return (r.groups && r.groups.iotype) || ""; - } - else { - return void 0; - } -} - -/** - * Matches a "Output [OutputType]" column header and returns the OutputType as string. - */ -export function ActivePatterns_$007COutputColumnHeader$007C_$007C(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("Output\\s\\[(?.+)\\]", input); - if (activePatternResult != null) { - const r: any = value_1(activePatternResult); - return (r.groups && r.groups.iotype) || ""; - } - else { - return void 0; - } -} - -/** - * Matches auto-generated readable table names. Mainly used in ArcAssay.addTable(). Default tables will get such a name. - * - * Will match "New Table 10" and return the number `10`. - */ -export function ActivePatterns_$007CAutoGeneratedTableName$007C_$007C(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("^New\\sTable\\s(?\\d+)$", input); - if (activePatternResult != null) { - const r: any = value_1(activePatternResult); - return parse((r.groups && r.groups.number) || "", 511, false, 32); - } - else { - return void 0; - } -} - -export function tryParseTermAnnotationShort(str: string): Option<{ LocalTAN: string, TermSourceREF: string }> { - const matchValue: string = str.trim(); - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", matchValue); - if (activePatternResult != null) { - const value: any = value_1(activePatternResult); - const termsourceref: string = (value.groups && value.groups.termsourceref) || ""; - return { - LocalTAN: (value.groups && value.groups.localtan) || "", - TermSourceREF: termsourceref, - }; - } - else { - return void 0; - } -} - -/** - * This function can be used to extract `IDSPACE:LOCALID` (or: `Term Accession`) from Swate header strings or obofoundry conform URI strings. - * - * **Example 1:** "http://purl.obolibrary.org/obo/GO_000001" --> "GO:000001" - * - * **Example 2:** "Term Source REF (NFDI4PSO:0000064)" --> "NFDI4PSO:0000064" - */ -export function tryParseTermAnnotation(str: string): Option<{ LocalTAN: string, TermSourceREF: string }> { - const matchValue: string = str.trim(); - let matchResult: int32, value: any; - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("(?\\w+?):(?\\w+)", matchValue); - if (activePatternResult != null) { - matchResult = 0; - value = value_1(activePatternResult); - } - else { - const activePatternResult_1: Option = ActivePatterns_$007CRegex$007C_$007C("http://purl.obolibrary.org/obo/(?\\w+?)_(?\\w+)", matchValue); - if (activePatternResult_1 != null) { - matchResult = 0; - value = value_1(activePatternResult_1); - } - else { - const activePatternResult_2: Option = ActivePatterns_$007CRegex$007C_$007C(".*\\/(?\\w+?)[:_](?\\w+)", matchValue); - if (activePatternResult_2 != null) { - matchResult = 0; - value = value_1(activePatternResult_2); - } - else { - matchResult = 1; - } - } - } - switch (matchResult) { - case 0: { - const termsourceref: string = (value!.groups && value!.groups.termsourceref) || ""; - return { - LocalTAN: (value!.groups && value!.groups.localtan) || "", - TermSourceREF: termsourceref, - }; - } - default: - return void 0; - } -} - -/** - * Tries to parse 'str' to term accession and returns it in the format `Some "termsourceref:localtan"`. Exmp.: `Some "MS:000001"` - */ -export function tryGetTermAnnotationShortString(str: string): Option { - return map<{ LocalTAN: string, TermSourceREF: string }, string>((r: { LocalTAN: string, TermSourceREF: string }): string => ((r.TermSourceREF + ":") + r.LocalTAN), tryParseTermAnnotation(str)); -} - -/** - * Parses 'str' to term accession and returns it in the format "termsourceref:localtan". Exmp.: "MS:000001" - */ -export function getTermAnnotationShortString(str: string): string { - const matchValue: Option = tryGetTermAnnotationShortString(str); - if (matchValue == null) { - throw new Error(`Unable to parse '${str}' to term accession.`); - } - else { - return value_1(matchValue); - } -} - -/** - * This function is used to parse Excel numberFormat string to term name. - * - * **Example 1:** "0.00 "degree Celsius"" --> "degree Celsius" - */ -export function tryParseExcelNumberFormat(headerStr: string): Option { - const matchValue: string = headerStr.trim(); - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("\"(?(.*?))\"", matchValue); - if (activePatternResult != null) { - const value: any = value_1(activePatternResult); - return (value.groups && value.groups.numberFormat) || ""; - } - else { - return void 0; - } -} - -/** - * This function is used to match both Input and Output columns and capture the IOType as `iotype` group. - * - * **Example 1:** "Input [Sample]" --> "Sample" - */ -export function tryParseIOTypeHeader(headerStr: string): Option { - const matchValue: string = headerStr.trim(); - const activePatternResult: Option = ActivePatterns_$007CRegex$007C_$007C("(Input|Output)\\s\\[(?.+)\\]", matchValue); - if (activePatternResult != null) { - const value: any = value_1(activePatternResult); - return (value.groups && value.groups.iotype) || ""; - } - else { - return void 0; - } -} - -/** - * Matches any column header starting with some text, followed by one whitespace and a term name inside squared brackets. - */ -export function tryParseTermColumn(input: string): Option<{ TermColumnType: string, TermName: string }> { - const activePatternResult: Option<{ TermColumnType: string, TermName: string }> = ActivePatterns_$007CTermColumn$007C_$007C(input); - if (activePatternResult != null) { - const r: { TermColumnType: string, TermName: string } = value_1(activePatternResult); - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Unit" column header. - */ -export function tryParseUnitColumnHeader(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007CUnitColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r: any = value_1(activePatternResult); - return some(void 0); - } - else { - return void 0; - } -} - -/** - * Matches a "Parameter [Term]" or "Parameter Value [Term]" column header and returns the Term string. - */ -export function tryParseParameterColumnHeader(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007CParameterColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r: string = value_1(activePatternResult); - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Factor [Term]" or "Factor Value [Term]" column header and returns the Term string. - */ -export function tryParseFactorColumnHeader(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007CFactorColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r: string = value_1(activePatternResult); - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Characteristic [Term]" or "Characteristics [Term]" or "Characteristics Value [Term]" column header and returns the Term string. - */ -export function tryParseCharacteristicColumnHeader(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007CCharacteristicColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r: string = value_1(activePatternResult); - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Term Source REF (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. - * - * Example: "Term Source REF (MS:1003022)" --> term source ref: "MS"; annotation number: "1003022" - */ -export function tryParseTSRColumnHeader(input: string): Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> { - const activePatternResult: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTSRColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r: { LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string } = value_1(activePatternResult); - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Term Accession Number (ShortTerm)" column header and returns the ShortTerm as Term Source Ref and Annotation Number. - * - * Example: "Term Accession Number (MS:1003022)" --> term source ref: "MS"; annotation number: "1003022" - */ -export function tryParseTANColumnHeader(input: string): Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> { - const activePatternResult: Option<{ LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string }> = ActivePatterns_$007CTANColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r: { LocalTAN: string, TermAccessionNumber: string, TermSourceREF: string } = value_1(activePatternResult); - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Input [InputType]" column header and returns the InputType as string. - */ -export function tryParseInputColumnHeader(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007CInputColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r: string = value_1(activePatternResult); - return r; - } - else { - return void 0; - } -} - -/** - * Matches a "Output [OutputType]" column header and returns the OutputType as string. - */ -export function tryParseOutputColumnHeader(input: string): Option { - const activePatternResult: Option = ActivePatterns_$007COutputColumnHeader$007C_$007C(input); - if (activePatternResult != null) { - const r: string = value_1(activePatternResult); - return r; - } - else { - return void 0; - } -} - diff --git a/ts/ISA/ISA/Update.ts b/ts/ISA/ISA/Update.ts deleted file mode 100644 index c4d0fbaf..00000000 --- a/ts/ISA/ISA/Update.ts +++ /dev/null @@ -1,295 +0,0 @@ -import { Dictionary } from "../../fable_modules/fable-library-ts/MutableMap.js"; -import { isIterable, defaultOf, IMap, structuralHash, equals } from "../../fable_modules/fable-library-ts/Util.js"; -import { int32 } from "../../fable_modules/fable-library-ts/Int32.js"; -import { isEmpty, iterate } from "../../fable_modules/fable-library-ts/Seq.js"; -import { tryGetValue, addToDict } from "../../fable_modules/fable-library-ts/MapUtil.js"; -import { Union, toString, FSharpRef } from "../../fable_modules/fable-library-ts/Types.js"; -import { value as value_1, Option, some } from "../../fable_modules/fable-library-ts/Option.js"; -import { append_generic, distinct_generic, isList_generic, isMap_generic } from "./Fable.js"; -import { union_type, TypeInfo, makeUnion, option_type, makeGenericType, getUnionCases, name, obj_type } from "../../fable_modules/fable-library-ts/Reflection.js"; -import { exactlyOne, partition } from "../../fable_modules/fable-library-ts/Array.js"; - -export function Dict_ofSeq(s: Iterable<[Key, T]>): IMap { - const dict: IMap = new Dictionary([], { - Equals: equals, - GetHashCode: structuralHash, - }); - iterate<[Key, T]>((tupledArg: [Key, T]): void => { - addToDict(dict, tupledArg[0], tupledArg[1]); - }, s); - return dict; -} - -export function Dict_tryFind(key: Key, dict: IMap): Option { - let patternInput: [boolean, T]; - let outArg: T = defaultOf(); - patternInput = ([tryGetValue(dict, key, new FSharpRef((): T => outArg, (v: T): void => { - outArg = v; - })), outArg] as [boolean, T]); - if (patternInput[0]) { - return some(patternInput[1]); - } - else { - return void 0; - } -} - -export function Dict_ofSeqWithMerge(merge: ((arg0: T, arg1: T) => T), s: Iterable<[Key, T]>): IMap { - const dict: IMap = new Dictionary([], { - Equals: equals, - GetHashCode: structuralHash, - }); - iterate<[Key, T]>((tupledArg: [Key, T]): void => { - const k: Key = tupledArg[0]; - const v: T = tupledArg[1]; - const matchValue: Option = Dict_tryFind(k, dict); - if (matchValue == null) { - addToDict(dict, k, v); - } - else { - const v$0027: T = value_1(matchValue); - dict.delete(k); - addToDict(dict, k, merge(v$0027, v)); - } - }, s); - return dict; -} - -/** - * Get the type of the IEnumerable elements. E.g. for Array<'T> it would be 'T - */ -export function Update_isMapType(v: any): boolean { - return isMap_generic(v); -} - -export function Update_isListType(v: any): boolean { - return isList_generic(v); -} - -/** - * Get the type of the IEnumerable elements. E.g. for Array<'T> it would be 'T - */ -export function Update_enumGetInnerType(v: any): any { - return obj_type; -} - -/** - * updates oldRT with newRT by replacing all values, but appending all lists. - * - * newRTList@oldRTList - */ -export function Update_updateAppend(oldVal: any, newVal: any): any { - let matchResult: int32, oldInternal: any, others: any; - if (typeof oldVal === "string") { - matchResult = 0; - } - else if (isIterable(oldVal)) { - let activePatternResult: Option; - const a: any = oldVal; - activePatternResult = ((a == null) ? void 0 : (undefined)); - if (activePatternResult != null) { - matchResult = 1; - oldInternal = value_1(activePatternResult); - } - else { - matchResult = 2; - } - } - else { - let activePatternResult_1: Option; - const a_1: any = oldVal; - activePatternResult_1 = ((a_1 == null) ? void 0 : (undefined)); - if (activePatternResult_1 != null) { - matchResult = 1; - oldInternal = value_1(activePatternResult_1); - } - else { - matchResult = 3; - others = oldVal; - } - } - switch (matchResult) { - case 0: - return newVal; - case 1: - if (typeof oldInternal! === "string") { - return newVal; - } - else if (isIterable(oldInternal!)) { - let activePatternResult_2: Option; - const a_2: any = newVal; - activePatternResult_2 = ((a_2 == null) ? void 0 : (undefined)); - if (activePatternResult_2 != null) { - const newInternal: any = value_1(activePatternResult_2); - const v: any = Update_updateAppend(oldInternal!, newInternal); - const cases_1: [any[], any[]] = partition((x: any): boolean => (name(x) === "Some"), getUnionCases(makeGenericType(option_type(obj_type), [obj_type]))); - const patternInput = [exactlyOne(cases_1[0]), [v]] as [any, any[]]; - return makeUnion(patternInput[0], patternInput[1]); - } - else { - return oldVal; - } - } - else { - return newVal; - } - case 2: { - const oldSeq = oldVal as Iterable; - const newSeq = newVal as Iterable; - const innerType: any = Update_enumGetInnerType(oldVal); - if (Update_isMapType(oldVal)) { - return newVal; - } - else { - return distinct_generic, any>(append_generic, Iterable>(oldSeq, newSeq)); - } - } - default: - return newVal; - } -} - -/** - * updates oldRT with newRT by replacing all values, but only if the new value is not empty. - */ -export function Update_updateOnlyByExisting(oldVal: any, newVal: any): any { - if (equals(newVal, defaultOf())) { - return oldVal; - } - else { - let activePatternResult: Option; - const a: any = oldVal; - activePatternResult = ((a == null) ? void 0 : (undefined)); - if (activePatternResult != null) { - const oldInternal: any = value_1(activePatternResult); - let activePatternResult_1: Option; - const a_1: any = newVal; - activePatternResult_1 = ((a_1 == null) ? void 0 : (undefined)); - if (activePatternResult_1 != null) { - const newInternal: any = value_1(activePatternResult_1); - const v: any = Update_updateOnlyByExisting(oldInternal, newInternal); - const cases_1: [any[], any[]] = partition((x: any): boolean => (name(x) === "Some"), getUnionCases(makeGenericType(option_type(obj_type), [obj_type]))); - const patternInput = [exactlyOne(cases_1[0]), [v]] as [any, any[]]; - return makeUnion(patternInput[0], patternInput[1]); - } - else { - return oldVal; - } - } - else if (typeof oldVal === "string") { - const newStr: any = newVal; - if (toString(newStr) === "") { - return oldVal; - } - else { - return newStr; - } - } - else if (isIterable(oldVal)) { - const newSeq: any = newVal; - if (isEmpty(newSeq as Iterable as Iterable)) { - return oldVal; - } - else { - return newSeq; - } - } - else { - return newVal; - } - } -} - -/** - * updates oldRT with newRT by replacing all values, but only if the new value is not empty. - */ -export function Update_updateOnlyByExistingAppend(oldVal: any, newVal: any): any { - if (equals(newVal, defaultOf())) { - return oldVal; - } - else { - let activePatternResult: Option; - const a: any = oldVal; - activePatternResult = ((a == null) ? void 0 : (undefined)); - if (activePatternResult != null) { - const oldInternal: any = value_1(activePatternResult); - let activePatternResult_1: Option; - const a_1: any = newVal; - activePatternResult_1 = ((a_1 == null) ? void 0 : (undefined)); - if (activePatternResult_1 != null) { - const newInternal: any = value_1(activePatternResult_1); - const v: any = Update_updateOnlyByExistingAppend(oldInternal, newInternal); - const cases_1: [any[], any[]] = partition((x: any): boolean => (name(x) === "Some"), getUnionCases(makeGenericType(option_type(obj_type), [obj_type]))); - const patternInput = [exactlyOne(cases_1[0]), [v]] as [any, any[]]; - return makeUnion(patternInput[0], patternInput[1]); - } - else { - return oldVal; - } - } - else if (typeof oldVal === "string") { - const newStr: any = newVal; - if (toString(newStr) === "") { - return oldVal; - } - else { - return newStr; - } - } - else if (isIterable(oldVal)) { - const innerType: any = Update_enumGetInnerType(oldVal); - if (Update_isMapType(oldVal)) { - return newVal; - } - else { - return distinct_generic(append_generic(oldVal, newVal)); - } - } - else { - return newVal; - } - } -} - -export type Update_UpdateOptions_$union = - | Update_UpdateOptions<0> - | Update_UpdateOptions<1> - | Update_UpdateOptions<2> - | Update_UpdateOptions<3> - -export type Update_UpdateOptions_$cases = { - 0: ["UpdateAll", []], - 1: ["UpdateByExisting", []], - 2: ["UpdateAllAppendLists", []], - 3: ["UpdateByExistingAppendLists", []] -} - -export function Update_UpdateOptions_UpdateAll() { - return new Update_UpdateOptions<0>(0, []); -} - -export function Update_UpdateOptions_UpdateByExisting() { - return new Update_UpdateOptions<1>(1, []); -} - -export function Update_UpdateOptions_UpdateAllAppendLists() { - return new Update_UpdateOptions<2>(2, []); -} - -export function Update_UpdateOptions_UpdateByExistingAppendLists() { - return new Update_UpdateOptions<3>(3, []); -} - -export class Update_UpdateOptions extends Union { - constructor(readonly tag: Tag, readonly fields: Update_UpdateOptions_$cases[Tag][1]) { - super(); - } - cases() { - return ["UpdateAll", "UpdateByExisting", "UpdateAllAppendLists", "UpdateByExistingAppendLists"]; - } -} - -export function Update_UpdateOptions_$reflection(): TypeInfo { - return union_type("ISA.Aux.Update.UpdateOptions", [], Update_UpdateOptions, () => [[], [], [], []]); -} -