Class: HTS::Bam::Flag

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flag_value) ⇒ Flag

Returns a new instance of Flag.

Raises:

  • (TypeError)


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

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.



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

def value
  @value
end

Instance Method Details

#dup?Boolean

Returns:

  • (Boolean)


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

def dup?
  has_flag? LibHTS::BAM_FDUP
end

#has_flag?(m) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#mate_reverse?Boolean

Returns:

  • (Boolean)


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

def mate_reverse?
  has_flag? LibHTS::BAM_FMREVERSE
end

#mate_unmapped?Boolean

Returns:

  • (Boolean)


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

def mate_unmapped?
  has_flag? LibHTS::BAM_FMUNMAP
end

#paired?Boolean

TODO: Enabling bitwise operations hts-nim proc ‘and`*(f: Flag, o: uint16): uint16 borrow, inline . proc `and`*(f: Flag, o: Flag): uint16 borrow, inline . proc `or`*(f: Flag, o: uint16): uint16 borrow . proc `or`*(o: uint16, f: Flag): uint16 borrow . proc `==`*(f: Flag, o: Flag): bool borrow, inline . proc `==`*(f: Flag, o: uint16): bool borrow, inline . proc `==`*(o: uint16, f: Flag): bool borrow, inline .

Returns:

  • (Boolean)


40
41
42
# File 'lib/hts/bam/flag.rb', line 40

def paired?
  has_flag? LibHTS::BAM_FPAIRED
end

#proper_pair?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/hts/bam/flag.rb', line 44

def proper_pair?
  has_flag? LibHTS::BAM_FPROPER_PAIR
end

#qcfail?Boolean

Returns:

  • (Boolean)


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

def qcfail?
  has_flag? LibHTS::BAM_FQCFAIL
end

#read1?Boolean

Returns:

  • (Boolean)


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

def read1?
  has_flag? LibHTS::BAM_FREAD1
end

#read2?Boolean

Returns:

  • (Boolean)


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

def read2?
  has_flag? LibHTS::BAM_FREAD2
end

#reverse?Boolean

Returns:

  • (Boolean)


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

def reverse?
  has_flag? LibHTS::BAM_FREVERSE
end

#secondary?Boolean

Returns:

  • (Boolean)


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

def secondary?
  has_flag? LibHTS::BAM_FSECONDARY
end

#supplementary?Boolean

Returns:

  • (Boolean)


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

def supplementary?
  has_flag? LibHTS::BAM_FSUPPLEMENTARY
end

#to_sObject



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

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

#unmapped?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/hts/bam/flag.rb', line 48

def unmapped?
  has_flag? LibHTS::BAM_FUNMAP
end