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 Gigwa endpoints #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 12 additions & 5 deletions config/extract-brapi/entities/study.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
},
"detail": {
"required": true,
"call": {
"method": "GET",
"path": "studies/{studyDbId}"
}
"call": [
{
"method": "GET",
"path": "studies/{studyDbId}"
},
{
"method": "GET",
"path": "studies-search",
"param": {"param_name": "studyDbId", "param_value": "{studyDbId}"}
}
]
},
"links": [
{
Expand Down Expand Up @@ -96,4 +103,4 @@
"json-path": "."
}
]
}
}
12 changes: 12 additions & 0 deletions sources/Bioversity_GIGWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"@context": {
"schema": "http://schema.org/",
"brapi": "https://brapi.org/rdf/"
},
"@type": "schema:DataCatalog",
"@id": "https://www.bioversityinternational.org",
"schema:identifier": "Bioversity_GIGWA",
"schema:name": "Bioversity_GIGWA",
"brapi:endpointUrl": "https://www.crop-diversity.org/gigwa/rest/GWAS_musa_acuminata_v2/brapi/v1/",
"brapi:studyType": "Genotyping"
}
12 changes: 12 additions & 0 deletions sources/CIRAD_GIGWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"@context": {
"schema": "http://schema.org/",
"brapi": "https://brapi.org/rdf/"
},
"@type": "schema:DataCatalog",
"@id": "https://www.cirad.fr",
"schema:identifier": "CIRAD_GIGWA",
"schema:name": "CIRAD_GIGWA",
"brapi:endpointUrl": "https://gigwa.southgreen.fr/gigwa/rest/Sorghum-JGI_v1/brapi/v1/",
"brapi:studyType": "Genotyping"
}
12 changes: 12 additions & 0 deletions sources/IRD_GIGWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"@context": {
"schema": "http://schema.org/",
"brapi": "https://brapi.org/rdf/"
},
"@type": "schema:DataCatalog",
"@id": "https://www.ird.fr",
"schema:identifier": "IRD_GIGWA",
"schema:name": "IRD_GIGWA",
"brapi:endpointUrl": "https://gigwa.ird.fr/gigwa/rest/AfricanRice/brapi/v1/",
"brapi:studyType": "Genotyping"
}
77 changes: 76 additions & 1 deletion tests/common/test_brapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from etl.common.brapi import get_identifier, get_entity_links
from etl.common.brapi import get_identifier, get_entity_links, get_implemented_call


class TestGetIdentifier(unittest.TestCase):
Expand Down Expand Up @@ -105,3 +105,78 @@ def test_nested_DbIds(self):
]
actual = get_entity_links(self.data, 'DbId')
self.assertEqual(expected, actual)


class TestGetDetails(unittest.TestCase):
"""
Get DbId identifier from BrAPI object
"""

def test_get_simple_study_details(self):
test_source = {
"@context": {
"schema": "http://schema.org/",
"brapi": "https://brapi.org/rdf/"
},
"@type": "schema:DataCatalog",
"@id": "https://www.foo.fr",
"schema:identifier": "foo",
"schema:name": "foofoo",
"brapi:endpointUrl": "https://www.foo.fr/brapi/v1/",
"brapi:studyType": "Genotyping"
}
test_source['implemented-calls'] = {
"GET studies",
"GET studies/{studyDbId}"}
detail_call_group = {
"required": "true",
"call": {
"method": "GET",
"path": "studies/{studyDbId}"
}
}
entity_name = 'study'
entity_id = entity_name + 'DbId'
detail_call = get_implemented_call(test_source, detail_call_group, {entity_id: "myStudyId"})

self.assertEqual({'method': 'GET', 'path': 'studies/myStudyId'}, detail_call)

def test_get_complex_study_details(self):

entity_name = 'study'
entity_id = entity_name + 'DbId'
test_source = {
"@context": {
"schema": "http://schema.org/",
"brapi": "https://brapi.org/rdf/"
},
"@type": "schema:DataCatalog",
"@id": "https://www.foo.fr",
"schema:identifier": "foo",
"schema:name": "foofoo",
"brapi:endpointUrl": "https://www.foo.fr/brapi/v1/",
"brapi:studyType": "Genotyping"
}
test_source['implemented-calls'] = [
"GET studies",
"GET studies-search"
]
detail_call_group = {
"required": "true",
"call": [
{
"method": "GET",
"path": "studies/{studyDbId}"
},
{
"method": "GET",
"path": "studies-search",
"param": {"param_name": entity_id, "param_value": "{studyDbId}"}
}
]
}
detail_call = get_implemented_call(test_source, detail_call_group, {entity_id: "myStudyId"})

self.assertEqual({'method': 'GET',
'param': {'param_name': 'studyDbId', 'param_value': 'myStudyId'},
'path': 'studies-search'}, detail_call)