Skip to content

Commit

Permalink
#29 add orcid terms, add a list of obsolete terms as convenience func…
Browse files Browse the repository at this point in the history
…tions, add and adapt tests
  • Loading branch information
kMutagene committed Aug 17, 2023
1 parent 04f5158 commit 8ecd66b
Show file tree
Hide file tree
Showing 11 changed files with 366 additions and 339 deletions.
20 changes: 18 additions & 2 deletions src/ARCTokenization/Terms.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ module InvestigationMetadata =

let ontology = OboOntology.fromLines true obo

let obsoleteCvTerms =
ontology.Terms
|> List.filter (fun t -> t.IsObsolete)
|> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref = "INVMSO"))

let cvTerms =
ontology.Terms
|> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref = "INVMSO"))
Expand All @@ -32,9 +37,14 @@ module StudyMetadata =

let ontology = OboOntology.fromLines true obo

let obsoleteCvTerms =
ontology.Terms
|> List.filter (fun t -> t.IsObsolete)
|> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref = "STDMSO"))

let cvTerms =
ontology.Terms
|> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref ="STDMSO"))
|> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref = "STDMSO"))

module AssayMetadata =

Expand All @@ -44,7 +54,13 @@ module AssayMetadata =

let cvTerms =
ontology.Terms
|> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref ="ASSMSO"))
|> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref = "ASSMSO"))

let obsoleteCvTerms =
ontology.Terms
|> List.filter (fun t -> t.IsObsolete)
|> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref = "ASSMSO"))


module StructuralTerms =

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ def: ""
relationship: part_of INVMSO:00000021 ! INVESTIGATION CONTACTS
relationship: follows INVMSO:00000031 ! Investigation Person Roles Term Accession Number

[Term]
id: INVMSO:00000093
name: Comment[<Investigation Person ORCID>]
def: ""
synonym: "Comment[Investigation Person ORCID]" EXACT []
is_obsolete: true
relationship: part_of INVMSO:00000021 ! INVESTIGATION CONTACTS

[Term]
id: INVMSO:00000094
name: Comment[Investigation Person ORCID]
def: ""
synonym: "Comment[<Investigation Person ORCID>]" EXACT []
relationship: part_of INVMSO:00000021 ! INVESTIGATION CONTACTS

[Term]
name: STUDY
id: INVMSO:00000033
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ def: ""
relationship: part_of INVMSO:00000021 ! INVESTIGATION CONTACTS
relationship: follows INVMSO:00000031 ! Investigation Person Roles Term Accession Number

[Term]
id: INVMSO:00000093
name: Comment[<Investigation Person ORCID>]
def: ""
synonym: "Comment[Investigation Person ORCID]" EXACT []
is_obsolete: true
relationship: part_of INVMSO:00000021 ! INVESTIGATION CONTACTS

[Term]
id: INVMSO:00000094
name: Comment[Investigation Person ORCID]
def: ""
synonym: "Comment[<Investigation Person ORCID>]" EXACT []
relationship: part_of INVMSO:00000021 ! INVESTIGATION CONTACTS

[Term]
name: STUDY
id: INVMSO:00000033
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ synonym: "STUDY METADATA" EXACT []
relationship: part_of STDMSO:00000001 ! Study Metadata

[Term]
id: STDMSO:00000051
id: STDMSO:00000062
name: STUDY METADATA
def: ""
synonym: "STUDY" EXACT []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def: ""
relationship: part_of STDMSO:00000001 ! Study Metadata

[Term]
id: STDMSO:00000051
id: STDMSO:00000062
name: STUDY METADATA
def: ""
synonym: "STUDY" EXACT []
Expand Down
3 changes: 2 additions & 1 deletion tests/ARCTokenization.Tests/ARCTokenization.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
<None Include="Fixtures\**" CopyToOutputDirectory="Always" />
<Compile Include="TestUtils.fs" />
<Compile Include="TestObjects.fs" />
<Compile Include="StructuralOntologytests.fs" />
<Compile Include="IntegrationTests\InvestigationMetadata.fs" />
<Compile Include="IntegrationTests\StudyMetadata.fs" />
<Compile Include="IntegrationTests\StudyAnnotationTable.fs" />
<Compile Include="IntegrationTests\AssayMetadata.fs" />
<Compile Include="IntegrationTests\AssayAnnotationTable.fs" />
<Compile Include="IntegrationTests\InvestigationMetadata.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

