Skip to content

Commit

Permalink
Merge pull request #212 from dianakolusheva/disease_map
Browse files Browse the repository at this point in the history
Overwrite existing statements
  • Loading branch information
dianakolusheva committed Mar 25, 2021
2 parents ca1bf73 + efa271b commit 9c40385
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions emmaa/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def get_new_readings(self, date_limit=10):
lit_sources = [lit_sources]
if isinstance(readers, str):
readers = [readers]
# First get statements from literature if needed
# First get statements from literature and extend existing statements
# Some models are not updated from literature
if lit_sources is not None and readers is not None:
estmts = []
Expand Down Expand Up @@ -274,12 +274,12 @@ def get_new_readings(self, date_limit=10):
logger.info('Got a total of %d new EMMAA Statements from reading' %
len(estmts))
self.extend_unique(estmts)
# Then update from other sources
if self.reading_config.get('cord19_update'):
# This overwrites existing statements
self.update_with_cord19()
# The following methods can extend existing statements
# The following methods get subsets of statements from other sources
# and overwrite existing statements
estmts = []
if self.reading_config.get('cord19_update'):
new_estmts = self.update_with_cord19()
estmts += new_estmts
if self.reading_config.get('disease_map'):
new_estmts = self.update_from_disease_map(
self.reading_config['disease_map'])
Expand All @@ -289,7 +289,7 @@ def get_new_readings(self, date_limit=10):
self.reading_config['other_files'])
estmts += new_estmts
if estmts:
self.extend_unique(estmts)
self.stmts = estmts
self.eliminate_copies()

def extend_unique(self, estmts):
Expand Down Expand Up @@ -324,8 +324,9 @@ def update_with_cord19(self):
logger.info(f'Loaded {len(file_stmts)} statements from {fname}.')
other_stmts += file_stmts
new_stmts, paper_ids = make_model_stmts(current_stmts, other_stmts)
self.stmts = to_emmaa_stmts(new_stmts, datetime.datetime.now(), [])
new_estmts = to_emmaa_stmts(new_stmts, datetime.datetime.now(), [])
self.add_paper_ids(paper_ids, 'TRID')
return new_estmts

def update_from_disease_map(self, disease_map_config):
"""Update model by processing MINERVA Disease Map."""
Expand Down

0 comments on commit 9c40385

Please sign in to comment.