Skip to content

Commit

Permalink
Simplify (#27)
Browse files Browse the repository at this point in the history
* 🎨 Use script

Signed-off-by: zethson <[email protected]>

* ✨ Simplify language

Signed-off-by: zethson <[email protected]>

* 🎨 Refactor

Signed-off-by: zethson <[email protected]>

* 🎨 Wording

Signed-off-by: zethson <[email protected]>

* 🎨 Simplify

Signed-off-by: zethson <[email protected]>

---------

Signed-off-by: zethson <[email protected]>
  • Loading branch information
Zethson authored Apr 22, 2024
1 parent c445311 commit 82dcc53
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 52 deletions.
54 changes: 2 additions & 52 deletions docs/mcmicro_02.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"id": "e16d2a67",
"metadata": {},
"source": [
"Now we register our Nextflow run by specifying the pipeline name, its version and its associated reference."
"Now we register our Nextflow run by running our [registration script](https://github.com/laminlabs/nextflow-lamin-usecases/blob/main/docs/register_mcmicro_run.py)."
]
},
{
Expand All @@ -107,57 +107,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python register_nf_run.py -p mcmicro -v 1.0.0 -r https://github.com/labsyspharm/mcmicro"
]
},
{
"cell_type": "markdown",
"id": "863bbe66",
"metadata": {},
"source": [
":::{dropdown} How to amend a `register_nf_run.py` to register input & output files in LaminDB?\n",
"\n",
"First we created a Transform for the run:\n",
"\n",
"```python\n",
"parser = argparse.ArgumentParser()\n",
"parser.add_argument(\"-p\", \"--pipeline-name\", required=True)\n",
"parser.add_argument(\"-v\", \"--pipeline-version\", required=True)\n",
"parser.add_argument(\"-r\", \"--pipeline-reference\", required=True)\n",
"args = parser.parse_args()\n",
"\n",
"transform = ln.Transform(\n",
" name=args.pipeline_name,\n",
" version=args.pipeline_version,\n",
" type=\"pipeline\",\n",
" reference=args.pipeline_reference,\n",
")\n",
"ln.track(transform=transform)\n",
"run = ln.dev.run_context.run\n",
"```\n",
"\n",
"To query input files via LaminDB, we added the following lines:\n",
"\n",
"```python\n",
"mcmicro_input = ln.Artifact.filter(key__startswith=\"exemplar-001\")\n",
"input_paths = [input_fastq.stage() for input_fastq in mcmicro_input]\n",
"```\n",
"\n",
"To register the output file and nextflow ID with LaminDB, we added the following line to the last task:\n",
"\n",
"```python\n",
"output = ln.Artifact(\n",
" \"exemplar-001/registration/exemplar-001.ome.tif\", description=\"mcmicro\"\n",
")\n",
"output.save()\n",
"\n",
"nextflow_id = getoutput(f\"nextflow log | awk '/{run.id}/{{print $8}}'\")\n",
"run.reference = nextflow_id\n",
"run.reference_type = \"nextflow_id\"\n",
"run.save()\n",
"```\n",
"\n",
":::\n"
"!python register_mcmicro_run.py"
]
},
{
Expand Down
25 changes: 25 additions & 0 deletions docs/register_mcmicro_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from subprocess import getoutput

import lamindb as ln

transform = ln.Transform(
name="mcmicro",
version="1.0.0",
type="pipeline",
reference="https://github.com/labsyspharm/mcmicro",
)
ln.track(transform=transform)
run = ln.dev.run_context.run

mcmicro_input = ln.Artifact.filter(key__startswith="exemplar-001")
input_paths = [input_fastq.stage() for input_fastq in mcmicro_input]

output = ln.Artifact(
"exemplar-001/registration/exemplar-001.ome.tif", description="mcmicro"
)
output.save()

nextflow_id = getoutput(f"nextflow log | awk '/{run.id}/{{print $8}}'")
run.reference = nextflow_id
run.reference_type = "nextflow_id"
run.save()

0 comments on commit 82dcc53

Please sign in to comment.