Skip to content

Commit

Permalink
Added position(gene)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdyrhage committed Jan 3, 2024
1 parent b043398 commit 7374b19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ end
chr.genes[2].locus_tag = "test123"
```

The `Locus` of a `Gene` retrieved with `locus(gene)`. The `Locus` itself is immutable, but can be updated with `locus!(gene, newlocus)`. For simplicity, `position(gene)` is shorthand for `locus(gene).position`.
```julia
# Create a new Locus, copying all fields of the old one but shifting the position by 1
oldloc = locus(gene)
locus!(gene, Locus(oldloc.position .+ 1, oldloc.strand, oldloc.complete_left, oldloc.complete_right, oldloc.order, oldloc.join))

# Access the genomic positions of all genes
position.(chr.genes)
```

Accessing properties that haven't been stored will return missing. For this reason, it often makes more sense to use `get()` than to access the property directly.
```julia
# chr.genes[2].pseudo returns missing, so this will throw an error
Expand Down
1 change: 1 addition & 0 deletions src/record.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ Base.iterate(loc::Locus) = iterate(loc.position)

index(g::Gene) = getfield(g, :index)
locus(g::Gene) = getfield(g, :locus)
position(g::Gene) = getfield(g, :locus).position
feature(g::Gene) = getfield(g, :feature)
Base.parent(g::Gene) = getfield(g, :parent)
function Base.parent(gs::AbstractVector{G}) where {G <: AbstractGene}
Expand Down

0 comments on commit 7374b19

Please sign in to comment.