GithubHelp home page GithubHelp logo

tripal / brapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 3.0 1.39 MB

Breeding API client-server implementation (v1 & v2) for Tripal

Home Page: https://www.drupal.org/project/brapi

PHP 97.28% Twig 0.85% JavaScript 1.86%

brapi's Introduction

alt tag

Tripal 4 (Drupal 10)

               _   _                 _____                 _                                  _
     /\       | | (_)               |  __ \               | |                                | |
    /  \   ___| |_ ___   _____      | |  | | _____   _____| | ___  _ __  _ __ ___   ___ _ __ | |_
   / /\ \ / __| __| \ \ / / _ \     | |  | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __|
  / ____ \ (__| |_| |\ V /  __/     | |__| |  __/\ V /  __/ | (_) | |_) | | | | | |  __/ | | | |_
 /_/    \_\___|\__|_| \_/ \___|     |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__|
                                                                  | |
                                                                  |_|

Compatibility

Target Drupal Version 10.2.x-dev

Tested on PostgreSQL 13 + PostgreSQL 16

Drupal 10.2.x 10.3.x
PHP 8.1 Grid81-102-Badge Grid81-103-Badge
PHP 8.2 Grid82-102-Badge Grid82-103-Badge
PHP 8.3 Grid83-102-Badge Grid83-103-Badge

Code Coverage

This project uses Code Climate to determine the quality of our codebase and the coverage of our test suite. Compatibility above is based on passing of this test suite.

Test Coverage

Maintainability

Current Timeline

Required for Tripal 4.alpha3 Release

  • Display suite / page work
  • Importers: Publications
  • Search (ElasticSearch + Views)

How to get involved!

This upgrade to Drupal 10 is a community effort. As such, we NEED YOUR HELP!

  • To get involved, please join our Tripal Slack and comment in the #core-dev channel.
    • Alternatively, feel free to contact Lacey-Anne Sanderson through Slack direct message.
    • We can use help both with programming, documentation, outreach and welcome all individuals from all backgrounds!
  • We prefer automated testing for all Pull Requests (PRs) and are happy to guide you through the process!
    • Just comment on the issue if you need help designing tests
    • If you need help implementing tests see our documentation
  • If more documentation would be helpful, please create an issue here and we'll add it.

Documentation

Documentation for Tripal 4 has begun on ReadtheDocs.

Tripal Docker

Tripal Docker is currently focused on Development and Automated Testing. There will be a production focused Tripal Docker soon and if you're interested in helping or providing tips -please join us on our Slack channel!

For more information about how to use our fully functional development docker, see our documentation on ReadtheDocs!

brapi's People

Watchers

 avatar  avatar  avatar  avatar  avatar

brapi's Issues

Germplasm call does not work

Create three germplasms (same type: cultivar) in a fresh triple site, got this error when tried to call these germplasms.

Fatal error: Call to undefined function chado_get_nid_from_id() in /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.const.inc on line 1824 Call Stack: 0.0004 238536 1. {main}() /home/ubuntu/workspace/index.php:0 0.1129 2813760 2. menu_execute_active_handler() /home/ubuntu/workspace/index.php:21 0.1130 2814856 3. call_user_func_array:{/home/ubuntu/workspace/includes/menu.inc:527}() /home/ubuntu/workspace/includes/menu.inc:527 0.1130 2815360 4. brapi_call_wrapper() /home/ubuntu/workspace/includes/menu.inc:527 0.1133 3035592 5. call_user_func_array:{/home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:90}() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:90 0.1133 3035792 6. brapi_v1_germplasm_json() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:90 0.1284 3054152 7. brapi_process_crud() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:1087 0.1347 3158168 8. brapi_v1_germplasm_search_json() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.api.inc:1789 0.1348 3165168 9. brapi_v1_object_search_json() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:1054 0.1928 3291152 10. call_user_func:{/home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:528}() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:528 0.1928 3291216 11. brapi_get_germplasm_details() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:528 0.1946 3298336 12. brapi_get_field() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.calls.inc:1307 0.1946 3298656 13. {closure:/home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.const.inc:1815-1832}() /home/ubuntu/workspace/sites/all/modules/brapi/api/brapi.api.inc:1412

7.x-3.x some sql is missing braces around chado table names

Example error accessing traits:

"CRUD error! An exception occurred (mode list): SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "cvterm" does not exist\nLINE 1: ...bx.accession AS "trait_id" FROM cvterm cvt...\n ^"

Using the Tripal v3 Web Services Class

In order to integrate more fully with Tripal v3 I would like to propose using the web services classes that Tripal provides. I recently met with @laceysanderson to review those classes and in the process we experimented to see how well BrAPI could fit into those classes. Our early results were promising! I want to do a bit more work on the class implementation and then I'll share the sample implementation.

