Class: Bio::DB::Alignment
- Inherits:
-
Object
- Object
- Bio::DB::Alignment
- Defined in:
- lib/bio/db/alignment.rb
Overview
Attrobites frp, the flag field (see chapter 2.2.2 of the sam file documentation) query_strand and mate_strand are true if they are forward. It is the opposite to the definition in the BAM format for clarity. primary is the negation of is_negative from the BAM format
Instance Attribute Summary collapse
-
#al ⇒ Object
Returns the value of attribute al.
-
#calend ⇒ Object
Returns the value of attribute calend.
-
#cigar ⇒ Object
Returns the value of attribute cigar.
-
#failed_quality ⇒ Object
Returns the value of attribute failed_quality.
-
#first_in_pair ⇒ Object
Returns the value of attribute first_in_pair.
-
#flag ⇒ Object
Returns the value of attribute flag.
-
#is_duplicate ⇒ Object
Returns the value of attribute is_duplicate.
-
#is_mapped ⇒ Object
Returns the value of attribute is_mapped.
-
#is_paired ⇒ Object
Returns the value of attribute is_paired.
-
#isize ⇒ Object
Returns the value of attribute isize.
-
#mapq ⇒ Object
Returns the value of attribute mapq.
-
#mate_strand ⇒ Object
Returns the value of attribute mate_strand.
-
#mate_unmapped ⇒ Object
Returns the value of attribute mate_unmapped.
-
#mpos ⇒ Object
Returns the value of attribute mpos.
-
#mrnm ⇒ Object
Returns the value of attribute mrnm.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#primary ⇒ Object
Returns the value of attribute primary.
-
#qlen ⇒ Object
Returns the value of attribute qlen.
-
#qname ⇒ Object
Returns the value of attribute qname.
-
#qual ⇒ Object
Returns the value of attribute qual.
-
#query_strand ⇒ Object
Returns the value of attribute query_strand.
-
#query_unmapped ⇒ Object
Returns the value of attribute query_unmapped.
-
#rname ⇒ Object
Returns the value of attribute rname.
-
#sam_string ⇒ Object
Returns the value of attribute sam_string.
-
#samstr ⇒ Object
Returns the value of attribute samstr.
-
#second_in_pair ⇒ Object
Returns the value of attribute second_in_pair.
-
#seq ⇒ Object
Returns the value of attribute seq.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(sam_string) ⇒ Alignment
constructor
parses the SAM string into its constituents and set its attributes.
Constructor Details
#initialize(sam_string) ⇒ Alignment
parses the SAM string into its constituents and set its attributes
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bio/db/alignment.rb', line 24 def initialize(sam_string) s = sam_string.chomp.split("\t") @sam_string = sam_string @qname = s[0] @flag = s[1].to_i @rname = s[2] @pos = s[3].to_i @mapq = s[4].to_i @cigar = s[5] @mrnm = s[6] @mpos = s[7].to_i @isize = s[8].to_i @seq = s[9] @qual = s[10] @tags = {} 11.upto(s.size-1) {|n| t = Bio::DB::Tag.new t.set(s[n]) [t.tag] = t } @is_paired = (@flag & 0x0001) > 0 @is_mapped = @flag & 0x0002 > 0 @query_unmapped = @flag & 0x0004 > 0 @mate_unmapped = @flag & 0x0008 > 0 @query_strand = !(@flag & 0x0010 > 0) @mate_strand = !(@flag & 0x0020 > 0) @first_in_pair = @flag & 0x0040 > 0 @second_in_pair = @flag & 0x0080 > 0 @primary = !(@flag & 0x0100 > 0) @failed_quality = @flag & 0x0200 > 0 @is_duplicate = @flag & 0x0400 > 0 end |
Instance Attribute Details
#al ⇒ Object
Returns the value of attribute al.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def al @al end |
#calend ⇒ Object
Returns the value of attribute calend.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def calend @calend end |
#cigar ⇒ Object
Returns the value of attribute cigar.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def cigar @cigar end |
#failed_quality ⇒ Object
Returns the value of attribute failed_quality.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def failed_quality @failed_quality end |
#first_in_pair ⇒ Object
Returns the value of attribute first_in_pair.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def first_in_pair @first_in_pair end |
#flag ⇒ Object
Returns the value of attribute flag.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def flag @flag end |
#is_duplicate ⇒ Object
Returns the value of attribute is_duplicate.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def is_duplicate @is_duplicate end |
#is_mapped ⇒ Object
Returns the value of attribute is_mapped.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def is_mapped @is_mapped end |
#is_paired ⇒ Object
Returns the value of attribute is_paired.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def is_paired @is_paired end |
#isize ⇒ Object
Returns the value of attribute isize.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def isize @isize end |
#mapq ⇒ Object
Returns the value of attribute mapq.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def mapq @mapq end |
#mate_strand ⇒ Object
Returns the value of attribute mate_strand.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def mate_strand @mate_strand end |
#mate_unmapped ⇒ Object
Returns the value of attribute mate_unmapped.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def mate_unmapped @mate_unmapped end |
#mpos ⇒ Object
Returns the value of attribute mpos.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def mpos @mpos end |
#mrnm ⇒ Object
Returns the value of attribute mrnm.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def mrnm @mrnm end |
#pos ⇒ Object
Returns the value of attribute pos.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def pos @pos end |
#primary ⇒ Object
Returns the value of attribute primary.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def primary @primary end |
#qlen ⇒ Object
Returns the value of attribute qlen.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def qlen @qlen end |
#qname ⇒ Object
Returns the value of attribute qname.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def qname @qname end |
#qual ⇒ Object
Returns the value of attribute qual.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def qual @qual end |
#query_strand ⇒ Object
Returns the value of attribute query_strand.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def query_strand @query_strand end |
#query_unmapped ⇒ Object
Returns the value of attribute query_unmapped.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def query_unmapped @query_unmapped end |
#rname ⇒ Object
Returns the value of attribute rname.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def rname @rname end |
#sam_string ⇒ Object
Returns the value of attribute sam_string.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def sam_string @sam_string end |
#samstr ⇒ Object
Returns the value of attribute samstr.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def samstr @samstr end |
#second_in_pair ⇒ Object
Returns the value of attribute second_in_pair.
21 22 23 |
# File 'lib/bio/db/alignment.rb', line 21 def second_in_pair @second_in_pair end |
#seq ⇒ Object
Returns the value of attribute seq.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def seq @seq end |
#tags ⇒ Object
Returns the value of attribute tags.
19 20 21 |
# File 'lib/bio/db/alignment.rb', line 19 def @tags end |