Skip to content

Commit

Permalink
add additional contracts to assay and study remove
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Nov 20, 2023
1 parent 60e3fff commit cb128d1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
30 changes: 24 additions & 6 deletions src/ARCtrl/ARC.fs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,40 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste
and set(fs) = _fs <- fs

member this.RemoveAssay(assayIdentifier: string) =
if this.ISA.IsNone then failwith "Cannot remove assay from null ISA value."
this.ISA.Value.RemoveAssay(assayIdentifier)
let isa =
match this.ISA with
| Some i -> i
| None -> failwith "Cannot remove assay from null ISA value."
let assay = isa.GetAssay(assayIdentifier)
let studies = assay.StudiesRegisteredIn
isa.RemoveAssay(assayIdentifier)
let paths = this.FileSystem.Tree.ToFilePaths()
let assayFolderPath = Path.getAssayFolderPath(assayIdentifier)
let filteredPaths = paths |> Array.filter (fun p -> p.StartsWith(assayFolderPath) |> not)
this.SetFilePaths(filteredPaths)
Contract.createDelete(assayFolderPath)
this.SetFilePaths(filteredPaths)
[
assay.ToDeleteContract()
isa.ToUpdateContract()
for s in studies do
s.ToUpdateContract()
]
|> ResizeArray

member this.RemoveStudy(studyIdentifier: string) =
if this.ISA.IsNone then failwith "Cannot remove study from null ISA value."
let isa =
match this.ISA with
| Some i -> i
| None -> failwith "Cannot remove study from null ISA value."
this.ISA.Value.RemoveStudy(studyIdentifier)
let paths = this.FileSystem.Tree.ToFilePaths()
let studyFolderPath = Path.getStudyFolderPath(studyIdentifier)
let filteredPaths = paths |> Array.filter (fun p -> p.StartsWith(studyFolderPath) |> not)
this.SetFilePaths(filteredPaths)
Contract.createDelete(studyFolderPath)
[
Contract.createDelete(studyFolderPath)
isa.ToUpdateContract()
]
|> ResizeArray

//static member updateISA (isa : ISA.Investigation) (arc : ARC) : ARC =
// raise (System.NotImplementedException())
Expand Down
21 changes: 11 additions & 10 deletions src/ARCtrl/Contracts/Contracts.ArcTypes.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace ARCtrl.Contract

open ARCtrl
open ARCtrl.Path
open ARCtrl.ISA.Spreadsheet
open ARCtrl.ISA
Expand Down Expand Up @@ -42,15 +43,15 @@ module ArcTypeExtensions =
let c = Contract.createUpdate(path, DTOType.ISA_Investigation, DTO.Spreadsheet (this |> ArcInvestigation.toFsWorkbook))
c

member this.ToDeleteContract () =
let path = InvestigationFileName
let c = Contract.createDelete(path)
c
//member this.ToDeleteContract () =
// let path = InvestigationFileName
// let c = Contract.createDelete(path)
// c

static member toDeleteContract () : Contract =
let path = InvestigationFileName
let c = Contract.createDelete(path)
c
//static member toDeleteContract () : Contract =
// let path = InvestigationFileName
// let c = Contract.createDelete(path)
// c

static member toCreateContract (inv: ArcInvestigation) : Contract =
inv.ToCreateContract()
Expand Down Expand Up @@ -80,7 +81,7 @@ module ArcTypeExtensions =
c

member this.ToDeleteContract () =
let path = Identifier.Study.fileNameFromIdentifier this.Identifier
let path = Path.getStudyFolderPath(this.Identifier)
let c = Contract.createDelete(path)
c

Expand Down Expand Up @@ -114,7 +115,7 @@ module ArcTypeExtensions =
c

member this.ToDeleteContract () =
let path = Identifier.Assay.fileNameFromIdentifier this.Identifier
let path = Path.getAssayFolderPath(this.Identifier)
let c = Contract.createDelete(path)
c

Expand Down

0 comments on commit cb128d1

Please sign in to comment.