Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BioSequences"
uuid = "7e6ae17a-c86d-528c-b3b9-7f778a29fe59"
authors = ["Sabrina Jaye Ward <sabrinajward@protonmail.com>", "Jakob Nissen <jakobnybonissen@gmail.com>"]
version = "3.5.1"
authors = ["Sabrina Jaye Ward <sabrinajward@protonmail.com>", "Jakob Nybo Andersen <jnandersen@proton.me>"]
version = "3.5.2"

[deps]
BioSymbols = "3c28c6f8-a34d-59c4-9654-267d177fcfa9"
Expand Down
56 changes: 31 additions & 25 deletions docs/src/construction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ end

# Construction & conversion

Here we will showcase the various ways you can construct the various sequence
types in BioSequences.
Here we will showcase the various ways you can construct the sequence types in
BioSequences.

## Constructing sequences

Expand All @@ -35,7 +35,7 @@ UUAGC

```

Type alias' can also be used for brevity.
Type aliases can also be used for brevity.

```jldoctest
julia> LongDNA{4}("TTANC")
Expand Down Expand Up @@ -72,7 +72,8 @@ TTAGC

### Constructing sequences from other sequences

You can create sequences, by concatenating other sequences together:
You can create sequences by concatenating other sequences together:

```jldoctest
julia> LongDNA{2}("ACGT") * LongDNA{2}("TGCA")
8nt DNA Sequence:
Expand All @@ -88,7 +89,7 @@ TATATATATATATATATATA

```

Sequence views (`LongSubSeq`s) are special, in that they do not own their own data,
Sequence views (`LongSubSeq`s) are special in that they do not own their own data,
and must be constructed from a `LongSequence` or another `LongSubSeq`:

```jldoctest
Expand All @@ -112,7 +113,9 @@ true

## Conversion of sequence types

You can convert between sequence types, if the sequences are compatible - that is, if the source sequence does not contain symbols that are un-encodable by the destination type.
You can convert between sequence types if the sequences are compatible—that is,
if the source sequence does not contain symbols that are unencodable by the
destination type.
```jldoctest
julia> dna = dna"TTACGTAGACCG"
12nt DNA Sequence:
Expand Down Expand Up @@ -201,7 +204,7 @@ CTTA

```

However, this is not what happens, instead the following happens:
However, this is not what happens; instead, the following happens:

```@meta
DocTestSetup = quote
Expand All @@ -228,21 +231,21 @@ CTTAAA

```

The reason for this is because the sequence literal is allocated only once
before the first time the function `foo` is called and run. Therefore, `s` in
The reason for this is that the sequence literal is allocated only once
before the first time the function `foo` is called. Therefore, `s` in
`foo` is always a reference to that one sequence that was allocated.
So one sequence is created before `foo` is called, and then it is pushed to
every time `foo` is called. Thus, that one allocated sequence grows with every
call of `foo`.
So one sequence is created before `foo` is called, and then a nucleotide is appended
to it on every call to `foo`. Thus, that one allocated sequence grows with every
call to `foo`.

If you wanted `foo` to create a new sequence each time it is called,
If you want `foo` to create a new sequence each time it is called,
then you can add a flag to the end of the sequence literal to dictate behaviour:
A flag of 's' means 'static': the sequence will be allocated before code is run,
A flag of `s` means 'static': the sequence will be allocated before the code is run,
as is the default behaviour described above.
However providing 'd' flag changes the behaviour: 'd' means 'dynamic':
However, providing the `d` flag changes the behaviour: `d` means 'dynamic':
the sequence will be allocated whilst the code is running, and not before.
So to change `foo` so as it creates a new sequence
each time it is called, simply add the 'd' flag to the sequence literal:
So to change `foo` so that it creates a new sequence
each time it is called, simply add the `d` flag to the sequence literal:
```@meta
DocTestSetup = quote
using BioSequences
Expand Down Expand Up @@ -290,11 +293,11 @@ DocTestSetup = quote
end
```

So the take home message of sequence literals is this:
So the take-home message of sequence literals is this:

Be careful when you are using sequence literals inside of functions, and inside
the bodies of things like for loops. And if you use them and are unsure, use the
's' and 'd' flags to ensure the behaviour you get is the behaviour you intend.
the `s` and `d` flags to ensure the behaviour you get is the behaviour you intend.

```@docs
@dna_str
Expand All @@ -303,7 +306,7 @@ the bodies of things like for loops. And if you use them and are unsure, use the
```

## Loose parsing
As of version 3.2.0, BioSequences.jl provide the [`bioseq`](@ref) function, which can be used to build a `LongSequence`
As of version 3.2.0, BioSequences.jl provides the [`bioseq`](@ref) function, which can be used to build a `LongSequence`
from a string (or an `AbstractVector{UInt8}`) without knowing the correct `Alphabet`.

```jldoctest
Expand All @@ -312,7 +315,9 @@ julia> bioseq("ATGTGCTGA")
ATGTGCTGA
```

The function will prioritise 2-bit alphabets over 4-bit alphabets, and prefer smaller alphabets (like `DNAAlphabet{4}`) over larger (like `AminoAcidAlphabet`).
The function will prioritise 2-bit alphabets over 4-bit alphabets, and prefer
smaller alphabets (like `DNAAlphabet{4}`) over larger (like
`AminoAcidAlphabet`).
If the input cannot be encoded by any of the built-in alphabets, an error is thrown:

```jldoctest
Expand All @@ -321,8 +326,9 @@ ERROR: cannot encode 0x30 (Char '0') in AminoAcidAlphabet
[...]
```

Note that this function is only intended to be used for interactive, ephemeral work.
The function is necessarily type unstable, and the precise returned alphabet for a given input is a heuristic which is subject to change.
Note that this function is only intended to be used for interactive, ephemeral
work. The function is necessarily type unstable, and the precise returned
alphabet for a given input is a heuristic that is subject to change.

```@docs
bioseq
Expand All @@ -331,13 +337,13 @@ guess_alphabet

