Module: TaxonWorks::Analysis::AssertedDistribution::BasicEndemism

Defined in:
lib/analysis/asserted_distribution/basic_endemism.rb

Class Method Summary collapse

Class Method Details

.quick_endemism(taxon_name, geographic_area) ⇒ Hash

Returns a very simple report summarizing asserted distributions !! only a single geographic area is used (not its children)

Parameters:

  • taxon_name (TaxonName)

    required

  • geographic_area (GeographicArea)

    required

Returns:

  • (Hash)

    a very simple report summarizing asserted distributions !! only a single geographic area is used (not its children)



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/analysis/asserted_distribution/basic_endemism.rb', line 12

def self.quick_endemism(taxon_name, geographic_area) 
  data = {  }

  ::AssertedDistribution.where(
    geographic_area: geographic_area,
    project: taxon_name.project,
    otu: Otu.descendant_of_taxon_name(taxon_name.id) 
  ).each do |a|
    e = ::AssertedDistribution.where(project: taxon_name.project, otu: a.otu).where.not(geographic_area: geographic_area).count
    n = a.otu.taxon_name.valid_taxon_name
    if e == 0 && !data[n]
      data[n] = false 
    else
      data[n] = true 
    end
  end
  data
end