Giter Club home page Giter Club logo

smarter-backend's People

Contributors

bunop avatar

Watchers

 avatar  avatar  avatar

smarter-backend's Issues

:sparkles: return 4xx error when querying with wrong parameters

When making a request with a wrong parameter (a parameter not implemented) such parameter is ignored and there's no cloue to understand that this parameter is wrong (for example, there's a typo) and more results than expected are returned. The allowed parameters need to be clearly stated when defining and endpoint

:sparkles: query with multiple parameters

Support query with multiple parameters like /smarter-api/datasets?type=foreground&type=phenotypes traslated in R with:

get_smarter_datasets(token, query=list(type='foreground', type='phenotypes'))

When searching in arrays, all condition need to be applied. When searching in a single field or condition need to be applied

Desidered behaviour:

  • query for multiple dataset types (all condition)
  • query for multiple chips (all condition) in variants
  • query for multiple chips (or condition) in dataset and samples
  • query for multiple breeds, breed codes and countries in samples (or condition)
  • query for multiple datasets in samples (or condition)

:sparkles: enforce token authentication

Enforce token authentication to browse data:

  • Install and configure bcrypt and jwt-extended flask module
  • Add user using script (no API for new user)
  • Test cli script
  • Add endpoint for authentication
  • Test authentication
  • Protect all endpoints using authentication
  • Test authentication with endpoints

:card_file_box: support variant sorting by locations

Sorting variant by locations is a little tricky, since ordering with mongoengine or using a mongodb query doesn't work as intended (it's not clear which fields in the location array is used). The only way to order by the desired location is by using an aggregation pipeline using $filter method, since $elemMatch can't be applied in projection. The query is the structured like this:

db.variantSheep.aggregate(
    [
        {
            $match: {
                locations: {
                    $elemMatch: {
                        imported_from: "SNPchiMp v.3",
                        version: "Oar_v3.1"
                    }
                }
            }
        },
        {
            $project:  {
                name: 1,
                rs_id:1,
                locations: {
                    $filter: {
                        input: "$locations",
                        as: "loc",
                        cond: {
                            $and: [
                                {$eq: ["$$loc.imported_from", "SNPchiMp v.3"]},
                                {$eq: ["$$loc.version", "Oar_v3.1"]}
                            ]
                        }
                    }
                }
            }
        },
        {
            $sort: {
                "locations.chrom": 1
            }
        }
    ], { "allowDiskUse" : true }
).pretty()

Moreover, this aggregation exceed the default 100Mb or RAM reserved by sorting in aggregation, and require to use disk to be completed. Considering this, is not clear how could be informative sorting variants by location, especially if this endpoints will be used with async operations. Ordering by locations will be not supported

:sparkles: support parameters into GeoJSON endpoint

Support query with parameters for GeoJSON endpoints

  • Accept parameters for get endpoints (breed, breed_code, country, chip_name, dataset_id)
  • Accept multiple parameters for get endpoints
  • Model geo_within_polygon and geo_within_sphere in post endpoints

:zap: limit variant locations in variants detail page

display only smarter coordinates in variant detail endpoint. This could be done by creating a new collection with only the information I need. This collection will be served by the endpoint.

  • Create variant collections with only SMARTER coordinates
  • Replace the collection used by the variant endpoints
  • Test if there are improvement in speed or in fetching data

:recycle: flat location data in variants endpoints

Since variation endpoints return a single location from database, location content can be flatten within the varriation object. For example

{
    "_id": {
        "$oid": "6151e7cbb031ca6359300237"
    },
    "chip_name": [
        "IlluminaGoatSNP50"
    ],
    "locations": [
        {
            "chrom": "1",
            "date": {
                "$date": 1610064000000
            },
            "illumina": "T/C",
            "illumina_strand": "BOT",
            "illumina_top": "A/G",
            "imported_from": "manifest",
            "position": 18960,
            "strand": "TOP",
            "version": "ARS1"
        }
    ],
    "name": "1_18960_AF-PAKI",
    "probeset_id": [],
    "sequence": {
        "manifest": "AGCTGGAGATGACACTGGCTCGGAGTGGAGCTGTGGCCACGCAGGCGGAATATGAAACGC[A/G]TTTTGGAGGCATAGGAGATCTGGGGCAAGGACCAAGGACCACTCAAAAAACTTAAGAGAC"
    }
}

Could become

{
    "_id": {
        "$oid": "6151e7cbb031ca6359300237"
    },
    "chip_name": [
        "IlluminaGoatSNP50"
    ],
    
    "chrom": "1",
    "date": {
        "$date": 1610064000000
    },
    "illumina": "T/C",
    "illumina_strand": "BOT",
    "illumina_top": "A/G",
    "imported_from": "manifest",
    "position": 18960,
    "strand": "TOP",
    "version": "ARS1",

    "name": "1_18960_AF-PAKI",
    "probeset_id": [],
    "sequence": {
        "manifest": "AGCTGGAGATGACACTGGCTCGGAGTGGAGCTGTGGCCACGCAGGCGGAATATGAAACGC[A/G]TTTTGGAGGCATAGGAGATCTGGGGCAAGGACCAAGGACCACTCAAAAAACTTAAGAGAC"
    }
}

An this will be simpler to parser with smarterapi R library

:whale: try to install a newer version of docker compose

Try to install a more recent docker-compose version on Partner Queue Solution machines, by modifying .travis.yml (maybe by changing uname -s and uname -m outputs):

env:
  global:
  - DOCKER_COMPOSE_VERSION=1.27.4
# https://docs.travis-ci.com/user/docker/#using-docker-compose
before_install:
  - sudo rm /usr/local/bin/docker-compose
  - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
  - chmod +x docker-compose
  - sudo mv docker-compose /usr/local/bin

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.