Skip to content

Commit

Permalink
work in chunks when verify if class exists and to construct suggestio…
Browse files Browse the repository at this point in the history
…n graph (#321)

Co-authored-by: Anita Caron <[email protected]>
  • Loading branch information
Anita Caron and anitacaron authored May 1, 2024
1 parent 7743578 commit 3948fff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/template_generation_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame, log_dict: dict):
terms.add(r['o'])

# ENTITY CHECK
no_valid_class = ug.query_uberon(" ".join(terms), ug.select_class)
if len(terms) > 90:
for chunk in chunks(list(terms), 90):
no_valid_class = ug.query_uberon(" ".join(chunk), ug.select_class)
else:
no_valid_class = ug.query_uberon(" ".join(chunk), ug.select_class)

del_index = []
for t in no_valid_class:
Expand Down
15 changes: 12 additions & 3 deletions src/uberongraph_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,19 @@ def get_suggestion_graph(self, all_as, terms_as_d, all_ct, terms_ct, terms_ct_d)


if len(terms_ct_d) > 20:
for chunk in chunks(list(terms_ct_d), 30):
sec_graph += self.construct_relation(subject="\n".join(chunk), objects="\n".join(list(all_ct)), property="rdfs:subClassOf")
for chunk in chunks(list(terms_ct_d), 20):
if len(all_ct) > 90:
for chunck in chunks(list(all_ct), 90):
sec_graph += self.construct_relation(subject="\n".join(chunk), objects="\n".join(list(chunck)), property="rdfs:subClassOf")
else:
sec_graph += self.construct_relation(subject="\n".join(chunk), objects="\n".join(list(all_ct)), property="rdfs:subClassOf")
else:
sec_graph += self.construct_relation(subject="\n".join(terms_ct_d), objects="\n".join(list(all_ct)), property="rdfs:subClassOf")
if len(all_ct) > 90:
for chunck in chunks(list(all_ct), 90):
sec_graph += self.construct_relation(subject="\n".join(terms_ct_d), objects="\n".join(list(chunck)), property="rdfs:subClassOf")
else:
sec_graph += self.construct_relation(subject="\n".join(terms_ct_d), objects="\n".join(list(all_ct)), property="rdfs:subClassOf")


return sec_graph

Expand Down

0 comments on commit 3948fff

Please sign in to comment.