Skip to content

Commit

Permalink
remove mapping count if there ontologies does no more exist
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 2, 2024
1 parent 376c261 commit 70565c2
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/ontologies_linked_data/concerns/mappings/mapping_counts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def create_mapping_count_totals_for_ontologies(logger, arr_acronyms)
persistent_counts[m.ontologies.first] = m
end

# ontologies = LinkedData::Models::Ontology.where.include(:acronym).all.map(&:acronym)
# delete_zombie_mapping_count(persistent_counts.values, ontologies)
ontologies = LinkedData::Models::Ontology.where.include(:acronym).all.map(&:acronym)
delete_zombie_mapping_count(persistent_counts.values, ontologies)

num_counts = new_counts.keys.length
ctr = 0
Expand Down Expand Up @@ -182,7 +182,7 @@ def create_mapping_count_pairs_for_ontologies(logger, arr_acronyms)
persistent_counts[other] = m
end

# delete_zombie_mapping_count(persistent_counts.values, ontologies)
delete_zombie_mapping_count(persistent_counts.values, ontologies)

num_counts = new_counts.keys.length
logger.info("Ontology: #{acr}. #{num_counts} mapping pair counts to record...")
Expand Down Expand Up @@ -252,7 +252,23 @@ def create_mapping_count_pairs_for_ontologies(logger, arr_acronyms)
# fsave.close
end

private

def delete_zombie_mapping_count(mappings_count, ontologies)
special_mappings = ["http://data.bioontology.org/metadata/ExternalMappings",
"http://data.bioontology.org/metadata/InterportalMappings/agroportal",
"http://data.bioontology.org/metadata/InterportalMappings/ncbo",
"http://data.bioontology.org/metadata/InterportalMappings/sifr"]

mappings_count.each do |mapping|
next mapping if mapping.ontologies.all? { |x| ontologies.include?(x) }
next mapping if mapping.ontologies.size == 1 && !(mapping.ontologies & special_mappings).empty?

next mapping unless mapping.persistent?

mapping.delete
end
end
end
end
end
Expand Down

0 comments on commit 70565c2

Please sign in to comment.