Skip to content

Commit

Permalink
Merge pull request #195 from VirtualFlyBrain/hotfix1
Browse files Browse the repository at this point in the history
include symbols in templates
  • Loading branch information
Robbie1977 authored Sep 4, 2024
2 parents a8ce672 + ec0deff commit d556234
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/vfb_connect/cross_server_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def lookup_id(self, key, return_curie=False, allow_subsitutions=True, subsitutio
print(f"\033[31mError:\033[0m Unrecognized value: \033[31m{key}\033[0m")
return ''

@property
def __version__(self):
from importlib.metadata import version, PackageNotFoundError
return version('vfb_connect')
Expand Down Expand Up @@ -742,13 +743,13 @@ def get_images(self, short_forms: iter, template=None, image_folder=None, image_
return self.neo_query_wrapper.get_images(short_forms, template=template, image_folder=image_folder,
image_type=image_type, stomp=stomp)

def get_templates(self, summary=True, return_dataframe=True):
def get_templates(self, summary=True, return_dataframe=True, include_symbols=False):
"""Get all templates in the database.
:return: List of templates in the database.
:rtype: list
"""
return self.neo_query_wrapper.get_templates(summary=summary, return_dataframe=return_dataframe)
return self.neo_query_wrapper.get_templates(summary=summary, return_dataframe=return_dataframe, include_symbols=include_symbols)

@batch_query
def get_terms_by_xref(self, xrefs: iter, db='', summary=True, return_dataframe=True):
Expand Down
9 changes: 7 additions & 2 deletions src/vfb_connect/neo/query_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def get_datasets(self, summary=True, return_dataframe=True):
return pd.DataFrame.from_records(results)
return results

def get_templates(self, summary=True, return_dataframe=True):
def get_templates(self, summary=True, return_dataframe=True, include_symbols=False):
"""Generate JSON report of all available templates.
:param summary: Optional. Returns summary reports if `True`. Default `True`
Expand All @@ -394,7 +394,12 @@ def get_templates(self, summary=True, return_dataframe=True):
dc = self._query("MATCH (i:Individual:Template:Anatomy) "
"RETURN i.short_form as sf")
short_forms = [d['sf'] for d in dc]
return self.get_anatomical_individual_TermInfo(short_forms, summary=summary)
if include_symbols:
dc = self._query("MATCH (i:Individual:Template:Anatomy) ",
"WHERE exists(i.symbol) and not i.symbol[0] = '' "
"RETURN i.symbol[0] as s")
short_forms.extend([d['s'] for d in dc if d['s']])
return self.get_anatomical_individual_TermInfo(short_forms, summary=summary, return_dataframe=return_dataframe)

def vfb_id_2_xrefs(self, vfb_id: iter, db='', id_type='', reverse_return=False):
"""Map a list of short_form IDs in VFB to external DB IDs
Expand Down

0 comments on commit d556234

Please sign in to comment.