## Comparison to other sequence types
Following Base standards, BioSequences do not compare equal to other containers even if they have the same elements.
To e.g. compare a BioSequence with a vector of DNA, compare the elements themselves:
To compare a BioSequence with a vector of DNA, for example, compare the elements themselves:
```jldoctest
julia> seq = dna"GAGCTGA"; vec = collect(seq);

julia> seq == vec, isequal(seq, vec)
(false, false)

julia> length(seq) == length(vec) && all(i == j for (i, j) in zip(seq, vec))
true
true
```
14 changes: 7 additions & 7 deletions docs/src/counting.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ end
```

# Counting
`BioSequences` contains functionality to efficiently count biosymbols in a biosequence
that satisfies some predicate.
`BioSequences` contains functionality to efficiently count biosymbols in a
biosequence that satisfies some predicate.

Consider a naive counting function like this:
```julia
Expand All @@ -17,18 +17,18 @@ function count_Ns(seq::BioSequence{<:DNAAlphabet})
ns += (i == DNA_N)::Bool
end
ns
end
end
```

This function can be more efficiently implemented by exploiting the internal
data layout of certain biosequences.
Therefore, Julia provides optimised methods for `Base.count`, such that `count_Ns`
above can be more efficiently expressed `count(==(DNA_N), seq)`.
above can be more efficiently expressed as `count(==(DNA_N), seq)`.

!!! note
It is important to understand that this speed is achieved with custom methods of
`Base.count`, and not by a generic mechanism that improves the speed of counting
symbols in `BioSequence `in general.
symbols in a `BioSequence` in general.
Hence, while `count(==(DNA_N), seq)` may be optimised,
`count(i -> i == DNA_N, seq)` is not, as this is a different method.

Expand All @@ -44,7 +44,7 @@ have optimised methods.

## Matches and mismatches
The methods `matches` and `mismatches` take two
sequences and count the number of positions where the sequences are unequal or equal, respectively.
sequences and count the number of positions where the sequences are equal or unequal, respectively.

They are equivalent to `matches(a, b) = count(splat(==), zip(a, b))`
(and with `!=`, respectively).
Expand All @@ -62,7 +62,7 @@ gc_content
```

## Deprecated aliases
Several of the optimised `count` methods have function names, which are deprecated:
Several of the optimised `count` methods have function names that are deprecated:

| Deprecated function | Instead use |
| :------------------- | :------------------------ |
Expand Down
8 changes: 4 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ biological sequences, including DNA, RNA, and amino acid sequences.


## Installation
You can install BioSequences from the julia
REPL. Press `]` to enter pkg mode again, and enter the following:
You can install BioSequences from the Julia
REPL. Press `]` to enter pkg mode, and enter the following:

