INCATools / INCATools/oakx-grape

Index is out of bound during the all_by_all_pairwise_similarity

Open
#28 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
5
Forks
2
PR merge metrics
No merged PRs in 30d

Description

**Component**

```python
GrapeImplementation.all_by_all_pairwise_similarity
```

**Description**

During the `GrapeImplementation.all_by_all_pairwise_similarity` method call, I got an index out of bounds exception:

```python
IndexError Traceback (most recent call last)
Cell In [64], line 1
----> 1 tp = oi.all_by_all_pairwise_similarity(oba_list, vt_list)

File ~/.pyenv/versions/3.10.8/lib/python3.10/site-packages/oakx_grape/grape_implementation.py:402, in GrapeImplementation.all_by_all_pairwise_similarity(self, subjects, objects, predicates)
398 raise ValueError("For now can only use hardcoded ensmallen predicates")
400 resnik_model = self._make_grape_resnik_model()
--> 402 sim = resnik_model.get_similarities_from_bipartite_graph_node_names(
403 source_node_names=subjects,
404 destination_node_names=objects,
405 return_similarities_dataframe=True,
406 return_node_names=True,
407 )
409 pairs = iter(self._df_to_pairwise_similarity(sim))
411 return pairs

File ~/.pyenv/versions/3.10.8/lib/python3.10/site-packages/embiggen/similarities/dag_resnik.py:145, in DAGResnik.get_similarities_from_bipartite_graph_node_names(self, source_node_names, destination_node_names, minimum_similarity, return_similarities_dataframe, return_node_names)
120 def get_similarities_from_bipartite_graph_node_names(
121 self,
122 source_node_names: List[str],
(...)
126 return_node_names: bool = False
...
81 ),
82 "resnik_score": similarities
83 })
```

**To Reproduce**

Steps to reproduce the behavior:

First of all, I merged two ontologies into one, then I did two terms lists subsetting them based on their prefixes. The first one contains OBA terms while the other contains VT terms.

```python
oi = get_implementation_from_shorthand("grape:sqlite:../tmp/oba-vt.owl")
oba_terms = pd.read_csv('../tmp/oba_terms.txt', header=None)
#['OBA:1000035', 'OBA:1000045', 'OBA:0000003', 'OBA:0000005', 'OBA:0000006']
vt_terms = pd.read_csv('../tmp/vt_terms.txt', header=None)
#['VT:0000181', 'VT:0000362', 'VT:0000717', 'VT:0000813', 'VT:0001097']
tp = oi.all_by_all_pairwise_similarity(oba_list, vt_list)
```

**Expected behavior**

When I pass the same list in both of `GrapeImplementation.all_by_all_pairwise_similarity` parameters everything works fine.

```python
tp = oi.all_by_all_pairwise_similarity(oba_list, oba_list)

for t in tp:
print(t.ancestor_information_content)
```
```
10.202258110046387
5.5109100341796875
0.0001483669620938599
0.0001483669620938599
0.11778302490711212
5.5109100341796875
10.202258110046387
0.0001483669620938599
0.0001483669620938599
0.11778302490711212
10.202258110046387
5.587137222290039
5.587137222290039
10.202258110046387
0.0001483669620938599
0.0001483669620938599
10.202258110046387
```
**Additional context**

Library versions:
oaklib 0.1.70
oakx-grape 0.1.2
embiggen 0.11.39

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with GrapeImplementation.all_by_all_pairwise_similarity in grape_implementation.py and trace its call into embiggen/similarities/dag_resnik.py. Run the reproduction using separate OBA and VT lists, then compare it with the same-list case. Done means cross-prefix inputs complete without IndexError while preserving the reported similarity results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.