Class: HTS::Bam::Alignment
- Inherits:
-
Object
- Object
- HTS::Bam::Alignment
- Defined in:
- lib/hts/bam/alignment.rb
Class Method Summary collapse
-
.rom_sam_str ⇒ Object
def initialize_copy super end.
Instance Method Summary collapse
- #base_at(n) ⇒ Object
- #base_qualities ⇒ Object
- #base_quality_at(n) ⇒ Object
-
#chrom ⇒ Object
returns the chromosome or ” if not mapped.
-
#cigar ⇒ Object
returns a
Cigarobject. -
#flag ⇒ Object
returns a
Flagobject. - #flag_str ⇒ Object
-
#initialize(bam1_t, bam_hdr_t) ⇒ Alignment
constructor
A new instance of Alignment.
-
#isize ⇒ Object
insert size.
-
#mapping_quality ⇒ Object
mapping quality.
-
#mate_chrom ⇒ Object
returns the chromosome of the mate or ” if not mapped.
-
#mate_pos ⇒ Object
mate position.
-
#mate_tid ⇒ Object
returns the tid of the mate or -1 if not mapped.
- #qlen ⇒ Object
-
#qname ⇒ Object
Read (query) name.
- #rlen ⇒ Object
-
#sequence ⇒ Object
return the read sequence.
-
#start ⇒ Object
returns 0-based start position.
-
#stop ⇒ Object
returns end position of the read.
- #strand ⇒ Object
- #tags ⇒ Object
-
#tid ⇒ Object
returns the tid of the alignment or -1 if not mapped.
Constructor Details
#initialize(bam1_t, bam_hdr_t) ⇒ Alignment
Returns a new instance of Alignment.
9 10 11 12 |
# File 'lib/hts/bam/alignment.rb', line 9 def initialize(bam1_t, bam_hdr_t) @b = bam1_t @h = bam_hdr_t end |
Class Method Details
.rom_sam_str ⇒ Object
def initialize_copy
super
end
18 |
# File 'lib/hts/bam/alignment.rb', line 18 def self.rom_sam_str; end |
Instance Method Details
#base_at(n) ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/hts/bam/alignment.rb', line 119 def base_at(n) n += @b[:core][:l_qseq] if n < 0 seq_nt16_str = '=ACMGRSVTWYHKDBN' return '.' if (n >= @b[:core][:l_qseq]) || (n < 0) # eg. base_at(-1000) r = FFI.bam_get_seq(@b) seq_nt16_str[FFI.bam_seqi(r, n)] end |
#base_qualities ⇒ Object
128 129 130 131 |
# File 'lib/hts/bam/alignment.rb', line 128 def base_qualities q_ptr = FFI.bam_get_qual(@b) q_ptr.read_array_of_uint8(@b[:core][:l_qseq]) end |
#base_quality_at(n) ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/hts/bam/alignment.rb', line 133 def base_quality_at(n) n += @b[:core][:l_qseq] if n < 0 # eg. base_quality_at(-1000) return 0 if (n >= @b[:core][:l_qseq]) || (n < 0) q_ptr = FFI.bam_get_qual(@b) q_ptr.get_uint8(n) end |
#chrom ⇒ Object
returns the chromosome or ” if not mapped.
66 67 68 69 70 71 |
# File 'lib/hts/bam/alignment.rb', line 66 def chrom tid = @b[:core][:tid] return '' if tid == -1 FFI.sam_hdr_tid2name(@h, tid) end |
#cigar ⇒ Object
returns a Cigar object.
92 93 94 |
# File 'lib/hts/bam/alignment.rb', line 92 def cigar Cigar.new(FFI.bam_get_cigar(@b), @b[:core][:n_cigar]) end |
#flag ⇒ Object
returns a Flag object.
146 147 148 |
# File 'lib/hts/bam/alignment.rb', line 146 def flag @b[:core][:flag] end |
#flag_str ⇒ Object
141 142 143 |
# File 'lib/hts/bam/alignment.rb', line 141 def flag_str FFI.bam_flag2str(flag) end |
#isize ⇒ Object
insert size
82 83 84 |
# File 'lib/hts/bam/alignment.rb', line 82 def isize @b[:core][:isize] end |
#mapping_quality ⇒ Object
mapping quality
87 88 89 |
# File 'lib/hts/bam/alignment.rb', line 87 def mapping_quality @b[:core][:qual] end |
#mate_chrom ⇒ Object
returns the chromosome of the mate or ” if not mapped.
33 34 35 36 37 38 |
# File 'lib/hts/bam/alignment.rb', line 33 def mate_chrom tid = @b[:core][:mtid] return '' if tid == -1 FFI.sam_hdr_tid2name(@h, tid) end |
#mate_pos ⇒ Object
mate position
51 52 53 |
# File 'lib/hts/bam/alignment.rb', line 51 def mate_pos @b[:core][:mpos] end |
#mate_tid ⇒ Object
returns the tid of the mate or -1 if not mapped.
41 42 43 |
# File 'lib/hts/bam/alignment.rb', line 41 def mate_tid @b[:core][:mtid] end |
#qlen ⇒ Object
96 97 98 99 100 101 |
# File 'lib/hts/bam/alignment.rb', line 96 def qlen FFI.bam_cigar2qlen( @b[:core][:n_cigar], FFI.bam_get_cigar(@b) ) end |
#qname ⇒ Object
Read (query) name.
23 24 25 |
# File 'lib/hts/bam/alignment.rb', line 23 def qname FFI.bam_get_qname(@b).read_string end |
#rlen ⇒ Object
103 104 105 106 107 108 |
# File 'lib/hts/bam/alignment.rb', line 103 def rlen FFI.bam_cigar2rlen( @b[:core][:n_cigar], FFI.bam_get_cigar(@b) ) end |
#sequence ⇒ Object
return the read sequence
111 112 113 114 115 116 117 |
# File 'lib/hts/bam/alignment.rb', line 111 def sequence seq_nt16_str = '=ACMGRSVTWYHKDBN' r = FFI.bam_get_seq(@b) Array.new(@b[:core][:l_qseq]) do |i| seq_nt16_str[FFI.bam_seqi(r, i)] end.join end |
#start ⇒ Object
returns 0-based start position.
56 57 58 |
# File 'lib/hts/bam/alignment.rb', line 56 def start @b[:core][:pos] end |
#stop ⇒ Object
returns end position of the read.
61 62 63 |
# File 'lib/hts/bam/alignment.rb', line 61 def stop FFI.bam_endpos @b end |
#strand ⇒ Object
73 74 75 |
# File 'lib/hts/bam/alignment.rb', line 73 def strand FFI.bam_is_rev(@b) ? '-' : '+' end |
#tags ⇒ Object
20 |
# File 'lib/hts/bam/alignment.rb', line 20 def ; end |
#tid ⇒ Object
returns the tid of the alignment or -1 if not mapped.
46 47 48 |
# File 'lib/hts/bam/alignment.rb', line 46 def tid @b[:core][:tid] end |