Skip to content

Commit

Permalink
add datamap contract handling
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed May 14, 2024
1 parent b54b5a5 commit db9fbf8
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/ARCtrl/ARC.fs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ type ARC(?isa : ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSystem) =
assay.DataMap <- datamap
assay.Tables <- updatedTables.Tables
)
investigation.Assays |> Seq.iter (fun a -> a.StaticHash <- a.GetHashCode())
investigation.Assays |> Seq.iter (fun a -> a.StaticHash <- a.GetLightHashCode())
investigation.Studies |> Seq.iter (fun s -> s.StaticHash <- s.GetLightHashCode())
investigation.StaticHash <- investigation.GetLightHashCode()
this.ISA <- Some investigation
Expand Down Expand Up @@ -303,7 +303,7 @@ type ARC(?isa : ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSystem) =
)
inv.Assays
|> Seq.iter (fun a ->
a.StaticHash <- a.GetHashCode()
a.StaticHash <- a.GetLightHashCode()
workbooks.Add (
Identifier.Assay.fileNameFromIdentifier a.Identifier,
(DTOType.ISA_Assay, Spreadsheet.ArcAssay.toFsWorkbook a))
Expand Down Expand Up @@ -373,7 +373,7 @@ type ARC(?isa : ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSystem) =

// Get Assay contracts
for a in inv.Assays do
let hash = a.GetHashCode()
let hash = a.GetLightHashCode()
if a.StaticHash = 0 then
yield! a.ToCreateContract(WithFolder = true)
elif a.StaticHash <> hash then
Expand Down
4 changes: 3 additions & 1 deletion src/ARCtrl/ARCtrl.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@
<Package Name="requests" Version="&gt;= 2.28.1 &lt; 3.0.0" ResolutionStrategy="Max" />
</PythonDependencies>
</PropertyGroup>
<ItemGroup />
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="7.0.401" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions src/Contract/ARCtrl.Contract.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<ItemGroup>
<None Include="../../build/logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="7.0.401" />
</ItemGroup>
<PropertyGroup>
<Authors>nfdi4plants, Kevin Frey, Lukas Weil, Kevin Schneider, Oliver Maus</Authors>
<Description>ARC helper functions for contracts management.</Description>
Expand Down
17 changes: 11 additions & 6 deletions src/Contract/Datamap.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ module DatamapContractExtensions =
static member tryFromReadContractForAssay (assayIdentifier : string) (c:Contract) =
let path = Identifier.Assay.datamapFileNameFromIdentifier assayIdentifier
match c with
| {Path = p; Operation = READ; DTOType = Some DTOType.ISA_Datamap; DTO = Some (DTO.Spreadsheet fsworkbook)} when p = path->
fsworkbook :?> FsWorkbook
|> DataMap.fromFsWorkbook
| {Path = p; Operation = READ; DTOType = Some DTOType.ISA_Datamap; DTO = Some (DTO.Spreadsheet fsworkbook)} when p = path ->
let dm =
fsworkbook :?> FsWorkbook
|> DataMap.fromFsWorkbook
dm.StaticHash <- dm.GetHashCode()
dm
|> Some
| _ -> None

Expand Down Expand Up @@ -81,7 +84,9 @@ module DatamapContractExtensions =
let path = Identifier.Study.datamapFileNameFromIdentifier studyIdentifier
match c with
| {Path = p; Operation = READ; DTOType = Some DTOType.ISA_Datamap; DTO = Some (DTO.Spreadsheet fsworkbook)} when p = path->
fsworkbook :?> FsWorkbook
|> DataMap.fromFsWorkbook
|> Some
let dm =
fsworkbook :?> FsWorkbook
|> DataMap.fromFsWorkbook
dm.StaticHash <- dm.GetHashCode()
Some (dm)
| _ -> None
14 changes: 14 additions & 0 deletions src/Core/ArcTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,20 @@ type ArcAssay(identifier: string, ?measurementType : OntologyAnnotation, ?techno
this.StructurallyEquals(assay)
| _ -> false

// Hashcode without Datamap
member this.GetLightHashCode() =
[|
box this.Identifier
HashCodes.boxHashOption this.MeasurementType
HashCodes.boxHashOption this.TechnologyType
HashCodes.boxHashOption this.TechnologyPlatform
HashCodes.boxHashSeq this.Tables
HashCodes.boxHashSeq this.Performers
HashCodes.boxHashSeq this.Comments
|]
|> HashCodes.boxHashArray
|> fun x -> x :?> int

override this.GetHashCode() =
[|
box this.Identifier
Expand Down
3 changes: 3 additions & 0 deletions src/Json/ARCtrl.Json.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
<Content Include="*.fsproj; **\*.fs; **\*.fsi" PackagePath="fable\" />
<None Include="../../build/logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="7.0.401" />
</ItemGroup>
<PropertyGroup>
<Authors>nfdi4plants, Lukas Weil, Florian Wetzels, Kevin Frey</Authors>
<Description>ARC and ISA json compliant parser for experimental metadata toolkit in F#. This project is meant as an easy means to open, manipulate and save ISA (Investigation,Study,Assay) metadata files in isa-json format.</Description>
Expand Down
5 changes: 4 additions & 1 deletion src/Spreadsheet/ARCtrl.Spreadsheet.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Compile Include="Template.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FsSpreadsheet" Version="5.1.3" />
<PackageReference Include="FsSpreadsheet" Version="6.1.2" />
</ItemGroup>
<ItemGroup>
<None Include="../../build/logo.png" Pack="true" PackagePath="\" />
Expand All @@ -45,6 +45,9 @@
<ProjectReference Include="..\Core\ARCtrl.Core.fsproj" />
<ProjectReference Include="..\FileSystem\ARCtrl.FileSystem.fsproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="7.0.401" />
</ItemGroup>
<PropertyGroup>
<Authors>nfdi4plants, Lukas Weil</Authors>
<Description>ARC and ISA xlsx compliant parser for experimental metadata toolkit in F#. This project is meant as an easy means to open, manipulate and save ISA (Investigation,Study,Assay) metadata files in isa-xlsx format.</Description>
Expand Down
1 change: 1 addition & 0 deletions src/Spreadsheet/Metadata/Assays.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Assays =
(Option.fromValueWithDefault (OntologyAnnotation()) technologyType)
(technologyPlatform |> Option.map JsonTypes.decomposeTechnologyPlatform)
(ResizeArray())
None
(ResizeArray())
(comments)

Expand Down
1 change: 1 addition & 0 deletions src/Spreadsheet/Metadata/Study.fs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ module Studies =
(ResizeArray contacts)
(ResizeArray designDescriptors)
(ResizeArray())
None
(ResizeArray(assayIdentifiers))
(ResizeArray studyInfo.Comments)
|> fun arcstudy ->
Expand Down

0 comments on commit db9fbf8

Please sign in to comment.