gyorilab / indra_db

A Database-based knowledge back-end built on and for INDRA. The INDRA Database is a service that can be set up by any user with their own content and knowledge access. Our implementation of the database is the back-end to many of our projects, providing a vast and detailed knowledge base derived from many resources.
GNU General Public License v3.0
16 stars 10 forks source link

Expose the statements submodule #213

Open cthoyt opened 2 years ago

cthoyt commented 2 years ago

EMMAA is trying to import this and can't because there's a missing mid-level import

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [8], in <module>
----> 1 gene_prior.make_config()

File ~/dev/emmaa/emmaa/priors/gene_list_prior.py:69, in GeneListPrior.make_config(self)
     67     self.make_search_terms()
     68 if not self.stmts:
---> 69     self.make_gene_statements()
     70 config = dict()
     71 config['name'] = self.name

File ~/dev/emmaa/emmaa/priors/gene_list_prior.py:59, in GeneListPrior.make_gene_statements(self)
     56 """Generate Statements from the gene list."""
     57 drug_names = [st.name for st in self.search_terms if
     58               st.type == 'drug']
---> 59 indra_stmts = get_stmts_for_gene_list(self.gene_list, drug_names)
     60 estmts = [EmmaaStatement(stmt, datetime.datetime.now(), [])
     61           for stmt in indra_stmts]
     62 self.stmts = estmts

File ~/dev/emmaa/emmaa/priors/prior_stmts.py:45, in get_stmts_for_gene_list(gene_list, other_entities)
     43 for gene in gene_list:
     44     logger.info(f'Querying {gene}')
---> 45     st = get_stmts_for_gene(gene)
     46     logger.info(f'Got {len(st)} statements for {gene}')
     47     stmts += st

File ~/dev/emmaa/emmaa/priors/prior_stmts.py:22, in get_stmts_for_gene(gene)
      9 def get_stmts_for_gene(gene):
     10     """Return all existing Statements for a given gene from the DB.
     11 
     12     Parameters
   (...)
     20         A list of INDRA Statements in which the given gene is involved.
     21     """
---> 22     return client.get_statements_by_gene_role_type(gene, preassembled=False,
     23                                                    count=100000)

AttributeError: module 'indra_db.client' has no attribute 'get_statements_by_gene_role_type'

This PR fixes it since the get_statements_by_gene_role_type is inside indra_db.client.statements. This PR also puts some more stuff into the .gitignore so any packaging artifacts don't accidentally get committed.