Class: Bio::DB::Pileup
- Inherits:
-
Object
- Object
- Bio::DB::Pileup
- Defined in:
- lib/bio/db/pileup.rb
Instance Attribute Summary collapse
-
#ar1 ⇒ Object
Returns the value of attribute ar1.
-
#ar2 ⇒ Object
Returns the value of attribute ar2.
-
#ar3 ⇒ Object
Returns the value of attribute ar3.
-
#consensus ⇒ Object
returns the consensus (most frequent) base from the pileup, if there are equally represented bases returns a string containing all equally represented bases in alphabetical order.
-
#consensus_quality ⇒ Object
Returns the value of attribute consensus_quality.
-
#coverage ⇒ Object
Returns the value of attribute coverage.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#read_bases ⇒ Object
Returns the value of attribute read_bases.
-
#read_quals ⇒ Object
Returns the value of attribute read_quals.
-
#ref_base ⇒ Object
Returns the value of attribute ref_base.
-
#ref_name ⇒ Object
Returns the value of attribute ref_name.
-
#rms_mapq ⇒ Object
Returns the value of attribute rms_mapq.
-
#snp_quality ⇒ Object
Returns the value of attribute snp_quality.
Instance Method Summary collapse
-
#initialize(pile_up_line) ⇒ Pileup
constructor
creates the Pileup object pile_up_line = “seq2t151tGtGt36t0t99t12t.….……At:9<;;7=<<<<<” pile = Bio::DB::Pileup.new(pile_up_line).
-
#non_ref_count ⇒ Object
returns the total non-reference bases in the reads at this position.
-
#non_refs ⇒ Object
Calculate the total count of each non-reference nucleotide and return a hash of all 4 nt counts, returns a hash pile.non_refs #=> 1, :C => 0, :T => 0, :G => 0.
-
#ref_count ⇒ Object
returns the count of reference-bases in the reads at this position.
Constructor Details
#initialize(pile_up_line) ⇒ Pileup
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bio/db/pileup.rb', line 35 def initialize(pile_up_line) cols = pile_up_line.split(/\t/) if cols.length == 6 ##should only be able to get 6 lines from mpileup @ref_name, @pos, @ref_base, @coverage, @read_bases, @read_quals = cols elsif (10..13).include?(cols.length) ##incase anyone tries to use deprecated pileup with -c flag we get upto 13 cols... @ref_name, @pos, @ref_base, @consensus, @consensus_quality, @snp_quality, @rms_mapq, @coverage, @read_bases, @read_quals, @ar1, @ar2, @ar3 = cols @consensus_quality = @consensus_quality.to_f @snp_quality = @snp_quality.to_f @rms_mapq = @rms_mapq.to_f else #raise RuntimeError, "parsing line '#{pile_up_line.chomp}' failed" end @pos = @pos.to_i @coverage = @coverage.to_f @ref_count = nil @non_ref_count_hash = nil @non_ref_count = nil end |
Instance Attribute Details
#ar1 ⇒ Object
Returns the value of attribute ar1.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def ar1 @ar1 end |
#ar2 ⇒ Object
Returns the value of attribute ar2.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def ar2 @ar2 end |
#ar3 ⇒ Object
Returns the value of attribute ar3.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def ar3 @ar3 end |
#consensus ⇒ Object
returns the consensus (most frequent) base from the pileup, if there are equally represented bases returns a string containing all equally represented bases in alphabetical order
81 82 83 |
# File 'lib/bio/db/pileup.rb', line 81 def consensus @consensus end |
#consensus_quality ⇒ Object
Returns the value of attribute consensus_quality.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def consensus_quality @consensus_quality end |
#coverage ⇒ Object
Returns the value of attribute coverage.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def coverage @coverage end |
#pos ⇒ Object
Returns the value of attribute pos.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def pos @pos end |
#read_bases ⇒ Object
Returns the value of attribute read_bases.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def read_bases @read_bases end |
#read_quals ⇒ Object
Returns the value of attribute read_quals.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def read_quals @read_quals end |
#ref_base ⇒ Object
Returns the value of attribute ref_base.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def ref_base @ref_base end |
#ref_name ⇒ Object
Returns the value of attribute ref_name.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def ref_name @ref_name end |
#rms_mapq ⇒ Object
Returns the value of attribute rms_mapq.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def rms_mapq @rms_mapq end |
#snp_quality ⇒ Object
Returns the value of attribute snp_quality.
30 31 32 |
# File 'lib/bio/db/pileup.rb', line 30 def snp_quality @snp_quality end |
Instance Method Details
#non_ref_count ⇒ Object
returns the total non-reference bases in the reads at this position
65 66 67 68 69 70 |
# File 'lib/bio/db/pileup.rb', line 65 def non_ref_count if @non_ref_count.nil? @non_ref_count = @read_bases.count("ATGCatgc").to_f end @non_ref_count end |
#non_refs ⇒ Object
Calculate the total count of each non-reference nucleotide and return a hash of all 4 nt counts, returns a hash
pile.non_refs #{:A => 1, :C => 0, :T => 0, :G => 0}
57 58 59 60 61 62 |
# File 'lib/bio/db/pileup.rb', line 57 def non_refs if @non_ref_count_hash.nil? @non_ref_count_hash = {:A => self.read_bases.count("Aa"), :C => self.read_bases.count("Cc"), :G => self.read_bases.count("Gg"), :T => self.read_bases.count("Tt")} end @non_ref_count_hash end |
#ref_count ⇒ Object
returns the count of reference-bases in the reads at this position
73 74 75 76 77 78 |
# File 'lib/bio/db/pileup.rb', line 73 def ref_count if @ref_count.nil? @ref_count = self.read_bases.count(".,") end @ref_count end |