From 71ebf5fbce1749724bf5286db395f6b69c958a11 Mon Sep 17 00:00:00 2001 From: Karl Dyrhage Date: Mon, 18 Nov 2024 10:18:38 +0100 Subject: [PATCH] Added iteration section to docs --- docs/src/loci.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/src/loci.md b/docs/src/loci.md index f1adaef..5025361 100644 --- a/docs/src/loci.md +++ b/docs/src/loci.md @@ -20,4 +20,24 @@ Compound loci are represented with `Join` and `Order`. Both types have a single ```julia Locus("complement(join(10..20,30..>40))") isa Complement{Join{SpanLocus{ClosedSpan}, SpanLocus{OpenRightSpan}}} +``` + +## Iteration +`AbstractLocus` instances are themselves iterable, yielding each compound locus in sequence. If the locus is wrapped in `Complement`, the compound loci are returned in reverse order, and individually wrapped in `Complement`. + +```julia +julia> for loc in Locus("complement(join(1..3,7..9))") + println(loc) + end +complement(7..9) +complement(1..3) +``` + +The `eachposition(locus)` function is provided for iterating over the individual genomic positions in the locus. Note that this ignores any metadata such as strandedness. + +```julia +julia> for p in eachposition(Locus("complement(join(1..3,7..9))")) + print(p) + end +987321 ``` \ No newline at end of file