Skip to content

Commit a823910

Browse files
committed
Further fixes for evidence list references
1 parent bb9f79b commit a823910

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

indra/preassembler/grounding_mapper/adeft.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def run_adeft_disambiguation(stmt, agent, idx):
4848
return
4949
# Initialize annotations if needed so Adeft predicted
5050
# probabilities can be added to Agent annotations
51-
annots = stmt.evidence[0].annotations
51+
ev = stmt.evidence[0]
52+
annots = ev.annotations
5253
agent_txt = agent.db_refs['TEXT']
5354
if 'agents' in annots:
5455
if 'adeft' not in annots['agents']:
@@ -78,6 +79,7 @@ def run_adeft_disambiguation(stmt, agent, idx):
7879
GroundingMapper.standardize_agent_name(agent,
7980
standardize_refs=True)
8081
annots['agents']['adeft'][idx] = disamb_scores
82+
stmt.evidence[0] = ev
8183

8284

8385
def _get_text_for_grounding(stmt, agent_text):

indra/sources/sparser/processor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ def set_statements_pmid(self, pmid):
168168
ev['pmid'] = pmid
169169
# Replace PMID value in extracted Statements next
170170
for stmt in self.statements:
171-
for ev in stmt.evidence:
171+
evs = stmt.evidence
172+
for ev in evs:
172173
ev.pmid = pmid
174+
stmt.evidence = evs
173175

174176

175177
def _fix_agent(agent):

indra/tests/test_assemble_corpus.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,13 @@ def test_merge_groundings():
588588

589589
def test_merge_deltas():
590590
def add_annots(stmt):
591-
for ev in stmt.evidence:
591+
evs = stmt.evidence
592+
for ev in evs:
592593
ev.annotations['subj_adjectives'] = stmt.subj.delta.adjectives
593594
ev.annotations['obj_adjectives'] = stmt.obj.delta.adjectives
594595
ev.annotations['subj_polarity'] = stmt.subj.delta.polarity
595596
ev.annotations['obj_polarity'] = stmt.obj.delta.polarity
597+
stmt.evidence = evs
596598
return stmt
597599
# d1 = {'adjectives': ['a', 'b', 'c'], 'polarity': 1}
598600
# d2 = {'adjectives': [], 'polarity': -1}

indra/tests/test_medscan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ def test_evidence():
157157
coords = s0.evidence[0].annotations['agents']['coords']
158158
assert isinstance(coords, list), type(coords)
159159
assert len(coords) == 2, len(coords)
160-
assert coords[0] == (90, 97), coords[0]
161-
assert coords[1] == (106, 120), coords[1]
160+
assert tuple(coords[0]) == (90, 97), tuple(coords[0])
161+
assert tuple(coords[1]) == (106, 120), tuple(coords[1])
162162

163163

164164
def test_molsynthesis_positive():

indra/tests/test_preassembler.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ def test_flatten_evidence_hierarchy():
510510
supporting_stmt = top_stmt.supported_by[0]
511511
assert len(supporting_stmt.evidence) == 1
512512
assert supporting_stmt.evidence[0].text == 'foo'
513-
supporting_stmt.evidence[0].text = 'changed_foo'
513+
evs = supporting_stmt.evidence
514+
evs[0].text = 'changed_foo'
515+
supporting_stmt.evidence = evs
514516
assert supporting_stmt.evidence[0].text == 'changed_foo'
515517
assert 'changed_foo' not in [e.text for e in top_stmt.evidence]
516518
assert 'foo' in [e.text for e in top_stmt.evidence]
@@ -915,8 +917,10 @@ def test_agent_coordinates():
915917
evidence_list = unique_stmt.evidence
916918
agent_annots = [ev.annotations['agents'] for ev in unique_stmt.evidence]
917919
assert all(a['raw_text'] == ['MEK1', 'ERK2'] for a in agent_annots)
918-
assert {tuple(a['coords']) for a in agent_annots} == {((21, 25), (0, 4)),
919-
((0, 4), (15, 19))}
920+
expected_coords = {((21, 25), (0, 4)), ((0, 4), (15, 19))}
921+
for annot in agent_annots:
922+
coords = tuple(tuple(a) for a in annot['coords'])
923+
assert coords in expected_coords
920924

921925

922926
def test_association_duplicate():

indra/tools/assemble_corpus.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,11 @@ def merge_deltas(stmts_in):
244244
for info in ('polarity', 'adjectives'):
245245
key = (role, info)
246246
deltas[key] = []
247+
evs = stmt.evidence
247248
for ev in stmt.evidence:
248249
entry = ev.annotations.get('%s_%s' % key)
249250
deltas[key].append(entry if entry else None)
251+
stmt.evidence = evs
250252
# POLARITY
251253
# For polarity we need to work in pairs
252254
polarity_pairs = list(zip(deltas[('subj', 'polarity')],

0 commit comments

Comments
 (0)