Class: HTS::Bam::Flag

Inherits:
Object
  • Object
show all
Defined in:
lib/hts/bam/flag.rb

Overview

SAM flags

Constant Summary collapse

TABLE =

BAM_FPAIRED = 1 BAM_FPROPER_PAIR = 2 BAM_FUNMAP = 4 BAM_FMUNMAP = 8 BAM_FREVERSE = 16 BAM_FMREVERSE = 32 BAM_FREAD1 = 64 BAM_FREAD2 = 128 BAM_FSECONDARY = 256 BAM_FQCFAIL = 512 BAM_FDUP = 1024 BAM_FSUPPLEMENTARY = 2048

{ paired?: LibHTS::BAM_FPAIRED,
proper_pair?: LibHTS::BAM_FPROPER_PAIR,
unmapped?: LibHTS::BAM_FUNMAP,
mate_unmapped?: LibHTS::BAM_FMUNMAP,
reverse?: LibHTS::BAM_FREVERSE,
mate_reverse?: LibHTS::BAM_FMREVERSE,
read1?: LibHTS::BAM_FREAD1,
read2?: LibHTS::BAM_FREAD2,
secondary?: LibHTS::BAM_FSECONDARY,
qcfail?: LibHTS::BAM_FQCFAIL,
duplicate?: LibHTS::BAM_FDUP,
supplementary?: LibHTS::BAM_FSUPPLEMENTARY }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flag_value) ⇒ Flag

Returns a new instance of Flag.

Raises:

  • (TypeError)


10
11
12
13
14
# File 'lib/hts/bam/flag.rb', line 10

def initialize(flag_value)
  raise TypeError unless flag_value.is_a? Integer

  @value = flag_value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



16
17
18
# File 'lib/hts/bam/flag.rb', line 16

def value
  @value
end

Instance Method Details

#&(other) ⇒ Object



71
72
73
# File 'lib/hts/bam/flag.rb', line 71

def &(other)
  self.class.new(@value & other.to_i)
end

#<<(f) ⇒ Object



89
90
91
# File 'lib/hts/bam/flag.rb', line 89

def <<(f)
  self.class.new(@value << f.to_i)
end

#>>(other) ⇒ Object



93
94
95
# File 'lib/hts/bam/flag.rb', line 93

def >>(other)
  self.class.new(@value >> other.to_i)
end

#^(other) ⇒ Object



79
80
81
# File 'lib/hts/bam/flag.rb', line 79

def ^(other)
  self.class.new(@value ^ other.to_i)
end

#duplicate?Boolean

Returns:

  • (Boolean)


64
# File 'lib/hts/bam/flag.rb', line 64

generate :duplicate?

#has_flag?(f) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/hts/bam/flag.rb', line 67

def has_flag?(f)
  (@value & f) != 0
end

#mate_reverse?Boolean

Returns:

  • (Boolean)


59
# File 'lib/hts/bam/flag.rb', line 59

generate :mate_reverse?

#mate_unmapped?Boolean

Returns:

  • (Boolean)


57
# File 'lib/hts/bam/flag.rb', line 57

generate :mate_unmapped?

#paired?Boolean

Returns:

  • (Boolean)


54
# File 'lib/hts/bam/flag.rb', line 54

generate :paired?

#proper_pair?Boolean

Returns:

  • (Boolean)


55
# File 'lib/hts/bam/flag.rb', line 55

generate :proper_pair?

#qcfail?Boolean

Returns:

  • (Boolean)


63
# File 'lib/hts/bam/flag.rb', line 63

generate :qcfail?

#read1?Boolean

Returns:

  • (Boolean)


60
# File 'lib/hts/bam/flag.rb', line 60

generate :read1?

#read2?Boolean

Returns:

  • (Boolean)


61
# File 'lib/hts/bam/flag.rb', line 61

generate :read2?

#reverse?Boolean

Returns:

  • (Boolean)


58
# File 'lib/hts/bam/flag.rb', line 58

generate :reverse?

#secondary?Boolean

Returns:

  • (Boolean)


62
# File 'lib/hts/bam/flag.rb', line 62

generate :secondary?

#supplementary?Boolean

Returns:

  • (Boolean)


65
# File 'lib/hts/bam/flag.rb', line 65

generate :supplementary?

#to_iObject



97
98
99
# File 'lib/hts/bam/flag.rb', line 97

def to_i
  @value
end

#to_sObject



101
102
103
104
# File 'lib/hts/bam/flag.rb', line 101

def to_s
  LibHTS.bam_flag2str(@value)
  # "0x#{format('%x', @value)}\t#{@value}\t#{LibHTS.bam_flag2str(@value)}"
end

#unmapped?Boolean

Returns:

  • (Boolean)


56
# File 'lib/hts/bam/flag.rb', line 56

generate :unmapped?

#|(other) ⇒ Object



75
76
77
# File 'lib/hts/bam/flag.rb', line 75

def |(other)
  self.class.new(@value | other.to_i)
end

#~Object



83
84
85
86
87
# File 'lib/hts/bam/flag.rb', line 83

def ~
  # FIXME: Only 12bits are used for flags
  # The result is different from the Crystal version.
  self.class.new(~@value)
end