Skip to content

Commit

Permalink
Added iteration section to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kdyrhage committed Nov 18, 2024
1 parent a6247b1 commit 71ebf5f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/src/loci.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit 71ebf5f

Please sign in to comment.