Showing 4 of 22 files from the diff.

@@ -6,9 +6,27 @@
Loading
6 6
# This file is a part of BioJulia.
7 7
# License is MIT: https://github.com/BioJulia/Bio.jl/blob/master/LICENSE.md
8 8
9 +
"""
10 +
# Outer constructors
11 +
* [`Strand(strand::Char)`](@ref)
12 +
* [`Strand(strand::UInt8)`](@ref)
13 +
14 +
[`Strand`](@ref) can take four kinds of values listed in the next table:
15 +
16 +
| Symbol | Constant              | Meaning                           |
17 +
| :----- | :-------------------- | :-------------------------------- |
18 +
| `'?'`  | [`STRAND_NA`](@ref)   | strand is unknown or inapplicable |
19 +
| `'+'`  | [`STRAND_POS`](@ref)  | positive strand                   |
20 +
| `'-'`  | [`STRAND_NEG`](@ref)  | negative strand                   |
21 +
| `'.'`  | [`STRAND_BOTH`](@ref) | non-strand-specific feature       |
22 +
"""
9 23
primitive type Strand 8 end
10 24
11 25
Base.convert(::Type{Strand}, strand::UInt8) = reinterpret(Strand, strand)
26 +
27 +
"""
28 +
    Strand(strand::UInt8)
29 +
"""
12 30
Strand(strand::UInt8) = convert(Strand, strand)
13 31
Base.convert(::Type{UInt8}, strand::Strand) = reinterpret(UInt8, strand)
14 32
@@ -45,6 +63,10 @@
Loading
45 63
46 64
    error("'$(strand)' is not a valid strand")
47 65
end
66 +
67 +
"""
68 +
    Strand(strand::Char)
69 +
"""
48 70
Strand(strand::Char) = convert(Strand, strand)
49 71
50 72
function Base.convert(::Type{Char}, strand::Strand)

@@ -7,7 +7,18 @@
Loading
7 7
# License is MIT: https://github.com/BioJulia/Bio.jl/blob/master/LICENSE.md
8 8
9 9
# Note, just to be clear: this shadows IntervalTrees.Interval
10 -
"A genomic interval specifies interval with some associated metadata"
10 +
"""
11 +
    struct Interval{T} <: IntervalTrees.AbstractInterval{Int64}
12 +
13 +
The first three fields (`seqname`, `first`, and `last`) are mandatory arguments when constructing the [`Interval`](@ref Interval) object.
14 +
15 +
# Fields
16 +
- `seqname::String`: the sequence name associated with the interval.
17 +
- `first::Int64`: the leftmost position.
18 +
- `last::Int64`: the rightmost position.
19 +
- `strand::Strand`: the [`strand`](@ref Strand).
20 +
- `metadata::T`
21 +
"""
11 22
struct Interval{T} <: IntervalTrees.AbstractInterval{Int64}
12 23
    seqname::String
13 24
    first::Int64

@@ -19,6 +19,23 @@
Loading
19 19
This function would return a new set of disjoint intervals with annotated coverage like:
20 20
21 21
    [1][-2-][-1-][--2--][--1--]
22 +
23 +
# Example
24 +
25 +
```jldoctest
26 +
julia> intervals = [
27 +
           Interval("chr1", 1, 8),
28 +
           Interval("chr1", 4, 20),
29 +
           Interval("chr1", 14, 27)];
30 +
31 +
julia> coverage(intervals)
32 +
IntervalCollection{UInt32} with 5 intervals:
33 +
  chr1:1-3  .  1
34 +
  chr1:4-8  .  2
35 +
  chr1:9-13  .  1
36 +
  chr1:14-20  .  2
37 +
  chr1:21-27  .  1
38 +
```
22 39
"""
23 40
function coverage(stream, seqname_isless::Function=isless)
24 41
    cov = IntervalCollection{UInt32}()

@@ -39,6 +39,7 @@
Loading
39 39
const ICTreeIntersectionIterator{F,S,T}       = IntervalTrees.IntersectionIterator{F,Int64,Interval{S},64,Interval{T},64}
40 40
const ICTreeIntervalIntersectionIterator{F,T} = IntervalTrees.IntervalIntersectionIterator{F, Int64,Interval{T},64}
41 41
42 +
"An IntervalCollection is an efficiently stored and indexed set of annotated genomic intervals."
42 43
mutable struct IntervalCollection{T}
43 44
    # Sequence name mapped to IntervalTree, which in turn maps intervals to a list of metadata.
44 45
    trees::Dict{String,ICTree{T}}
@@ -51,11 +52,12 @@
Loading
51 52
    ordered_trees::Vector{ICTree{T}}
52 53
    ordered_trees_outdated::Bool
53 54
55 +
    "Empty initaialzation."
54 56
    function IntervalCollection{T}() where T
55 57
        return new{T}(Dict{String,ICTree{T}}(), 0, ICTree{T}[], false)
56 58
    end
57 59
58 -
    # Bulk insertion.
60 +
    "Bulk insertion."
59 61
    function IntervalCollection{T}(intervals::AbstractVector{Interval{T}}, sort::Bool=false) where T
60 62
        if sort
61 63
            sort!(intervals)
@@ -80,17 +82,26 @@
Loading
80 82
    end
81 83
end
82 84
83 -
# Shorthand constructor.
85 +
"""
86 +
    IntervalCollection(intervals::AbstractVector{Interval{T}}, sort::Bool=false) where T
87 +
Shorthand constructor.
88 +
"""
84 89
function IntervalCollection(intervals::AbstractVector{Interval{T}}, sort::Bool=false) where T
85 90
    return IntervalCollection{T}(intervals, sort)
86 91
end
87 92
88 -
# Constructor that offers conversion through collection.
93 +
"""
94 +
    IntervalCollection{T}(data, sort::Bool=false) where T
95 +
Constructor that offers conversion through collection.
96 +
"""
89 97
function IntervalCollection{T}(data, sort::Bool=false) where T
90 98
    return IntervalCollection(collect(Interval{T}, data), sort)
91 99
end
92 100
93 -
# Constructor that guesses metadatatype, and offers conversion through collection.
101 +
"""
102 +
    IntervalCollection(data, sort::Bool=false)
103 +
Constructor that guesses metadatatype, and offers conversion through collection.
104 +
"""
94 105
function IntervalCollection(data, sort::Bool=false)
95 106
    return IntervalCollection(collect(Interval{metadatatype(data)}, data), sort)
96 107
end
Files Coverage
src 80.00%
Project Totals (7 files) 80.00%
codecov-umbrella
Build #134312249 -
unittests
codecov-umbrella
Build #134312249 -
unittests
codecov-umbrella
Build #134312249 -
unittests
codecov-umbrella
Build #134312249 -
unittests
codecov-umbrella
Build #134312249 -
unittests
codecov-umbrella
Build #134312249 -
unittests
codecov-umbrella
Build #134312249 -
unittests

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading