Class: Minimap2::Alignment
- Inherits:
-
Object
- Object
- Minimap2::Alignment
- Defined in:
- lib/minimap2/alignment.rb
Overview
Alignment result.
Instance Attribute Summary collapse
-
#blen ⇒ Integer
Length of the alignment, including both alignment matches and gaps but excluding ambiguous bases.
-
#cigar ⇒ Array
CIGAR returned as an array of shape (n_cigar,2).
-
#cigar_str ⇒ String
CIGAR string.
-
#cs ⇒ String
The cs tag.
-
#ctg ⇒ String
Name of the reference sequence the query is mapped to.
-
#ctg_len ⇒ Integer
Total length of the reference sequence.
-
#mapq ⇒ Integer
Mapping quality.
-
#md ⇒ String
The MD tag as in the SAM format.
-
#mlen ⇒ Integer
Length of the matching bases in the alignment, excluding ambiguous base matches.
-
#nm ⇒ Integer
Number of mismatches, gaps and ambiguous positions in the alignment.
-
#primary ⇒ Integer
If the alignment is primary (typically the best and the first to generate).
-
#q_en ⇒ Integer
End positions on the query.
-
#q_st ⇒ Integer
Start positions on the query.
-
#r_en ⇒ Integer
End positions on the reference.
-
#r_st ⇒ Integer
Start positions on the reference.
-
#read_num ⇒ Integer
Read number that the alignment corresponds to; 1 for the first read and 2 for the second read.
-
#strand ⇒ Integer
+1 if on the forward strand; -1 if on the reverse strand.
-
#trans_strand ⇒ Integer
Transcript strand.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(h, cigar, cs = nil, md = nil) ⇒ Alignment
constructor
A new instance of Alignment.
- #primary? ⇒ Boolean
-
#to_h ⇒ Object
Convert Alignment to hash.
-
#to_s ⇒ Object
Convert to the PAF format without the QueryName and QueryLength columns.
Constructor Details
#initialize(h, cigar, cs = nil, md = nil) ⇒ Alignment
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/minimap2/alignment.rb', line 57 def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end |
Instance Attribute Details
#blen ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#cigar ⇒ Array
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#cigar_str ⇒ String
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#cs ⇒ String
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#ctg ⇒ String
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#ctg_len ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#mapq ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#md ⇒ String
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#mlen ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#nm ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#primary ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#q_en ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#q_st ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#r_en ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#r_st ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#read_num ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#strand ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
#trans_strand ⇒ Integer
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/minimap2/alignment.rb', line 49 class Alignment def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end attr_reader(*keys) def initialize(h, cigar, cs = nil, md = nil) @ctg = h[:ctg] @ctg_len = h[:ctg_len] @r_st = h[:ctg_start] @r_en = h[:ctg_end] @strand = h[:strand] @trans_strand = h[:trans_strand] @blen = h[:blen] @mlen = h[:mlen] @nm = h[:NM] @primary = h[:is_primary] @q_st = h[:qry_start] @q_en = h[:qry_end] @mapq = h[:mapq] @cigar = cigar @read_num = h[:seg_id] + 1 @cs = cs @md = md @cigar_str = cigar.map { |x| x[0].to_s + FFI::CIGAR_STR[x[1]] }.join end def primary? @primary == 1 end # Convert Alignment to hash. def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end # Convert to the PAF format without the QueryName and QueryLength columns. def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end end |
Class Method Details
.keys ⇒ Object
50 51 52 53 |
# File 'lib/minimap2/alignment.rb', line 50 def self.keys i[ctg ctg_len r_st r_en strand trans_strand blen mlen nm primary q_st q_en mapq cigar read_num cs md cigar_str] end |
Instance Method Details
#primary? ⇒ Boolean
79 80 81 |
# File 'lib/minimap2/alignment.rb', line 79 def primary? @primary == 1 end |
#to_h ⇒ Object
Convert Alignment to hash.
85 86 87 |
# File 'lib/minimap2/alignment.rb', line 85 def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end |
#to_s ⇒ Object
Convert to the PAF format without the QueryName and QueryLength columns.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/minimap2/alignment.rb', line 91 def to_s strand = if @strand > 0 "+" elsif @strand < 0 "-" else "?" end tp = @primary != 0 ? "tp:A:P" : "tp:A:S" ts = if @trans_strand > 0 "ts:A:+" elsif @trans_strand < 0 "ts:A:-" else "ts:A:." end a = [@q_st, @q_en, strand, @ctg, @ctg_len, @r_st, @r_en, @mlen, @blen, @mapq, tp, ts, "cg:Z:#{@cigar_str}"] a << "cs:Z:#{@cs}" if @cs a << "MD:Z:#{@md}" if @md a.join("\t") end |