vfb_connect.neo package¶
Subpackages¶
Submodules¶
vfb_connect.neo.neo4j_tools module¶
-
class
vfb_connect.neo.neo4j_tools.Neo4jConnect(endpoint='http://pdb.virtualflybrain.org', usr='neo4j', pwd='vfb')¶ Bases:
objectThin layer over REST API to hold connection details, handle multi-statement POST queries, return results and report errors.
-
commit_csv(url, statement, chunk_size=1000, sep=',')¶
-
commit_list(statements, return_graphs=False)¶ Commit a list of statements to neo4J DB via REST API. Prints requests status and warnings if any problems with commit.
statements = list of cypher statements as strings
return_graphs, optionally specify graphs to be returned in JSON results.
Errors prompt warnings, not exceptions, and cause return = FALSE. Returns results list of results or False if any errors are encountered.
-
commit_list_in_chunks(statements, verbose=False, chunk_length=1000)¶ Commit a list of statements to neo4J DB via REST API, split into chunks. cypher_statments = list of cypher statements as strings base_uri = base URL for neo4J DB Default chunk size = 1000 statements. This can be overridden by KWARG chunk_length. Returns a list of results. Output is indistinguishable from output of commit_list (i.e. chunking is not reflected in results list).
-
get_lookup(limit_by_prefix=None, include_individuals=False, limit_properties_by_prefix=('RO', 'BFO', 'VFBext'))¶ Generate a name:ID lookup from a VFB neo4j DB, optionally restricted by a list of prefixes limit_by_prefix - Optional list of id prefixes for limiting lookup. credentials - default = production DB include_individuals: If true, individuals included in lookup.
-
list_all_edge_props()¶
-
list_all_node_props()¶
-
rest_return_check(response)¶ Checks status response to post. Prints warnings to STDERR if not OK. If OK, checks for errors in response. Prints any present as warnings to STDERR. Returns True STATUS OK and no errors, otherwise returns False.
-
test_connection()¶
-
-
vfb_connect.neo.neo4j_tools.chunks(l, n)¶ Yield successive n-sized chunks from l.
-
vfb_connect.neo.neo4j_tools.cli_credentials()¶ Parses command line credentials for Neo4J rest connection; Optionally specify additional args as a list of dicts with args required by argparse.add_argument(). Order in list specified arg order
-
vfb_connect.neo.neo4j_tools.cli_neofj_connect()¶
-
vfb_connect.neo.neo4j_tools.dict_cursor(results)¶ Takes JSON results from a neo4J query and turns them into a list of dicts.
-
vfb_connect.neo.neo4j_tools.escape_string(strng)¶
vfb_connect.neo.query_wrapper module¶
-
class
vfb_connect.neo.query_wrapper.QueryWrapper(*args, **kwargs)¶ Bases:
vfb_connect.neo.neo4j_tools.Neo4jConnect-
get_DataSet_TermInfo(short_forms, summary=False)¶
-
get_TermInfo(**kwargs)¶
-
get_anatomical_individual_TermInfo(short_forms, summary=False)¶
-
get_datasets(summary=False)¶
-
get_dbs()¶
-
get_images(short_forms: iter, template, image_folder, image_type='swc', stomp=False)¶ Given an array of short_forms for instances, find all images of specified image_type registered to template. Save these to image_folder along with a manifest.tsv. Return manifest as pandas DataFrame.
-
get_images_by_filename(filenames, dataset=None)¶ Takes a list of filenames as input and returns a list of image terminfo. Optionally restrict by dataset (improves speed)
-
get_template_TermInfo(short_forms)¶
-
get_templates(summary=False)¶
-
get_terms_by_xref(**kwargs)¶
-
get_type_TermInfo(short_forms, summary=False)¶
-
vfb_id_2_neuprint_bodyID(vfb_id, db='')¶
-
vfb_id_2_xrefs(vfb_id: iter, db='', id_type='', reverse_return=False)¶ Map a list of node short_form IDs in VFB to external DB IDs Args:
vfb_id: list of short_form IDs of nodes in the VFB KB db: {optional} database identifier (short_form) in VFB id_type: {optional} name of external id type (e.g. bodyId) reverse_return:
- Return if reverse_return is False:
dict { VFB_id : [{ db: <db> : acc : <acc> }
- Return if reverse_return is True:
dict { acc : [{ db: <db> : vfb_id : <VFB_id> }
-
xref_2_vfb_id(acc=None, db='', id_type='', reverse_return=False)¶ Map an external ID (acc) to a VFB_id args:
acc: list of external DB IDs (accessions) db: {optional} database identifier (short_form) in VFB id_type: {optional} name of external id type (e.g. bodyId)
- Return:
dict { VFB_id : [{ db: <db> : acc : <acc> }]}
-
-
vfb_connect.neo.query_wrapper.batch_query(func)¶
-
vfb_connect.neo.query_wrapper.gen_simple_report(terms)¶