Method: InterMine::PathQuery::Query#summarise

Defined in:
lib/intermine/query.rb

#summarise(path, start = 0, size = nil) ⇒ Object

Return a summary for a column as a Hash

For numeric values the hash has four keys: “average”, “stdev”, “min”, and “max”.

summary = query.summarise("length")
puts summary["average"]

For non-numeric values, the hash will have each possible value as a key, and the count of the occurrences of that value in this query’s result set as the corresponding value:

summary = query.summarise("chromosome.primaryIdentifier")
puts summary["2L"]

To limit the size of the result set you can use start and size as per normal queries - this has no real effect with numeric queries, which always return the same information.



537
538
539
540
541
542
543
544
# File 'lib/intermine/query.rb', line 537

def summarise(path, start=0, size=nil)
    t = make_path(add_prefix(path)).end_type
    if InterMine::Metadata::Model::NUMERIC_TYPES.include? t
        return Hash[summaries(path, start, size).first.map {|k, v| [k, v.to_f]}]
    else
        return Hash[summaries(path, start, size).map {|sum| [sum["item"], sum["count"]]}]
    end
end