Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards semi-automated path generation #178

Merged
merged 8 commits into from
Sep 11, 2023
Merged

Conversation

sanjayankur31
Copy link
Contributor

Given that the schema is well defined, we should, in some way be able to automate the generation of paths or provide "hints" towards what paths should be. This is sort of a first step to provide the user with more information about relative paths and hierarchies of the schema, without them having to click through the docs to figure it all out. It adds:

  • a method to generate a hierarchy of the whole standard/schema, or of a particular component type
  • print this out in a tree view
  • use this to generate a networkx graph that can then be used to construct paths from one component type to another.

example usage:

(ins)>>> import neuroml
(ins)>>> hier  = neuroml.Cell.get_class_hierarchy()
(ins)>>> hier
{'Cell': [{'morphology_attr': []}, {'metaid': []}, {'id': []}, {'notes': []}, {'neuro_lex_id': []}, {'Property': [{'tag': []}, {'value': []}]}, {'biophysical_properties_attr': []}, {'Annotation': [{'__ANY__': []}]}, {'Morphology': [{'metaid': []}, {'id': []}, {'notes': []}, {'Segment': [{'id': []}, {'Point3DWithDiam': [{'y': []}, {'diameter': []}, {'x': []}, {'z': []}]}, {'Point3DWithDiam': [{'y': []}, {'diameter': []}, {'x': []}, {'z': []}]}, {'SegmentParent': [{'fraction_along': []}, {'segments': []}]}, {'neuro_lex_id': []}, {'name': []}]}, {'Property': [{'tag': []}, {'value': []}]}, {'SegmentGroup': [{'InhomogeneousParameter': [{'variable': []}, {'id': []}, {'DistalDetails': [{'normalization_end': []}]}, {'ProximalDetails': [{'translation_start': []}]}, {'Metric': []}]}, {'SubTree': [{'SegmentEndPoint': [{'segments': []}]}, {'SegmentEndPoint': [{'segments': []}]}]}, {'Path': [{'SegmentEndPoint': [{'segments': []}]}, {'SegmentEndPoint': [{'segments': []}]}]}, {'Include': [{'segment_groups': []}]}, {'Member': [{'segments': []}]}, {'Annotation': [{'__ANY__': []}]}, {'id': []}, {'Property': [{'tag': []}, {'value': []}]}, {'notes': []}, {'neuro_lex_id': []}]}, {'Annotation': [{'__ANY__': []}]}]}, {'BiophysicalProperties': [{'metaid': []}, {'id': []}, {'notes': []}, {'Property': [{'tag': []}, {'value': []}]}, {'MembraneProperties': [{'ChannelDensityGHK2': [{'cond_density': []}, {'ion_channel': []}, {'id': []}, {'segment_groups': []}, {'segments': []}, {'ion': []}]}, {'ChannelDensityNonUniform': [{'VariableParameter': [{'segment_groups': []}, {'InhomogeneousValue': [{'inhomogeneous_parameters': []}, {'value': []}]}, {'parameter': []}]}, {'id': []}, {'ion_channel': []}, {'erev': []}, {'ion': []}]}, {'ChannelDensityNonUniformNernst': [{'id': []}, {'VariableParameter': [{'segment_groups': []}, {'InhomogeneousValue': [{'inhomogeneous_parameters': []}, {'value': []}]}, {'parameter': []}]}, {'ion_channel': []}, {'ion': []}]}, {'ChannelDensityNonUniformGHK': [{'ion_channel': []}, {'id': []}, {'ion': []}, {'VariableParameter': [{'segment_groups': []}, {'InhomogeneousValue': [{'inhomogeneous_parameters': []}, {'value': []}]}, {'parameter': []}]}]}, {'SpikeThresh': [{'value': []}, {'segment_groups': []}]}, {'SpecificCapacitance': [{'segment_groups': []}, {'value': []}]}, {'ChannelPopulation': [{'number': []}, {'erev': []}, {'segment_groups': []}, {'segments': []}, {'ion': []}, {'VariableParameter': [{'segment_groups': []}, {'InhomogeneousValue': [{'inhomogeneous_parameters': []}, {'value': []}]}, {'parameter': []}]}, {'id': []}, {'ion_channel': []}]}, {'InitMembPotential': [{'value': []}, {'segment_groups': []}]}, {'ChannelDensity': [{'erev': []}, {'segment_groups': []}, {'segments': []}, {'ion': []}, {'VariableParameter': [{'segment_groups': []}, {'InhomogeneousValue': [{'inhomogeneous_parameters': []}, {'value': []}]}, {'parameter': []}]}, {'id': []}, {'ion_channel': []}, {'cond_density': []}]}, {'ChannelDensityVShift': [{'erev': []}, {'segment_groups': []}, {'segments': []}, {'v_shift': []}, {'ion': []}, {'VariableParameter': [{'segment_groups': []}, {'InhomogeneousValue': [{'inhomogeneous_parameters': []}, {'value': []}]}, {'parameter': []}]}, {'id': []}, {'ion_channel': []}, {'cond_density': []}]}, {'ChannelDensityNernst': [{'ion_channel': []}, {'cond_density': []}, {'segment_groups': []}, {'id': []}, {'segments': []}, {'ion': []}, {'VariableParameter': [{'segment_groups': []}, {'InhomogeneousValue': [{'inhomogeneous_parameters': []}, {'value': []}]}, {'parameter': []}]}]}, {'ChannelDensityGHK': [{'permeability': []}, {'segment_groups': []}, {'segments': []}, {'ion': []}, {'id': []}, {'ion_channel': []}]}]}, {'Annotation': [{'__ANY__': []}]}, {'IntracellularProperties': [{'Resistivity': [{'segment_groups': []}, {'value': []}]}, {'Species': [{'segment_groups': []}, {'initial_ext_concentration': []}, {'initial_concentration': []}, {'id': []}, {'ion': []}, {'concentration_model': []}]}]}, {'ExtracellularProperties': [{'id': []}, {'Species': [{'segment_groups': []}, {'initial_ext_concentration': []}, {'initial_concentration': []}, {'id': []}, {'ion': []}, {'concentration_model': []}]}]}]}]}
(ins)>>> from neuroml.utils import print_hierarchy
(ins)>>> print_hierarchy(hier)
Cell
└---morphology_attr
└---metaid
└---id
└---notes
└---neuro_lex_id
└---Property
    └---tag
    └---value