Expand Down
183 changes: 92 additions & 91 deletions tests/ARCTokenization.Tests/IntegrationTests/AssayAnnotationTable.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module IntegrationTests.Assay
namespace IntegrationTests

open ControlledVocabulary
open FsSpreadsheet
Expand All @@ -9,121 +9,122 @@ open Xunit
open TestUtils
open TestObjects

module Correct =
module Assay =
module Correct =

module ``Assay with only source and sample column`` =
module ``Assay with only source and sample column`` =

let assay = Assays.Correct.``assay with only source and sample column``
let assay = Assays.Correct.``assay with only source and sample column``

[<Fact>]
let ``AnnotationTable count`` () =
Assert.Equal(assay.Length, 1)
[<Fact>]
let ``AnnotationTable count`` () =
Assert.Equal(assay.Length, 1)

let table = assay.[0] |> snd
let table = assay.[0] |> snd

[<Fact>]
let ``IOColumns count`` () =
TokenizedAnnotationTable.hasIOColumnAmount 2 table
[<Fact>]
let ``IOColumns count`` () =
TokenizedAnnotationTable.hasIOColumnAmount 2 table

[<Fact>]
let ``TermRelatedBuildingBlocks count`` () =
TokenizedAnnotationTable.hasTermRelatedBuildingBlockAmount 0 table
[<Fact>]
let ``TermRelatedBuildingBlocks count`` () =
TokenizedAnnotationTable.hasTermRelatedBuildingBlockAmount 0 table

let expectedIOColumns =
[
let expectedIOColumns =
[
CvParam(
id = "(n/a)",
name = "Source Name",
ref = "(n/a)",
pv = (ParamValue.Value "Source A"),
attributes = []
)
[
CvParam(
id = "(n/a)",
name = "Source Name",
ref = "(n/a)",
pv = (ParamValue.Value "Source A"),
attributes = []
)
]
[
CvParam(
id = "(n/a)",
name = "Sample Name",
ref = "(n/a)",
pv = (ParamValue.Value "Sample A"),
attributes = []
)
]
]
[
CvParam(
id = "(n/a)",
name = "Sample Name",
ref = "(n/a)",
pv = (ParamValue.Value "Sample A"),
attributes = []
)
]
]

let expectedTermRelatedBuildingBlocks: CvParam list list = []
let expectedTermRelatedBuildingBlocks: CvParam list list = []

[<Fact>]
let ``IOColumns CvParams`` () =
table
|> TokenizedAnnotationTable.IOColumnsEqual expectedIOColumns
[<Fact>]
let ``IOColumns CvParams`` () =
table
|> TokenizedAnnotationTable.IOColumnsEqual expectedIOColumns


[<Fact>]
let ``TermRelatedBuildingBlocks CvParams`` () =
table
|> TokenizedAnnotationTable.termRelatedBuildingBlocksEqual expectedTermRelatedBuildingBlocks
[<Fact>]
let ``TermRelatedBuildingBlocks CvParams`` () =
table
|> TokenizedAnnotationTable.termRelatedBuildingBlocksEqual expectedTermRelatedBuildingBlocks


module ``Assay with single characteristics`` =
module ``Assay with single characteristics`` =

let assay = Assays.Correct.``assay with single characteristics``
let assay = Assays.Correct.``assay with single characteristics``

[<Fact>]
let ``AnnotationTable count`` () =
Assert.Equal(assay.Length, 1)
[<Fact>]
let ``AnnotationTable count`` () =
Assert.Equal(assay.Length, 1)

let table = assay.[0] |> snd
let table = assay.[0] |> snd

[<Fact>]
let ``IOColumns count`` () =
TokenizedAnnotationTable.hasIOColumnAmount 2 table
[<Fact>]
let ``IOColumns count`` () =
TokenizedAnnotationTable.hasIOColumnAmount 2 table

[<Fact>]
let ``TermRelatedBuildingBlocks count`` () =
TokenizedAnnotationTable.hasTermRelatedBuildingBlockAmount 1 table
[<Fact>]
let ``TermRelatedBuildingBlocks count`` () =
TokenizedAnnotationTable.hasTermRelatedBuildingBlockAmount 1 table

let expectedIOColumns =
[
[
CvParam(
id = "(n/a)",
name = "Source Name",
ref = "(n/a)",
pv = (ParamValue.Value "Source A"),
attributes = []
)
]
let expectedIOColumns =
[
CvParam(
id = "(n/a)",
name = "Sample Name",
ref = "(n/a)",
pv = (ParamValue.Value "Sample A"),
attributes = []
)
[
CvParam(
id = "(n/a)",
name = "Source Name",
ref = "(n/a)",
pv = (ParamValue.Value "Source A"),
attributes = []
)
]
[
CvParam(
id = "(n/a)",
name = "Sample Name",
ref = "(n/a)",
pv = (ParamValue.Value "Sample A"),
attributes = []
)
]
]
]

let expectedTermRelatedBuildingBlocks =
[
let expectedTermRelatedBuildingBlocks =
[
CvParam(
id = "Term Accession Number (OBI:0100026)",
name = "Characteristic [organism]",
ref = "Term Source REF (OBI:0100026)",
pv = ParamValue.CvValue (CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCBITaxon_3702", name = "Arabidopsis thaliana", ref = "NCBITaxon")),
attributes = []
)
[
CvParam(
id = "Term Accession Number (OBI:0100026)",
name = "Characteristic [organism]",
ref = "Term Source REF (OBI:0100026)",
pv = (ParamValue.CvValue (CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCBITaxon_3702", name = "Arabidopsis thaliana", ref = "NCBITaxon"))),
attributes = []
)
]
]
]

[<Fact>]
let ``IOColumns CvParams`` () =
table
|> TokenizedAnnotationTable.IOColumnsEqual expectedIOColumns
[<Fact>]
let ``IOColumns CvParams`` () =
table
|> TokenizedAnnotationTable.IOColumnsEqual expectedIOColumns

[<Fact>]
let ``TermRelatedBuildingBlocks CvParams`` () =
table
|> TokenizedAnnotationTable.termRelatedBuildingBlocksEqual expectedTermRelatedBuildingBlocks
[<Fact>]
let ``TermRelatedBuildingBlocks CvParams`` () =
table
|> TokenizedAnnotationTable.termRelatedBuildingBlocksEqual expectedTermRelatedBuildingBlocks
25 changes: 12 additions & 13 deletions tests/ARCTokenization.Tests/IntegrationTests/AssayMetadata.fs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
module IntegrationTests.AssayMetadata
namespace IntegrationTests

open ControlledVocabulary
open FsSpreadsheet
open FsSpreadsheet.ExcelIO
open ARCTokenization
open Xunit
module AssayMetadata =

open TestUtils
open ControlledVocabulary
open FsSpreadsheet
open FsSpreadsheet.ExcelIO
open ARCTokenization
open Xunit

open TestUtils


let allExpectedMetadataTerms =

Terms.AssayMetadata.cvTerms
|> List.skip 1 //(ignore root term)
|> List.map (fun p -> CvParam(p, ParamValue.Value "", []))
let allExpectedMetadataTermsEmpty =
Terms.AssayMetadata.cvTerms
|> List.skip 1 //(ignore root term)
|> List.map (fun p -> CvParam(p, ParamValue.CvValue (CvTerm.create(accession = "AGMO:00000001", name = "Metadata Section Key", ref = "AGMO")), []))
Loading

0 comments on commit 8ecd66b

Please sign in to comment.