Skip to content

Commit

Permalink
adding wrapped methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbie1977 committed Aug 13, 2024
1 parent 0798b15 commit 5be15a7
Show file tree
Hide file tree
Showing 7 changed files with 2,410 additions and 3,391 deletions.
2,775 changes: 311 additions & 2,464 deletions docs/source/tutorials/connectomics.ipynb

Large diffs are not rendered by default.

2,613 changes: 1,916 additions & 697 deletions docs/source/tutorials/discovery.ipynb

Large diffs are not rendered by default.

243 changes: 60 additions & 183 deletions docs/source/tutorials/overview.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ psycopg2
pandas
pandasql
jsonpath_rw
setuptools~=50.3.2
setuptools
neuprint-python
pysolr
bottleneck<=1.3.6
bottleneck<=1.3.6
backports.tarfile
88 changes: 45 additions & 43 deletions src/vfb_connect.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
Metadata-Version: 2.1
Name: vfb-connect
Version: 1.2.20.dev45+fcedd60.dirty
Name: vfb_connect
Version: 1.3.0.dev2+0798b15.dirty
Summary: Wrapper for querying VirtualFlyBrain servers.
Home-page: https://github.com/VirtualFlyBrain/VFB_connect
Author: David Osumi-Sutherland
Author-email: [email protected]
License: UNKNOWN
Project-URL: Bug Reports, https://github.com/VirtualFlyBrain/VFB_connect/issues
Project-URL: Source, https://github.com/VirtualFlyBrain/VFB_connect
Project-URL: Documentation, https://vfb-connect.readthedocs.io/en/stable/
Description: # VFB_connect [![test_vfb-connect](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/test_vfb-connect.yml/badge.svg)](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/test_vfb-connect.yml) [![publish-to-pypi](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/publish-to-pypi.yml) [![PyPI version](https://badge.fury.io/py/vfb-connect.svg)](https://pypi.org/project/vfb-connect/)
[![test_notebooks](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/test_notebooks.yml/badge.svg)](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/test_notebooks.yml) [![Documentation Status](https://readthedocs.org/projects/vfb-connect/badge/?version=stable)](https://vfb-connect.readthedocs.io/en/stable/?badge=latest)

VFB_connect is a Python lib that wraps data/knowledgeBase query endpoints and returns VFB_json.


Available on PyPi:

` pip install vfb_connect `


## Some examples:

```python

from vfb_connect.cross_server_tools import VfbConnect

# VFB connect object wraps connections and queries to public VFB servers.

vc=VfbConnect()

# Get TermInfo for Types/Classes, DataSets and anatomical individuals.

vc.neo_query_wrapper.get_type_TermInfo(['FBbt_00003686'])

vc.neo_query_wrapper.get_DataSet_TermInfo(['Ito02013'])

vc.neo_query_wrapper.get_anatomical_individual_TermInfo(['VFB_00010001'])

# Get all terms relevant to a brain region (all parts and all overlapping cells. Query by label supported by default.

vc.get_terms_by_region('fan-shaped body')

```

TermInfo return values conform to [VFB_json_schema](https://virtualflybrain.github.io/schema_doc.html)

For more examples see our [Quick Guide Jupyter Notebook](https://github.com/VirtualFlyBrain/VFB_connect/blob/master/snippets/VFB_connect_Quick_Guide.ipynb)

Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: pandas
Requires-Dist: jsonpath_rw

# VFB_connect [![test_vfb-connect](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/test_vfb-connect.yml/badge.svg)](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/test_vfb-connect.yml) [![publish-to-pypi](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/publish-to-pypi.yml) [![PyPI version](https://badge.fury.io/py/vfb-connect.svg)](https://pypi.org/project/vfb-connect/)
[![test_notebooks](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/test_notebooks.yml/badge.svg)](https://github.com/VirtualFlyBrain/VFB_connect/actions/workflows/test_notebooks.yml) [![Documentation Status](https://readthedocs.org/projects/vfb-connect/badge/?version=stable)](https://vfb-connect.readthedocs.io/en/stable/?badge=latest)

VFB_connect is a Python lib that wraps data/knowledgeBase query endpoints and returns VFB_json.


Available on PyPi:

` pip install vfb_connect `


## Some examples:

```python

from vfb_connect.cross_server_tools import VfbConnect

# VFB connect object wraps connections and queries to public VFB servers.

vc=VfbConnect()

# Get TermInfo for Types/Classes, DataSets and anatomical individuals.

vc.neo_query_wrapper.get_type_TermInfo(['FBbt_00003686'])

vc.neo_query_wrapper.get_DataSet_TermInfo(['Ito02013'])

vc.neo_query_wrapper.get_anatomical_individual_TermInfo(['VFB_00010001'])

# Get all terms relevant to a brain region (all parts and all overlapping cells. Query by label supported by default.

vc.get_terms_by_region('fan-shaped body')

```

TermInfo return values conform to [VFB_json_schema](https://virtualflybrain.github.io/schema_doc.html)

For more examples see our [Quick Guide Jupyter Notebook](https://github.com/VirtualFlyBrain/VFB_connect/blob/master/snippets/VFB_connect_Quick_Guide.ipynb)
70 changes: 70 additions & 0 deletions src/vfb_connect/cross_server_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,74 @@ def get_transcriptomic_profile(self, cell_type, gene_type=False, return_datafram
return pd.DataFrame.from_records(dc)
else:
return dc

# Wrapped neo_query_wrapper methods
def get_datasets(self, summary=True, return_dataframe=True):
"""Get all datasets in the database.
:return: List of datasets in the database.
:rtype: list
"""
return self.neo_query_wrapper.get_datasets(summary=summary, return_dataframe=return_dataframe)

def get_images(self, short_forms, template=None, image_folder=None, image_type='swc', stomp=False):
"""Get images for a list of individuals.
:param short_forms: List of short_form IDs for individuals.
:param template: Optional. Template name.
:param image_folder: Optional. Folder to save image files & manifest to.
:param image_type: Optional. Image type (file extension).
:param stomp: Optional. Overwrite image_folder if already exists.
:return: Manifest as Pandas DataFrame
"""
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):
"""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)

def get_terms_by_xref(self, xrefs, db, summary=True, return_dataframe=True):
"""Get terms by cross-reference.
:param xrefs: List of cross-references.
:param db: Database name.
:return: List of terms.
:rtype: list
"""
return self.neo_query_wrapper.get_terms_by_xref(xrefs, db=db, summary=summary, return_dataframe=return_dataframe)

def get_vfb_id_by_xref(self, xrefs, db, summary=True, return_dataframe=True):
"""Get VFB ID by cross-reference.
:param xrefs: List of cross-references.
:param db: Database name.
:return: List of VFB IDs.
:rtype: list
"""
return self.neo_query_wrapper.xref_2_vfb_id(xrefs, db=db, summary=summary, return_dataframe=return_dataframe)

def get_xref_by_vfbid(self, vfbids, db, summary=True, return_dataframe=True):
"""Get cross-reference by VFB ID.
:param vfbids: List of VFB IDs.
:param db: Database name.
:return: List of cross-references.
:rtype: list
"""
return self.neo_query_wrapper.vfb_id_2_xrefs(vfbids, db=db, summary=summary, return_dataframe=return_dataframe)

def get_images_by_filename(self, filenames, dataset=None, summary=True, return_dataframe=True):
"""Get images by filename.
:param filenames: List of filenames.
:param dataset: Optional. Dataset name.
:return: List of images.
:rtype: list
"""
return self.neo_query_wrapper.get_images_by_filename(filenames, dataset=dataset, summary=summary,
return_dataframe=return_dataframe)
7 changes: 5 additions & 2 deletions src/vfb_connect/neo/query_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def get_dbs(self):
"return i.short_form"
return [d['i.short_form'] for d in self._query(query)]

def get_datasets(self, summary=True):
def get_datasets(self, summary=True, return_datasets=True):
"""Generate JSON report of all datsets.
:param summary: Optional. Returns summary reports if `True`. Default `True`
Expand All @@ -324,7 +324,10 @@ def get_datasets(self, summary=True):
dc = self._query("MATCH (ds:DataSet) "
"RETURN ds.short_form AS sf")
short_forms = [d['sf'] for d in dc]
return self.get_DataSet_TermInfo(short_forms, summary=summary)
results = self.get_DataSet_TermInfo(short_forms, summary=summary)
if return_datasets and summary:
return pd.DataFrame.from_records(results)
return results

def get_templates(self, summary=True):
"""Generate JSON report of all available templates.
Expand Down

0 comments on commit 5be15a7

Please sign in to comment.