Class: Bio::DB::Alignment
- Inherits:
-
Object
- Object
- Bio::DB::Alignment
- Defined in:
- lib/bio/db/sam.rb
Instance Attribute Summary collapse
-
#al ⇒ Object
Attributes from the format.
-
#calend ⇒ Object
Attributes pulled with the C library.
-
#cigar ⇒ Object
Attributes from the format.
-
#failed_quality ⇒ Object
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.
-
#first_in_pair ⇒ Object
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.
-
#flag ⇒ Object
Attributes from the format.
-
#is_duplicate ⇒ Object
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.
-
#is_mapped ⇒ Object
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.
-
#is_paired ⇒ Object
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.
-
#isize ⇒ Object
Attributes from the format.
-
#mapq ⇒ Object
Attributes from the format.
-
#mate_strand ⇒ Object
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.
-
#mate_unmapped ⇒ Object
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.
-
#mpos ⇒ Object
Attributes from the format.
-
#mrnm ⇒ Object
Attributes from the format.
-
#pos ⇒ Object
Attributes from the format.
-
#primary ⇒ Object
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.
-
#qlen ⇒ Object
Attributes pulled with the C library.
-
#qname ⇒ Object
Attributes from the format.
-
#qual ⇒ Object
Attributes from the format.
-
#query_strand ⇒ Object
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.
-
#query_unmapped ⇒ Object
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.
-
#rname ⇒ Object
Attributes from the format.
-
#samstr ⇒ Object
Attributes from the format.
-
#second_in_pair ⇒ Object
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.
-
#seq ⇒ Object
Attributes from the format.
-
#tags ⇒ Object
Attributes from the format.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Alignment
constructor
A new instance of Alignment.
- #sam=(sam) ⇒ Object
- #set(bam_alignment, header) ⇒ Object
Constructor Details
#initialize ⇒ Alignment
Returns a new instance of Alignment.
559 560 561 562 |
# File 'lib/bio/db/sam.rb', line 559 def initialize ObjectSpace.define_finalizer(self, self.class.method(:finalize).to_proc) end |
Instance Attribute Details
#al ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def al @al end |
#calend ⇒ Object
Attributes pulled with the C library
579 580 581 |
# File 'lib/bio/db/sam.rb', line 579 def calend @calend end |
#cigar ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def cigar @cigar end |
#failed_quality ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def failed_quality @failed_quality end |
#first_in_pair ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def first_in_pair @first_in_pair end |
#flag ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def flag @flag end |
#is_duplicate ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def is_duplicate @is_duplicate end |
#is_mapped ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def is_mapped @is_mapped end |
#is_paired ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def is_paired @is_paired end |
#isize ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def isize @isize end |
#mapq ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def mapq @mapq end |
#mate_strand ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def mate_strand @mate_strand end |
#mate_unmapped ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def mate_unmapped @mate_unmapped end |
#mpos ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def mpos @mpos end |
#mrnm ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def mrnm @mrnm end |
#pos ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def pos @pos end |
#primary ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def primary @primary end |
#qlen ⇒ Object
Attributes pulled with the C library
579 580 581 |
# File 'lib/bio/db/sam.rb', line 579 def qlen @qlen end |
#qname ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def qname @qname end |
#qual ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def qual @qual end |
#query_strand ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def query_strand @query_strand end |
#query_unmapped ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def query_unmapped @query_unmapped end |
#rname ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def rname @rname end |
#samstr ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def samstr @samstr end |
#second_in_pair ⇒ Object
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
583 584 585 |
# File 'lib/bio/db/sam.rb', line 583 def second_in_pair @second_in_pair end |
#seq ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def seq @seq end |
#tags ⇒ Object
Attributes from the format
577 578 579 |
# File 'lib/bio/db/sam.rb', line 577 def @tags end |
Class Method Details
.finalize(object_id) ⇒ Object
563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/bio/db/sam.rb', line 563 def Alignment.finalize(object_id) # puts "Object #{object_id} dying at #{Time.new}" # p "?" . object_id.al # p object_id.al LibC.free object_id.al LibC.free object_id.sam LibC.free object_id.calend LibC.free object_id.qlen LibC.free object_id.samstr end |
Instance Method Details
#sam=(sam) ⇒ Object
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 |
# File 'lib/bio/db/sam.rb', line 617 def sam=(sam) #p sam s = sam.split("\t") self.qname = s[0] self.flag = s[1].to_i self.rname = s[2] self.pos = s[3].to_i self.mapq = s[4].to_i self.cigar = s[5] self.mrnm = s[6] self.mpos = s[7].to_i self.isize = s[8].to_i self.seq = s[9] self.qual = s[10] self. = {} 11.upto(s.size-1) {|n| t = Tag.new t.set(s[n]) [t.tag] = t } #<QNAME> <FLAG> <RNAME> <POS> <MAPQ> <CIGAR> <MRNM> <MPOS> <ISIZE> <SEQ> <QUAL> \ #[<TAG>:<VTYPE>:<VALUE> [...]] end |
#set(bam_alignment, header) ⇒ Object
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/bio/db/sam.rb', line 585 def set(bam_alignment, header) #Create the FFI object @al = Bio::DB::SAM::Tools::Bam1T.new(bam_alignment) #set the raw data tmp_str = Bio::DB::SAM::Tools.bam_format1(header,al) #self.sam = tmp_str #ObjectSpace.define_finalizer(self, proc {|id| puts "Finalizer one on #{id}" }) self.sam = String.new(tmp_str) #LibC.free tmp_str #Set values calculated by libbam core = al[:core] cigar = al[:data][core[:l_qname]]#define bam1_cigar(b) ((uint32_t*)((b)->data + (b)->core.l_qname)) @calend = Bio::DB::SAM::Tools.bam_calend(core,cigar) @qlen = Bio::DB::SAM::Tools.bam_cigar2qlen(core,cigar) #process the flags @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 |