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

HERD Updates #968

Merged
merged 50 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e77132c
HERD Updates
mavaylon1 Oct 18, 2023
43877e4
rework in progress
mavaylon1 Oct 19, 2023
54cbf95
updated tests/go through for final checks
mavaylon1 Oct 21, 2023
3d5972a
Merge branch 'dev' into herd_update
mavaylon1 Oct 30, 2023
2f8ab37
add_ref_termset and tests
mavaylon1 Oct 30, 2023
e9c9728
comments
mavaylon1 Oct 30, 2023
2fb33fd
comments
mavaylon1 Oct 30, 2023
1a287b1
gallery
mavaylon1 Oct 30, 2023
9cf7bc0
checks
mavaylon1 Oct 30, 2023
ff54bc0
Merge branch 'dev' into herd_update
mavaylon1 Oct 31, 2023
a8d1ecc
path
mavaylon1 Oct 31, 2023
d2cb2e8
path
mavaylon1 Oct 31, 2023
18e3456
path
mavaylon1 Oct 31, 2023
2c24e04
cov
mavaylon1 Oct 31, 2023
8043d0f
cov
mavaylon1 Oct 31, 2023
a62ad00
doc
mavaylon1 Oct 31, 2023
90abebe
notes'
mavaylon1 Oct 31, 2023
abcbcc7
Update CHANGELOG.md
mavaylon1 Oct 31, 2023
b5787b8
resuse uri
mavaylon1 Oct 31, 2023
756f062
typo
mavaylon1 Oct 31, 2023
ecd01f8
edits
mavaylon1 Oct 31, 2023
0dbbf14
Merge branch 'dev' into herd_update
mavaylon1 Nov 7, 2023
6e75289
Update CHANGELOG.md
mavaylon1 Nov 7, 2023
350d165
Merge branch 'dev' into herd_update
mavaylon1 Nov 28, 2023
5338ece
Merge branch 'dev' into herd_update
mavaylon1 Dec 4, 2023
cc9ea4d
Merge branch 'dev' into herd_update
mavaylon1 Dec 4, 2023
07930e9
Update docs/gallery/plot_external_resources.py
mavaylon1 Dec 8, 2023
5c61708
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 8, 2023
8a3f5b2
name change
mavaylon1 Dec 8, 2023
f49cfd4
Update src/hdmf/common/resources.py
mavaylon1 Dec 8, 2023
fe97bba
Update src/hdmf/common/resources.py
mavaylon1 Dec 8, 2023
d92873e
Update src/hdmf/common/resources.py
mavaylon1 Dec 8, 2023
b028077
Update src/hdmf/common/resources.py
mavaylon1 Dec 8, 2023
b5b36ac
Update src/hdmf/common/resources.py
mavaylon1 Dec 8, 2023
7a636de
doc
mavaylon1 Dec 12, 2023
a1ffa34
Update src/hdmf/common/resources.py
mavaylon1 Dec 12, 2023
6192d02
Merge branch 'dev' into herd_update
rly Dec 12, 2023
d78f335
checks
mavaylon1 Dec 12, 2023
6ccb4b8
Merge branch 'herd_update' of https://github.com/hdmf-dev/hdmf into h…
mavaylon1 Dec 12, 2023
ae6494b
ruff
mavaylon1 Dec 12, 2023
12132dc
gallery
mavaylon1 Dec 12, 2023
82d6ed4
path
mavaylon1 Dec 12, 2023
fd72d73
todo
mavaylon1 Dec 12, 2023
186a839
Merge branch 'dev' into herd_update
mavaylon1 Dec 12, 2023
e688be0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2023
9042dfa
Update docs/gallery/plot_external_resources.py
rly Dec 13, 2023
4477bea
Update src/hdmf/common/resources.py
rly Dec 13, 2023
d441b1f
Update docs/gallery/plot_external_resources.py
rly Dec 13, 2023
25f5afb
Update resources.py
rly Dec 13, 2023
ada2e30
Merge branch 'dev' into herd_update
rly Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## HDMF 3.11.1 (Upcoming)

### Enhancements
- Added `add_ref_termset`, updated helper methods for `HERD`, and revised `add_ref` to support validations prior to populating the tables. @mavaylon1 [#968](https://github.com/hdmf-dev/hdmf/pull/968)
mavaylon1 marked this conversation as resolved.
Show resolved Hide resolved

### Minor Improvements
- Updated `__gather_columns` to ignore the order of bases when generating columns from the super class. @mavaylon1 [#991](https://github.com/hdmf-dev/hdmf/pull/991)
- Improve HTML rendering of tables. @bendichter [#998](https://github.com/hdmf-dev/hdmf/pull/998)
Expand Down
49 changes: 48 additions & 1 deletion docs/gallery/plot_external_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
# sphinx_gallery_thumbnail_path = 'figures/gallery_thumbnail_externalresources.png'
from hdmf.common import HERD
from hdmf.common import DynamicTable, VectorData
from hdmf.term_set import TermSet
from hdmf import Container, HERDManager
from hdmf import Data
import numpy as np
Expand Down Expand Up @@ -269,7 +270,7 @@ def __init__(self, **kwargs):
###############################################################################
# Using the get_object_type
# ------------------------------------------------------
# The :py:class:`~hdmf.common.resources.HERD.get_object_entities` method
# The :py:func:`~hdmf.common.resources.HERD.get_object_entities` method
# allows the user to retrieve all entities and key information associated with an `Object` in
# the form of a pandas DataFrame.

Expand Down Expand Up @@ -306,6 +307,52 @@ def __init__(self, **kwargs):
entity_uri='https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=10090'
)

###############################################################################
# Using add_ref_termset
# ------------------------------------------------------
# :py:class:`~hdmf.common.resources.HERD` has multiple ways for users to add
# external references. The :py:func:`~hdmf.common.resources.HERD.add_ref_termset`
# method allows users to not only validate terms, i.e., keys, but also adds the
# ability to iteratively add references for entire datasets, lists, arrays, etc.
mavaylon1 marked this conversation as resolved.
Show resolved Hide resolved

# The :py:func:`~hdmf.common.resources.HERD.add_ref_container` method is directly
# used for populating :py:class:`~hdmf.common.resources.HERD` when writing a file.
# :py:func:`~hdmf.common.resources.HERD.add_ref_termset` can be used for new files;
# however, it is also the best practice when adding references for existing files.
mavaylon1 marked this conversation as resolved.
Show resolved Hide resolved

# :py:func:`~hdmf.common.resources.HERD.add_ref_termset` has many optional fields,
# giving the user a range of control when adding references. Let's see an example.
er = HERD()
mavaylon1 marked this conversation as resolved.
Show resolved Hide resolved
terms = TermSet(term_schema_path='example_term_set.yaml')
file = HERDManagerContainer(name='file')
mavaylon1 marked this conversation as resolved.
Show resolved Hide resolved

er.add_ref_termset(file=file,
container=species,
attribute='Species_Data',
key='Ursus arctos horribilis',
termset=terms)

###############################################################################
# Using add_ref_termset for an entire dataset
# ------------------------------------------------------
# As mentioned above, :py:func:`~hdmf.common.resources.HERD.add_ref_termset`
# supports iteratively validating and populating :py:class:`~hdmf.common.resources.HERD`.

# When populating :py:class:`~hdmf.common.resources.HERD`, users may have some terms
# that are not in the :py:class:`~hdmf.term_set.TermSet`. As a result,
# :py:func:`~hdmf.common.resources.HERD.add_ref_termset` will return an all the missing
rly marked this conversation as resolved.
Show resolved Hide resolved
# terms in a dictionary. It is up to the user to either add these terms to the
# :py:class:`~hdmf.term_set.TermSet` or remove them from the dataset.
mavaylon1 marked this conversation as resolved.
Show resolved Hide resolved

er = HERD()
terms = TermSet(term_schema_path='example_term_set.yaml')
file = HERDManagerContainer(name='file')

er.add_ref_termset(file=file,
container=species,
attribute='Species_Data',
termset=terms)

###############################################################################
# Write HERD
# ------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions docs/gallery/plot_term_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,6 @@
# To add a column that is validated using :py:class:`~hdmf.term_set.TermSetWrapper`,
# wrap the data in the :py:func:`~hdmf.common.table.DynamicTable.add_column`
# method as if you were making a new instance of :py:class:`~hdmf.common.table.VectorData`.
species.add_column(name='Species_3',
description='...',
data=TermSetWrapper(value=['Ursus arctos horribilis', 'Mus musculus'], termset=terms),)
4 changes: 2 additions & 2 deletions src/hdmf/backends/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def write(self, **kwargs):
from hdmf.common import HERD
herd = HERD(type_map=self.manager.type_map)

# add_ref_term_set to search for and resolve the TermSetWrapper
herd.add_ref_term_set(container) # container would be the NWBFile
# add_ref_container to search for and resolve the TermSetWrapper
herd.add_ref_container(container) # container would be the NWBFile
# write HERD
herd.to_zip(path=self.herd_path)

Expand Down
Loading
Loading