Skip to content

Commit

Permalink
implement first POC of ISA ROCrate profile
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Sep 4, 2024
1 parent f71faea commit ef15f35
Show file tree
Hide file tree
Showing 16 changed files with 854 additions and 139 deletions.
17 changes: 15 additions & 2 deletions src/ROCrate/ARCtrl.ROCrate.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Content Include="*.fsproj; **\*.fs; **\*.fsi" PackagePath="fable\" />
<Compile Include="IROCrateObject.fs" />
<Compile Include="ISAProfile\Dataset.fs" />
<Compile Include="ISAProfile\Investigation.fs" />
<Compile Include="ISAProfile\Study.fs" />
<Compile Include="ISAProfile\Assay.fs" />
<Compile Include="ISAProfile\LabProcess.fs" />
<Compile Include="ISAProfile\LabProtocol.fs" />
<Compile Include="ISAProfile\Sample.fs" />
<Compile Include="ISAProfile\Data.fs" />
<Compile Include="ISAProfile\PropertyValue.fs" />
<Compile Include="ISAProfile\Person.fs" />
<Compile Include="ISAProfile\ScholarlyArticle.fs" />
<Compile Include="ROCrateObject.fs" />
<None Include="playground.fsx" />
<None Include="../../build/logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Library.fs" />
<PackageReference Include="DynamicObj" Version="3.0.0" />
</ItemGroup>
<PropertyGroup>
<Authors>Kevin Schneider, nfdi4plants, DataPLANT OSS contributors</Authors>
Expand Down
7 changes: 7 additions & 0 deletions src/ROCrate/IROCrateObject.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ARCtrl.ROCrate

/// Base interface implemented by all explicitly known objects in our ROCrate profiles.
type IROCrateObject =
abstract member SchemaType : string
abstract member Id: string
abstract member AdditionalType: string option
46 changes: 46 additions & 0 deletions src/ROCrate/ISAProfile/Assay.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace ARCtrl.ROCrate

open DynamicObj
open Fable.Core

///
[<AttachMembers>]
type Assay(id: string) =
// inheritance
inherit Dataset(id, "Assay")
static member create(
// mandatory
id,
// Properties from Thing
identifier,
// optional
// Properties from CreativeWork
// Properties from Dataset
?measurementMethod,
?measurementTechnique,
?variableMeasured,
// Properties from CreativeWork
?about,
?comment,
?creator,
?hasPart,
?url
) =
let ds = Assay(id = id)

// Properties from Dataset
DynObj.setValueOpt ds (nameof measurementMethod) measurementMethod
DynObj.setValueOpt ds (nameof measurementTechnique) measurementTechnique
DynObj.setValueOpt ds (nameof variableMeasured) variableMeasured

// Properties from CreativeWork
DynObj.setValueOpt ds (nameof about) about
DynObj.setValueOpt ds (nameof comment) comment
DynObj.setValueOpt ds (nameof creator) creator
DynObj.setValueOpt ds (nameof hasPart) hasPart
DynObj.setValueOpt ds (nameof url) url

// Properties from Thing
DynObj.setValue ds (nameof identifier) identifier

ds
47 changes: 47 additions & 0 deletions src/ROCrate/ISAProfile/Data.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace ARCtrl.ROCrate

open DynamicObj
open Fable.Core

///
[<AttachMembers>]
type Data(id: string, ?additionalType: string) =
inherit DynamicObj()

let mutable _schemaType = "schema.org/MediaObject"
let mutable _additionalType = additionalType

member this.Id
with get() = id

member this.SchemaType
with get() = _schemaType
and set(value) = _schemaType <- value

member this.AdditionalType
with get() = _additionalType
and set(value) = _additionalType <- value

//interface implementations
interface IROCrateObject with
member this.Id with get () = this.Id
member this.SchemaType with get (): string = this.SchemaType
member this.AdditionalType with get (): string option = this.AdditionalType

static member create(
// mandatory
id,
name,
?comment,
?encodingFormat,
?disambiguatingDescription
) =
let d = Data(id)

DynObj.setValue d (nameof name) name

DynObj.setValueOpt d (nameof comment) comment
DynObj.setValueOpt d (nameof encodingFormat) encodingFormat
DynObj.setValueOpt d (nameof disambiguatingDescription) disambiguatingDescription

d
29 changes: 29 additions & 0 deletions src/ROCrate/ISAProfile/Dataset.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace ARCtrl.ROCrate

open DynamicObj
open Fable.Core

///
[<AttachMembers>]
type Dataset (id: string, ?additionalType: string) =
inherit DynamicObj()

let mutable _schemaType = "schema.org/Dataset"
let mutable _additionalType = additionalType

member this.Id
with get() = id

member this.SchemaType
with get() = _schemaType
and set(value) = _schemaType <- value

member this.AdditionalType
with get() = _additionalType
and set(value) = _additionalType <- value

//interface implementations
interface IROCrateObject with
member this.Id with get () = this.Id
member this.SchemaType with get (): string = this.SchemaType
member this.AdditionalType with get (): string option = this.AdditionalType
49 changes: 49 additions & 0 deletions src/ROCrate/ISAProfile/Investigation.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace ARCtrl.ROCrate

open DynamicObj
open Fable.Core

///
[<AttachMembers>]
type Investigation(id: string) =

inherit Dataset(id, "Investigation")

static member create(
id,
// Properties from Thing
identifier,
// optional
// Properties from CreativeWork
?citation,
?comment,
?creator,
?dateCreated,
?dateModified,
?datePublished,
?hasPart,
?headline,
?mentions,
?url,
// Properties from Thing
?description
) =
let ds = Investigation(id = id)

