@@ -11,13 +11,16 @@ pframes := import("@platforma-sdk/workflow-tengo:pframes")
1111
1212reconstructShmTreesTpl := assets.importTemplate(":reconstruct-shm-trees")
1313
14+ // this templete should run only after resolving of all inputs
1415self.awaitState("datasets", { wildcard: "*" }, "ResourceReady")
1516self.awaitState("donorColumn", "ResourceReady")
1617
1718self.body(func(inputs) {
19+ // overall description of data that we have.
1820 dataDescription := {
1921 "hasUmiTags": false,
2022 "hasCellTags": false,
23+ // will be filled
2124 "coveredFeatures": []
2225 }
2326
@@ -32,23 +35,30 @@ self.body(func(inputs) {
3235 dataDescription["hasUmiTags"] = true
3336 }
3437 dataDescription["coveredFeatures"] = text.re_split(',', presetAnnotations["mixcr.com/coveredFeaturesOnExport"])
38+ // check that assemblingFeature feature is the same. If so, coveredFeatures will be the same too
3539 if (assemblingFeature == "") {
3640 assemblingFeature = dataDescription["mixcr.com/assemblingFeature"]
3741 } else if (assemblingFeature != dataDescription["mixcr.com/assemblingFeature"]) {
3842 ll.panic("Assmble features should be the same for process tress. Got " + assemblingFeature + " and " + dataDescription["mixcr.com/assemblingFeature"])
3943 }
4044 }
4145
46+ // there should be call join on pfFrames, but it's not implements, so we will do it by hand
4247 dataGroupedByDonorId := prepareDonorColumn.groupDataByDonorId(inputs.donorColumn, inputs.datasets)
4348
49+ // collect params for running export commands and to parse result tsv files into pColumns
4450 shmTreeTableOptions := exportSettings.shmTreeTableOptions(dataDescription, false)
4551 shmTreeNodesTableOptions := exportSettings.shmTreeNodesTableOptions(dataDescription, false)
4652 shmTreeNodesWithClonesTableOptions := exportSettings.shmTreeNodesWithClonesTableOptions(dataDescription, inputs.donorColumn, false)
4753
54+ // TODO that call is too low level. Should be replaced with something that works with pColumns, not data only
4855 mixcrResults := llPFrames.aggregate(
56+ // files to iterate through
4957 dataGroupedByDonorId["data"],
58+ // columns not to combine - sampleId and mixcrBlockId
5059 [1, 2],
5160 reconstructShmTreesTpl,
61+ // all the outputs that should be gethered
5262 [
5363 {
5464 "name": "trees",
@@ -74,43 +84,46 @@ self.body(func(inputs) {
7484 }
7585 ],
7686 false,
87+ // inputs
7788 {
7889 "shmTreeTableOptions": shmTreeTableOptions["cmdArgs"],
7990 "shmTreeNodesTableOptions": shmTreeNodesTableOptions["cmdArgs"],
8091 "shmTreeNodesWithClonesTableOptions": shmTreeNodesWithClonesTableOptions["cmdArgs"]
8192 }
8293 )
8394
95+ // donorId axis is inherited from dataGroupedByDonorId and we should specify it explicitly (other axes will be supplied by pfconvParams)
96+ additionalArgsForImportTsv := {
97+ additionalAxesSpec: dataGroupedByDonorId["spec"]["axesSpec"][:1]
98+ }
99+
84100 trees := xsv.importFileMap(
85101 mixcrResults.output("trees"),
86102 "tsv",
87103 shmTreeTableOptions["pfconvParams"],
88- {
89- additionalAxesSpec: dataGroupedByDonorId["spec"]["axesSpec"][:1]
90- }
104+ additionalArgsForImportTsv
91105 )
92106
93107 treeNodes := xsv.importFileMap(
94108 mixcrResults.output("treeNodes"),
95109 "tsv",
96110 shmTreeNodesTableOptions["pfconvParams"],
97- {
98- additionalAxesSpec: dataGroupedByDonorId["spec"]["axesSpec"][:1]
99- }
111+ additionalArgsForImportTsv
100112 )
101113
102114 treeNodesWithClones := xsv.importFileMap(
103115 mixcrResults.output("treeNodesWithClones"),
104116 "tsv",
105117 shmTreeNodesWithClonesTableOptions["pfconvParams"],
106- {
107- additionalAxesSpec: dataGroupedByDonorId["spec"]["axesSpec"][:1]
108- }
118+ additionalArgsForImportTsv
109119 )
110120
111121 return {
122+ // combine columns into pFrame
112123 "trees": pframes.exportFrame(trees),
124+ // combine columns into pFrame
113125 "treeNodes": pframes.exportFrame(treeNodes),
126+ // combine columns into pFrame
114127 "treeNodesWithClones": pframes.exportFrame(treeNodesWithClones),
115128
116129 "allelesLogs": mixcrResults.output("allelesLog"),
0 commit comments