Skip to content

Commit

Permalink
Updated docs to use FASTX
Browse files Browse the repository at this point in the history
  • Loading branch information
kdyrhage committed Sep 25, 2019
1 parent f0b5e5e commit 5ea9f25
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The macro `@genes` can be used to filter through the annotations. The keyword `g

Gene sequences can be accessed with `sequence(gene)`. For example, the following code will write the translated sequences of all protein-coding genes to a file:
```julia
using BioSequences
using FASTX
writer = FASTA.Writer(open("proteins.fasta", "w"))
for gene in @genes(chr, iscds)
aaseq = translate(sequence(gene))
Expand Down
21 changes: 20 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ end
Add gene to `chr`. `locus` can be a `Locus`, a UnitRange, or a StepRange (for
decreasing ranges, which will be annotated on the complementary strand).
# Example
```julia
addgene!(chr, "CDS", 1:756;
locus_tag = "gene0001",
product = "Chromosomal replication initiator protein dnaA")
```
"""
function addgene!(chr::Chromosome, feature, locus; kw...)
locus = convert(Locus, locus)
Expand Down Expand Up @@ -141,7 +148,7 @@ end


"""
pushproperty!(gene::AbstractGene, name::Symbol, x::T)
pushproperty!(gene::AbstractGene, qualifier::Symbol, value::T)
Add a property to `gene`, similarly to `Base.setproperty!(::gene)`, but if the
property is not missing in `gene`, it will be transformed to store a vector
Expand Down Expand Up @@ -225,6 +232,18 @@ end
sequence(gene::AbstractGene)
Return genomic sequence for `gene`.
# Example
The following code will write the translated sequences of all genes in `chr` to a file:
```julia
using FASTX
writer = FASTA.Writer(open("proteins.fasta", "w"))
for gene in @genes(chr, iscds)
aaseq = translate(sequence(gene))
write(writer, FASTA.record(gene.locus_tag, get(gene, :product, ""), aaseq))
end
close(writer)
```
"""
function sequence(gene::AbstractGene)
ifelse(gene.locus.strand == '-',
Expand Down

0 comments on commit 5ea9f25

Please sign in to comment.