diff --git a/docs/examples.md b/docs/examples.md index 045d2ae..4d7dca8 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -8,4 +8,5 @@ Generated documentation for real-world Nextflow pipelines. | rnaseq-nf | Simple RNA-seq pipeline | [HTML](examples/rnaseq-nf/index.html) | [Markdown](examples/rnaseq-nf/markdown/index.md) | [Table](examples/rnaseq-nf/table/README.md) | [JSON](examples/rnaseq-nf/json/pipeline-api.json) | [YAML](examples/rnaseq-nf/yaml/pipeline-api.yaml) | | rnavar | nf-core/rnavar — RNA variant calling | [HTML](examples/rnavar/index.html) | [Markdown](examples/rnavar/markdown/index.md) | [Table](examples/rnavar/table/README.md) | [JSON](examples/rnavar/json/pipeline-api.json) | [YAML](examples/rnavar/yaml/pipeline-api.yaml) | | sarek | nf-core/sarek — variant calling & annotation | [HTML](examples/sarek/index.html) | [Markdown](examples/sarek/markdown/index.md) | [Table](examples/sarek/table/README.md) | [JSON](examples/sarek/json/pipeline-api.json) | [YAML](examples/sarek/yaml/pipeline-api.yaml) | +| nf-fgsv | Fulcrum Genomics structural variant calling | [HTML](examples/nf-fgsv/index.html) | [Markdown](examples/nf-fgsv/markdown/index.md) | [Table](examples/nf-fgsv/table/README.md) | [JSON](examples/nf-fgsv/json/pipeline-api.json) | [YAML](examples/nf-fgsv/yaml/pipeline-api.yaml) | | wf-metagenomics | Oxford Nanopore metagenomics workflow | [HTML](examples/wf-metagenomics/index.html) | [Markdown](examples/wf-metagenomics/markdown/index.md) | [Table](examples/wf-metagenomics/table/README.md) | [JSON](examples/wf-metagenomics/json/pipeline-api.json) | [YAML](examples/wf-metagenomics/yaml/pipeline-api.yaml) | diff --git a/docs/examples/nf-fgsv/index.html b/docs/examples/nf-fgsv/index.html new file mode 100644 index 0000000..0b8b4e3 --- /dev/null +++ b/docs/examples/nf-fgsv/index.html @@ -0,0 +1,3218 @@ + + +
+ Showing results for "" +
Enter a search term
Find parameters, processes, workflows, and more
No results found
Try a different search term
Nextflow workflow for running fgsv.
This repository is primarily for testing the latest Nextflow features and the workflow is relatively simple.
This is a Nextflow workflow for running fgsv on a BAM file to gather evidence for structural variation via breakpoint detection.
Make sure Pixi and Docker are installed.
The environment for this analysis is in pixi.toml and is named nf-fgsv.
nf-fgsv
To install:
pixi install +
To save on typing, a pixi task is available which aliases nextflow run main.nf.
nextflow run main.nf
pixi run \ + nf-workflow \ + -profile "local,docker" \ + --input tests/data/basic_input.tsv +
Several default profiles are available:
local
docker
linux
--user root
runOptions
A full description of input parameters is available using the workflow --help parameter, pixi run nf-workflow --help.
--help
pixi run nf-workflow --help
The required columns in the --input samplesheet are:
--input
sample
bam
If using more than a few parameters, consider saving them in a YAML format file (e.g. tests/integration/params.yml).
pixi run \ + nf-workflow \ + -profile "local,docker" \ + -params-file my_params.yml +
The output directory can be specified using the -output-dir Nextflow parameter. +The default output directory is results/. +-output-dir cannot be specified in a params.yml file, because it is a Nextflow parameter rather than a workflow parameter. +It must be specified on the command line or in a nextflow.config file.
-output-dir
results/
params.yml
nextflow.config
pixi run \ + nf-workflow \ + -profile "local,docker" \ + --input tests/data/basic_input.tsv \ + -output-dir results +
results +└── {sample_name} + ├── {sample_name}_sorted.bam # Coordinate-sorted BAM file + ├── {sample_name}_svpileup.txt # SvPileup breakpoint candidates + ├── {sample_name}_svpileup.bam # BAM with SV tags from SvPileup + ├── {sample_name}_svpileup.aggregate.txt # Aggregated/merged breakpoint pileups + └── {sample_name}_svpileup.aggregate.bedpe # Aggregated pileups in BEDPE format +
*_sorted.bam
*_svpileup.txt
*_svpileup.bam
*_svpileup.aggregate.txt
*_svpileup.aggregate.bedpe
See our Contributing Guide for development and testing guidelines.
+ This page documents all input parameters for the pipeline. +
.*.tsv$
Path to tab-separated file containing information about the samples in the experiment.
This page documents all workflows in the pipeline.
main.nf:19
This page documents all processes in the pipeline.
modules/aggregate_sv_pileup.nf:12
Aggregate and merge pileups that are likely to support the same breakpoint +using fgsv AggregateSvPileup.
val(meta), path(bam), path(txt)
tuple
meta: Map containing sample information (must include 'id'); bam: Input BAM file; txt: SvPileup breakpoint output file
meta
txt
val(meta), file("*_svpileup.aggregate.txt")
Tuple of meta and aggregated SvPileup output file
modules/aggregate_sv_pileup_to_bedpe.nf:11
Convert aggregated SvPileup output to BEDPE format using fgsv +AggregateSvPileupToBedPE.
val(meta), path(txt)
meta: Map containing sample information (must include 'id'); txt: Aggregated SvPileup output file
val(meta), file("*_svpileup.aggregate.bedpe")
bedpe
Tuple of meta and BEDPE format output file
modules/coordinate_sort.nf:10
Sort a BAM file by genomic coordinates using samtools sort.
val(meta), path(bam)
meta: Map containing sample information (must include 'id'); bam: Input BAM file to be sorted
val(meta), file("*_sorted.bam")
Tuple of meta and coordinate-sorted BAM file
modules/sv_pileup.nf:11
Detect structural variant evidence from a BAM file using fgsv SvPileup.
meta: Map containing sample information (must include 'id'); bam: Input BAM file
val(meta), file("*_svpileup.txt")
Tuple of meta and SvPileup breakpoint output file
val(meta), file("*_svpileup.bam")
Tuple of meta and SvPileup BAM file
{{ inp.pattern }}
:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-primary{border-color:var(--color-primary)}.border-slate-200{border-color:var(--color-slate-200)}.border-slate-300{border-color:var(--color-slate-300)}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-green-100{background-color:var(--color-green-100)}.bg-primary{background-color:var(--color-primary)}.bg-primary-light{background-color:var(--color-primary-light)}.bg-purple-100{background-color:var(--color-purple-100)}.bg-red-100{background-color:var(--color-red-100)}.bg-slate-50{background-color:var(--color-slate-50)}.bg-slate-100{background-color:var(--color-slate-100)}.bg-slate-200{background-color:var(--color-slate-200)}.bg-white{background-color:var(--color-white)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-6{padding:calc(var(--spacing)*6)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-8{padding-block:calc(var(--spacing)*8)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pt-14{padding-top:calc(var(--spacing)*14)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-6{padding-bottom:calc(var(--spacing)*6)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.text-green-700{color:var(--color-green-700)}.text-primary{color:var(--color-primary)}.text-primary-dark{color:var(--color-primary-dark)}.text-purple-700{color:var(--color-purple-700)}.text-red-600{color:var(--color-red-600)}.text-slate-300{color:var(--color-slate-300)}.text-slate-400{color:var(--color-slate-400)}.text-slate-500{color:var(--color-slate-500)}.text-slate-600{color:var(--color-slate-600)}.text-slate-700{color:var(--color-slate-700)}.text-slate-800{color:var(--color-slate-800)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.no-underline{text-decoration-line:none}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media (hover:hover){.hover\:border-primary:hover{border-color:var(--color-primary)}.hover\:bg-slate-50:hover{background-color:var(--color-slate-50)}.hover\:bg-slate-100:hover{background-color:var(--color-slate-100)}.hover\:text-primary:hover{color:var(--color-primary)}.hover\:text-slate-600:hover{color:var(--color-slate-600)}.hover\:text-slate-900:hover{color:var(--color-slate-900)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}}.focus\:border-transparent:focus{border-color:#0000}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-primary:focus{--tw-ring-color:var(--color-primary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}@media (min-width:40rem){.sm\:inline{display:inline}}@media (min-width:48rem){.md\:ml-56{margin-left:calc(var(--spacing)*56)}.md\:block{display:block}.md\:hidden{display:none}.md\:w-64{width:calc(var(--spacing)*64)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-6{padding-inline:calc(var(--spacing)*6)}}@media (min-width:64rem){.lg\:mr-64{margin-right:calc(var(--spacing)*64)}.lg\:block{display:block}.lg\:p-12{padding:calc(var(--spacing)*12)}}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false} \ No newline at end of file +@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-100:oklch(93.6% .032 17.717);--color-red-600:oklch(57.7% .245 27.325);--color-yellow-100:oklch(97.3% .071 103.193);--color-yellow-800:oklch(47.6% .114 61.907);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-700:oklch(49.6% .265 301.924);--color-slate-50:oklch(98.4% .003 247.858);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-500:oklch(55.4% .046 257.417);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25/1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--ease-in-out:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-primary:#0dc09d;--color-primary-light:#e6f9f5;--color-primary-dark:#0a9a7d}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.collapse{visibility:collapse}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.top-0{top:calc(var(--spacing)*0)}.top-1\/2{top:50%}.top-14{top:calc(var(--spacing)*14)}.right-0{right:calc(var(--spacing)*0)}.right-2{right:calc(var(--spacing)*2)}.left-0{left:calc(var(--spacing)*0)}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.my-2{margin-block:calc(var(--spacing)*2)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.hidden{display:none}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-\[calc\(100vh-3\.5rem\)\]{height:calc(100vh - 3.5rem)}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-12{width:calc(var(--spacing)*12)}.w-48{width:calc(var(--spacing)*48)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-full{width:100%}.max-w-none{max-width:none}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1/2*100%)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-primary{border-color:var(--color-primary)}.border-slate-200{border-color:var(--color-slate-200)}.border-slate-300{border-color:var(--color-slate-300)}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-green-100{background-color:var(--color-green-100)}.bg-primary{background-color:var(--color-primary)}.bg-primary-light{background-color:var(--color-primary-light)}.bg-purple-100{background-color:var(--color-purple-100)}.bg-red-100{background-color:var(--color-red-100)}.bg-slate-50{background-color:var(--color-slate-50)}.bg-slate-100{background-color:var(--color-slate-100)}.bg-slate-200{background-color:var(--color-slate-200)}.bg-white{background-color:var(--color-white)}.bg-yellow-100{background-color:var(--color-yellow-100)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-6{padding:calc(var(--spacing)*6)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-8{padding-block:calc(var(--spacing)*8)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pt-14{padding-top:calc(var(--spacing)*14)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-6{padding-bottom:calc(var(--spacing)*6)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.text-green-700{color:var(--color-green-700)}.text-primary{color:var(--color-primary)}.text-primary-dark{color:var(--color-primary-dark)}.text-purple-700{color:var(--color-purple-700)}.text-red-600{color:var(--color-red-600)}.text-slate-300{color:var(--color-slate-300)}.text-slate-400{color:var(--color-slate-400)}.text-slate-500{color:var(--color-slate-500)}.text-slate-600{color:var(--color-slate-600)}.text-slate-700{color:var(--color-slate-700)}.text-slate-800{color:var(--color-slate-800)}.text-white{color:var(--color-white)}.text-yellow-800{color:var(--color-yellow-800)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.no-underline{text-decoration-line:none}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media (hover:hover){.hover\:border-primary:hover{border-color:var(--color-primary)}.hover\:bg-slate-50:hover{background-color:var(--color-slate-50)}.hover\:bg-slate-100:hover{background-color:var(--color-slate-100)}.hover\:text-primary:hover{color:var(--color-primary)}.hover\:text-slate-600:hover{color:var(--color-slate-600)}.hover\:text-slate-900:hover{color:var(--color-slate-900)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}}.focus\:border-transparent:focus{border-color:#0000}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-primary:focus{--tw-ring-color:var(--color-primary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}@media (min-width:40rem){.sm\:inline{display:inline}}@media (min-width:48rem){.md\:ml-56{margin-left:calc(var(--spacing)*56)}.md\:block{display:block}.md\:hidden{display:none}.md\:w-64{width:calc(var(--spacing)*64)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-6{padding-inline:calc(var(--spacing)*6)}}@media (min-width:64rem){.lg\:mr-64{margin-right:calc(var(--spacing)*64)}.lg\:block{display:block}.lg\:p-12{padding:calc(var(--spacing)*12)}}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false} \ No newline at end of file diff --git a/tests/test_extractor.py b/tests/test_extractor.py index 3339e66..535b1d8 100644 --- a/tests/test_extractor.py +++ b/tests/test_extractor.py @@ -160,3 +160,113 @@ def test_parse_empty_name(self, tmp_path: Path): symbol_type, name = extractor._parse_symbol_name("") assert symbol_type == "unknown" assert name == "" + + +class TestGroovydocParsing: + """Tests for Groovydoc parsing from source files.""" + + def test_parse_groovydoc_at_param_return(self): + """Parse standard @param and @return tags.""" + from nf_docs.extractor import _parse_groovydoc_comment + + comment = """ + * Align reads to reference genome. + * + * @param meta Map containing sample information + * @param bam Input BAM file + * @return txt Tuple of meta and output text file + * @return bam Tuple of meta and output BAM file + """ + docstring, params = _parse_groovydoc_comment(comment) + assert docstring == "Align reads to reference genome." + assert params["meta"] == "Map containing sample information" + assert params["bam"] == "Input BAM file" + assert params["_return_txt"] == "Tuple of meta and output text file" + assert params["_return_bam"] == "Tuple of meta and output BAM file" + + def test_parse_groovydoc_bullet_format(self): + """Parse Inputs:/Outputs: bullet-list format.""" + from nf_docs.extractor import _parse_groovydoc_comment + + comment = """ + * Detect structural variants. + * + * Inputs: + * - - meta: Map of sample info + * - bam: Input BAM file + * Outputs: + * - - meta: Map of sample info + * - txt: SvPileup breakpoint output + """ + docstring, params = _parse_groovydoc_comment(comment) + assert docstring == "Detect structural variants." + assert params["meta"] == "Map of sample info" + assert params["bam"] == "Input BAM file" + assert params["_return_txt"] == "SvPileup breakpoint output" + + def test_parse_groovydoc_from_source_with_intervening_code(self): + """Groovydoc with code between */ and process declaration.""" + from nf_docs.extractor import _parse_groovydoc_from_source + + source = """\ +/** + * Detect SVs from BAM. + * + * @param meta Sample metadata + * @param bam Input BAM + * @return txt Output text file + */ +nextflow.preview.types = true +process SV_PILEUP { + input: + (meta, bam): Tuple, Path> + + output: + txt + bam +} +""" + docstring, params = _parse_groovydoc_from_source(source, "SV_PILEUP") + assert "Detect SVs from BAM" in docstring + assert params["meta"] == "Sample metadata" + assert params["bam"] == "Input BAM" + assert params["_return_txt"] == "Output text file" + + def test_parse_groovydoc_from_source_not_found(self): + """Returns empty when process not found in source.""" + from nf_docs.extractor import _parse_groovydoc_from_source + + docstring, params = _parse_groovydoc_from_source( + "process OTHER { script: '' }\n", "MISSING" + ) + assert docstring == "" + assert params == {} + + def test_find_param_description_simple(self): + """Match a simple input name to param docs.""" + from nf_docs.extractor import _find_param_description + + param_docs = {"reads": "FASTQ input files", "genome": "Reference genome"} + assert _find_param_description("reads", param_docs) == "FASTQ input files" + + def test_find_param_description_tuple(self): + """Match tuple component names to param docs.""" + from nf_docs.extractor import _find_param_description + + param_docs = { + "meta": "Sample metadata map", + "bam": "Input BAM file", + } + desc = _find_param_description("val(meta), path(bam)", param_docs) + assert "meta" in desc + assert "Sample metadata map" in desc + assert "bam" in desc + assert "Input BAM file" in desc + + def test_find_param_description_no_match(self): + """Returns empty when no param docs match.""" + from nf_docs.extractor import _find_param_description + + assert _find_param_description("unknown", {"meta": "desc"}) == "" + assert _find_param_description("val(x)", {"meta": "desc"}) == "" + assert _find_param_description("reads", {}) == "" diff --git a/tests/test_nf_parser.py b/tests/test_nf_parser.py new file mode 100644 index 0000000..f02d47e --- /dev/null +++ b/tests/test_nf_parser.py @@ -0,0 +1,644 @@ +"""Tests for the Nextflow code parser.""" + +from nf_docs.nf_parser import ( + ParsedInput, + ParsedOutput, + _parse_named_output, + _parse_single_input, + _parse_single_output, + _typed_to_qualifier, + enrich_outputs_from_source, + parse_process_hover, + parse_workflow_hover, +) + + +class TestParseSingleInput: + """Tests for _parse_single_input.""" + + def test_empty_line(self): + assert _parse_single_input("") is None + assert _parse_single_input(" ") is None + + def test_simple_val(self): + result = _parse_single_input("val(x)") + assert result == ParsedInput(name="x", type="val") + + def test_simple_path(self): + result = _parse_single_input("path(reads)") + assert result == ParsedInput(name="reads", type="path") + + def test_simple_env(self): + result = _parse_single_input("env(MY_VAR)") + assert result == ParsedInput(name="MY_VAR", type="env") + + def test_simple_file(self): + result = _parse_single_input("file(data)") + assert result == ParsedInput(name="data", type="file") + + def test_stdin(self): + result = _parse_single_input("stdin") + assert result == ParsedInput(name="stdin", type="stdin") + + def test_path_with_pattern(self): + result = _parse_single_input("path '*.txt'") + assert result == ParsedInput(name="*.txt", type="path") + + def test_tuple_traditional(self): + result = _parse_single_input("tuple val(meta), path(reads)") + assert result is not None + assert result.type == "tuple" + assert result.name == "val(meta), path(reads)" + + def test_tuple_multiple_paths(self): + result = _parse_single_input("tuple val(meta), path(reads), path(index)") + assert result is not None + assert result.type == "tuple" + assert result.name == "val(meta), path(reads), path(index)" + + # Typed input syntax tests + + def test_typed_tuple_two_elements(self): + """Typed tuple: (meta, bam): Tuple""" + result = _parse_single_input("(meta, bam): Tuple") + assert result is not None + assert result.type == "tuple" + assert result.name == "val(meta), path(bam)" + assert result.qualifier == "Tuple" + + def test_typed_tuple_three_elements(self): + """Typed tuple: (meta, bam, txt): Tuple""" + result = _parse_single_input("(meta, bam, txt): Tuple") + assert result is not None + assert result.type == "tuple" + assert result.name == "val(meta), path(bam), path(txt)" + assert result.qualifier == "Tuple" + + def test_typed_tuple_all_vals(self): + """Typed tuple with all value types.""" + result = _parse_single_input("(name, count): Tuple") + assert result is not None + assert result.type == "tuple" + assert result.name == "val(name), val(count)" + assert result.qualifier == "Tuple" + + def test_typed_simple_integer(self): + """Simple typed input: x: Integer""" + result = _parse_single_input("x: Integer") + assert result is not None + assert result.type == "val" + assert result.name == "x" + assert result.qualifier == "Integer" + + def test_typed_simple_path(self): + """Simple typed input: bam: Path""" + result = _parse_single_input("bam: Path") + assert result is not None + assert result.type == "path" + assert result.name == "bam" + assert result.qualifier == "Path" + + def test_typed_simple_string(self): + """Simple typed input: name: String""" + result = _parse_single_input("name: String") + assert result is not None + assert result.type == "val" + assert result.name == "name" + assert result.qualifier == "String" + + def test_typed_simple_map(self): + """Simple typed input: meta: Map""" + result = _parse_single_input("meta: Map") + assert result is not None + assert result.type == "val" + assert result.name == "meta" + assert result.qualifier == "Map" + + def test_typed_simple_file(self): + """Simple typed input: data: File""" + result = _parse_single_input("data: File") + assert result is not None + assert result.type == "path" + assert result.name == "data" + assert result.qualifier == "File" + + def test_typed_tuple_with_question_mark_type(self): + """Typed tuple with ? (unresolved) type from LSP: (meta, bam): Tuple, Path>""" + result = _parse_single_input("(meta, bam): Tuple, Path>") + assert result is not None + assert result.type == "tuple" + assert result.name == "val(meta), path(bam)" + assert result.qualifier == "Tuple, Path>" + + def test_typed_tuple_three_with_question_mark(self): + """Typed 3-tuple with ? type: (meta, bam, txt): Tuple, Path, Path>""" + result = _parse_single_input("(meta, bam, txt): Tuple, Path, Path>") + assert result is not None + assert result.type == "tuple" + assert result.name == "val(meta), path(bam), path(txt)" + assert result.qualifier == "Tuple, Path, Path>" + + def test_each_qualifier_not_mismatched_as_typed(self): + """Traditional 'each' qualifier must not be parsed as typed input.""" + # 'each' followed by a colon-like pattern should not match typed simple + result = _parse_single_input("each val(x)") + # 'each val(x)' is not currently handled - should return None rather than misparsing + assert result is None + + def test_typed_tuple_mismatched_counts(self): + """Typed tuple with more names than types falls back to val() for extras.""" + result = _parse_single_input("(a, b, c): Tuple") + assert result is not None + assert result.type == "tuple" + # 'a' -> val(a), 'b' -> path(b), 'c' -> val(c) (fallback) + assert result.name == "val(a), path(b), val(c)" + assert result.qualifier == "Tuple" + + +class TestTypedToQualifier: + """Tests for _typed_to_qualifier.""" + + def test_path_type(self): + assert _typed_to_qualifier("Path") == "path" + + def test_file_type(self): + assert _typed_to_qualifier("File") == "path" + + def test_map_type(self): + assert _typed_to_qualifier("Map") == "val" + + def test_integer_type(self): + assert _typed_to_qualifier("Integer") == "val" + + def test_string_type(self): + assert _typed_to_qualifier("String") == "val" + + def test_boolean_type(self): + assert _typed_to_qualifier("Boolean") == "val" + + +class TestParseSingleOutput: + """Tests for _parse_single_output.""" + + def test_empty_line(self): + assert _parse_single_output("") is None + assert _parse_single_output(" ") is None + + def test_simple_path_with_emit(self): + result = _parse_single_output('path "versions.yml", emit: versions') + assert result is not None + assert result.type == "path" + assert result.name == "versions.yml" + assert result.emit == "versions" + + def test_tuple_with_emit(self): + result = _parse_single_output('tuple val(meta), path("*.html"), emit: html') + assert result is not None + assert result.type == "tuple" + assert result.name == 'val(meta), path("*.html")' + assert result.emit == "html" + + def test_stdout(self): + result = _parse_single_output("stdout") + assert result is not None + assert result.type == "stdout" + + def test_optional_output(self): + result = _parse_single_output('path "*.log", emit: log, optional: true') + assert result is not None + assert result.optional is True + + # Named assignment output tests (typed syntax) + + def test_named_tuple_output(self): + """Named assignment: txt = tuple(meta, file("*_svpileup.txt"))""" + result = _parse_single_output('txt = tuple(meta, file("*_svpileup.txt"))') + assert result is not None + assert result.type == "tuple" + assert result.emit == "txt" + assert 'file("*_svpileup.txt")' in result.name + + def test_named_tuple_with_two_files(self): + """Named assignment: bam = tuple(meta, file("*_sorted.bam"))""" + result = _parse_single_output('bam = tuple(meta, file("*_sorted.bam"))') + assert result is not None + assert result.type == "tuple" + assert result.emit == "bam" + + def test_named_simple_file(self): + """Named assignment: report = file("*.html")""" + result = _parse_single_output('report = file("*.html")') + assert result is not None + assert result.type == "file" + assert result.name == "*.html" + assert result.emit == "report" + + def test_named_simple_path(self): + """Named assignment: versions = path("versions.yml")""" + result = _parse_single_output('versions = path("versions.yml")') + assert result is not None + assert result.type == "path" + assert result.name == "versions.yml" + assert result.emit == "versions" + + def test_named_val(self): + """Named assignment: count = val(total)""" + result = _parse_single_output("count = val(total)") + assert result is not None + assert result.type == "val" + assert result.name == "total" + assert result.emit == "count" + + def test_bare_emit_name(self): + """Bare identifier output from typed syntax LSP hover (e.g. just 'txt').""" + result = _parse_single_output("txt") + assert result is not None + assert result.name == "txt" + assert result.emit == "txt" + assert result.type == "" + + def test_bare_emit_name_bam(self): + """Bare identifier output: bam.""" + result = _parse_single_output("bam") + assert result is not None + assert result.name == "bam" + assert result.emit == "bam" + + def test_bare_emit_name_bedpe(self): + """Bare identifier output: bedpe.""" + result = _parse_single_output("bedpe") + assert result is not None + assert result.name == "bedpe" + assert result.emit == "bedpe" + + def test_topic_publish_skipped(self): + """Topic publish lines should be skipped.""" + assert _parse_single_output(">> 'sample_outputs'") is None + assert _parse_single_output('>> "my_topic"') is None + + +class TestParseNamedOutput: + """Tests for _parse_named_output.""" + + def test_tuple_with_file(self): + result = _parse_named_output("txt", 'tuple(meta, file("*_svpileup.txt"))') + assert result.type == "tuple" + assert result.emit == "txt" + assert "file" in result.name + + def test_tuple_with_multiple_components(self): + result = _parse_named_output("out", 'tuple(meta, file("*.bam"), file("*.bai"))') + assert result.type == "tuple" + assert result.emit == "out" + + def test_tuple_plain_names(self): + result = _parse_named_output("result", "tuple(meta, data)") + assert result.type == "tuple" + assert result.emit == "result" + assert result.name == "val(meta), val(data)" + + def test_simple_file(self): + result = _parse_named_output("report", 'file("report.html")') + assert result.type == "file" + assert result.emit == "report" + assert result.name == "report.html" + + def test_simple_path(self): + result = _parse_named_output("versions", 'path("versions.yml")') + assert result.type == "path" + assert result.emit == "versions" + assert result.name == "versions.yml" + + def test_fallback(self): + result = _parse_named_output("x", "some_expression") + assert result.type == "val" + assert result.emit == "x" + assert result.name == "some_expression" + + +class TestParseProcessHover: + """Tests for parse_process_hover.""" + + def test_traditional_process(self): + """Parse a traditional DSL2 process definition.""" + hover = """```nextflow +process FASTQC { + input: + tuple val(meta), path(reads) + + output: + tuple val(meta), path("*.html"), emit: html + path "versions.yml", emit: versions +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert result.name == "FASTQC" + assert len(result.inputs) == 1 + assert result.inputs[0].type == "tuple" + assert len(result.outputs) == 2 + assert result.outputs[0].emit == "html" + assert result.outputs[1].emit == "versions" + + def test_typed_process(self): + """Parse a typed process definition (Nextflow typed syntax).""" + hover = """```nextflow +process SV_PILEUP { + input: + (meta, bam): Tuple + + output: + txt = tuple(meta, file("*_svpileup.txt")) + bam = tuple(meta, file("*_svpileup.bam")) +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert result.name == "SV_PILEUP" + assert len(result.inputs) == 1 + assert result.inputs[0].type == "tuple" + assert result.inputs[0].name == "val(meta), path(bam)" + assert result.inputs[0].qualifier == "Tuple" + assert len(result.outputs) == 2 + assert result.outputs[0].emit == "txt" + assert result.outputs[0].type == "tuple" + assert result.outputs[1].emit == "bam" + assert result.outputs[1].type == "tuple" + + def test_typed_process_three_inputs(self): + """Parse typed process with 3-element tuple input.""" + hover = """```nextflow +process AGGREGATE { + input: + (meta, bam, txt): Tuple + + output: + txt = tuple(meta, file("*_aggregate.txt")) +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert result.name == "AGGREGATE" + assert len(result.inputs) == 1 + assert result.inputs[0].name == "val(meta), path(bam), path(txt)" + assert len(result.outputs) == 1 + assert result.outputs[0].emit == "txt" + + def test_typed_process_with_topic_section(self): + """Topic section should not interfere with output parsing.""" + hover = """```nextflow +process MY_PROC { + input: + (meta, bam): Tuple + + output: + txt = tuple(meta, file("*.txt")) + + topic: + >> 'sample_outputs' +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert len(result.inputs) == 1 + assert len(result.outputs) == 1 + assert result.outputs[0].emit == "txt" + + def test_mixed_typed_and_traditional_outputs(self): + """Process with both named assignment and traditional output syntax.""" + hover = """```nextflow +process MIXED { + input: + val(x) + + output: + txt = file("output.txt") + path "versions.yml", emit: versions +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert len(result.outputs) == 2 + assert result.outputs[0].emit == "txt" + assert result.outputs[0].type == "file" + assert result.outputs[1].emit == "versions" + + def test_typed_simple_inputs(self): + """Process with simple typed inputs.""" + hover = """```nextflow +process SIMPLE_TYPED { + input: + x: Integer + bam: Path + + output: + result = val(x) +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert len(result.inputs) == 2 + assert result.inputs[0].name == "x" + assert result.inputs[0].type == "val" + assert result.inputs[0].qualifier == "Integer" + assert result.inputs[1].name == "bam" + assert result.inputs[1].type == "path" + assert result.inputs[1].qualifier == "Path" + + def test_no_code_block(self): + """Handle hover text without code fences.""" + result = parse_process_hover("just some text") + assert result is None + + def test_empty_process(self): + """Process with no inputs or outputs.""" + hover = """```nextflow +process EMPTY { + script: + echo "hello" +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert result.name == "EMPTY" + assert len(result.inputs) == 0 + assert len(result.outputs) == 0 + + def test_topic_in_output_block_skipped(self): + """Topic publish lines within output block should be skipped.""" + hover = """```nextflow +process WITH_TOPIC { + output: + txt = file("out.txt") + >> 'my_topic' +} +```""" + result = parse_process_hover(hover) + assert result is not None + # Only the file output, not the topic line + assert len(result.outputs) == 1 + assert result.outputs[0].emit == "txt" + + def test_typed_process_with_bare_outputs(self): + """Real LSP hover for a typed process with bare emit names as outputs.""" + hover = """```nextflow +process SV_PILEUP { + input: + (meta, bam): Tuple, Path> + + output: + txt + bam +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert result.name == "SV_PILEUP" + # Input: typed tuple with ? type + assert len(result.inputs) == 1 + assert result.inputs[0].type == "tuple" + assert result.inputs[0].name == "val(meta), path(bam)" + assert result.inputs[0].qualifier == "Tuple, Path>" + # Outputs: bare emit names + assert len(result.outputs) == 2 + assert result.outputs[0].name == "txt" + assert result.outputs[0].emit == "txt" + assert result.outputs[1].name == "bam" + assert result.outputs[1].emit == "bam" + + def test_typed_process_three_inputs_bare_output(self): + """Real LSP hover for typed process with 3-element tuple and bare output.""" + hover = """```nextflow +process AGGREGATE_SV_PILEUP { + input: + (meta, bam, txt): Tuple, Path, Path> + + output: + txt +} +```""" + result = parse_process_hover(hover) + assert result is not None + assert len(result.inputs) == 1 + assert result.inputs[0].name == "val(meta), path(bam), path(txt)" + assert len(result.outputs) == 1 + assert result.outputs[0].emit == "txt" + + +class TestParseWorkflowHover: + """Tests for parse_workflow_hover.""" + + def test_workflow_with_takes_and_emits(self): + hover = """```nextflow +workflow MAIN { + take: + reads + genome + + emit: + bam = aligned + vcf = variants +} +```""" + result = parse_workflow_hover(hover) + assert result is not None + assert result.name == "MAIN" + assert result.takes == ["reads", "genome"] + assert result.emits == ["bam", "vcf"] + + def test_empty_workflow(self): + hover = """```nextflow +workflow EMPTY { +} +```""" + result = parse_workflow_hover(hover) + assert result is not None + assert result.name == "EMPTY" + assert result.takes == [] + assert result.emits == [] + + +class TestEnrichOutputsFromSource: + """Tests for enriching bare outputs with data from .nf source files.""" + + SV_PILEUP_SOURCE = """\ +process SV_PILEUP { + container "community.wave.seqera.io/library/fgsv:0.2.1" + + input: + (meta, bam): Tuple, Path> + + output: + txt = tuple(meta, file("*_svpileup.txt")) + bam = tuple(meta, file("*_svpileup.bam")) + + topic: + tuple(meta, file("*_svpileup.txt")) >> 'sample_outputs' + + script: + def prefix = "${meta.id}" + \""" + fgsv SvPileup --input ${bam} --output ${prefix}_svpileup + \""" +} +""" + + def test_bare_outputs_enriched(self): + """Bare emit names are replaced with full declarations from source.""" + bare_outputs = [ + ParsedOutput(name="txt", type="", emit="txt"), + ParsedOutput(name="bam", type="", emit="bam"), + ] + result = enrich_outputs_from_source(bare_outputs, self.SV_PILEUP_SOURCE, "SV_PILEUP") + + assert len(result) == 2 + assert result[0].emit == "txt" + assert result[0].type == "tuple" + assert "file(" in result[0].name + assert result[1].emit == "bam" + assert result[1].type == "tuple" + assert "file(" in result[1].name + + def test_already_qualified_outputs_not_changed(self): + """Outputs that already have a type are left untouched.""" + qualified_outputs = [ + ParsedOutput(name="val(meta), path(*.html)", type="tuple", emit="html"), + ] + result = enrich_outputs_from_source(qualified_outputs, self.SV_PILEUP_SOURCE, "SV_PILEUP") + + assert len(result) == 1 + assert result[0] is qualified_outputs[0] # same object, unchanged + + def test_process_not_found_returns_originals(self): + """If the process name isn't in the source, return outputs unchanged.""" + bare_outputs = [ParsedOutput(name="txt", type="", emit="txt")] + result = enrich_outputs_from_source( + bare_outputs, "process OTHER_PROC {\n output:\n x = val(1)\n}\n", "SV_PILEUP" + ) + assert result is bare_outputs + + def test_partial_match_enriches_only_matching(self): + """Only bare outputs whose emit matches a source declaration are enriched.""" + outputs = [ + ParsedOutput(name="txt", type="", emit="txt"), + ParsedOutput(name="unknown", type="", emit="unknown"), + ] + result = enrich_outputs_from_source(outputs, self.SV_PILEUP_SOURCE, "SV_PILEUP") + + assert result[0].type == "tuple" # enriched + assert result[0].emit == "txt" + assert result[1].type == "" # not found in source, unchanged + assert result[1].emit == "unknown" + + def test_simple_named_output(self): + """Named simple output: versions = path("versions.yml").""" + source = ( + 'process SIMPLE {\n output:\n versions = path("versions.yml")\n\n script:\n ""\n}\n' + ) + + bare_outputs = [ParsedOutput(name="versions", type="", emit="versions")] + result = enrich_outputs_from_source(bare_outputs, source, "SIMPLE") + + assert result[0].emit == "versions" + assert result[0].type == "path" + assert result[0].name == "versions.yml"