Skip to content
Snippets Groups Projects
Commit 2a210fdf authored by AndiMajore's avatar AndiMajore
Browse files

fixed issue with strange gene name for proteins; fixed issue with empty string symbol for protein

parent f3b6528e
No related branches found
No related tags found
No related merge requests found
...@@ -96,16 +96,24 @@ class NedrexImporter: ...@@ -96,16 +96,24 @@ class NedrexImporter:
if update: if update:
self.cache.init_proteins() self.cache.init_proteins()
def format_prot_name(name):
if '{' in name:
idx1 = name.index('{')
adjusted_name = name[:idx1 - 1].strip() if idx1 > 0 else ''
if '=' in adjusted_name:
idx2 = adjusted_name.index('=')
return adjusted_name[idx2+1:].strip()
return adjusted_name
return name
def add_protein(node): def add_protein(node):
id = to_id(node['primaryDomainId']) id = to_id(node['primaryDomainId'])
name = node['geneName'] name = format_prot_name(node['geneName'])
gene = name
if len(node['synonyms']) > 0: if len(node['synonyms']) > 0:
name = node['synonyms'][0] name = format_prot_name(node['synonyms'][0])
if '{' in name: proteins[id] = models.Protein(uniprot_code=id, protein_name=name, gene=gene)
idx = name.index('{')
if idx > 0:
name = name[:idx - 1]
proteins[id] = models.Protein(uniprot_code=id, protein_name=name, gene=node['geneName'])
def add_edges(edge): def add_edges(edge):
id = to_id(edge['sourceDomainId']) id = to_id(edge['sourceDomainId'])
......
...@@ -215,20 +215,20 @@ def populate(kwargs): ...@@ -215,20 +215,20 @@ def populate(kwargs):
print(f'Populated {n} DrDi associations from DrugBank.') print(f'Populated {n} DrDi associations from DrugBank.')
if kwargs['protein_protein']: if kwargs['protein_protein']:
# print('Importing PPIs from unlicenced NeDRexDB...') print('Importing PPIs from unlicenced NeDRexDB...')
# n = NedrexImporter.import_protein_protein_interactions(importer, n = NedrexImporter.import_protein_protein_interactions(importer,
# DatasetLoader.get_ppi_nedrex(nedrex_api_url_unlicenced, False), DatasetLoader.get_ppi_nedrex(nedrex_api_url_unlicenced, False),
# update) update)
# total_n += n total_n += n
# print(f'Imported {n} PPIs from unlicended NeDRexDB') print(f'Imported {n} PPIs from unlicended NeDRexDB')
# print('Importing PPIs from licenced NeDRexDB...') print('Importing PPIs from licenced NeDRexDB...')
# n = NedrexImporter.import_protein_protein_interactions(importer, n = NedrexImporter.import_protein_protein_interactions(importer,
# DatasetLoader.get_ppi_nedrex(nedrex_api_url_licenced, DatasetLoader.get_ppi_nedrex(nedrex_api_url_licenced,
# True), True),
# update) update)
# total_n += n total_n += n
# nedrex_update = True nedrex_update = True
# print(f'Imported {n} PPIs from licended NeDRexDB') print(f'Imported {n} PPIs from licended NeDRexDB')
print('Populating PPIs from STRING...') print('Populating PPIs from STRING...')
n = DataPopulator.populate_ppi_string(populator, DatasetLoader.get_ppi_string(), update) n = DataPopulator.populate_ppi_string(populator, DatasetLoader.get_ppi_string(), update)
total_n += n total_n += n
......
...@@ -24,7 +24,7 @@ def query_proteins_by_identifier(node_ids: Set[str], identifier: str) -> Tuple[L ...@@ -24,7 +24,7 @@ def query_proteins_by_identifier(node_ids: Set[str], identifier: str) -> Tuple[L
Returns name of backend attribute of Protein table Returns name of backend attribute of Protein table
""" """
# query protein table # query protein table
if(len(node_ids) == 0): if (len(node_ids) == 0):
return list(), identifier return list(), identifier
if identifier == 'symbol': if identifier == 'symbol':
protein_attribute = 'symbol' protein_attribute = 'symbol'
...@@ -70,7 +70,8 @@ def aggregate_nodes(nodes: List[OrderedDict]): ...@@ -70,7 +70,8 @@ def aggregate_nodes(nodes: List[OrderedDict]):
for key, value in n.items(): for key, value in n.items():
if isinstance(value, list): if isinstance(value, list):
for e in value: for e in value:
node[key].add(e) if e is not None and len(e) > 0:
else: node[key].add(e)
elif value is not None and len(value) > 0:
node[key].add(value) node[key].add(value)
return {k: list(v) for k, v in node.items()} return {k: list(v) for k, v in node.items()}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment