GithubHelp home page GithubHelp logo

dmachi / p3api Goto Github PK

View Code? Open in Web Editor NEW
0.0 5.0 1.0 40.12 MB

p3api dev

JavaScript 73.57% Shell 0.01% CSS 23.22% HTML 1.37% Python 1.21% Ruby 0.01% Smarty 0.01% ActionScript 0.22% PHP 0.17% XSLT 0.21% Batchfile 0.01%

p3api's Introduction

PATRIC 3 API SERVER

##Installation

# git clone --recursive [email protected]:dmachi/p3api.git
# cd p3api
# npm install
# cp p3api.conf.sample p3api.conf and modify as appropriate

##Running ./bin/p3api-server

##Running With Debugging Enabled DEBUG=p3api-server ./bin/p3api-server

##Testing Testing requires internjs to be installed (https://theintern.github.io/). It can be installed globally like so:

sudo npm install intern -g

Test files exist in the tests/ directory. All of the configured tests can be run by launching the p3api server locally on port 3001 (the default port) and then running

npm test

Individual test suites from the tests/ directory can be run by specifying them to intern-client

intern-client config=tests/intern suite=tests/query

###API Usage

The p3api server allows for direct retrieval of objects from the data source through HTTP GET request using the unique ID for each data type (i.e., genome_id for the Genome collections) as well as querying data sources using either RQL syntax or SOLR query syntax.

Genome Retrieval Example:

http://HOST:PORT/genome/GENOME_ID

Queries can be submitted as GET requests (with the query in the URL) or as POST requests with the query contained in the request body. The latter is useful for large queries which would exceed the maximum length of URLs supported by browsers/servers.

Genome Feature Query Example:

http://HOST:PORT/genome_feature/?eq(annotation,PATRIC)&select(genome_id,genome_name,annotation)&limit(10)&http_accept=application/json

Responses from queries are available in a number of formats:

  • application/json : Returns an array of response objects
  • application/solr+json : Returns an objects in the SOLR response format
  • text/csv : Returns objects in comma separated values format. Columns are separated by ',', Multi-value columns are separated by ';', and rows are separated by "\n"
  • text/tsv : Returns objects in tab separated values format. Columns are separted by "\t", Multi-value columns are separated by ";", and rows are separted by "\n"
  • application/vnd.openxmlformats : Returns objects for use in MS Excel
  • application/dna+fasta : Returns DNA sequences for queries in FASTA format (this currently only makes sense for the 'genome_feature' collection)
  • application/protein+fasta: Returns Protein sequences for queries in FASTA format (this currently only makes sense for the 'genome_feature' collection)
  • application/gff : Returns a genomic features in GFF format (This only makes sense for the 'genome_feature' collection)

The response format is determined by passing in the desired type in the HTTP Accept header of the request. In cases where it is not possible to supply HTTP headers, the accept header can be specified by adding &http_accept=FORMAT in the URL itself (e.g., &http_accept=application/json)

The following operators are available for RQL Queries:

  • eq(FIELD,VALUE) : Equals
  • gt(FIELD,VALUE) : Greater than
  • lt(FIELD,VALUE) : Less than
  • gte(FIELD,VALUE) : Greater than or equal to
  • lte(FIELD,VALUE) : Less than or equal to
  • keyword(VALUE) : Text search (the specific fields that will be searched depends on the data sources' configuration)
  • in(FIELD,(VALUE1,VALUE2,VALUE3)) : Returns objects whose FIELD contains any of the provided values
  • and(EXPRESSION,EXPRESSION,...) : ANDs two or more expressions together
  • or(EXPRESSION,EXPRESSION,...) : ORs two or more expressions together
  • select(FIELD1,FIELD2,FIELD3,....) : Returns only the specified fields from result objects
  • sort([+|-]FIELD,[+|-]FIELD2) : Sorts result data by field. Specify + or - to sort the results ascending or descending
  • limit(COUNT,START) : Specifies a limit to the query where COUNT is the total number of objects to return and start is the starting index within the query to return from
  • GenomeGroup(WORKSPACE_PATH) : Retrieves the GenomeGroup from WORKSPACE_PATH for use in a query (e.g., &in(genome_id,GenomeGroup(/path/to/my/group)) )
  • FeatureGroup(WORKSPACE_PATH) : Retrieves the FeatureGroup from WORKSPACE_PATH for use in a query (e.g., &in(feature_id,FeatureGroup(/path/to/my/group)) )
  • facet((FACET_PROPERTY,PROPERTY_VALUE),(FACET_PROPERTY,PROPERTY_VALUE),...) : Allows facets to be specified along with a query. Facet results are included in the HTTP response header when the response content-type is application/json and included in the response body for application/solr+json

HTTP Headers can be supplied normally or in a url by preceding the header name with "http_". (e.g., &http_accept=application/json)

Requests can force the server to set content-dispostion (thereby forcing a browser to download the file) by adding &http_download onto the url.

p3api's People

Contributors

aswarren avatar hyoo avatar

Watchers

Dustin Machi avatar  avatar James Cloos avatar  avatar H. Mendes-Soares avatar

Forkers

aswarren

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.