Fix BRAVA Error on metadata model of various endpoints

Failed BRAVA test: Response structure doesn't match schema:

Test: Json matches schema: /schemas/v1.2/metadata.json

Error: validation - additionalProperties
In element: /metadata
Invalid items: aggregated_from
Message: object instance has properties which are not allowed by the schema: ["aggregated_from"]

Fix BRAVA Error on /locations listing of location data

BRAVA Test Failure:

Test: Json matches schema: /schemas/v1.2/locations.json

Response structure doesn't match Schema.

Error: validation - type
In element: /result/data/*/name
Expected: string
Found: null
Message: instance type (null) does not match any allowed primitive type (allowed: ["string"])

(note: '*' denotes any number of location id's

Default implementation of commonCropNames: should this be organism.common_name rather than orgranism.species?

The call /commonCropNames defaults to the species field in the organism table if a list isn't provided. Is this the expected behavior per the BrAPI spec? I currently have 80 species of peanut which are associated with stocks, which creates a long list that I would rather not have to enter in the settings field to get them returned correctly by the commonCropNames call. Also, this would be incorrect for databases that manage more than one genus.

7.x-3.x install issue, detecting tripal 2 instead of 3

The module install is detecting tripal version as 2 on a version 3 site. This is because a v2 module tripal_core is reported as existing on the v3 site.
I will submit a pull request to invert the order of version checking and check for the v3 module tripal first.

PHP8 warning on "/brapi/v1/variables"

There is an error in the code for the 1.1 /brapi/v1/variables call, it attempts to look up a leadPerson from a cvterm, but leadPerson is not a field that this should return? Errors that show up in the log:

Warning: Undefined variable $project in {closure}() (line 3708 of .../sites/all/modules/brapi/api/brapi.const.inc).
Warning: Attempt to read property "project_id" on null in {closure}() (line 3708 of .../sites/all/modules/brapi/api/brapi.const.inc).
Warning: Trying to access array offset on value of type bool in {closure}() (line 3714 of .../sites/all/modules/brapi/api/brapi.const.inc).

Bugs in brapi_get_field() when field is of type array.

This may be a PHP version issue. Running PHP 7.1, this type of statement:
$identifier = $object->$field_fetcher['object_key'];
fails with:
Array to string conversion
and
Undefined property: stdClass::$Array
Even though PHP admits that $field_fetcher['object_key'] is of type string.

This fixes the problem:

$ok = $field_fetcher['object_key'];
$identifier = $object->$ok

But is rather ugly. Hoping there's a nicer solution.

Fix BRAVA error on Germplasm biologicalStatusOfAccessionCode retrieval

BrAPI BRAVA failed test for /germplasm-search
Test Json matches schema: /schemas/v1.2/germplasm-search.json

Error: validation - type
In element: /result/data/1/biologicalStatusOfAccessionCode
Expected: integer, null
Found: string
Message: instance type (string) does not match any allowed primitive type (allowed: ["integer","null"])

Javascript error

The module settings page won't work for me: none of the divs will open and there's an error:

TypeError: $(...).not(...).addClass(...).on is not a functionbrapi.module.js:356:6
    attach https://peanutbase-dev.usda.iastate.edu/sites/all/modules/brapi/theme/js/brapi.module.js?pswjux:356
    jQuery 2
    init https://peanutbase-dev.usda.iastate.edu/misc/drupal.js?pswjux:26
    b jQuery
    attach https://peanutbase-dev.usda.iastate.edu/sites/all/modules/brapi/theme/js/brapi.module.js?pswjux:327
    attachBehaviors https://peanutbase-dev.usda.iastate.edu/misc/drupal.js?pswjux:112
    each jQuery
    attachBehaviors https://peanutbase-dev.usda.iastate.edu/misc/drupal.js?pswjux:110
    <anonymous> https://peanutbase-dev.usda.iastate.edu/misc/drupal.js?pswjux:593
    jQuery 2

The problem seems to have started in commit e17f493 (Merge pull request #28...). Could this be related to BrAPI.js? It was merged into the code in that commit.

7.x-3.x Infraspecific nomenclature

It appears that the chado 1.3 infraspecific nomenclature in the organism table is not being used as a method to generate the BrAPI "subtaxa" value. I will propose a fix to brapi_get_organism_info()

Implement pre-filtering on data types

Some data types may need to be pre-filtered. For instance germplasm and sample share the same table but differ by type_id. The type_id is filtered on the search call but not when an identifier is provided. Therefore, the sample/{sampleDbId} will work with a germplasmDbId while it should not because no-prefiltering occurs.
Another case is the traits/ call that will list all the CV terms, even non-trait ones.
Pre-filtering should be specified in the brapi_get_data_mapping() call.

Change Default branch?

As we're now developing on 7.x-3.x, we should change the default branch for this repository.

The reason I bring this up is that it impacts which README is shown to users. Currently, even though PR #18 is merged, no one sees the new README. This means, no one is told there is more documentation available...

Trait terms limitation

Only trait-related CV terms should be returned by the traits/ call. This issue should be solved after issue #21 has been fixed. Then, fields should be added on the setting page to select CVs containing traits and parent CV terms of trait CV terms, the same way it has been done for germplasm attributes.

Fix BRAVA Error on /variables endpoint

BRAVA test error: Response structure doesn't match schema:

Test: Json matches schema: /schemas/v1.2/variables.json

Error: validation - type
In element: /result/data/0/contextOfUse
Expected: array, null
Found: string
Message: instance type (string) does not match any allowed primitive type (allowed: ["array","null"])

AND

Error: validation - minItems
In element: /result/data/2/scale/validValues/categories
Minimum items: 1
Message: array is too short: must have at least 1 elements but instance has 0 elements

NOTE: This latter error may be due to the absence of data in the test database used.

Generally, the tripal/brapi module doesn't seem to implement the full set of fields covered by the variable specification. The above error simply picks up on a field which has an expected type of 'array' (other empty or missing fields are just ignored).

Failed attempt to install latest (commit 962ffe4) Tripal Brapi module inside docker-tripal v3.x

In an exploratory way, I attempt to add in the BrAPI module into the tripal service of the dockerized-gmod-deployment (master branch, latest commit 135079e) docker-compose build. Here's the relevant failure point in the log:

tripal_1 | WD system: brapi_site module installed. [info]
tripal_1 | WD system: brapi_site module enabled. [info]
tripal_1 | WD php: Error: Call to undefined function tripal_cv_load_obo_v1_2() [error]
tripal_1 | in brapi_add_cvs() (line 206 of
tripal_1 | /var/www/html/sites/all/modules/brapi/brapi.install).
tripal_1 | Cannot modify header information - headers already sent by (output [warning]
tripal_1 | started at /root/.composer/vendor/drush/drush/includes/output.inc:40)
tripal_1 | bootstrap.inc:1486
tripal_1 | Error: Call to undefined function tripal_cv_load_obo_v1_2() in brapi_add_cvs() (line 206 of /var/www/html/sites/all/modules/brapi/brapi.install).
tripal_1 | Drush command terminated abnormally due to an unrecoverable error. [error]
tripal_1 | A non well formed numeric value encountered drush.inc:1643 [notice]

OBOLoader error when trying to install on Tripal 3

I received the following error message:

Warning: array_key_exists(): The first argument should be either a string or an integer in OBOImporter->addDB() (line 2217 of /home/ubuntu/workspace/sites/all/modules/tripal/tripal_chado/includes/TripalImporter/OBOImporter.inc).
Exception: Cannot cache terms without a default DB.Array ( [id] => Array ( [0] => CO_020:0000000 ) [name] => Array ( [0] => multicrop passport ontology ) [comment] => Array ( [0] => release date: June 30, 2015\nversion: 2.1. Adapted from FAO/Bioversity Multi-Crop Passport Descriptors, December 2015\ncoverage: Multi-Crop Passport Descriptors\ncreator: Jeffrey Detras, Tom Hazekamp and Richard Bruskiewich, updated by Leo Valette\npublisher: Bioversity International and IRRI under the Generation Challenge Program ) [xref] => Array ( [0] => GCPDomainModel:CO_000:0000165 ) ) in OBOImporter->cacheTermStanza() (line 1721 of /home/ubuntu/workspace/sites/all/modules/tripal/tripal_chado/includes/TripalImporter/OBOImporter.inc).

PDO Error when trying to configure without first setting permissions

After installing the modules and loading the MCPD ontology, I attempted to configure the module by going to admin/tripal/extension/brapi. On this page I receive the following

PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near ")" LINE 4: WHERE r.name IN (); ^: SELECT COUNT(DISTINCT(ur.uid)) FROM {users_roles} ur JOIN {role} r ON r.rid = ur.rid WHERE r.name IN ();; Array ( ) in brapi_theme_compute_role_stats() (line 47 of /var/www/dev/tripal/sites/all/modules/brapi/theme/brapi.theme.inc).

When navigating to People > Permissions, there were none set for "Breeding API" or "Breeding API site entity".

Fix BRAVA Error on /traits endpoint

Failed BRAVA test: Response structure doesn't match schema.

Test: Json matches schema: /schemas/v1.2/traits.json

Error: validation - additionalProperties
In element: /result/data/0
Invalid items: traitName
Message: object instance has properties which are not allowed by the schema: ["traitName"]

AND

Error: validation - minItems
In element: /result/data/0/observationVariables
Minimum items: 1
Message: array is too short: must have at least 1 elements but instance has 0 elements

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.