Class: Chipgps

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

Defined Under Namespace

Classes: Event, Search

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Chipgps

End of Search class



52
53
54
55
56
57
58
59
# File 'lib/chipgps.rb', line 52

def initialize(file)
  @gps_out_file = file
  @lines = File.open(@gps_out_file).readlines
  @header = @lines.shift

  @num_of_conditions = num_of_conditions
  @num_of_events     = num_of_events
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



60
61
62
# File 'lib/chipgps.rb', line 60

def header
  @header
end

Instance Method Details

#each_by_condition(condition_id) ⇒ Object

condition_id starts from 0



73
74
75
76
77
# File 'lib/chipgps.rb', line 73

def each_by_condition(condition_id) # condition_id starts from 0
  @lines.each_with_index do |line, idx|
    yield Chipgps::Search.new(line, {:condition => condition_id, :event => idx})
  end
end

#num_of_conditionsObject



62
63
64
65
66
67
# File 'lib/chipgps.rb', line 62

def num_of_conditions
  f = @lines[0].split(/\t/)
  num_of_conditions = (f.size - 2) / 9  # each condition has 9 cols
  # pp f.size
  return num_of_conditions
end

#num_of_eventsObject



69
70
71
# File 'lib/chipgps.rb', line 69

def num_of_events
  return @lines.size
end