└---biophysical_properties_attr
└---Annotation
    └---__ANY__
└---Morphology
    └---metaid
    └---id
    └---notes
    └---Segment
        └---id
        └---Point3DWithDiam
            └---y
            └---diameter
            └---x
            └---z
        └---Point3DWithDiam
            └---y
            └---diameter
            └---x
            └---z
        └---SegmentParent
            └---fraction_along
            └---segments
        └---neuro_lex_id
        └---name
    └---Property
 ...

For paths, it adds a convenience function that provides hints on the relative paths from one place in the standard hierarchy to another:

(ins)>>> from neuroml.utils import get_relative_component_path
(ins)>>> p, g = get_relative_component_path("Input", "Instance")
Path1: NeuroMLDocument/Network/Population/Instance
Path2: NeuroMLDocument/Network/InputList/Input
Relative path: ../Population/Instance
(ins)>>> print(p)
../Population/Instance

A lot more "intelligence" can be baked into these bits to fill up lots of common bits for the user.

@sanjayankur31 sanjayankur31 added the T: enhancement Type: enhancement label Sep 8, 2023
@dkuhlman
Copy link

dkuhlman commented Sep 8, 2023

That is very cool.

(Caution. I'm the implementer/maintainer of generateDS and its
support for GraphQL, so viewer discretion advised.)

You might also look at the GraphQL support that is provided by the
latest version of generateDS? I don't believe that it quite gives
what you are asking for, but for some similar use cases it comes
close enough to be worth considering. The Web app is interactive,
so it can be made available across the Web.

I've attached a screen shot.

And, here are two bash scripts that show how I generated the
generateDS GraphQL module (run-gen-graphql.sh) and how I ran the
Strawberry GraphQL server ('run-serve-graphql.sh`):

#!/usr/bin/bash -x
generateDS.py \
    -f \
    -o tmp01_graphql.py \
    --graphql="neuroml:NeuroMLDocument" \
    NeuroML2/Schemas/NeuroML2/NeuroML_v2.2.xsd
#!/usr/bin/bash -x
GRAPHQL_ARGS=NeuroML2/examples/NML2_FullCell.nml strawberry server tmp01_graphql

The above requires the latest version of generateDS and
installation of strawberry-qraphql. See
https://strawberry.rocks/docs. For example:

$ python -m venv virtualenv
$ source virtualenv/bin/activate
$ pip install 'strawberry-graphql[debug-server]'

You can learn more about the GraphQL support provide by generateDS
here: http://davekuhlman.org/generateds-graphql.html

Dave
neuroml-graphql01

@sanjayankur31
Copy link
Contributor Author

Woah! That's really nice! It's on my TODO list to learn about GraphQL and see how we can leverage generateDS's support for it to make it easier to inspect (but also hopefully create?) NeuroML objects/models. After seeing your screenshot, i think I need to bump it up the list :)

Thanks again for all your help.

@pgleeson pgleeson changed the base branch from development to experimental September 11, 2023 10:56
@pgleeson pgleeson merged commit 81d4d5c into experimental Sep 11, 2023
20 checks passed
@sanjayankur31 sanjayankur31 deleted the feat/path-util branch September 11, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: enhancement Type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants