Skip to content

Commit

Permalink
Add tests for parseKeyWithTerms
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Aug 17, 2023
1 parent ccb95fd commit 1254645
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 370 deletions.
30 changes: 13 additions & 17 deletions src/ARCTokenization/MetadataSheet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ open ControlledVocabulary
open FSharpAux
open FsSpreadsheet
open ARCTokenization.Terms
open Regex.ActivePatterns

module MetadataSheet =

Expand All @@ -17,29 +18,24 @@ module MetadataSheet =
// we need to have separate functions here because matching is done based on term name, of which some are contained in multiple structural ontologies
// (e.g. the study metadata section is a copy of the resepctive section in an investigation file)

let rec parseAssayKey (attributes : IParam list) (key : string) : ParamValue -> IParam =
match key with
let rec parseKeyWithTerms (terms: CvTerm list) (attributes : IParam list) (key : string) : ParamValue -> IParam =

| Term AssayMetadata.cvTerms term ->
fun (pv) -> CvParam(term,pv,attributes)
match key with

| UnMatchable name ->
fun (pv) -> UserParam(name,pv,attributes) // UserParam(name,pv,Attributes)
| Term terms term ->
fun (pv) -> CvParam(term, pv, attributes)

let rec parseStudyKey (attributes : IParam list) (key : string) : ParamValue -> IParam =
match key with
| Comment _ ->
fun pv -> CvParam(Terms.StructuralTerms.userComment, pv, attributes)

| Term StudyMetadata.cvTerms term ->
fun (pv) -> CvParam(term,pv,attributes)
| key when key.StartsWith("#") ->
fun pv -> CvParam(Terms.StructuralTerms.ignoreLine, pv, attributes)

| UnMatchable name ->
fun (pv) -> UserParam(name,pv,attributes) // UserParam(name,pv,Attributes)
fun (pv) -> UserParam(name, pv, attributes)

let rec parseInvestigationKey (attributes : IParam list) (key : string) : ParamValue -> IParam =
match key with
let rec parseAssayKey = parseKeyWithTerms AssayMetadata.cvTerms

| Term InvestigationMetadata.cvTerms term ->
fun (pv) -> CvParam(term,pv,attributes)
let rec parseStudyKey = parseKeyWithTerms StudyMetadata.cvTerms

| UnMatchable name ->
fun (pv) -> UserParam(name,pv,attributes) // UserParam(name,pv,Attributes)
let rec parseInvestigationKey = parseKeyWithTerms InvestigationMetadata.cvTerms
Loading

0 comments on commit 1254645

Please sign in to comment.