Skip to content

Commit 5b3cb85

Browse files
committed
[feature] sr2silo in V-pipe
1 parent 4110c17 commit 5b3cb85

3 files changed

Lines changed: 122 additions & 26 deletions

File tree

workflow/envs/sr2silo.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
channels:
2-
- bioconda
32
- conda-forge
4-
- defaults
3+
- bioconda
54
dependencies:
6-
- sr2silo=0.0.4
5+
- sr2silo=1.0.1

workflow/rules/publish.smk

Lines changed: 69 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -189,41 +189,87 @@ rule checksum:
189189
ruleorder: unfiltered_cram > checksum
190190

191191

192-
rule transform_upload_to_SILO:
192+
rule silo_preprocess:
193193
"""
194194
Handles the wrangleing and upload to SILO.
195195
196196
Takes the primer trimmed nudlitide aligments, wrangles them
197197
into cleartext sequences, transalted to amino acids, aligns them,
198-
then uploads the result to SILO, with all the metadata.
198+
and combine with all the metadata.
199199
"""
200200
input:
201-
nudlitide_alignment="{alignment_wildcard}",
201+
nuc_alignment=alignment_wildcard,
202202
output:
203-
silo_input= "{dataset}/alignments/silo_input.ndjson.zst",
204-
205-
# TO EDIT WIP
203+
silo_input="{dataset}/alignments/silo_input.ndjson.zst",
206204
params:
207-
sample_id = rebase_datadir(config.input["datadir"], wildcards.dataset),
208-
batch_id=lambda wildcards: wildcards.batch_id,
209-
timeline_file=config["TIMELINE_FILE"],
210-
primers_file=config["PRIMERS_FILE"],
211-
nuc_reference=config["NUC_REFERENCE"],
212-
aa_reference=config["NUC_REFERENCE"],
205+
s_rec=get_s_rec,
206+
timeline_file=(
207+
config.tallymut.get("timeline_file", None) or cohortdir("timeline.tsv")
208+
),
209+
primers_file=config["input"]["protocols_file"],
210+
nextclade_reference=config["loculus"]["nextclade_reference"],
211+
SR2SILO=config["applications"]["sr2silo"],
213212
log:
214-
# ???
213+
outlog="{dataset}/alignments/silo_input.out.log",
214+
errlog="{dataset}/alignments/silo_input.out.err",
215215
conda:
216-
"envs/sr2silo.yaml"
216+
config["loculus"]["conda"]
217+
benchmark:
218+
"{dataset}/alignments/silo_input.benchmark"
219+
resources:
220+
disk_mb=65536,
221+
mem_mb=config["loculus"]["mem"],
222+
runtime=config["loculus"]["time"],
223+
threads: config["loculus"]["threads"]
224+
shell:
225+
"""
226+
{params.SR2SILO} process-from-vpipe \
227+
--input-file "{input.nuc_alignment}" \
228+
--sample-id "{params.s_rec.sample_id}" \
229+
--batch-id "{params.s_rec.date}" \
230+
--timeline-file "{params.timeline_file}" \
231+
--primer-file "{params.primers_file}" \
232+
--output-fp "{output.silo_input}" \
233+
--reference "{params.nextclade_reference}" \
234+
> {log.outfile} 2> >(tee {log.errfile} >&2)
235+
"""
236+
217237

238+
if config.loculus["local"]:
239+
240+
localrules:
241+
silo_upload,
242+
243+
244+
rule silo_upload:
245+
input:
246+
silo_input="{dataset}/alignments/silo_input.ndjson.zst",
247+
output:
248+
flag="{dataset}/alignments/silo_input.uploaded",
249+
params:
250+
upload_name=get_s_rec,
251+
keycloak_token_url=config["loculus"]["keycloak_token_url"],
252+
submission_url=config["loculus"]["submission_url"],
253+
SR2SILO=config["applications"]["sr2silo"],
254+
log:
255+
outlog="{dataset}/alignments/silo_upload.out.log",
256+
errlog="{dataset}/alignments/silo_upload.out.err",
257+
conda:
258+
config["loculus"]["conda"]
259+
benchmark:
260+
"{dataset}/alignments/silo_upload.benchmark"
261+
resources:
262+
disk_mb=65536,
263+
mem_mb=config["loculus"]["mem"],
264+
runtime=config["loculus"]["time"],
265+
threads: config["loculus"]["threads"]
218266
shell:
219267
"""
220-
sr2silo import-to-loculus \
221-
--input-file {input.nudlitide_alignment} \
222-
--sample-id {params.sample_id} \
223-
--batch-id {params.batch_id} \
224-
--timeline-file {params.timeline_file} \
225-
--primer-file {params.primers_file} \
226-
--output-fp {output.silo_input} \
227-
--reference {params.nuc_reference} \
228-
--no-upload 2>&1 | tee -a {log}
268+
{params.SR2SILO} submit-to-loculus \
269+
--keycloak-token-url "{params.keycloak_token_url}" \
270+
--submission-url "{params.submission_url}" \
271+
--processed-file "{input.silo_input}" \
272+
--sample-id "{params.s_rec.sample_id}" && \
273+
mkdir -p $(dirname {output.flag}) && \
274+
touch {output.flag}
229275
"""

workflow/schemas/config_schema.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@
440440
"lollipop": {
441441
"type": "string",
442442
"default": "lollipop"
443+
},
444+
"sr2silo": {
445+
"type": "string",
446+
"default": "sr2silo"
443447
}
444448
},
445449
"default": {},
@@ -1933,6 +1937,53 @@
19331937
},
19341938
"default": {},
19351939
"type": "object"
1940+
},
1941+
"loculus": {
1942+
"description": "This section is used to assist and prepare uploads of the data to instances of [Loculus](https://loculus.org/).\n\nNOTE: The upload package for Loculus requires metadata, currently this metadata is fetched from the same timeline.tsv file as used by tallymut, see [`tallymut` => `timeline_file`](#tallymut_timeline_file)",
1943+
"properties": {
1944+
"conda": {
1945+
"type": "string",
1946+
"default": "{VPIPE_BASEDIR}/envs/sr2silo.yaml"
1947+
},
1948+
"mem": {
1949+
"type": "integer",
1950+
"default": 8192
1951+
},
1952+
"time": {
1953+
"type": "integer",
1954+
"default": 120
1955+
},
1956+
"threads": {
1957+
"type": "integer",
1958+
"default": 1
1959+
},
1960+
"nextclade_reference": {
1961+
"type": "string",
1962+
"default": "",
1963+
"description": "Name of the reference. Loculus uses the same names as nextclade datasets.",
1964+
"example": ["sars-cov-2"]
1965+
},
1966+
"local": {
1967+
"type": "boolean",
1968+
"default": true,
1969+
"description": "Don't dispatch the upload rule to the cluster for execution, run the upload locally.\n\nThis is useful for execution on clusters where the compute nodes are isolated from internet.",
1970+
"examples": [false]
1971+
},
1972+
"keycloak_token_url": {
1973+
"type": "string",
1974+
"default": "",
1975+
"description": "Keycloak authentication URL to use during submission",
1976+
"example": ["https://auth.example.com/token"]
1977+
},
1978+
"submission_url": {
1979+
"type": "string",
1980+
"default": "",
1981+
"description": "Loculus submission URL to use during submission",
1982+
"example": ["https://backend.example.com/api"]
1983+
}
1984+
},
1985+
"default": {},
1986+
"type": "object"
19361987
}
19371988
}
19381989
}

0 commit comments

Comments
 (0)