Class: Minimap2::Alignment

Inherits:
Object
  • Object
show all
Defined in:
lib/minimap2/alignment.rb

Overview

Alignment result.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#blenInteger



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

#cigarArray



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_strString



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

#csString



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

#ctgString



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_lenInteger



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

#mapqInteger



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

#mdString



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

#mlenInteger



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

#nmInteger



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

#primaryInteger



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_enInteger



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_stInteger



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_enInteger



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_stInteger



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_numInteger



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

#strandInteger



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_strandInteger



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

.keysObject



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_hObject

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_sObject

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