@@ -196,10 +196,9 @@ module AnnotationTable =
196196 /// Updates the sample information in the given processes with the information of the samples in the given referenceProcesses.
197197 ///
198198 /// If the processes contain a source with the same name as a sample in the referenceProcesses. Additionally transforms it to a sample
199- let updateSamplesByReference ( referenceProcesses : Process seq ) ( processes : Process seq ) =
199+ let private updateSamplesBy ( referenceProcesses : Process seq ) ( processes : Process seq ) =
200200 let samples =
201201 referenceProcesses
202- |> Seq.append processes
203202 |> Seq.collect ( fun p ->
204203 printfn " %O " p.Name
205204 let inputs =
@@ -213,14 +212,16 @@ module AnnotationTable =
213212 Seq.append inputs outputs
214213 |> Seq.distinct
215214 )
216- |> Seq.filter ( fun ( name , _ , s ) -> name <> None && name <> ( Some " " ))
217- |> Seq.groupBy ( fun ( name , _ , s ) -> name)
218- |> Seq.map ( fun ( name , s ) ->
219- let x = s |> Seq.map ( fun ( name , _ , s ) -> s) |> Seq.reduce API.Update.UpdateByExisting.updateRecordType
220- if Seq.exists ( fun ( name , isSample , s ) -> isSample) s then
221- name, ProcessInput.Sample x
222- else name, ProcessInput.Source ( sourceOfSample x)
223-
215+ |> Seq.filter ( fun ( name , _ , samples ) -> name <> None && name <> ( Some " " ))
216+ |> Seq.groupBy ( fun ( name , _ , samples ) -> name)
217+ |> Seq.map ( fun ( name , samples ) ->
218+ let aggregatedSample =
219+ samples
220+ |> Seq.map ( fun ( name , _ , s ) -> s)
221+ |> Seq.reduce ( fun s1 s2 -> if s1 = s2 then s1 else API.Update.UpdateByExistingAppendLists.updateRecordType s1 s2)
222+ if Seq.exists ( fun ( name , isSample , s ) -> isSample) samples then
223+ name, ProcessInput.Sample aggregatedSample
224+ else name, ProcessInput.Source ( sourceOfSample aggregatedSample)
224225 )
225226 |> Map.ofSeq
226227
@@ -242,4 +243,18 @@ module AnnotationTable =
242243 Outputs = p.Outputs |> Option.map ( List.map updateOutput)
243244 }
244245 )
245-
246+
247+ /// Updates the sample information in the given processes with the information of the samples in the given referenceProcesses.
248+ ///
249+ /// If the processes contain a source with the same name as a sample in the referenceProcesses. Additionally transforms it to a sample
250+ let updateSamplesByReference ( referenceProcesses : Process seq ) ( processes : Process seq ) =
251+ referenceProcesses
252+ |> Seq.append processes
253+ |> updateSamplesBy processes
254+
255+ /// Updates the sample information in the given processes with the information of the samples in the given referenceProcesses.
256+ ///
257+ /// If the processes contain a source with the same name as a sample in the referenceProcesses. Additionally transforms it to a sample
258+ let updateSamplesByThemselves ( processes : Process seq ) =
259+ processes
260+ |> updateSamplesBy processes
0 commit comments