Class: Bio::Bam::QueryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-sambamba/filtering.rb

Constant Summary collapse

@@default_value =
{ :ref_id          =>  -1,
  :mate_ref_id     =>  -1,
  :position        =>   0,
  :mate_position   =>   0,
  :template_length =>   0,
  :mapping_quality => 255
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQueryBuilder

Returns a new instance of QueryBuilder.



56
57
58
59
60
61
62
63
# File 'lib/bio-sambamba/filtering.rb', line 56

def initialize
  @subexpressions = []
  class << @subexpressions
    def pjoin str
      self.map{|expr| '(' + expr + ')'}.join str
    end
  end
end

Instance Attribute Details

#subexpressionsObject

Returns the value of attribute subexpressions.



54
55
56
# File 'lib/bio-sambamba/filtering.rb', line 54

def subexpressions
  @subexpressions
end

Instance Method Details

#expressionObject



129
130
131
# File 'lib/bio-sambamba/filtering.rb', line 129

def expression
  subexpressions.pjoin ' and '
end

#flagObject



65
66
67
# File 'lib/bio-sambamba/filtering.rb', line 65

def flag
  FlagQueryBuilder.new(self)
end

#intersection(&block) ⇒ Object



123
124
125
126
127
# File 'lib/bio-sambamba/filtering.rb', line 123

def intersection &block
  qb = QueryBuilder.new
  qb.instance_eval &block
  @subexpressions << (qb.subexpressions.pjoin ' and ')
end

#negate(&block) ⇒ Object



110
111
112
113
114
# File 'lib/bio-sambamba/filtering.rb', line 110

def negate &block
  qb = QueryBuilder.new
  qb.instance_eval &block
  @subexpressions << ('not (' + qb.expression + ')')
end

#tag(tagname) ⇒ Object



69
70
71
# File 'lib/bio-sambamba/filtering.rb', line 69

def tag tagname
  TagQueryBuilder.new(self, tagname)
end

#union(&block) ⇒ Object



116
117
118
119
120
121
# File 'lib/bio-sambamba/filtering.rb', line 116

def union &block
  qb = QueryBuilder.new
  qb.instance_eval &block
  @subexpressions << (qb.subexpressions.pjoin ' or ')
  nil
end