// Properties from CreativeWork
DynObj.setValueOpt ds (nameof citation) citation
DynObj.setValueOpt ds (nameof comment) comment
DynObj.setValueOpt ds (nameof creator) creator
DynObj.setValueOpt ds (nameof dateCreated) dateCreated
DynObj.setValueOpt ds (nameof dateModified) dateModified
DynObj.setValueOpt ds (nameof datePublished) datePublished
DynObj.setValueOpt ds (nameof hasPart) hasPart
DynObj.setValueOpt ds (nameof headline) headline
DynObj.setValueOpt ds (nameof mentions) mentions
DynObj.setValueOpt ds (nameof url) url

// Properties from Thing
DynObj.setValueOpt ds (nameof description) description
DynObj.setValue ds (nameof identifier) identifier

ds
58 changes: 58 additions & 0 deletions src/ROCrate/ISAProfile/LabProcess.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace ARCtrl.ROCrate

open DynamicObj
open Fable.Core

///
[<AttachMembers>]
type LabProcess(id: string, ?additionalType: string) =
inherit DynamicObj()

let mutable _schemaType = "bioschemas.org/LabProcess"
let mutable _additionalType = additionalType

member this.Id
with get() = id

member this.SchemaType
with get() = _schemaType
and set(value) = _schemaType <- value

member this.AdditionalType
with get() = _additionalType
and set(value) = _additionalType <- value

//interface implementations
interface IROCrateObject with
member this.Id with get () = this.Id
member this.SchemaType with get (): string = this.SchemaType
member this.AdditionalType with get (): string option = this.AdditionalType

static member create(
// mandatory
id,
name,
agent,
object,
result,
// optional
?additionalType,
?executesLabProtocol,
?parameterValue,
?endTime,
?disambiguatingDescription
) =
let lp = LabProcess(id)

DynObj.setValue lp (nameof name) name
DynObj.setValue lp (nameof agent) agent
DynObj.setValue lp (nameof object) object
DynObj.setValue lp (nameof result) result

DynObj.setValueOpt lp (nameof additionalType) additionalType
DynObj.setValueOpt lp (nameof executesLabProtocol) executesLabProtocol
DynObj.setValueOpt lp (nameof parameterValue) parameterValue
DynObj.setValueOpt lp (nameof endTime) endTime
DynObj.setValueOpt lp (nameof disambiguatingDescription) disambiguatingDescription

lp
56 changes: 56 additions & 0 deletions src/ROCrate/ISAProfile/LabProtocol.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
namespace ARCtrl.ROCrate

open DynamicObj
open Fable.Core

///
[<AttachMembers>]
type LabProtocol(id: string, ?additionalType: string) =
inherit DynamicObj()

let mutable _schemaType = "bioschemas.org/LabProtocol"
let mutable _additionalType = additionalType

member this.Id
with get() = id

member this.SchemaType
with get() = _schemaType
and set(value) = _schemaType <- value

member this.AdditionalType
with get() = _additionalType
and set(value) = _additionalType <- value

//interface implementations
interface IROCrateObject with
member this.Id with get () = this.Id
member this.SchemaType with get (): string = this.SchemaType
member this.AdditionalType with get (): string option = this.AdditionalType

static member create(
// mandatory
id,
?name,
?intendedUse,
?description,
?url,
?comment,
?version,
?labEquipment,
?reagent,
?computationalTool
) =
let lp = LabProcess(id)

DynObj.setValueOpt lp (nameof name) name
DynObj.setValueOpt lp (nameof intendedUse) intendedUse
DynObj.setValueOpt lp (nameof description) description
DynObj.setValueOpt lp (nameof url) url
DynObj.setValueOpt lp (nameof comment) comment
DynObj.setValueOpt lp (nameof version) version
DynObj.setValueOpt lp (nameof labEquipment) labEquipment
DynObj.setValueOpt lp (nameof reagent) reagent
DynObj.setValueOpt lp (nameof computationalTool) computationalTool

lp
61 changes: 61 additions & 0 deletions src/ROCrate/ISAProfile/Person.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
namespace ARCtrl.ROCrate

open DynamicObj
open Fable.Core

///
[<AttachMembers>]
type Person(id: string, ?additionalType: string) =
inherit DynamicObj()

let mutable _schemaType = "schema.org/Person"
let mutable _additionalType = additionalType

member this.Id
with get() = id

member this.SchemaType
with get() = _schemaType
and set(value) = _schemaType <- value

member this.AdditionalType
with get() = _additionalType
and set(value) = _additionalType <- value

//interface implementations
interface IROCrateObject with
member this.Id with get () = this.Id
member this.SchemaType with get (): string = this.SchemaType
member this.AdditionalType with get (): string option = this.AdditionalType

static member create(
// mandatory
id,
givenName,
?familyName,
?email,
?identifier,
?affiliation,
?jobTitle,
?additionalName,
?address,
?telephone,
?faxNumber,
?disambiguatingDescription
) =
let p = Person(id)

DynObj.setValue p (nameof givenName) givenName

DynObj.setValueOpt p (nameof familyName) familyName
DynObj.setValueOpt p (nameof email) email
DynObj.setValueOpt p (nameof identifier) identifier
DynObj.setValueOpt p (nameof affiliation) affiliation
DynObj.setValueOpt p (nameof jobTitle) jobTitle
DynObj.setValueOpt p (nameof additionalName) additionalName
DynObj.setValueOpt p (nameof address) address
DynObj.setValueOpt p (nameof telephone) telephone
DynObj.setValueOpt p (nameof faxNumber) faxNumber
DynObj.setValueOpt p (nameof disambiguatingDescription) disambiguatingDescription

p
Loading

0 comments on commit ef15f35

Please sign in to comment.