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.
229 230 231 232 |
# File 'lib/bio/db/sam.rb', line 229 def initialize ObjectSpace.define_finalizer(self, self.class.method(:finalize).to_proc) end |
Instance Attribute Details
#al ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 def al @al end |
#calend ⇒ Object
Attributes pulled with the C library
249 250 251 |
# File 'lib/bio/db/sam.rb', line 249 def calend @calend end |
#cigar ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 def first_in_pair @first_in_pair end |
#flag ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 def is_paired @is_paired end |
#isize ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 def isize @isize end |
#mapq ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 def mate_unmapped @mate_unmapped end |
#mpos ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 def mpos @mpos end |
#mrnm ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 def mrnm @mrnm end |
#pos ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 def primary @primary end |
#qlen ⇒ Object
Attributes pulled with the C library
249 250 251 |
# File 'lib/bio/db/sam.rb', line 249 def qlen @qlen end |
#qname ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 def qname @qname end |
#qual ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 def query_unmapped @query_unmapped end |
#rname ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 def rname @rname end |
#samstr ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 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
253 254 255 |
# File 'lib/bio/db/sam.rb', line 253 def second_in_pair @second_in_pair end |
#seq ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 def seq @seq end |
#tags ⇒ Object
Attributes from the format
247 248 249 |
# File 'lib/bio/db/sam.rb', line 247 def @tags end |
Class Method Details
.finalize(object_id) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/bio/db/sam.rb', line 233 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
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/bio/db/sam.rb', line 287 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
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/bio/db/sam.rb', line 255 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 |