Skip to content

Commit

Permalink
Update manager functions and documentation
Browse files Browse the repository at this point in the history
- change iteration to use .nodes() so size can change during iteration
  • Loading branch information
cthoyt committed Apr 30, 2018
1 parent a5569b1 commit e03b1e5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/bio2bel_hgnc/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ def get_gene_by_mgi_symbol(self, mgi_symbol):
:param str mgi_symbol: MGI gene symbol
:rtype: Optional[bio2bel_hgnc.models.HumanGene]
"""
# TODO how to deal with getting the MGI name to MGI identifiers mapping? Should this be part of Bio2BEL , or something different?

# TODO this data is not in HGNC...
raise NotImplementedError

def get_gene_by_rgd_id(self, rgd_id):
Expand Down Expand Up @@ -285,8 +284,7 @@ def get_gene_by_rgd_symbol(self, rgd_symbol):
:param str rgd_symbol: RGD gene symbol
:rtype: Optional[bio2bel_hgnc.models.HumanGene]
"""
# TODO how to deal with getting the RGD name to RGD identifiers mapping? Should this be part of Bio2BEL, or something different?

# TODO this data is not in HGNC...
raise NotImplementedError

def get_node(self, graph, node):
Expand Down Expand Up @@ -389,6 +387,13 @@ def get_family_by_name(self, family_name):
return _deal_with_nonsense(results)

def _enrich_hgnc_with_entrez_equivalences(self, graph, node):
"""
:param pybel.BELGraph graph:
:param node:
:return: the hash of the edge added
:rtype: str
"""
data = graph.node[node]

namespace = data.get(NAMESPACE)
Expand All @@ -400,7 +405,7 @@ def _enrich_hgnc_with_entrez_equivalences(self, graph, node):
name = data[NAME]
entrez = self.hgnc_symbol_entrez_id_mapping[name]

graph.add_equivalence(node, _func_to_dsl[func](
return graph.add_equivalence(node, _func_to_dsl[func](
namespace='ENTREZ',
name=name,
identifier=str(entrez)
Expand All @@ -411,7 +416,7 @@ def enrich_hgnc_with_entrez_equivalences(self, graph):
:param pybel.BELGraph graph: The BEL graph to enrich
"""
for node in graph:
for node in graph.nodes():
self._enrich_hgnc_with_entrez_equivalences(graph, node)

def enrich_families_with_genes(self, graph):
Expand Down Expand Up @@ -713,7 +718,8 @@ def add_node_equivalencies(self, graph, node, add_leaves=True):
def _iterate_namespace_models(self):
return tqdm(self.session.query(HumanGene), total=self.count_human_genes())

def _create_namespace_entry_from_model(self, model, namespace=None):
@staticmethod
def _create_namespace_entry_from_model(model, namespace=None):
return NamespaceEntry(
encoding=encodings.get(model.locus_type, 'GRP'),
identifier=model.identifier,
Expand Down

0 comments on commit e03b1e5

Please sign in to comment.