Class: Bio::DB::Alignment

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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])
    tags[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

#alObject

Returns the value of attribute al.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def al
  @al
end

#calendObject

Returns the value of attribute calend.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def calend
  @calend
end

#cigarObject

Returns the value of attribute cigar.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def cigar
  @cigar
end

#failed_qualityObject

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_pairObject

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

#flagObject

Returns the value of attribute flag.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def flag
  @flag
end

#is_duplicateObject

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_mappedObject

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_pairedObject

Returns the value of attribute is_paired.



21
22
23
# File 'lib/bio/db/alignment.rb', line 21

def is_paired
  @is_paired
end

#isizeObject

Returns the value of attribute isize.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def isize
  @isize
end

#mapqObject

Returns the value of attribute mapq.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def mapq
  @mapq
end

#mate_strandObject

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_unmappedObject

Returns the value of attribute mate_unmapped.



21
22
23
# File 'lib/bio/db/alignment.rb', line 21

def mate_unmapped
  @mate_unmapped
end

#mposObject

Returns the value of attribute mpos.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def mpos
  @mpos
end

#mrnmObject

Returns the value of attribute mrnm.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def mrnm
  @mrnm
end

#posObject

Returns the value of attribute pos.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def pos
  @pos
end

#primaryObject

Returns the value of attribute primary.



21
22
23
# File 'lib/bio/db/alignment.rb', line 21

def primary
  @primary
end

#qlenObject

Returns the value of attribute qlen.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def qlen
  @qlen
end

#qnameObject

Returns the value of attribute qname.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def qname
  @qname
end

#qualObject

Returns the value of attribute qual.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def qual
  @qual
end

#query_strandObject

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_unmappedObject

Returns the value of attribute query_unmapped.



21
22
23
# File 'lib/bio/db/alignment.rb', line 21

def query_unmapped
  @query_unmapped
end

#rnameObject

Returns the value of attribute rname.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def rname
  @rname
end

#sam_stringObject

Returns the value of attribute sam_string.



21
22
23
# File 'lib/bio/db/alignment.rb', line 21

def sam_string
  @sam_string
end

#samstrObject

Returns the value of attribute samstr.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def samstr
  @samstr
end

#second_in_pairObject

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

#seqObject

Returns the value of attribute seq.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def seq
  @seq
end

#tagsObject

Returns the value of attribute tags.



19
20
21
# File 'lib/bio/db/alignment.rb', line 19

def tags
  @tags
end