Class: GenomerPluginSummary::Gaps
- Inherits:
-
Genomer::Plugin
- Object
- Genomer::Plugin
- GenomerPluginSummary::Gaps
show all
- Includes:
- Format
- Defined in:
- lib/genomer-plugin-summary/gaps.rb
Constant Summary
collapse
- COLUMNS =
[:number, :length, :start, :end, :type]
- FORMATTING =
{
:title => 'Scaffold Gaps',
:headers => ['Number', 'Length', 'Start', 'End', 'Type'],
:width => {
0 => 8,
1 => 8,
2 => 8,
3 => 8,
4 => 12
},
:justification => {
0 => :right,
1 => :right,
2 => :right,
3 => :right,
4 => :center
}
}
Constants included
from Format
Format::DEFAULTS
Instance Method Summary
collapse
Methods included from Format
#create_cells, #csv, #format_cell, #pretty, #table
Instance Method Details
#determine_gaps(scaffold) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/genomer-plugin-summary/gaps.rb', line 43
def determine_gaps(scaffold)
count = 0
length = 0
scaffold.map do |entry|
gaps = case entry.entry_type
when :sequence then
gap_locations(entry.sequence).map do |gap|
count += 1
{:number => count,
:length => (gap.end - gap.begin) + 1,
:start => gap.begin + length,
:end => gap.end + length,
:type => :contig}
end
when :unresolved then
count += 1
{:number => count,
:length => entry.sequence.length,
:start => length + 1,
:end => length + entry.sequence.length,
:type => :unresolved}
end
length += entry.sequence.length
gaps
end.flatten
end
|
#gap_locations(seq) ⇒ Object
37
38
39
40
41
|
# File 'lib/genomer-plugin-summary/gaps.rb', line 37
def gap_locations(seq)
seq.upcase.enum_for(:scan, /(N+)/).map do
(Regexp.last_match.begin(0)+1)..(Regexp.last_match.end(0))
end
end
|
#run ⇒ Object
7
8
9
|
# File 'lib/genomer-plugin-summary/gaps.rb', line 7
def run
tabulate(determine_gaps(scaffold),flags)
end
|
#tabulate(gaps, flags) ⇒ Object
32
33
34
35
|
# File 'lib/genomer-plugin-summary/gaps.rb', line 32
def tabulate(gaps,flags)
FORMATTING[:output] = flags[:output]
table(gaps.map{|gap| COLUMNS.map{|col| gap[col]}},FORMATTING)
end
|