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

Add resource reference tables #442

Merged
merged 49 commits into from
Nov 14, 2020
Merged

Add resource reference tables #442

merged 49 commits into from
Nov 14, 2020

Conversation

ajtritt
Copy link
Contributor

@ajtritt ajtritt commented Oct 21, 2020

Motivation

Add the ability to track the use of external resource references across a file.

Fix #156

How to test the behavior?

import pandas as pd
from hdmf.common import ExternalResources

er = ExternalResources('terms')
er.add_ref('01234567-89ab-cdef-0123-456789abcdef', 'species', 'mouse', 'NCBI Taxonomy', '10090',
           'https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=10090')
er.add_ref('fedcba98-7654-3210-fedc-ba9876543210', 'gene', 'Cacna1s', 'Mouse Genome Informatics', 'MGI:88294',
           'http://www.informatics.jax.org/marker/MGI:88294')


# Alternatively, keys can be added in bulk

df = pd.DataFrame(
    data = [['mouse', 'NCBI Taxonomy', '10090', 'https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=10090'],
            ['Cacna1s', 'Mouse Genome Informatics', 'MGI:88294', 'http://www.informatics.jax.org/marker/MGI:88294']],
    columns = ['key_name', 'resource_name', 'resource_id', 'resource_uri']
)

keys = er.add_keys(df)
er.add_ref('01234567-89ab-cdef-0123-456789abcdef', 'species', keys['mouse'])
er.add_ref('fedcba98-7654-3210-fedc-ba9876543210', 'gene', keys['Cacna1s'])

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running flake8 from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

@ajtritt ajtritt requested review from rly and oruebel October 21, 2020 00:59
@rly
Copy link
Contributor

rly commented Nov 14, 2020

Looking at https://codecov.io/gh/hdmf-dev/hdmf/pull/442/diff

Can you also write tests for Table.to_dataframe(), Table.from_dataframe(), and ExternalResources.get_key()? It would be nice to get 100% diff coverage for all of this new code (we'll have to write these tests eventually and it's better done now than later), but if not, these functions should be tested at least partially.

@rly
Copy link
Contributor

rly commented Nov 14, 2020

Otherwise, it looks good to me!

@ajtritt ajtritt merged commit ed9b98f into dev Nov 14, 2020
@rly rly deleted the enh/resref branch November 16, 2020 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move NWBTable functionality to generic Table class in hdmf.common
4 participants