diff --git a/build/PackageTasks.fs b/build/PackageTasks.fs index 4b6d93ff..654c9a27 100644 --- a/build/PackageTasks.fs +++ b/build/PackageTasks.fs @@ -1,7 +1,5 @@ module PackageTasks -open ProjectInfo - open MessagePrompts open BasicTasks open TestTasks @@ -18,7 +16,7 @@ let private replaceCommitLink input = Regex.Replace(input,commitLinkPattern,"") let packDotNet = BuildTask.create "PackDotNet" [clean; build; runTests] { - if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag ) + if promptYesNo (sprintf "[NUGET] creating stable package with version %s OK?" ProjectInfo.stableVersionTag ) then !! "src/**/*.*proj" -- "src/bin/*" @@ -26,21 +24,21 @@ let packDotNet = BuildTask.create "PackDotNet" [clean; build; runTests] { let msBuildParams = {p.MSBuildParams with Properties = ([ - "Version",stableVersionTag - "PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.concat "\r\n" ) + "Version", ProjectInfo.stableVersionTag + "PackageReleaseNotes", (ProjectInfo.release.Notes |> List.map replaceCommitLink |> String.concat "\r\n" ) ] @ p.MSBuildParams.Properties) } { p with MSBuildParams = msBuildParams - OutputPath = Some pkgDir + OutputPath = Some ProjectInfo.pkgDir } )) else failwith "aborted" } let packDotNetPrerelease = BuildTask.create "PackDotNetPrerelease" [setPrereleaseTag; clean; build; (*runTests*)] { - if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag ) + if promptYesNo (sprintf "[NUGET] package tag will be %s OK?" ProjectInfo.prereleaseTag ) then !! "src/**/*.*proj" -- "src/bin/*" @@ -48,14 +46,14 @@ let packDotNetPrerelease = BuildTask.create "PackDotNetPrerelease" [setPrereleas let msBuildParams = {p.MSBuildParams with Properties = ([ - "Version", prereleaseTag - "PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.toLines ) + "Version", ProjectInfo.prereleaseTag + "PackageReleaseNotes", (ProjectInfo.release.Notes |> List.map replaceCommitLink |> String.toLines ) ] @ p.MSBuildParams.Properties) } { p with - VersionSuffix = Some prereleaseSuffix - OutputPath = Some pkgDir + VersionSuffix = Some ProjectInfo.prereleaseSuffix + OutputPath = Some ProjectInfo.pkgDir MSBuildParams = msBuildParams } )) @@ -63,46 +61,36 @@ let packDotNetPrerelease = BuildTask.create "PackDotNetPrerelease" [setPrereleas failwith "aborted" } -let packJS = BuildTask.create "PackJS" [clean; build; runTests] { - if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag ) - then - Fake.JavaScript.Npm.run "bundlejs" (fun o -> o) - Fake.IO.File.readAsString "build/release_package.json" - |> Fake.IO.File.writeString false "dist/js/package.json" - - Fake.IO.File.readAsString "README.md" - |> Fake.IO.File.writeString false "dist/js/README.md" - - "" // "fable-library.**/**" - |> Fake.IO.File.writeString false "dist/js/fable_modules/.npmignore" - - Fake.JavaScript.Npm.exec "pack" (fun o -> - { o with - WorkingDirectory = "./dist/js/" - }) - else failwith "aborted" -} - - -let packJSPrerelease = BuildTask.create "PackJSPrerelease" [setPrereleaseTag; clean; build; runTests] { - if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag ) then +module BundleJs = + let bundle (versionTag: string) = Fake.JavaScript.Npm.run "bundlejs" (fun o -> o) - + GenerateIndexJs.ARCtrl_generate ProjectInfo.npmPkgDir Fake.IO.File.readAsString "build/release_package.json" |> fun t -> - let t = t.Replace(stableVersionTag, prereleaseTag) - Fake.IO.File.writeString false "dist/js/package.json" t + let t = t.Replace(ProjectInfo.stableVersionTag, versionTag) + Fake.IO.File.writeString false $"{ProjectInfo.npmPkgDir}/package.json" t Fake.IO.File.readAsString "README.md" - |> Fake.IO.File.writeString false "dist/js/README.md" + |> Fake.IO.File.writeString false $"{ProjectInfo.npmPkgDir}/README.md" "" // "fable-library.**/**" - |> Fake.IO.File.writeString false "dist/js/fable_modules/.npmignore" + |> Fake.IO.File.writeString false $"{ProjectInfo.npmPkgDir}/fable_modules/.npmignore" Fake.JavaScript.Npm.exec "pack" (fun o -> { o with - WorkingDirectory = "./dist/js/" + WorkingDirectory = ProjectInfo.npmPkgDir }) + +let packJS = BuildTask.create "PackJS" [clean; build; runTests] { + if promptYesNo (sprintf "[NPM] creating stable package with version %s OK?" ProjectInfo.stableVersionTag ) + then + BundleJs.bundle ProjectInfo.stableVersionTag + else failwith "aborted" +} + +let packJSPrerelease = BuildTask.create "PackJSPrerelease" [setPrereleaseTag; clean; build; runTests] { + if promptYesNo (sprintf "[NPM] package tag will be %s OK?" ProjectInfo.prereleaseTag ) then + BundleJs.bundle ProjectInfo.prereleaseTag else failwith "aborted" } diff --git a/build/ProjectInfo.fs b/build/ProjectInfo.fs index aa9a5392..4603b20e 100644 --- a/build/ProjectInfo.fs +++ b/build/ProjectInfo.fs @@ -31,7 +31,7 @@ let gitHome = $"https://github.com/{gitOwner}" let projectRepo = $"https://github.com/{gitOwner}/{project}" let pkgDir = "dist/pkg" -let npmPkgDir = "dist/js" +let npmPkgDir = "./dist/js" // Create RELEASE_NOTES.md if not existing. Or "release" would throw an error. Fake.Extensions.Release.ReleaseNotes.ensure() diff --git a/package-lock.json b/package-lock.json index a4e265cd..bc539578 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,11 @@ { - "name": "@nfdi4plants/arctrl", + "name": "ARCtrl", "version": "1.0.0+ece863d", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@nfdi4plants/arctrl", "hasInstallScript": true, - "license": "ISC", "dependencies": { "fable-library": "^1.1.1", "isomorphic-fetch": "^3.0.0" diff --git a/src/ARCtrl/ARCtrl.fs b/src/ARCtrl/ARC.fs similarity index 98% rename from src/ARCtrl/ARCtrl.fs rename to src/ARCtrl/ARC.fs index 6aa9f8bd..155420c4 100644 --- a/src/ARCtrl/ARCtrl.fs +++ b/src/ARCtrl/ARC.fs @@ -64,6 +64,7 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste with get() = _isa and set(newISA : ArcInvestigation option) = _isa <- newISA + this.UpdateFileSystem() member this.CWL with get() = cwl @@ -225,8 +226,8 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste ) | None -> + //printfn "ARC contains no ISA part." 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. _fs.Tree.ToFilePaths(true) @@ -355,6 +356,9 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste |> Option.bind (fun tree -> if ignoreHidden then tree |> FileSystemTree.filterFolders (fun n -> not (n.StartsWith("."))) else Some tree) |> Option.defaultValue (FileSystemTree.fromFilePaths [||]) + static member DefaultContracts = Map [| + ARCtrl.Contract.Git.gitignoreFileName, ARCtrl.Contract.Git.gitignoreContract + |] //-Pseudo code-// //// Option 1 diff --git a/src/ARCtrl/ARCtrl.fsproj b/src/ARCtrl/ARCtrl.fsproj index c8e67dad..6f46582c 100644 --- a/src/ARCtrl/ARCtrl.fsproj +++ b/src/ARCtrl/ARCtrl.fsproj @@ -34,7 +34,7 @@ - + diff --git a/src/ARCtrl/Templates/Template.Json.fs b/src/ARCtrl/Templates/Template.Json.fs index afc2e674..e5376e7d 100644 --- a/src/ARCtrl/Templates/Template.Json.fs +++ b/src/ARCtrl/Templates/Template.Json.fs @@ -105,12 +105,12 @@ module Template = ) ) - let decodeFromString (jsonString: string) = + let fromJsonString (jsonString: string) = match Decode.fromString decode jsonString with | Ok template -> template | Error exn -> failwithf "Error. Given json string cannot be parsed to Template: %A" exn - let encodeToString (spaces: int) (template:Template) = + let toJsonString (spaces: int) (template:Template) = Encode.toString spaces (encode template) module Templates = @@ -125,12 +125,12 @@ module Templates = let d = Decode.dict Template.decode Decode.fromString d - let decodeFromString (jsonString: string) = + let fromJsonString (jsonString: string) = match decode jsonString with | Ok templateMap -> templateMap | Error exn -> failwithf "Error. Given json string cannot be parsed to Templates map: %A" exn - let encodeToString (spaces: int) (templateList: (string*Template) []) = + let toJsonString (spaces: int) (templateList: (string*Template) []) = Encode.toString spaces (encode templateList) @@ -140,4 +140,4 @@ module Extension = type Template with member this.ToJson(?spaces: int) = let spaces = defaultArg spaces 0 - Template.encodeToString(spaces) \ No newline at end of file + Template.toJsonString(spaces) \ No newline at end of file diff --git a/src/ARCtrl/Templates/Template.Web.fs b/src/ARCtrl/Templates/Template.Web.fs index d58d3d27..4a11e485 100644 --- a/src/ARCtrl/Templates/Template.Web.fs +++ b/src/ARCtrl/Templates/Template.Web.fs @@ -10,7 +10,7 @@ let getTemplates(url: string option) = let url = defaultArg url defaultURL async { let! jsonString = ARCtrl.WebRequest.downloadFile url - let mapResult = Json.Templates.decodeFromString jsonString + let mapResult = Json.Templates.fromJsonString jsonString return mapResult } diff --git a/src/FileSystem/DefaultGitignore.fs b/src/FileSystem/DefaultGitignore.fs index 57bf63be..93b9a331 100644 --- a/src/FileSystem/DefaultGitignore.fs +++ b/src/FileSystem/DefaultGitignore.fs @@ -1,5 +1,8 @@ module ARCtrl.FileSystem.DefaultGitignore +/// +/// A string containing the default .gitignore file content. +/// let dgi = """# ----- macos rules ----- # taken from https://github.com/github/gitignore/blob/main/Global/macOS.gitignore # General diff --git a/src/ISA/ISA.Json/Assay.fs b/src/ISA/ISA.Json/Assay.fs index 724ddaa7..14530ecf 100644 --- a/src/ISA/ISA.Json/Assay.fs +++ b/src/ISA/ISA.Json/Assay.fs @@ -37,13 +37,13 @@ module Assay = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Assay |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Assay" - GEncode.tryInclude "filename" GEncode.string (oa |> GEncode.tryGetPropertyValue "FileName") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Assay |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Assay" + GEncode.tryInclude "filename" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "FileName") GEncode.tryInclude "measurementType" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "MeasurementType") GEncode.tryInclude "technologyType" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "TechnologyType") - GEncode.tryInclude "technologyPlatform" GEncode.string (oa |> GEncode.tryGetPropertyValue "TechnologyPlatform") + GEncode.tryInclude "technologyPlatform" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "TechnologyPlatform") GEncode.tryInclude "dataFiles" (Data.encoder options) (oa |> GEncode.tryGetPropertyValue "DataFiles") GEncode.tryInclude "materials" (AssayMaterials.encoder options) (oa |> GEncode.tryGetPropertyValue "Materials") GEncode.tryInclude "characteristicCategories" (MaterialAttribute.encoder options) (oa |> GEncode.tryGetPropertyValue "CharacteristicCategories") @@ -71,10 +71,10 @@ module Assay = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:Assay) = + let toJsonString (p:Assay) = encoder (ConverterOptions()) p |> Encode.toString 2 @@ -95,11 +95,11 @@ module ArcAssay = open Assay - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s |> ArcAssay.fromAssay - let toString (a:ArcAssay) = + let toJsonString (a:ArcAssay) = encoder (ConverterOptions()) (a.ToAssay()) |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Comment.fs b/src/ISA/ISA.Json/Comment.fs index 9d5cc98a..7a2e466d 100644 --- a/src/ISA/ISA.Json/Comment.fs +++ b/src/ISA/ISA.Json/Comment.fs @@ -22,11 +22,11 @@ module Comment = let encoder (options : ConverterOptions) (comment : obj) = [ - if options.SetID then "@id", GEncode.string (comment :?> Comment |> genID) - else GEncode.tryInclude "@id" GEncode.string (comment |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Comment" - GEncode.tryInclude "name" GEncode.string (comment |> GEncode.tryGetPropertyValue "Name") - GEncode.tryInclude "value" GEncode.string (comment |> GEncode.tryGetPropertyValue "Value") + if options.SetID then "@id", GEncode.toJsonString (comment :?> Comment |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (comment |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Comment" + GEncode.tryInclude "name" GEncode.toJsonString (comment |> GEncode.tryGetPropertyValue "Name") + GEncode.tryInclude "value" GEncode.toJsonString (comment |> GEncode.tryGetPropertyValue "Value") ] |> GEncode.choose |> Encode.object @@ -40,10 +40,10 @@ module Comment = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (c:Comment) = + let toJsonString (c:Comment) = encoder (ConverterOptions()) c |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Data.fs b/src/ISA/ISA.Json/Data.fs index 12bdf82c..bcb4f7e1 100644 --- a/src/ISA/ISA.Json/Data.fs +++ b/src/ISA/ISA.Json/Data.fs @@ -44,10 +44,10 @@ module Data = let rec encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Data |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Data" - GEncode.tryInclude "name" GEncode.string (oa |> GEncode.tryGetPropertyValue "Name") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Data |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Data" + GEncode.tryInclude "name" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Name") GEncode.tryInclude "type" (DataFile.encoder options) (oa |> GEncode.tryGetPropertyValue "DataType") GEncode.tryInclude "comments" (Comment.encoder options) (oa |> GEncode.tryGetPropertyValue "Comments") ] @@ -71,10 +71,10 @@ module Data = ) s json - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (m:Data) = + let toJsonString (m:Data) = encoder (ConverterOptions()) m |> Encode.toString 2 @@ -102,10 +102,10 @@ module Source = let rec encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Source |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Source" - GEncode.tryInclude "name" GEncode.string (oa |> GEncode.tryGetPropertyValue "Name") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Source |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Source" + GEncode.tryInclude "name" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Name") GEncode.tryInclude "characteristics" (MaterialAttributeValue.encoder options) (oa |> GEncode.tryGetPropertyValue "Characteristics") ] |> GEncode.choose |> Encode.object @@ -125,10 +125,10 @@ module Source = ) s json - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (m:Source) = + let toJsonString (m:Source) = encoder (ConverterOptions()) m |> Encode.toString 2 @@ -155,10 +155,10 @@ module Sample = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Sample |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Sample" - GEncode.tryInclude "name" GEncode.string (oa |> GEncode.tryGetPropertyValue "Name") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Sample |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Sample" + GEncode.tryInclude "name" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Name") GEncode.tryInclude "characteristics" (MaterialAttributeValue.encoder options) (oa |> GEncode.tryGetPropertyValue "Characteristics") GEncode.tryInclude "factorValues" (FactorValue.encoder options) (oa |> GEncode.tryGetPropertyValue "FactorValues") GEncode.tryInclude "derivesFrom" (Source.encoder options) (oa |> GEncode.tryGetPropertyValue "DerivesFrom") @@ -182,10 +182,10 @@ module Sample = ) s json - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (m:Sample) = + let toJsonString (m:Sample) = encoder (ConverterOptions()) m |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Decode.fs b/src/ISA/ISA.Json/Decode.fs index 0da7bcd0..e55ac8b8 100644 --- a/src/ISA/ISA.Json/Decode.fs +++ b/src/ISA/ISA.Json/Decode.fs @@ -22,7 +22,7 @@ module GDecode = | Ok s -> Error (DecoderError(s,ErrorReason.FailMessage (sprintf "Expected URI, got %s" s))) | Error e -> Error e - let fromString (decoder : Decoder<'a>) (s : string) : 'a = + let fromJsonString (decoder : Decoder<'a>) (s : string) : 'a = match Decode.fromString decoder s with | Ok a -> a | Error e -> failwith (sprintf "Error decoding string: %s" e) diff --git a/src/ISA/ISA.Json/Factor.fs b/src/ISA/ISA.Json/Factor.fs index 57e995cd..cc8070c5 100644 --- a/src/ISA/ISA.Json/Factor.fs +++ b/src/ISA/ISA.Json/Factor.fs @@ -38,10 +38,10 @@ module Value = | Error e -> Error e - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (v:Value) = + let toJsonString (v:Value) = encoder (ConverterOptions()) v |> Encode.toString 2 @@ -63,10 +63,10 @@ module Factor = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Factor |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Factor" - GEncode.tryInclude "factorName" GEncode.string (oa |> GEncode.tryGetPropertyValue "Name") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Factor |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Factor" + GEncode.tryInclude "factorName" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Name") GEncode.tryInclude "factorType" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "FactorType") GEncode.tryInclude "comments" (Comment.encoder options) (oa |> GEncode.tryGetPropertyValue "Comments") ] @@ -83,10 +83,10 @@ module Factor = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (f:Factor) = + let toJsonString (f:Factor) = encoder (ConverterOptions()) f |> Encode.toString 2 @@ -112,9 +112,9 @@ module FactorValue = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> FactorValue |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "FactorValue" + if options.SetID then "@id", GEncode.toJsonString (oa :?> FactorValue |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "FactorValue" GEncode.tryInclude "category" (Factor.encoder options) (oa |> GEncode.tryGetPropertyValue "Category") GEncode.tryInclude "value" (Value.encoder options) (oa |> GEncode.tryGetPropertyValue "Value") GEncode.tryInclude "unit" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "Unit") @@ -132,10 +132,10 @@ module FactorValue = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (f:FactorValue) = + let toJsonString (f:FactorValue) = encoder (ConverterOptions()) f |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/GEncode.fs b/src/ISA/ISA.Json/GEncode.fs index 5287cb6a..9e30575e 100644 --- a/src/ISA/ISA.Json/GEncode.fs +++ b/src/ISA/ISA.Json/GEncode.fs @@ -35,7 +35,7 @@ module GEncode = ) #endif - let inline string (value : obj) = + let inline toJsonString (value : obj) = match value with | :? string as s -> Encode.string s | _ -> Encode.nil diff --git a/src/ISA/ISA.Json/Investigation.fs b/src/ISA/ISA.Json/Investigation.fs index c3920986..1116b9d0 100644 --- a/src/ISA/ISA.Json/Investigation.fs +++ b/src/ISA/ISA.Json/Investigation.fs @@ -23,15 +23,15 @@ module Investigation = | None -> "#EmptyStudy" let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Investigation |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Investigation" - GEncode.tryInclude "filename" GEncode.string (oa |> GEncode.tryGetPropertyValue "FileName") - GEncode.tryInclude "identifier" GEncode.string (oa |> GEncode.tryGetPropertyValue "Identifier") - GEncode.tryInclude "title" GEncode.string (oa |> GEncode.tryGetPropertyValue "Title") - GEncode.tryInclude "description" GEncode.string (oa |> GEncode.tryGetPropertyValue "Description") - GEncode.tryInclude "submissionDate" GEncode.string (oa |> GEncode.tryGetPropertyValue "SubmissionDate") - GEncode.tryInclude "publicReleaseDate" GEncode.string (oa |> GEncode.tryGetPropertyValue "PublicReleaseDate") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Investigation |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Investigation" + GEncode.tryInclude "filename" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "FileName") + GEncode.tryInclude "identifier" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Identifier") + GEncode.tryInclude "title" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Title") + GEncode.tryInclude "description" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Description") + GEncode.tryInclude "submissionDate" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "SubmissionDate") + GEncode.tryInclude "publicReleaseDate" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "PublicReleaseDate") GEncode.tryInclude "ontologySourceReferences" (OntologySourceReference.encoder options) (oa |> GEncode.tryGetPropertyValue "OntologySourceReferences") GEncode.tryInclude "publications" (Publication.encoder options) (oa |> GEncode.tryGetPropertyValue "Publications") GEncode.tryInclude "people" (Person.encoder options) (oa |> GEncode.tryGetPropertyValue "Contacts") @@ -60,10 +60,10 @@ module Investigation = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:Investigation) = + let toJsonString (p:Investigation) = encoder (ConverterOptions()) p |> Encode.toString 2 @@ -76,11 +76,11 @@ module ArcInvestigation = open Investigation - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s |> ArcInvestigation.fromInvestigation - let toString (a:ArcInvestigation) = + let toJsonString (a:ArcInvestigation) = encoder (ConverterOptions()) (a.ToInvestigation()) |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Material.fs b/src/ISA/ISA.Json/Material.fs index 4646a22c..f715f07d 100644 --- a/src/ISA/ISA.Json/Material.fs +++ b/src/ISA/ISA.Json/Material.fs @@ -37,9 +37,9 @@ module MaterialAttribute = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> MaterialAttribute |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "MaterialAttribute" + if options.SetID then "@id", GEncode.toJsonString (oa :?> MaterialAttribute |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "MaterialAttribute" GEncode.tryInclude "characteristicType" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "CharacteristicType") ] |> GEncode.choose @@ -53,10 +53,10 @@ module MaterialAttribute = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (m:MaterialAttribute) = + let toJsonString (m:MaterialAttribute) = encoder (ConverterOptions()) m |> Encode.toString 2 @@ -81,9 +81,9 @@ module MaterialAttributeValue = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> MaterialAttributeValue |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "MaterialAttributeValue" + if options.SetID then "@id", GEncode.toJsonString (oa :?> MaterialAttributeValue |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "MaterialAttributeValue" GEncode.tryInclude "category" (MaterialAttribute.encoder options) (oa |> GEncode.tryGetPropertyValue "Category") GEncode.tryInclude "value" (Value.encoder options) (oa |> GEncode.tryGetPropertyValue "Value") GEncode.tryInclude "unit" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "Unit") @@ -101,10 +101,10 @@ module MaterialAttributeValue = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (m:MaterialAttributeValue) = + let toJsonString (m:MaterialAttributeValue) = encoder (ConverterOptions()) m |> Encode.toString 2 @@ -132,10 +132,10 @@ module Material = let rec encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Material |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Material" - GEncode.tryInclude "name" GEncode.string (oa |> GEncode.tryGetPropertyValue "Name") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Material |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Material" + GEncode.tryInclude "name" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Name") GEncode.tryInclude "type" (MaterialType.encoder options) (oa |> GEncode.tryGetPropertyValue "MaterialType") GEncode.tryInclude "characteristics" (MaterialAttributeValue.encoder options) (oa |> GEncode.tryGetPropertyValue "Characteristics") GEncode.tryInclude "derivesFrom" (encoder options) (oa |> GEncode.tryGetPropertyValue "DerivesFrom") @@ -158,10 +158,10 @@ module Material = } ) s json - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (m:Material) = + let toJsonString (m:Material) = encoder (ConverterOptions()) m |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Ontology.fs b/src/ISA/ISA.Json/Ontology.fs index 2ad7dcce..1adb4e30 100644 --- a/src/ISA/ISA.Json/Ontology.fs +++ b/src/ISA/ISA.Json/Ontology.fs @@ -44,12 +44,12 @@ module OntologySourceReference = let encoder (options : ConverterOptions) (osr : obj) = [ - if options.SetID then "@id", GEncode.string (osr :?> OntologySourceReference |> genID) - if options.IncludeType then "@type", GEncode.string "OntologySourceReference" - GEncode.tryInclude "description" GEncode.string (osr |> GEncode.tryGetPropertyValue "Description") - GEncode.tryInclude "file" GEncode.string (osr |> GEncode.tryGetPropertyValue "File") - GEncode.tryInclude "name" GEncode.string (osr |> GEncode.tryGetPropertyValue "Name") - GEncode.tryInclude "version" GEncode.string (osr |> GEncode.tryGetPropertyValue "Version") + if options.SetID then "@id", GEncode.toJsonString (osr :?> OntologySourceReference |> genID) + if options.IncludeType then "@type", GEncode.toJsonString "OntologySourceReference" + GEncode.tryInclude "description" GEncode.toJsonString (osr |> GEncode.tryGetPropertyValue "Description") + GEncode.tryInclude "file" GEncode.toJsonString (osr |> GEncode.tryGetPropertyValue "File") + GEncode.tryInclude "name" GEncode.toJsonString (osr |> GEncode.tryGetPropertyValue "Name") + GEncode.tryInclude "version" GEncode.toJsonString (osr |> GEncode.tryGetPropertyValue "Version") GEncode.tryInclude "comments" (Comment.encoder options) (osr |> GEncode.tryGetPropertyValue "Comments") ] |> GEncode.choose @@ -66,10 +66,10 @@ module OntologySourceReference = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (oa:OntologySourceReference) = + let toJsonString (oa:OntologySourceReference) = encoder (ConverterOptions()) oa |> Encode.toString 2 @@ -98,12 +98,12 @@ module OntologyAnnotation = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> OntologyAnnotation |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "OntologyAnnotation" + if options.SetID then "@id", GEncode.toJsonString (oa :?> OntologyAnnotation |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "OntologyAnnotation" GEncode.tryInclude "annotationValue" (AnnotationValue.encoder options) (oa |> GEncode.tryGetPropertyValue "Name") - GEncode.tryInclude "termSource" GEncode.string (oa |> GEncode.tryGetPropertyValue "TermSourceREF") - GEncode.tryInclude "termAccession" GEncode.string (oa |> GEncode.tryGetPropertyValue "TermAccessionNumber") + GEncode.tryInclude "termSource" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "TermSourceREF") + GEncode.tryInclude "termAccession" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "TermAccessionNumber") GEncode.tryInclude "comments" (Comment.encoder options) (oa |> GEncode.tryGetPropertyValue "Comments") ] |> GEncode.choose @@ -121,10 +121,10 @@ module OntologyAnnotation = ) ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (oa:OntologyAnnotation) = + let toJsonString (oa:OntologyAnnotation) = encoder (ConverterOptions()) oa |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Person.fs b/src/ISA/ISA.Json/Person.fs index 8c479898..52a7be5d 100644 --- a/src/ISA/ISA.Json/Person.fs +++ b/src/ISA/ISA.Json/Person.fs @@ -34,17 +34,17 @@ module Person = let rec encoder (options : ConverterOptions) (oa : obj) = let oa = oa :?> Person |> Person.setCommentFromORCID [ - 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") - GEncode.tryInclude "lastName" GEncode.string (oa |> GEncode.tryGetPropertyValue "LastName") - GEncode.tryInclude "midInitials" GEncode.string (oa |> GEncode.tryGetPropertyValue "MidInitials") - GEncode.tryInclude "email" GEncode.string (oa |> GEncode.tryGetPropertyValue "EMail") - GEncode.tryInclude "phone" GEncode.string (oa |> GEncode.tryGetPropertyValue "Phone") - GEncode.tryInclude "fax" GEncode.string (oa |> GEncode.tryGetPropertyValue "Fax") - GEncode.tryInclude "address" GEncode.string (oa |> GEncode.tryGetPropertyValue "Address") - GEncode.tryInclude "affiliation" GEncode.string (oa |> GEncode.tryGetPropertyValue "Affiliation") + if options.SetID then "@id", GEncode.toJsonString (oa |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Person" + GEncode.tryInclude "firstName" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "FirstName") + GEncode.tryInclude "lastName" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "LastName") + GEncode.tryInclude "midInitials" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "MidInitials") + GEncode.tryInclude "email" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "EMail") + GEncode.tryInclude "phone" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Phone") + GEncode.tryInclude "fax" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Fax") + GEncode.tryInclude "address" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Address") + GEncode.tryInclude "affiliation" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Affiliation") GEncode.tryInclude "roles" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "Roles") GEncode.tryInclude "comments" (Comment.encoder options) (oa |> GEncode.tryGetPropertyValue "Comments") ] @@ -71,10 +71,10 @@ module Person = ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:Person) = + let toJsonString (p:Person) = encoder (ConverterOptions()) p |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Process.fs b/src/ISA/ISA.Json/Process.fs index 410eeec7..730c55cf 100644 --- a/src/ISA/ISA.Json/Process.fs +++ b/src/ISA/ISA.Json/Process.fs @@ -22,8 +22,8 @@ module ProcessParameterValue = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> ProcessParameterValue |> genID) - if options.IncludeType then "@type", GEncode.string "ProcessParameterValue" + if options.SetID then "@id", GEncode.toJsonString (oa :?> ProcessParameterValue |> genID) + if options.IncludeType then "@type", GEncode.toJsonString "ProcessParameterValue" GEncode.tryInclude "category" (ProtocolParameter.encoder options) (oa |> GEncode.tryGetPropertyValue "Category") GEncode.tryInclude "value" (Value.encoder options) (oa |> GEncode.tryGetPropertyValue "Value") GEncode.tryInclude "unit" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "Unit") @@ -40,10 +40,10 @@ module ProcessParameterValue = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:ProcessParameterValue) = + let toJsonString (p:ProcessParameterValue) = encoder (ConverterOptions()) p |> Encode.toString 2 @@ -89,10 +89,10 @@ module ProcessInput = | Ok s -> Ok (ProcessInput.Material s) | Error e -> Error e - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (m:ProcessInput) = + let toJsonString (m:ProcessInput) = encoder (ConverterOptions()) m |> Encode.toString 2 @@ -132,10 +132,10 @@ module ProcessOutput = | Ok s -> Ok (ProcessOutput.Material s) | Error e -> Error e - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (m:ProcessInput) = + let toJsonString (m:ProcessInput) = encoder (ConverterOptions()) m |> Encode.toString 2 @@ -158,14 +158,14 @@ module Process = let rec encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Process |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Process" - GEncode.tryInclude "name" GEncode.string (oa |> GEncode.tryGetPropertyValue "Name") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Process |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Process" + GEncode.tryInclude "name" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Name") GEncode.tryInclude "executesProtocol" (Protocol.encoder options) (oa |> GEncode.tryGetPropertyValue "ExecutesProtocol") GEncode.tryInclude "parameterValues" (ProcessParameterValue.encoder options) (oa |> GEncode.tryGetPropertyValue "ParameterValues") - GEncode.tryInclude "performer" GEncode.string (oa |> GEncode.tryGetPropertyValue "Performer") - GEncode.tryInclude "date" GEncode.string (oa |> GEncode.tryGetPropertyValue "Date") + GEncode.tryInclude "performer" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Performer") + GEncode.tryInclude "date" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Date") GEncode.tryInclude "previousProcess" (encoder options) (oa |> GEncode.tryGetPropertyValue "PreviousProcess") GEncode.tryInclude "nextProcess" (encoder options) (oa |> GEncode.tryGetPropertyValue "NextProcess") GEncode.tryInclude "inputs" (ProcessInput.encoder options) (oa |> GEncode.tryGetPropertyValue "Inputs") @@ -192,10 +192,10 @@ module Process = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:Process) = + let toJsonString (p:Process) = encoder (ConverterOptions()) p |> Encode.toString 2 @@ -213,10 +213,10 @@ module Process = module ProcessSequence = - let fromString (s:string) = - GDecode.fromString (Decode.list (Process.decoder (ConverterOptions()))) s + let fromJsonString (s:string) = + GDecode.fromJsonString (Decode.list (Process.decoder (ConverterOptions()))) s - let toString (p:Process list) = + let toJsonString (p:Process list) = p |> List.map (Process.encoder (ConverterOptions())) |> Encode.list diff --git a/src/ISA/ISA.Json/Protocol.fs b/src/ISA/ISA.Json/Protocol.fs index 38531549..b50d5aed 100644 --- a/src/ISA/ISA.Json/Protocol.fs +++ b/src/ISA/ISA.Json/Protocol.fs @@ -18,9 +18,9 @@ module ProtocolParameter = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> ProtocolParameter |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "ProtocolParameter" + if options.SetID then "@id", GEncode.toJsonString (oa :?> ProtocolParameter |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "ProtocolParameter" GEncode.tryInclude "parameterName" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "ParameterName") ] |> GEncode.choose @@ -34,8 +34,8 @@ module ProtocolParameter = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s let toString (p:ProtocolParameter) = encoder (ConverterOptions()) p @@ -62,9 +62,9 @@ module Component = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Component |> genID) - if options.IncludeType then "@type", GEncode.string "Component" - GEncode.tryInclude "componentName" GEncode.string (oa |> GEncode.tryGetPropertyValue "ComponentName") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Component |> genID) + if options.IncludeType then "@type", GEncode.toJsonString "Component" + GEncode.tryInclude "componentName" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ComponentName") GEncode.tryInclude "componentType" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "ComponentType") ] |> GEncode.choose @@ -89,10 +89,10 @@ module Component = ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:Component) = + let toJsonString (p:Component) = encoder (ConverterOptions()) p |> Encode.toString 2 @@ -121,14 +121,14 @@ module Protocol = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Protocol |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Protocol" - GEncode.tryInclude "name" GEncode.string (oa |> GEncode.tryGetPropertyValue "Name") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Protocol |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Protocol" + GEncode.tryInclude "name" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Name") GEncode.tryInclude "protocolType" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "ProtocolType") - GEncode.tryInclude "description" GEncode.string (oa |> GEncode.tryGetPropertyValue "Description") - GEncode.tryInclude "uri" GEncode.string (oa |> GEncode.tryGetPropertyValue "Uri") - GEncode.tryInclude "version" GEncode.string (oa |> GEncode.tryGetPropertyValue "Version") + GEncode.tryInclude "description" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Description") + GEncode.tryInclude "uri" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Uri") + GEncode.tryInclude "version" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Version") GEncode.tryInclude "parameters" (ProtocolParameter.encoder options) (oa |> GEncode.tryGetPropertyValue "Parameters") GEncode.tryInclude "components" (Component.encoder options) (oa |> GEncode.tryGetPropertyValue "Components") GEncode.tryInclude "comments" (Comment.encoder options) (oa |> GEncode.tryGetPropertyValue "Comments") @@ -151,10 +151,10 @@ module Protocol = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:Protocol) = + let toJsonString (p:Protocol) = encoder (ConverterOptions()) p |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Publication.fs b/src/ISA/ISA.Json/Publication.fs index c710f875..3c1397d7 100644 --- a/src/ISA/ISA.Json/Publication.fs +++ b/src/ISA/ISA.Json/Publication.fs @@ -21,12 +21,12 @@ module Publication = let rec encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Publication |> genID) - if options.IncludeType then "@type", GEncode.string "Publication" - GEncode.tryInclude "pubMedID" GEncode.string (oa |> GEncode.tryGetPropertyValue "PubMedID") - GEncode.tryInclude "doi" GEncode.string (oa |> GEncode.tryGetPropertyValue "DOI") - GEncode.tryInclude "authorList" GEncode.string (oa |> GEncode.tryGetPropertyValue "Authors") - GEncode.tryInclude "title" GEncode.string (oa |> GEncode.tryGetPropertyValue "Title") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Publication |> genID) + if options.IncludeType then "@type", GEncode.toJsonString "Publication" + GEncode.tryInclude "pubMedID" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "PubMedID") + GEncode.tryInclude "doi" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "DOI") + GEncode.tryInclude "authorList" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Authors") + GEncode.tryInclude "title" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Title") GEncode.tryInclude "status" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "Status") GEncode.tryInclude "comments" (Comment.encoder options) (oa |> GEncode.tryGetPropertyValue "Comments") ] @@ -46,10 +46,10 @@ module Publication = ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:Publication) = + let toJsonString (p:Publication) = encoder (ConverterOptions()) p |> Encode.toString 2 diff --git a/src/ISA/ISA.Json/Study.fs b/src/ISA/ISA.Json/Study.fs index d2f8b04d..8a3db137 100644 --- a/src/ISA/ISA.Json/Study.fs +++ b/src/ISA/ISA.Json/Study.fs @@ -44,15 +44,15 @@ module Study = let encoder (options : ConverterOptions) (oa : obj) = [ - if options.SetID then "@id", GEncode.string (oa :?> Study |> genID) - else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID") - if options.IncludeType then "@type", GEncode.string "Study" - GEncode.tryInclude "filename" GEncode.string (oa |> GEncode.tryGetPropertyValue "FileName") - GEncode.tryInclude "identifier" GEncode.string (oa |> GEncode.tryGetPropertyValue "Identifier") - GEncode.tryInclude "title" GEncode.string (oa |> GEncode.tryGetPropertyValue "Title") - GEncode.tryInclude "description" GEncode.string (oa |> GEncode.tryGetPropertyValue "Description") - GEncode.tryInclude "submissionDate" GEncode.string (oa |> GEncode.tryGetPropertyValue "SubmissionDate") - GEncode.tryInclude "publicReleaseDate" GEncode.string (oa |> GEncode.tryGetPropertyValue "PublicReleaseDate") + if options.SetID then "@id", GEncode.toJsonString (oa :?> Study |> genID) + else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID") + if options.IncludeType then "@type", GEncode.toJsonString "Study" + GEncode.tryInclude "filename" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "FileName") + GEncode.tryInclude "identifier" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Identifier") + GEncode.tryInclude "title" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Title") + GEncode.tryInclude "description" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "Description") + GEncode.tryInclude "submissionDate" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "SubmissionDate") + GEncode.tryInclude "publicReleaseDate" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "PublicReleaseDate") GEncode.tryInclude "publications" (Publication.encoder options) (oa |> GEncode.tryGetPropertyValue "Publications") GEncode.tryInclude "people" (Person.encoder options) (oa |> GEncode.tryGetPropertyValue "Contacts") GEncode.tryInclude "studyDesignDescriptors" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "StudyDesignDescriptors") @@ -92,10 +92,10 @@ module Study = } ) - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s - let toString (p:Study) = + let toJsonString (p:Study) = encoder (ConverterOptions()) p |> Encode.toString 2 @@ -109,11 +109,11 @@ module ArcStudy = open Study - let fromString (s:string) = - GDecode.fromString (decoder (ConverterOptions())) s + let fromJsonString (s:string) = + GDecode.fromJsonString (decoder (ConverterOptions())) s |> ArcStudy.fromStudy - let toString (a:ArcStudy) (assays: ResizeArray) = + let toJsonString (a:ArcStudy) (assays: ResizeArray) = encoder (ConverterOptions()) (a.ToStudy(assays)) |> Encode.toString 2 diff --git a/src/ISA/ISA/ArcTypes/ArcTypes.fs b/src/ISA/ISA/ArcTypes/ArcTypes.fs index d1f2aa07..d007bf54 100644 --- a/src/ISA/ISA/ArcTypes/ArcTypes.fs +++ b/src/ISA/ISA/ArcTypes/ArcTypes.fs @@ -602,6 +602,32 @@ type ArcAssay(identifier: string, ?measurementType : OntologyAnnotation, ?techno ?comments = (a.Comments |> Option.map Array.ofList) ) + member this.StructurallyEquals (other: ArcAssay) : bool = + let i = this.Identifier = other.Identifier + let mst = this.MeasurementType = other.MeasurementType + let tt = this.TechnologyType = other.TechnologyType + let tp = this.TechnologyPlatform = other.TechnologyPlatform + let tables = Aux.compareSeq this.Tables other.Tables + let perf = Aux.compareSeq this.Performers other.Performers + let comments = Aux.compareSeq this.Comments other.Comments + // Todo maybe add reflection check to prove that all members are compared? + [|i; mst; tt; tp; tables; perf; comments|] |> Seq.forall (fun x -> x = true) + + /// + /// Use this function to check if this ArcAssay and the input ArcAssay refer to the same object. + /// + /// If true, updating one will update the other due to mutability. + /// + /// The other ArcAssay to test for reference. + member this.ReferenceEquals (other: ArcAssay) = System.Object.ReferenceEquals(this,other) + + // custom check + override this.Equals other = + match other with + | :? ArcAssay as assay -> + this.StructurallyEquals(assay) + | _ -> false + [] type ArcStudy(identifier : string, ?title, ?description, ?submissionDate, ?publicReleaseDate, ?publications, ?contacts, ?studyDesignDescriptors, ?tables, ?registeredAssayIdentifiers: ResizeArray, ?factors, ?comments) = let publications = defaultArg publications [||] @@ -1212,6 +1238,37 @@ type ArcStudy(identifier : string, ?title, ?description, ?submissionDate, ?publi ), assays + member this.StructurallyEquals (other: ArcStudy) : bool = + let i = this.Identifier = other.Identifier + let t = this.Title = other.Title + let d = this.Description = other.Description + let sd = this.SubmissionDate = other.SubmissionDate + let prd = this.PublicReleaseDate = other.PublicReleaseDate + let pub = Aux.compareSeq this.Publications other.Publications + let con = Aux.compareSeq this.Contacts other.Contacts + let sdd = Aux.compareSeq this.StudyDesignDescriptors other.StudyDesignDescriptors + let tables = Aux.compareSeq this.Tables other.Tables + let reg_tables = Aux.compareSeq this.RegisteredAssayIdentifiers other.RegisteredAssayIdentifiers + let factors = Aux.compareSeq this.Factors other.Factors + let comments = Aux.compareSeq this.Comments other.Comments + // Todo maybe add reflection check to prove that all members are compared? + [|i; t; d; sd; prd; pub; con; sdd; tables; reg_tables; factors; comments|] |> Seq.forall (fun x -> x = true) + + /// + /// Use this function to check if this ArcStudy and the input ArcStudy refer to the same object. + /// + /// If true, updating one will update the other due to mutability. + /// + /// The other ArcStudy to test for reference. + member this.ReferenceEquals (other: ArcStudy) = System.Object.ReferenceEquals(this,other) + + // custom check + override this.Equals other = + match other with + | :? ArcStudy as s -> + this.StructurallyEquals(s) + | _ -> false + [] type ArcInvestigation(identifier : string, ?title : string, ?description : string, ?submissionDate : string, ?publicReleaseDate : string, ?ontologySourceReferences : OntologySourceReference [], ?publications : Publication [], ?contacts : Person [], ?assays : ResizeArray, ?studies : ResizeArray, ?registeredStudyIdentifiers : ResizeArray, ?comments : Comment [], ?remarks : Remark []) as this = @@ -1693,4 +1750,36 @@ type ArcInvestigation(identifier : string, ?title : string, ?description : strin ?contacts = (i.Contacts |> Option.map Array.ofList), ?comments = (i.Comments |> Option.map Array.ofList) ) - i \ No newline at end of file + i + + member this.StructurallyEquals (other: ArcInvestigation) : bool = + let i = this.Identifier = other.Identifier + let t = this.Title = other.Title + let d = this.Description = other.Description + let sd = this.SubmissionDate = other.SubmissionDate + let prd = this.PublicReleaseDate = other.PublicReleaseDate + let pub = Aux.compareSeq this.Publications other.Publications + let con = Aux.compareSeq this.Contacts other.Contacts + let osr = Aux.compareSeq this.OntologySourceReferences other.OntologySourceReferences + let assays = Aux.compareSeq this.Assays other.Assays + let studies = Aux.compareSeq this.Studies other.Studies + let reg_studies = Aux.compareSeq this.RegisteredStudyIdentifiers other.RegisteredStudyIdentifiers + let comments = Aux.compareSeq this.Comments other.Comments + let remarks = Aux.compareSeq this.Remarks other.Remarks + // Todo maybe add reflection check to prove that all members are compared? + [|i; t; d; sd; prd; pub; con; osr; assays; studies; reg_studies; comments; remarks|] |> Seq.forall (fun x -> x = true) + + /// + /// Use this function to check if this ArcInvestigation and the input ArcInvestigation refer to the same object. + /// + /// If true, updating one will update the other due to mutability. + /// + /// The other ArcInvestigation to test for reference. + member this.ReferenceEquals (other: ArcStudy) = System.Object.ReferenceEquals(this,other) + + // custom check + override this.Equals other = + match other with + | :? ArcInvestigation as i -> + this.StructurallyEquals(i) + | _ -> false \ No newline at end of file diff --git a/src/ISA/ISA/Regex.fs b/src/ISA/ISA/Regex.fs index 0d000c0c..e94b6687 100644 --- a/src/ISA/ISA/Regex.fs +++ b/src/ISA/ISA/Regex.fs @@ -96,7 +96,7 @@ module Pattern = /// /// Exmp. 2: Characteristic [species] --> termcolumntype: Characteristic; termname: species [] - let TermColumnPattern = @"(?.+)\s\[(?.+)\]" + let TermColumnPattern = @"(?.+?)\s\[(?.+)\]" /// This pattern is used to match auto-generated table names. Mainly used in ArcAssay.addTable(). Default tables will get such a name. /// diff --git a/tests/ARCtrl/ARCtrl.Tests.fs b/tests/ARCtrl/ARCtrl.Tests.fs index 3c570e4c..129daace 100644 --- a/tests/ARCtrl/ARCtrl.Tests.fs +++ b/tests/ARCtrl/ARCtrl.Tests.fs @@ -46,7 +46,6 @@ let private test_model = testList "model" [ Expect.equal actualFilePaths input "isSome fs" ] - let private test_isaFromContracts = testList "read_contracts" [ testCase "simpleISA" (fun () -> let iContract = SimpleISA.investigationReadContract @@ -132,7 +131,6 @@ let private test_writeContracts = testList "write_contracts" [ Expect.exists contracts (fun c -> c.Path = "studies/.gitkeep") "Contract for studies folder missing" Expect.exists contracts (fun c -> c.Path = "isa.investigation.xlsx") "Contract for investigation folder missing" Expect.exists contracts (fun c -> c.Path = "isa.investigation.xlsx" && c.DTOType.IsSome && c.DTOType.Value = Contract.DTOType.ISA_Investigation) "Contract for investigation exisiting but has wrong DTO type" - ) testCase "simpleISA" (fun _ -> let inv = ArcInvestigation("MyInvestigation", "BestTitle") @@ -286,6 +284,23 @@ let private test_updateFileSystem = testList "update_Filesystem" [ let newFS = arc.FileSystem Expect.notEqual oldFS.Tree newFS.Tree "Tree should be unequal" ) + testCase "set ISA" <| fun () -> + let arc = new ARC() + let paths = arc.FileSystem.Tree.ToFilePaths() + let expected_paths = [|"isa.investigation.xlsx"; "workflows/.gitkeep"; "runs/.gitkeep"; "assays/.gitkeep"; "studies/.gitkeep"|] + Expect.sequenceEqual paths expected_paths "paths" + let i = ARCtrl.ISA.ArcInvestigation.init("My Investigation") + let a = i.InitAssay("My Assay") + () + arc.ISA <- Some i + let paths2 = arc.FileSystem.Tree.ToFilePaths() + let expected_paths2 = [| + "isa.investigation.xlsx"; "workflows/.gitkeep"; "runs/.gitkeep"; + "assays/.gitkeep"; "assays/My Assay/isa.assay.xlsx"; + "assays/My Assay/README.md"; "assays/My Assay/dataset/.gitkeep"; + "assays/My Assay/protocols/.gitkeep"; "studies/.gitkeep" + |] + Expect.equal paths2 expected_paths2 "paths2" ] open ARCtrl.FileSystem diff --git a/tests/ISA/ISA.Json.Tests/Json.Tests.fs b/tests/ISA/ISA.Json.Tests/Json.Tests.fs index d9d25b67..9fc163e6 100644 --- a/tests/ISA/ISA.Json.Tests/Json.Tests.fs +++ b/tests/ISA/ISA.Json.Tests/Json.Tests.fs @@ -138,7 +138,7 @@ let testOntoloyAnnotation = testCase "ReaderSuccess" (fun () -> - let result = OntologyAnnotation.fromString OntologyAnnotation.peptidase + let result = OntologyAnnotation.fromJsonString OntologyAnnotation.peptidase let comment = Comment.create(Name = "comment",Value = "This is a comment") @@ -149,8 +149,8 @@ let testOntoloyAnnotation = ) testCase "WriterOutputMatchesInput" (fun () -> - let o_read_in = OntologyAnnotation.fromString OntologyAnnotation.peptidase - let o_out = OntologyAnnotation.toString o_read_in + let o_read_in = OntologyAnnotation.fromJsonString OntologyAnnotation.peptidase + let o_out = OntologyAnnotation.toJsonString o_read_in let expected = OntologyAnnotation.peptidase @@ -169,7 +169,7 @@ let testOntoloyAnnotationLD = testCase "ReaderSuccess" (fun () -> - let result = OntologyAnnotation.fromString OntologyAnnotation.peptidaseLD + let result = OntologyAnnotation.fromJsonString OntologyAnnotation.peptidaseLD let comment = Comment.create(Name = "comment",Value = "This is a comment") @@ -180,7 +180,7 @@ let testOntoloyAnnotationLD = ) testCase "WriterOutputMatchesInputGivenIDs" (fun () -> - let o_read_in = OntologyAnnotation.fromString OntologyAnnotation.peptidase + let o_read_in = OntologyAnnotation.fromJsonString OntologyAnnotation.peptidase let o_out = OntologyAnnotation.toStringLD o_read_in let expected = @@ -195,7 +195,7 @@ let testOntoloyAnnotationLD = ) testCase "WriterOutputMatchesInputDefaultIDs" (fun () -> - let o_read_in = OntologyAnnotation.fromString OntologyAnnotation.peptidaseWithoutIds + let o_read_in = OntologyAnnotation.fromJsonString OntologyAnnotation.peptidaseWithoutIds let o_out = OntologyAnnotation.toStringLD o_read_in let expected = @@ -217,7 +217,7 @@ let testProcessInput = testList "Source" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString ProcessInput.source + let result = ProcessInput.fromJsonString ProcessInput.source let expected = Source.create("#source/source-culture8","source-culture8") @@ -228,8 +228,8 @@ let testProcessInput = ) testCase "WriterOutputMatchesInput" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.source - let o_out = ProcessInput.toString o_read_in + let o_read_in = ProcessInput.fromJsonString ProcessInput.source + let o_out = ProcessInput.toJsonString o_read_in let expected = ProcessInput.source @@ -245,7 +245,7 @@ let testProcessInput = testList "Material" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString ProcessInput.material + let result = ProcessInput.fromJsonString ProcessInput.material let expected = Material.create("#material/extract-G-0.1-aliquot1","extract-G-0.1-aliquot1",MaterialType.ExtractName,Characteristics = []) @@ -257,8 +257,8 @@ let testProcessInput = ) testCase "WriterOutputMatchesInput" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.material - let o_out = ProcessInput.toString o_read_in + let o_read_in = ProcessInput.fromJsonString ProcessInput.material + let o_out = ProcessInput.toJsonString o_read_in let expected = ProcessInput.material @@ -274,7 +274,7 @@ let testProcessInput = testList "Data" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString ProcessInput.data + let result = ProcessInput.fromJsonString ProcessInput.data let expected = Data.create("#data/rawspectraldatafile-JIC64_Nitrogen_0.07_External_1_3.txt","JIC64_Nitrogen_0.07_External_1_3.txt",DataFile.RawDataFile,Comments = []) Expect.isTrue (ProcessInput.isData result) "Result is not a data" @@ -282,8 +282,8 @@ let testProcessInput = ) testCase "WriterOutputMatchesInput" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.data - let o_out = ProcessInput.toString o_read_in + let o_read_in = ProcessInput.fromJsonString ProcessInput.data + let o_out = ProcessInput.toJsonString o_read_in let expected = ProcessInput.data @@ -299,7 +299,7 @@ let testProcessInput = testList "Sample" [ testCase "ReaderSuccessSimple" (fun () -> - let result = ProcessInput.fromString ProcessInput.sampleSimple + let result = ProcessInput.fromJsonString ProcessInput.sampleSimple let expectedDerivesFrom = [Source.create("#source/source-culture8")] @@ -312,8 +312,8 @@ let testProcessInput = ) testCase "WriterOutputMatchesInputSimple" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.sampleSimple - let o_out = ProcessInput.toString o_read_in + let o_read_in = ProcessInput.fromJsonString ProcessInput.sampleSimple + let o_out = ProcessInput.toJsonString o_read_in let expected = ProcessInput.sampleSimple @@ -334,7 +334,7 @@ let testProcessInputLD = testList "Source" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString ProcessInput.sourceLD + let result = ProcessInput.fromJsonString ProcessInput.sourceLD let expected = Source.create("#source/source-culture8","source-culture8") @@ -345,7 +345,7 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputGivenID" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.source + let o_read_in = ProcessInput.fromJsonString ProcessInput.source let o_out = ProcessInput.toStringLD o_read_in let expected = @@ -360,7 +360,7 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputDefaultID" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.sourceWithoutID + let o_read_in = ProcessInput.fromJsonString ProcessInput.sourceWithoutID let o_out = ProcessInput.toStringLD o_read_in let expected = @@ -377,7 +377,7 @@ let testProcessInputLD = testList "Material" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString ProcessInput.materialLD + let result = ProcessInput.fromJsonString ProcessInput.materialLD let expected = Material.create("#material/extract-G-0.1-aliquot1","extract-G-0.1-aliquot1",MaterialType.ExtractName,Characteristics = []) @@ -389,7 +389,7 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputGivenID" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.material + let o_read_in = ProcessInput.fromJsonString ProcessInput.material let o_out = ProcessInput.toStringLD o_read_in let expected = @@ -404,7 +404,7 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputDefaultID" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.materialWithoutID + let o_read_in = ProcessInput.fromJsonString ProcessInput.materialWithoutID let o_out = ProcessInput.toStringLD o_read_in let expected = @@ -421,7 +421,7 @@ let testProcessInputLD = testList "Data" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString ProcessInput.dataLD + let result = ProcessInput.fromJsonString ProcessInput.dataLD let expected = Data.create("#data/rawspectraldatafile-JIC64_Nitrogen_0.07_External_1_3.txt","JIC64_Nitrogen_0.07_External_1_3.txt",DataFile.RawDataFile,Comments = []) Expect.isTrue (ProcessInput.isData result) "Result is not a data" @@ -429,7 +429,7 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputGivenID" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.data + let o_read_in = ProcessInput.fromJsonString ProcessInput.data let o_out = ProcessInput.toStringLD o_read_in let expected = @@ -444,7 +444,7 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputDefaultID" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.dataWithoutID + let o_read_in = ProcessInput.fromJsonString ProcessInput.dataWithoutID let o_out = ProcessInput.toStringLD o_read_in let expected = @@ -461,7 +461,7 @@ let testProcessInputLD = testList "Sample" [ testCase "ReaderSuccessSimple" (fun () -> - let result = ProcessInput.fromString ProcessInput.sampleSimpleLD + let result = ProcessInput.fromJsonString ProcessInput.sampleSimpleLD let expectedDerivesFrom = [Source.create("#source/source-culture8")] @@ -474,7 +474,7 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputSimpleGivenID" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.sampleSimple + let o_read_in = ProcessInput.fromJsonString ProcessInput.sampleSimple let o_out = ProcessInput.toStringLD o_read_in let expected = @@ -489,7 +489,7 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputSimpleDefaultID" (fun () -> - let o_read_in = ProcessInput.fromString ProcessInput.sampleSimpleWithoutID + let o_read_in = ProcessInput.fromJsonString ProcessInput.sampleSimpleWithoutID let o_out = ProcessInput.toStringLD o_read_in let expected = @@ -519,7 +519,7 @@ let testProtocolFile = ) testCase "ReaderSuccess" (fun () -> - let protocol = Protocol.fromString Protocol.protocol + let protocol = Protocol.fromJsonString Protocol.protocol let exptected_name = "peptide_digestion" let actual = protocol.Name Expect.isSome actual "Should be some" @@ -528,11 +528,11 @@ let testProtocolFile = testCase "WriterRunning" (fun () -> - let p = Protocol.fromString Protocol.protocol + let p = Protocol.fromJsonString Protocol.protocol let writingSuccess = try - Protocol.toString p |> ignore + Protocol.toJsonString p |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Writing the test file failed: %s" err.Message) @@ -542,9 +542,9 @@ let testProtocolFile = testAsync "WriterSchemaCorrectness" { - let p = Protocol.fromString Protocol.protocol + let p = Protocol.fromJsonString Protocol.protocol - let s = Protocol.toString p + let s = Protocol.toJsonString p let! validation = Validation.validateProtocol s @@ -553,13 +553,13 @@ let testProtocolFile = testCase "OutputMatchesInput" (fun () -> - let o_read_in = Protocol.fromString Protocol.protocol + let o_read_in = Protocol.fromJsonString Protocol.protocol let exptected_name = "peptide_digestion" let actual_name = o_read_in.Name Expect.isSome actual_name "Should be some" Expect.equal actual_name (Some exptected_name) "Name exists" - let o = o_read_in |> Protocol.toString + let o = o_read_in |> Protocol.toJsonString let expected = Protocol.protocol @@ -591,7 +591,7 @@ let testProtocolFileLD = ) testCase "ReaderSuccess" (fun () -> - let protocol = Protocol.fromString Protocol.protocolLD + let protocol = Protocol.fromJsonString Protocol.protocolLD let exptected_name = "peptide_digestion" let actual = protocol.Name Expect.isSome actual "Should be some" @@ -600,7 +600,7 @@ let testProtocolFileLD = testCase "WriterRunning" (fun () -> - let p = Protocol.fromString Protocol.protocol + let p = Protocol.fromJsonString Protocol.protocol let writingSuccess = try @@ -625,7 +625,7 @@ let testProtocolFileLD = testCase "OutputMatchesInputGivenIDs" (fun () -> - let o_read_in = Protocol.fromString Protocol.protocol + let o_read_in = Protocol.fromJsonString Protocol.protocol let exptected_name = "peptide_digestion" let actual_name = o_read_in.Name Expect.isSome actual_name "Should be some" @@ -650,7 +650,7 @@ let testProtocolFileLD = testCase "OutputMatchesInputDefaultIDs" (fun () -> - let o_read_in = Protocol.fromString Protocol.protocolWithoutIds + let o_read_in = Protocol.fromJsonString Protocol.protocolWithoutIds let exptected_name = "peptide_digestion" let actual_name = o_read_in.Name Expect.isSome actual_name "Should be some" @@ -681,7 +681,7 @@ let testProcessFile = let readingSuccess = try - Process.fromString Process.process' |> ignore + Process.fromJsonString Process.process' |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -692,11 +692,11 @@ let testProcessFile = testCase "WriterSuccess" (fun () -> - let p = Process.fromString Process.process' + let p = Process.fromJsonString Process.process' let writingSuccess = try - Process.toString p |> ignore + Process.toJsonString p |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Writing the test file failed: %s" err.Message) @@ -706,9 +706,9 @@ let testProcessFile = testAsync "WriterSchemaCorrectness" { - let p = Process.fromString Process.process' + let p = Process.fromJsonString Process.process' - let s = Process.toString p + let s = Process.toJsonString p let! validation = Validation.validateProcess s @@ -718,8 +718,8 @@ let testProcessFile = testCase "OutputMatchesInput" (fun () -> let o = - Process.fromString Process.process' - |> Process.toString + Process.fromJsonString Process.process' + |> Process.toJsonString let expected = Process.process' @@ -744,7 +744,7 @@ let testProcessFileLD = let readingSuccess = try - Process.fromString Process.processLD |> ignore + Process.fromJsonString Process.processLD |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -755,7 +755,7 @@ let testProcessFileLD = testCase "WriterSuccess" (fun () -> - let p = Process.fromString Process.processLD + let p = Process.fromJsonString Process.processLD let writingSuccess = try @@ -781,7 +781,7 @@ let testProcessFileLD = testCase "OutputMatchesInputGivenIDs" (fun () -> let o = - Process.fromString Process.process' + Process.fromJsonString Process.process' |> Process.toStringLD let expected = @@ -802,7 +802,7 @@ let testProcessFileLD = testCase "OutputMatchesInputDefaultLD" (fun () -> let o = - Process.fromString Process.processWithoutIDs + Process.fromJsonString Process.processWithoutIDs |> Process.toStringLD let expected = @@ -827,7 +827,7 @@ let testPersonFile = let readingSuccess = try - Person.fromString Person.person |> ignore + Person.fromJsonString Person.person |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -838,11 +838,11 @@ let testPersonFile = testCase "WriterSuccess" (fun () -> - let a = Person.fromString Person.person + let a = Person.fromJsonString Person.person let writingSuccess = try - Person.toString a |> ignore + Person.toJsonString a |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Writing the test file failed: %s" err.Message) @@ -852,9 +852,9 @@ let testPersonFile = testAsync "WriterSchemaCorrectness" { - let a = Person.fromString Person.person + let a = Person.fromJsonString Person.person - let s = Person.toString a + let s = Person.toJsonString a let! validation = Validation.validatePerson s @@ -864,8 +864,8 @@ let testPersonFile = testCase "OutputMatchesInput" (fun () -> let o = - Person.fromString Person.person - |> Person.toString + Person.fromJsonString Person.person + |> Person.toJsonString let expected = Person.person @@ -885,7 +885,7 @@ let testPersonFile = testCase "WithORCID ReaderCorrectness" (fun () -> - let p = Person.fromString Person.personWithORCID + let p = Person.fromJsonString 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" @@ -894,9 +894,9 @@ let testPersonFile = testAsync "WithORCID WriterSchemaCorrectness" { - let a = Person.fromString Person.personWithORCID + let a = Person.fromJsonString Person.personWithORCID - let s = Person.toString a + let s = Person.toJsonString a let! validation = Validation.validatePerson s @@ -906,8 +906,8 @@ let testPersonFile = testCase "WithORCID OutputMatchesInput" (fun () -> let o = - Person.fromString Person.personWithORCID - |> Person.toString + Person.fromJsonString Person.personWithORCID + |> Person.toJsonString let expected = Person.personWithORCID @@ -932,7 +932,7 @@ let testPersonFileLD = let readingSuccess = try - Person.fromString Person.personLD |> ignore + Person.fromJsonString Person.personLD |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -943,7 +943,7 @@ let testPersonFileLD = testCase "WriterSuccess" (fun () -> - let a = Person.fromString Person.person + let a = Person.fromJsonString Person.person let writingSuccess = try @@ -969,7 +969,7 @@ let testPersonFileLD = testCase "OutputMatchesInputGivenID" (fun () -> let o = - Person.fromString Person.person + Person.fromJsonString Person.person |> Person.toStringLD let expected = @@ -990,7 +990,7 @@ let testPersonFileLD = testCase "OutputMatchesInputDefaultLD" (fun () -> let o = - Person.fromString Person.personWithoutID + Person.fromJsonString Person.personWithoutID |> Person.toStringLD let expected = @@ -1016,7 +1016,7 @@ let testPublicationFile = let readingSuccess = try - Publication.fromString Publication.publication |> ignore + Publication.fromJsonString Publication.publication |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1027,11 +1027,11 @@ let testPublicationFile = testCase "WriterSuccess" (fun () -> - let a = Publication.fromString Publication.publication + let a = Publication.fromJsonString Publication.publication let writingSuccess = try - Publication.toString a |> ignore + Publication.toJsonString a |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Writing the test file failed: %s" err.Message) @@ -1041,9 +1041,9 @@ let testPublicationFile = testAsync "WriterSchemaCorrectness" { - let a = Publication.fromString Publication.publication + let a = Publication.fromJsonString Publication.publication - let s = Publication.toString a + let s = Publication.toJsonString a let! validation = Validation.validatePublication s @@ -1053,8 +1053,8 @@ let testPublicationFile = testCase "OutputMatchesInput" (fun () -> let o = - Publication.fromString Publication.publication - |> Publication.toString + Publication.fromJsonString Publication.publication + |> Publication.toJsonString let expected = Publication.publication @@ -1079,7 +1079,7 @@ let testPublicationFileLD = let readingSuccess = try - Publication.fromString Publication.publicationLD |> ignore + Publication.fromJsonString Publication.publicationLD |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1090,7 +1090,7 @@ let testPublicationFileLD = testCase "WriterSuccess" (fun () -> - let a = Publication.fromString Publication.publication + let a = Publication.fromJsonString Publication.publication let writingSuccess = try @@ -1116,7 +1116,7 @@ let testPublicationFileLD = testCase "OutputMatchesInput" (fun () -> let o = - Publication.fromString Publication.publication + Publication.fromJsonString Publication.publication |> Publication.toStringLD let expected = @@ -1142,7 +1142,7 @@ let testAssayFile = let readingSuccess = try - Assay.fromString Assay.assay |> ignore + Assay.fromJsonString Assay.assay |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1153,11 +1153,11 @@ let testAssayFile = testCase "WriterSuccess" (fun () -> - let a = Assay.fromString Assay.assay + let a = Assay.fromJsonString Assay.assay let writingSuccess = try - Assay.toString a |> ignore + Assay.toJsonString a |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Writing the test file failed: %s" err.Message) @@ -1167,9 +1167,9 @@ let testAssayFile = testAsync "WriterSchemaCorrectness" { - let a = Assay.fromString Assay.assay + let a = Assay.fromJsonString Assay.assay - let s = Assay.toString a + let s = Assay.toJsonString a let! validation = Validation.validateAssay s @@ -1179,8 +1179,8 @@ let testAssayFile = testCase "OutputMatchesInput" (fun () -> let o = - Assay.fromString Assay.assay - |> Assay.toString + Assay.fromJsonString Assay.assay + |> Assay.toJsonString let expected = Assay.assay @@ -1205,7 +1205,7 @@ let testInvestigationFile = let readingSuccess = try - Investigation.fromString Investigation.investigation |> ignore + Investigation.fromJsonString Investigation.investigation |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1215,11 +1215,11 @@ let testInvestigationFile = testCase "WriterSuccess" (fun () -> - let i = Investigation.fromString Investigation.investigation + let i = Investigation.fromJsonString Investigation.investigation let writingSuccess = try - Investigation.toString i |> ignore + Investigation.toJsonString i |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Writing the test file failed: %s" err.Message) @@ -1229,9 +1229,9 @@ let testInvestigationFile = testAsync "WriterSchemaCorrectness" { - let i = Investigation.fromString Investigation.investigation + let i = Investigation.fromJsonString Investigation.investigation - let s = Investigation.toString i + let s = Investigation.toJsonString i let! validation = Validation.validateInvestigation s @@ -1241,8 +1241,8 @@ let testInvestigationFile = testCase "OutputMatchesInput" (fun () -> let o = - Investigation.fromString Investigation.investigation - |> Investigation.toString + Investigation.fromJsonString Investigation.investigation + |> Investigation.toJsonString let expected = Investigation.investigation @@ -1262,7 +1262,7 @@ let testInvestigationFile = let json = "{}" - let i = Investigation.fromString json + let i = Investigation.fromJsonString json Expect.equal i.Remarks List.empty "Remark list should be an empty list." ) @@ -1596,12 +1596,12 @@ let testInvestigationFile = (Some [comment]) ([Remark.make 0 "hallo"]) - let s = Investigation.toString investigation + let s = Investigation.toJsonString investigation //MyExpect.matchingInvestigation s - let reReadInvestigation = Investigation.fromString s - let reWrittenInvestigation = Investigation.toString reReadInvestigation + let reReadInvestigation = Investigation.fromJsonString s + let reWrittenInvestigation = Investigation.toJsonString reReadInvestigation let i = s @@ -1627,7 +1627,7 @@ let testInvestigationFileLD = let readingSuccess = try - Investigation.fromString Investigation.investigationLD |> ignore + Investigation.fromJsonString Investigation.investigationLD |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1637,7 +1637,7 @@ let testInvestigationFileLD = testCase "WriterSuccess" (fun () -> - let i = Investigation.fromString Investigation.investigation + let i = Investigation.fromJsonString Investigation.investigation let writingSuccess = try diff --git a/tests/ISA/ISA.Tests/CompositeHeader.Tests.fs b/tests/ISA/ISA.Tests/CompositeHeader.Tests.fs index 20e38c5e..3baa0eca 100644 --- a/tests/ISA/ISA.Tests/CompositeHeader.Tests.fs +++ b/tests/ISA/ISA.Tests/CompositeHeader.Tests.fs @@ -142,6 +142,11 @@ let private tests_compositeHeader = let expected = CompositeHeader.Component <| OntologyAnnotation.fromString("temperature") Expect.equal actual expected "" ) + testCase "Parameter [Concentration of [nutrient] before start of the experiment]" <| fun _ -> + let headerString = "Parameter [Concentration of [nutrient] before start of the experiment]" + let actual = CompositeHeader.OfHeaderString headerString + let expected = CompositeHeader.Parameter <| OntologyAnnotation.fromString("Concentration of [nutrient] before start of the experiment") + Expect.equal actual expected "" ] testList "IoColumns" [ testCase "Input [Source]" (fun () -> diff --git a/tests/ISA/ISA.Tests/Regex.Tests.fs b/tests/ISA/ISA.Tests/Regex.Tests.fs index 63529ddc..f79a6b6a 100644 --- a/tests/ISA/ISA.Tests/Regex.Tests.fs +++ b/tests/ISA/ISA.Tests/Regex.Tests.fs @@ -127,8 +127,6 @@ let private tests_AnnotationTableColums = Expect.isNone r "Should not match other String" ) ] - - let main = testList "Regex" [