```julia
add BioSequences
```

If you are interested in the cutting edge of the development, please check out
If you are interested in the cutting edge of development, please check out
the master branch to try new features before release.


Expand All @@ -39,5 +39,5 @@ detailed contributor and maintainer guidelines, and code of conduct.

## Questions?
If you have a question about contributing or using BioJulia software, come
on over and chat to us on [the #biology channel on the Julia SLack](https://julialang.org/slack/), or you can try the
on over and chat to us on [the #biology channel on the Julia Slack](https://julialang.org/slack/), or you can try the
[Bio category of the Julia discourse site](https://discourse.julialang.org/c/domain/bio).
22 changes: 11 additions & 11 deletions docs/src/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ DocTestSetup = quote
end
```

# Custom BioSequences types
# Custom BioSequence types

If you're a developing your own Bioinformatics package or method, you may find
that the reference implementation of concrete `LongSequence` types provided in
If you're developing your own bioinformatics package or method, you may find
that the reference implementations of concrete `LongSequence` types provided in
this package are not optimal for your purposes.

This page describes the interfaces for BioSequences' core types for
developers or other packages implementing their own sequence types or extending
This page describes the interfaces for BioSequences' core types, for developers
and other packages implementing their own sequence types or extending
BioSequences functionality.

## Implementing custom Alphabets

Recall the required methods that define the [`Alphabet`](@ref) interface.
Recall the required methods that define the [`Alphabet`](@ref) interface.

To create an example custom alphabet, we need to create a singleton type, that
To create an example custom alphabet, we need to create a singleton type that
implements a few methods in order to conform to the interface as described in the
[`Alphabet`](@ref) documentation.

Let's do that for a restricted Amino Acid alphabet. We can test that it conforms
Let's do that for a restricted amino acid alphabet. We can test that it conforms
to the interface with the [`BioSequences.has_interface`](@ref) function.

```jldoctest
Expand Down Expand Up @@ -67,14 +67,14 @@ true

## Implementing custom BioSequences

Recall the required methods that define the [`BioSequence`](@ref) interface.
Recall the required methods that define the [`BioSequence`](@ref) interface.

To create an example custom alphabet, we need to create a singleton type, that
To create an example custom sequence type, we need to create a singleton type that
implements a few methods in order to conform to the interface as described in the
[`BioSequence`](@ref) documentation.

Let's do that for a custom sequence type that is optimised to represent a small
sequence: A Codon. We can test that it conforms to the interface with the
sequence: a codon. We can test that it conforms to the interface with the
[`BioSequences.has_interface`](@ref) function.

```jldoctest
Expand Down
6 changes: 3 additions & 3 deletions docs/src/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Versions of BioSequences prior to v2.0 provided a FASTA, FASTQ, and 2Bit
submodule for working with formatted sequence files.

After version v2.0, in order to neatly separate concerns, these submodules were
After v2.0, in order to neatly separate concerns, these submodules were
removed.

Instead there will now be dedicated BioJulia packages for each format. Each
Instead, there are now dedicated BioJulia packages for each format. Each
of these will be compatible with BioSequences.

A list of all of the different formats and packages is provided below to help
Expand All @@ -16,4 +16,4 @@ you find them quickly.
|:------ |:------------------------------------------------ |
| FASTA | [FASTX.jl](https://github.com/BioJulia/FASTX.jl) |
| FASTQ | [FASTX.jl](https://github.com/BioJulia/FASTX.jl) |
| 2Bit | [TwoBit.jl](https://github.com/BioJulia/TwoBit.jl) |
| 2Bit | [TwoBit.jl](https://github.com/BioJulia/TwoBit.jl) |
6 changes: 3 additions & 3 deletions docs/src/random.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ end

## Long sequences

You can generate random long sequences using the `randdna` function and the
`Sampler`'s implemented in BioSequences:
You can generate random long sequences using the `randdnaseq` function and the
samplers implemented in BioSequences:

```@docs
randseq
Expand All @@ -18,4 +18,4 @@ randrnaseq
randaaseq
SamplerUniform
SamplerWeighted
```
```
1 change: 0 additions & 1 deletion docs/src/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ one_hot(dna"TGNTKCTW-T")
1 0 1 1 1 0 1 1 0 1
```


Loading
Loading