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)
  Flag.new(@value & other.to_i)
end

#<<(f) ⇒ Object



87
88
89
# File 'lib/hts/bam/flag.rb', line 87

def <<(f)
  Flag.new(@value << f.to_i)
end

#>>(other) ⇒ Object



91
92
93
# File 'lib/hts/bam/flag.rb', line 91

def >>(other)
  Flag.new(@value >> other.to_i)
end

#^(other) ⇒ Object



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

def ^(other)
  Flag.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



95
96
97
# File 'lib/hts/bam/flag.rb', line 95

def to_i
  @value
end

#to_sObject



99
100
101
102
# File 'lib/hts/bam/flag.rb', line 99

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)
  Flag.new(@value | other.to_i)
end

#~Object



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

def ~
  Flag.new(~@value)
end