API Guide: Real-Time Personalization (+RTP) API | Universal Genomics API

Real-Time Personalization (+RTP) API Guide

Real-Time Personalization (+RTP) API Guide

Apps-Genes-Realtime-Personalization-Sequencing-com

Introduction

Developer Center Logo Sequencing.com

This Overview section provides a developer with information about using the Sequencing.com platform to develop apps using the Real-Time Personalization® (+RTP) API.

What is Real-Time Personalization (+RTP)?

Real-Time Personalization®  (+RTP) is a web service technology that enables software applications (apps) to provide context to data.

Context refers to an app having the ability to comprehend the uniqueness and individuality of each app user. In essence, the app is able to become cognizant of the app user as a unique individual.

Empowered by patent-pending Real-Time Personalization®  technology, apps can now implicitly understand whether data is relevant to the user as the data is generated in real-time. And with an app’s cognizance of the user comes the ability for the app to provide a truly personalized experience.

Example of Real-Time Personalization (+RTP)

Example of Real-Time Personalization (+RTP) API

The Weather My Way +RTP app is available in both the Apple App Store and Google Play. The open source code is also available on GitHub.

Available on the Apple App Store      Available for Android on the Google Play Store       Sequencing.com's GitHub Repo

How does Real-Time Personalization work?

Bioinformatics icon for Sequencing.com

Real-Time Personalization technology utilizes the most fundamental factor that makes each of us unique - our genes.

Sequencing.com’s Real-Time Personalization (+RTP) technology allows your app to obtain genetic-based information about the app user by making simple API calls to Sequencing.com.  The +RTP API enables your app to provide a personalized, gene-based user experience.

Adding +RTP to your app is easy. You don't need to know anything about genetics and you also don't need to learn any new coding languages.

Each +RTP API consists of:

  • API request to Sequencing.com that includes a specific App Chain #
  • Sequencing.com performs an ultra-rapid, real-time analysis of the app user's genes
  • API response to your app with the result
    • Most responses are simple "Yes" or "No"

Through this approach, app developers can easily create personalized apps simply by utilizing Sequencing.com’s straightforward open API.

+RTP API plugins and code snippets are available for multiple languages and platforms and their number is constantly extended.

 

Example

  1. App Chain88 determines whether the app user is likely to benefit from taking a Vitamin D supplement.
  2. Your app will submit an API request for Chain88, Sequencing.com will perform ultra-rapid genetic analysis of the app user's genes.  
  3. Your app will then receive the API response within a few milliseconds that will be one of the following:
    • yes
    • no
    • insufficient data
    • error
  4. You code your app accordingly so that the user experience is tailored to the possible API responses.
  5. Your app now provides a genetically tailored user experience to the app users genes!

 

Related

Developer Center

Plugins and Code Snippets

What is the ‘+RTP’ Designation?

+RTP icon

+RTP is a designation awarded to apps that are developed with Real-Time Personalization technology.

An app can be created by any developer and made available on any platform or operating system. If you already have an app that processes or uses genetic data and are interested in having your app appear in Sequencing.com's App Market, please register for a Sequencing.com account and submit a Support Request with information about your app.

If you're interested in using RTP technology to create an app for any platform, including iOS, Android, Linux, Windows, and Web, please register for a Sequencing.com account and then visit the Developer Center, which provides quick access to developer resources. 

What if I'm not familiar with genetics?

You can still easily integrate RTP into your own apps. This is because RTP technology was created so that it can be used by software developers regardless of their background or knowledge about genetics.

For those concerned about learning yet another new coding language, we hear you - we understand that you’re tired of learning one new language after the other. But fear not as we RTP translates genetic data into software code so that you don't have to learn anything new.

If you know how to use REST APIs then you can integrate RTP into your apps in a matter of minutes.

Plans and Pricing

Sequencing.com’s Real-Time Personalization (+RTP) API is free for development use.

 

View the +RTP API Subscription Plans

 

 

Related

Join the Developer Alliance and receive your own free VM (and more)

App Chains

App Chains Icon

Search the list of App Chains

 

App Chains enable app developers without any experience or understanding of genetics to easily and quickly add genetically-tailored personalization to their apps.

Each +RTP API call is defined by a specific Chain#. When Sequencing.com receives a +RTP API call for a chain#, it knows (based on the chain#), which disease, trait or medication reaction to analyze. Sequencing.com performs the genetic analysis on the app user's genes and provides straightforward results as the API response.

 

Example of using an +RTP API App Chain

You have an idea for a new iPhone App that uses Apple’s Healthkit to help prevent heart attacks. You’re interested in adding personalization to this app but you don’t know anything about the genes that cause a heart attack.

Simply search the list of App Chains and you'll find Chain73 is for heart attack risk. Add Chain73 to your app (its easy with the Objective-C or Swift +RTP API Master Plugin) and indicate the action that will trigger your app to make this API call to Sequencing.com. For example, the action may be if app senses via GPS that the user walks into a restaurant that sells unhealthy food or if the app senses the user's heart rate exceeds 100 beats per minute. As the developer, you also code how your app responds to the possible responses for each App Chain.

When the user downloads your app from the App Store, she sees the option to 'Sign in with Sequencing.com.' The user already has her genetic data safely stored at Sequencing.com so she signs in with her Sequencing.com credentials and authorizes your app to connect to her genetic data. Her app will then remain connected to her genetic data at Sequencing.com unless she revokes access. While the user has the option to revoke access at any time, most users connect an app to their Sequencing.com account once and then leave it connected.

The next day the user feels hungry and is passing by a McDonalds so she walks into the restaurant. Your app detects via GPS that she just walked into a fast food restaurant so the +RTP API is triggered and an API call for Chain73 is sent to Sequencing.com. Sequencing.com returns an almost immediate response that the user's genes indicate she has a 'Very High' risk for a heart attack. Your app sends the user a push notification that she should strongly consider a different restaurant and identifies several nearby restaurants that would be much better for her health.

A different user of your app also walks into McDonalds around that same time. Your app sends a +RTP API call to Sequencing.com for Chain73 and, for this user, the response is 'Slightly Increased risk' of a heart attack. Instead of advising the user go to a different restaurant, your app sends a push notification to the user that identifies healthier options on the McDonalds menu for the app user to consider.

By customizing your app based on the results of the +RTP API, your app is able to provide a truly personalized user experience to each app user. And since the +RTP API returns responses in milliseconds, the personalization can occur in real-time.

Who can create an app with Real-Time Personalization?

You can.

We make it easy for all app developers to add Real-Time Personalization into their apps. And to make app development as straightforward as possible, this documentation is divided into two categories: one for App Developers and the other for Bioinformatics Experts.

Open source code that uses +RTP

Sequencing.com’s GitHub repositories provide free access to the code of a growing number of open source apps that use RTP technology.

Creating apps

App developers

  • Add RTP to your app hosted on any platform. All development is free.

  • Plugins and Code Snippets enable you to quickly add Real-Time Personalization to any app.

  • Visit the Developer Center for documentation, tools, plugins and demos.

 

Bioinformatics experts

  • Add your script or app to Sequencing.com's App Market.

    • You own your code. We make it available to a global community and handle marketing, cloud computing, bandwidth, security and payment processing.

  • Submit a Support Request for additional information.

 

Non-coders

  • If you have a great idea for an app but no coding skills, submit a Support Request and we'll connect with an app developer through the Sequencing.com community.

Hack the Genome hackathons

Are you down with RTP?

Interested in competing to create innovative apps that use Sequencing.com's Real-Time Personalization (+RTP) API? Want to be at the forefront of a new technological revolution?

Sequencing.com's Hack the GenomeTM hackathons will allow you to show your skills to the world, receive financial backing and IT support to implement future apps and win some amazing prizes.

 

Hack the Genome 2 is co-hosted by Microsoft, LifeNome and Sequencing.com.

The two-day competition will take place at Microsoft's offices in Times Square, New York City on December 2-3, 2017!

REGISTER TO COMPETE

 

Past Hackathons

Hack the Genome 1: Sequencing.com's first Hack the Genome hackathon was co-hosted by Sequencing.com and Microsoft at Microsoft's Headquarters in Redmond, Washington on April 6-7, 2017.  Learn more

Registration

To add Real-Time Personalization to your app, simply log in to your free account and then visit the Developer Center.

The cost?

  • Registration and development (up to 5,000 API calls/app) are free.
  • After 5,000 calls your app status changes to production, which costs $0.03/call. Monthly and yearly plans are also available. 

Coding Personalization

Interested in developing apps that can access the app user's genes and provide them with truly personalized user experiences?

Sequencing.com's Personalization® technology adds the ultimate Personalization to your software apps... a personalized user experience delivered in real-time that's based on each app user's genes.

We accomplished this by translating the genetic code into software code and making it available to you as simple APIs called App Chains.

 

Related

Plugins and Code Snippets

Terminology

The following section defines key terminology and concepts.

 

Sequencing.com Users

People who have registered for an account at Sequencing.com.

 

Sample Files and User Files

A sample file consists of genetic data for a person that is made available to all users. For example, one sample file is the genome of a famous scientist (Craig Venter) and another sample file is the genome of a caveman that lived 45,000 years ago.  

A user file consists of genetic data that belongs to registered user of Sequencing.com. This data is confidential and protected by Sequencing.com's Privacy Policy and Terms of Service. Our open APIs can only access user files if the user provides consent for a specific app to have access to his or her genetic information.

 

Apps

Sequencing.com facilitates the development of two types of apps:

  • Apps that are hosted by Sequencing.com and run on our servers. They can be coded in a wide variety of languages and can choose to use our APIs. These apps can be accessed by signing into Sequencing.com and searching through our App Market.
  • Apps that are hosted elsewhere, such as your server or mobile devices. These apps can be coded in any language and leverage Sequencing.com's technology through our open APIs.

 

App Chains

An app chain includes an API call and an analysis of genetic data. The API response, which is obtained when using an app chain, provides straightforward information that is based on the genetic analysis.

For example, an App Chain for heart disease risk will analyze the genetic data of an app user and return an API response that the app user is at increased risk of heart disease. The app can be programmed to provide information that is tailored to a user who has an increased risk of heart disease, such as guidance about how often the user should exercise.

Combining App Chains with data from sensors in a mobile device can also be helpful. For example, if the accelerometer in the mobile device identifies that the user is in an elevator to notify the user that he or she should consider taking the stairs next time.

A searchable list of App Chains can be found here.

 

OAuth2

Our platform utilizes OAuth2 protocol for authentication and secure API access. App developers who register for a free account at Sequencing.com can easily generate OAuth2 secrets for their apps. All API calls have to send OAuth2 tokens to our API before access is granted. Additional information about using oAuth2 can be found in the OAuth2 Guide.

+RTP Plugins, Code Snippets and Demos

This section contains references to codebases published by Sequencing.com as open source on our GitHub repository.

 

Master Plugins and Code Snippets

  • An all-in-one plugin providing full API functionality that works out-of-the-box.
  • Includes all core Sequencing.com APIs for rapid application development.

Sample Applications

  • Applications you can use as a quick all-in-one bootstrap with master plugin integrated.
  • They work out of the box.
  • Full-fledged applications that include the Master Plugin

Example of an app with +RTP (Weather My Way +RTP)

Master Plugin & Code Snippets

The 'Master Plugin' is an aggregate plugin that includes all core +RTP APIs. It enables rapid application development. 

The Master Plugin includes everything necessary to use the +RTP API:

  • OAuth2 authentication
  • App Chains
  • File Selector

 

The +RTP API Master Plugin (Plug-n-Play) is available in the following languages:

Java (Android)

Swift (iOS)

Objective-C (iOS)

C#/.NET (Web and Windows)

 

Code snippets for the +RTP API are also available for PHP, Perl, Python-Django, Java (Servlet and Spring) and C#/.NET:

OAuth2 code

File selector code

Java plugin: Maven

Visual Studio: Nuget

Integration of Swift (iOS) Master Plugin

The documentation below provides guidance for integrating Sequencing.com Master plugin into your iOS Swift mobile application.

We developed a pluggable Cocoapods component to simplify adding +RTP into your mobile app.

 

There are several prerequisites in order to complete the integration:

 

Prepare environment

1) Create Podfile in your project directory

$ pod init

2) Specify "sequencing-master-plugin-api-objc" pod parameters in Podfile

pod 'sequencing-master-plugin-api-swift', '~> 1.3.1'

3) Install the dependency in your project

$ pod install

4) Open the Xcode workspace instead of the project file

$ open *.xcworkspace

5) As a result you'll have 3 CocoaPod plugins installed: OAuth, Files Selector and App Chains

 

Integrate plugin

1) Integrate OAuth2 integration by following integration instructions from this guide

2) Integrate file selector logic by following integration instructions from this guide

  • Note: you do not need to integrate any additional Cocoapods dependencies from OAuth2/File selector/App Chains guides because "sequencing-master-plugin-api-objc" contains already everything needed.

Integration of Objective-C (iOS) Master Plugin

The documentation below provides guidance for integrating Sequencing.com Master plugin into your iOS Objective-C mobile application.

We have developed a pluggable Cocoapods component to simplify adding +RTP into your mobile app.

 

There are several prerequisites in order to complete the integration:

 

Prepare environment

1) Create Podfile in your project directory

$ pod init

2) Specify "sequencing-master-plugin-api-objc" pod parameters in Podfile

pod 'sequencing-master-plugin-api-objc', '~> 1.4.1'

3) Install the dependency in your project

$ pod install

4) Open the Xcode workspace instead of the project file

$ open *.xcworkspace

5) As a result you'll have 3 CocoaPod plugins installed: OAuth, Files Selector and App Chains

 

Integrate plugin

1) Integrate OAuth2 integration by following integration instructions from this guide

2) Integrate file selector logic by following integration instructions from this guide

  • Please note that you will not need to integrate additional Cocoapod dependencies from OAuth2/File selector/App Chains guides because "sequencing-master-plugin-api-objc" already contains everything needed.

Integration of Java (Android) Master Plugin

The documentation below provides guidance for integrating Sequencing.com Master plugin into your Android Java application.

We have developed a pluggable Gradle component to simplify adding +RTP into your mobile app.

 

There are several prerequisites in order to complete the integration:

 

Prepare environment

1) Create a new Android Gradle based project (i.e. in Android Studio or Eclipse)

2) Add Gradle dependencies

dependencies { compile 'com.sequencing:master-plugin:1.0.32' }

3) Add Gradle jcenter repository

repositories {
   jcenter()
}

 

Integrate plugin

1) Integrate OAuth2 integration by following integration instructions from this guide

2) Integrate file selector logic by following integration instructions from this guide

  • Please note that you will not need to integrate additional Gradle dependencies from OAuth2/File selector/App Chains guides because "com.sequencing:master-plugin" already contains everything needed.

Integration of .NET Master Plugin

The documentation below provides guidance for integrating Sequencing.com Master plugin into your .NET (C#) application.

We have developed a pluggable Nuget component to simplify adding this code in your software:

 

There are several prerequisites in order to complete the integration:

 

Prepare environment

1. Create Empty Asp.Net MVC project

 

 

2. Open “References” tab and press “Manage NuGet packages”

 

3. Search for “Sequencing-Master-Plugin” and press “Install”

 

Integrate plugin

1. Accept all agreements and press “Yes to all”

 

2. Required components are added to the project.

 

3. Replace OAuth2 application secret values with your data. Open web.config and locate following configuration options as shown here.

.NET Master Plugin Change Webconfig

Sample Applications

Sequencing.com's Sample Applications provide a quick, all-in-one bootstrap that includes the Master Plugin. They work out of the box so you don't even have to follow our integration guides.

 

The following implementations are available:

Android application in Java

  • Clone via git and use in Eclipse or IntelliJ Idea.

iOS application in Objective-C

  • Clone via git and use in XCode

iOS application in Swift

  • Clone via git and use in XCode

 

iOS Screenshots
 

      

      

 

Android Screenshots
 

      

      

Example App +RTP

+RTP can be used to personalize any app. As an example, we integrated the +RTP API into a weather app to show how +RTP technology can help differentiate even the most generic app.

Weather My Way +RTP is an open source app that utilizes the +RTP API to provide app users with their daily genetically tailored weather forecast. 

Throughout the day, Weather My Way provides personalized guidance for a healthier day by analyzing your genes and the weather, together. This is not just another weather app. Weather My Way uses Sequencing.com's Real-TimeTM technology to securely access and understand your genes!

 

GitHub Repo     Available on the Apple App Store     Available for Android on the Google Play Store

   GitHub  

 

iOS application screenshots

      

   

 

Android application screenshots

      

   

Postman

Postman can be used to evaluate the +RTP API. 

 

Steps performed at Sequencing.com

Step A: Obtain an oAuth2 secret for your app

Step B: Identify an App Chain number to use

 

Steps performed using Postman

Step 1: Create new requestPostman Step 1: Create New Request

 

Step 2: For the 'Authorization type' select OAuth 2.0

Postman Step 2: Authorization

 

Step 3: Click 'Get New Access Token' and setup all parameters according to your app (the parameters below are just examples)

Client ID= [Name of your app]

Scope= External

Postman Step 3: Get New Access Token and Setup Parameters

 

Step 4: Authenticate and allow request

Postman Step 4: API Authenticate and Allow Request

 

Step 5: Receive access token for usage

Postman Step 5: Receive Access Token

 

Step 6: Enter URL, change type to POST and add content-type header. The Authorization header will be added by Postman.

Postman Step 6: Enter URL then Change type to Post and Add Content Type to Header

 

Step 7: Go to Body, select 'raw' and enter request

Postman Step 7: Select raw and Enter Request

 

Step 8: Click 'Send' and observe the results

Postman Step 8: Click Send and Observe the Results

 

Step 9: Retrieve File List

Postman Step 9: Retrieve File List

 

Questions? Please submit a Support Request.

+RTP Authorization API

oAuth2 Guide

This OAuth2 Guide provides information about Sequencing.com's OAuth2 system. Our simple yet secure OAuth2 system is used to authenticate apps with our API.

Sequencing.com uses the industry standard OAuth2 protocol for authentication. If you are interested in details, please refer to our explanation on our Github page.

 

Sequencing.com provides libraries, code snippets / sample code and plugins for implementing Authentication and all components of the +RTP API.

 

Authentication flow

Sequencing.com uses standard OAuth approach which enables applications to obtain limited access to user accounts on an HTTP service from 3rd party applications without exposing the user's password. OAuth acts as an intermediary on behalf of the end user, providing the service with an access token that authorizes specific account information to be shared.

 

Steps

Step 1: Authorization Code Link

First, the user is given an authorization code link that looks like the following:

https://sequencing.com/oauth2/authorize?redirect_uri=REDIRECT_URL&response_type=code&state=STATE&client_id=CLIENT_ID&scope=SCOPES

Here is an explanation of the link components:

  • https://sequencing.com/oauth2/authorize: the API authorization endpoint
  • client_id=CLIENT_ID: the application's client ID (how the API identifies the application)
  • redirect_uri=REDIRECT_URL: where the service redirects the user-agent after an authorization code is granted
  • response_type=code: specifies that your application is requesting an authorization code grant
  • scope=CODES: specifies the level of access that the application is requesting

Screenshot below shows authorization dialog shown when following the link shown above

Step 2: User Authorizes Application

When the user clicks the link, they must first log in to the service, to authenticate their identity (unless they are already logged in). Then they will be prompted by the service to authorize or deny the application access to their account. Here is an example authorize application prompt

Step 3: Application Receives Authorization Code

If the user clicks "Authorize Application", the service redirects the user-agent to the application redirect URI, which was specified during the client registration, along with an authorization code. The redirect would look something like this (assuming the application is "php-oauth-demo.sequencing.com"):

https://php-oauth-demo.sequencing.com/index.php?code=AUTHORIZATION_CODE

 

Step 4: Application Requests Access Token

The application requests an access token from the API, by passing the authorization code along with authentication details, including the client secret, to the API token endpoint. Here is an example POST request to Sequencing.com token endpoint:

https://sequencing.com/oauth2/token

Following POST parameters have to be sent

  • grant_type='authorization_code'
  • code=AUTHORIZATION_CODE (where AUTHORIZATION_CODE is a code acquired in a "code" parameter in the result of redirect from Sequencing.com)
  • redirect_uri=REDIRECT_URL (where REDIRECT_URL is the same URL as the one used in step 1)

Include the following in the header

Authorization: Basic base64_encode([your-client-id] . ':' . [your-client-secret])

Note: if you experience any issue with Step 4, please make sure that you have added the “Authorization” header to the request.

 

Step 5: Application Receives Access Token

If the authorization is valid, the API will send a JSON response containing the access token to the application.

 

Step 6: Token expires and needs to be refreshed

If the OAuth access token has expired, it may be refreshed by making a request to the OAuth server and passing in the expired OAuth token.

https://sequencing.com/oauth2/authorize?grant_type=refresh_token&refresh_token=your-oauth-token

 

Include the following in the header

Authorization: Basic base64_encode([your-client-id] . ':' . [your-client-secret])

Application registration and management

Registering an app and receiving an oAuth2 secret for an app called Feed.me

1) Log in to Sequencing.com

2) Click Developer Center

3) Click on Generate OAuth2 Secret link

4) Register your app by entering

  • App Name (will also be your App ID):  feedme
    Application name should be alphanumeric identifier.
  • App Description:  Provides personalized food recommendations for weight loss and health optimization based on both the user's genes and restaurant menus the user is viewing on the Grubhub, Seamless or Eat24 app.
  • Redirect URLhttps://feedme.com/token.php

5) Click the 'Generate OAuth2 secret' button

6) The generated OAuth2 Secret will appear, which will be a long string of numbers and characters

Once you have your OAuth secret generated, following actions may be done:

  1. View and modify your secrets
    1. go to the Developer Center
    2. click 'Generate OAuth2 secret'
  2. Monitor API usage for each OAuth2 secret
    1. go to the Developer Center
    2. click 'Manage OAuth2 secrets'

OAuth2 integration

Sequencing.com provides easy to use drop-in libraries for quick integration of OAuth2 and other various APIs. You can quickly integrate Sequencing OAuth2 authentication protocol into your project.

We support following languages/platforms

If your language is not on the list, let us know and we add implementation for it!

For developers interested in learning more about using oAuth2 with Sequencing.com's API, we created an oAuth2 demo with source code available at GitHub repository.

           

      oAuth2 Demo                 GitHub repo

 

OAuth2 integration using Android/Java

Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your Android/Java based environment.

Unless you have specific reason, please refer to "Master plugins" or "Sample applications" section as they provide kit for quick boot-straping mobile applications in all in one package.

 

We have developed a Maven/Gradle component to simplify using Sequencing OAuth2 library in your project. If you are new to Maven/Gradle, refer to the official guide.

There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret

In order to complete integration follow instructions below

 

Prepare environment

1) Create new or open existing Android Gradle based project (i.e. in Android Studio or Eclipse)

2) Add following Gradle dependency

dependencies {
    compile 'com.sequencing:android-oauth:1.0.22'
}

2) Add Gradle jcenter repository

repositories {
   jcenter()
}

 

Configure authorization

1) Add imports

import com.sequencing.androidoauth.core.OAuth2Parameters;
import com.sequencing.androidoauth.core.ISQAuthCallback;
import com.sequencing.androidoauth.core.SQUIoAuthHandler;
import com.sequencing.oauth.core.Token;

2) Specify your application parameters at AuthenticationParameters. Authorization plugin use custom url schema.

These parameters should conform your application confiiguration

AuthenticationParameters parameters = new AuthenticationParameters.ConfigurationBuilder()
            .withRedirectUri("feedme://login")
            .withClientId("feedme")
            .withClientSecret("RCGK_tcZliZw2z5BqCSr_r-psBTTGBqji_WWEyjNZnp8-eQ1hgle5d1IS_of_U7wkshNvCqXBs25B6Q7JL1EBA")
            .build();

3) Implement ISQAuthCallback, which is needed for your application to get Token passed on successful authentication or to get notified in case authentication failed

/**
 * Callback for handling success authentication
 * @param token token of success authentication
 */
void onAuthentication(Token token);
 
/**
 * Callback of handling failure authentication
 * @param e exception of failure
 */
void onFailedAuthentication(Exception e);

4) Create View that will serve as initial element for authentication flow. It can be a Button or an extension of View class. Do not define onClickListener for this View.

5) Create SQUIoAuthHandler instance that is handling authentication process

6) Register your authentication handler by invoking method authenticate on SQUIoAuthHandler passing view, callback and app configuration

public void authenticate(View viewLogin, final ISQAuthCallback authCallback, AuthenticationParameters parameters);

OAuth2 integration using C#

 

Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your .NET/C# based environment.

There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret
  • you need to have at Windows environment with Visual Studio

 

Complete working example of a project that has all following steps done you can find in our GitHub repository.
You can just clone it and by modifying OAuth2 related settings specified below get working project quickly. 
We have also deployed this code so you can test it in action here.


In order to complete integration follow instructions below

1) Visit https://github.com/SequencingDOTcom/OAuth2-code-with-demo repository
2) Clone repository locally to your environment
3) Check 
dot-net-cs directory which contains sample
4) Copy resources to your project
5) Now, edit configuration settings in /var/www/html/oauth/index.php so to make them conform your OAuth2 application settings. Make sure that application name, secret and redirect URL matches. 
OAuth2 management interface is available in the developer center under "Manage OAuth2 secrets" section.

For our test feedme application mentioned the section and looking as shown below, 

Web.config should be changed as follows

Web.config snippet from repository Web.config snippet with appropriate OAuth2 tokens
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    <add key="OAuthRedirectUrl" value="http://localhost:64140/Default/AuthCallback"/>
    <add key="OAuthAppId" value="Sample Code"/>
    <add key="OAuthSecret" value="WDhTcoqpgnG7R_1A5tsGzNMheS-jyWd-DnRlr4N150YD2eZlaSFsGVszpfeOxGMpjeWH5gWNIkiW5bxuIoDjfg"/>
    <add key="ApiUrl" value="https://api.sequencing.com/"/>
    <add key="OAuthUrl" value="https://sequencing.com/indexApi.php"/>
  </appSettings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    <add key="OAuthRedirectUrl" value="http://feedme.com/Default/AuthCallback"/>
    <add key="OAuthAppId" value="Sample Code"/>
    <add key="OAuthSecret" value="RCGK_tcZliZw2z5BqCSr_r-psBTTGBqji_WWEyjNZnp8-eQ1hgle5d1IS_of_U7wkshNvCqXBs25B6Q7JL1EBA"/>
    <add key="ApiUrl" value="https://api.sequencing.com/"/>
    <add key="OAuthUrl" value="https://sequencing.com/indexApi.php"/>
  </appSettings>

 

5) Point your browse to http://feedme.com/sequencing/AuthCallback
It will trigger redirect to Sequencing authorization page

After entering credentials you will be presented with access approval which contains application details

After clicking on "Yes (I authorize access)" result page will render (result.php) that contains list of sample files available in your account.

From the code perspective you need to note several important variables that are needed to communicate with Sequencing backend. That one is AuthInfo that is obtained on lines 59 of Controllers.AuthWorker class. We recommend storing them in user session and keeping safe.

 

OAuth2 integration using JEE

Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your JEE based environment.

There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret
  • you need to have at one of IDEs - Eclipse, IntelliJ Idea or Netbeans
Complete working example of a project that has all following steps done you can find in our GitHub repositories - here for servlets and here for Spring. You can just clone it and by modifying OAuth2 related settings specified below get working project quickly. 
We have also deployed this code so you can test it in action here.

 

Sequencing.com provides 2 possibilities to integrate OAuth2 for JEE environments

  • Pure servlet based
  • Spring boot based

 

Servlet based environment integration

1) Visit https://github.com/SequencingDOTcom/OAuth2-code-with-demo repository
2) Clone repository locally to your environment

$ git clone https://github.com/SequencingDOTcom/OAuth2-code-with-demo.git

3) Servlet based Maven project is in "java-servlet" folder

4) Review pom.xml and integrate dependencies into your project

5) Review web.xml and integrate servlet definitions into your project

6) Copy classes from com.sequencing.oauth2demo.servlet to your project

7) Edit configuration settings in SequencingServletContextListener class so to make them conform your OAuth2 application settings. Make sure that application name, secret and redirect URL matches. 
OAuth2 management interface is available in the developer center under "Manage OAuth2 secrets" section.

SequencingServletContextListener snippet from the repository SequencingServletContextListener snippet with actual OAuth data
public AuthenticationParameters getAppConfig()
{
    return new AuthenticationParameters.ConfigurationBuilder()
        .withRedirectUri("https://java-oauth-demo.sequencing.com/Default/Authcallback")
        .withClientId("oAuth2 Demo Java")
        .withClientSecret("vuwpK04r7ylcbe1oUJCrDXza7dj33ejcUkBY06jrmzYiYw8LEmd1IkUZnKBCmv-fiuIhQkCm_qNWoQ81eCsY7A")
        .build();
}
public AuthenticationParameters getAppConfig()
{
    return new AuthenticationParameters.ConfigurationBuilder()
        .withRedirectUri("http://feedme.com/Default/AuthCallback")
        .withClientId("feedme")
        .withClientSecret("RCGK_tcZliZw2z5BqCSr_r-psBTTGBqji_WWEyjNZnp8-eQ1hgle5d1IS_of_U7wkshNvCqXBs25B6Q7JL1EBA")
        .build();
}

 

After authorization is completed tokens can be accessed by following call. We recommend keeping them safe.

SequencingOAuth2Client oauthClient = (SequencingOAuth2Client) config.getServletContext().getAttribute(SequencingServletContextListener.CFG_OAUTH_HANDLER);
oauthClient.getToken();

 

Spring boot based environment integration

1) Visit https://github.com/SequencingDOTcom/OAuth2-code-with-demo repository
2) Clone repository locally to your environment

$ git clone https://github.com/SequencingDOTcom/OAuth2-code-with-demo.git

3) Servlet based Maven project is in "java-spring" folder

4) Review pom.xml and integrate dependencies into your project

6) Copy classes from com.sequencing.oauth2demo to your project

7) Edit configuration settings in application.properties file so to make them conform your OAuth2 application settings. Make sure that application name, secret and redirect URL matches. 
OAuth2 management interface is available in the developer center under "Manage OAuth2 secrets" section.

 

application.properties snippet from the repository application.properties snippet with actual OAuth2 tokens
redirectUri=https://java-oauth-demo.sequencing.com/Default/Authcallback
clientId=oAuth2 Demo Java
clientSecret=vuwpK04r7ylcbe1oUJCrDXza7dj33ejcUkBY06jrmzYiYw8LEmd1IkUZnKBCmv-
fiuIhQkCm_qNWoQ81eCsY7A
redirectUri=http://feedme.com/Default/AuthCallback
clientId=feedme
clientSecret=RCGK_tcZliZw2z5BqCSr_r-psBTTGBqji_WWEyjNZnp8-
eQ1hgle5d1IS_of_U7wkshNvCqXBs25B6Q7JL1EBA
 

 

After authorization is completed tokens can be accessed by following call. We recommend keeping them safe.

// inject dependency first
@Autowired
private SequencingOAuth2Client oauth;

// access token in this way
oauth.getToken();

 

Testing result

 

1) Deploy and start application

2) Point your browse to http://feedme.com/Default/AuthCallback
It will trigger redirect to Sequencing authorization page

 

After entering credentials you will be presented with access approval which contains application details

After clicking on "Yes (I authorize access)" result page will render (result.php) that contains list of sample files available in your account

 

 

OAuth2 integration using Objective-C

Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your Objective-C based environment.

Unless you have specific reason, please refer to "Master plugins" or "Sample applications" section as they provide kit for quick boot-straping mobile applications in all in one package.

 

We have developed a CocoaPod component to simplify using Objective-C library in your project. If you are new to CocoaPods, refer to the official guide.

There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret

In order to complete integration follow instructions below

 

Prepare environment

1) Open existing XCode project or create new one

2) create Podfile in your project directory:

$ pod init

3) specify "sequencing-oauth-api-objc" pod parameters in Podfile

$ pod 'sequencing-oauth-api-objc', '~> 2.0.5'

4) install the dependency in your project using terminal

$ pod install

5) Use Xcode workspace instead of the project file

$ open *.xcworkspace

 

Configure authorization

1) Add Application Transport Security setting

  • open project settings > Info tab
  • add App Transport Security Settings row parameter (as Dictionary)
  • add subrow to App Transport Security Settings parameter as Exception Domains dictionary parameter
  • add subrow to Exception Domains parameter with sequencing.com string value
  • add subrow to App Transport Security Settings parameter with Allow Arbitrary Loads boolean value
  • set Allow Arbitrary Loads boolean value as YES

2) Create View Controllers, e.g. for Login screen and for Start screen

3) In your login view controller add imports

#import "SQOAuth.h"
#import "SQToken.h"
#import "SQAuthorizationProtocol.h"

For our test feedme application mentioned the section and looking as shown below, 

4) Register these parameters in OAuth module instance. Should be done once before authentication happens. 

[[SQOAuth sharedInstance] registerApplicationParametersCliendID:@"feedme"
                                                clientSecret:@"at867K7W88Pxrut1kEFZiOXh2Ij36q6dgEDBZyXte-
rhYzBqrI_ay609awMD6ZEtGbuPHQnnW9zzncnOpxbdyg"
                                                 redirectUri:@"feedme://login"
                                                       scope:@"demo,external"
                                                    delegate:<your class delegate>
                                      viewControllerDelegate:<your VC delegate>];

 

 where:

  • delegate - class instance that conforms to "SQAuthorizationProtocol" protocol
  • viewControllerDelegate - provide your class instance as UI delegate

5) implement methods from SQAuthorizationProtocol

- (void)userIsSuccessfullyAuthorized:(SQToken *)token
- (void)userIsNotAuthorized
- (void)userDidCancelAuthorization

6) authorize your user via authorizeUser method

[[SQOAuth sharedInstance] authorizeUser];

In method userIsSuccessfullyAuthorized you'll receive SQToken object, that contains following 5 properties with clear titles for usage:

NSString *accessToken
NSDate   *expirationDate
NSString *tokenType
NSString *scope
NSString *refreshToken

To receive up-to-date token use token: method from SQOAuth API (it returns the updated token): 

 [[SQOAuth sharedInstance] token:^(SQToken *token, NSString *accessToken) {
 }];

Where SQToken is a instance of SQToken object, and accessToken as NSString

SQOAuth is already aware about possible token expiration and handles this all. Once you need a token using code snippet shown above and it will guarantee token validity.

 

OAuth2 integration using Perl

Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your Perl based environment.
 

Complete working example of a project that has all following steps done you can find in our GitHub repository.
You can just clone it and by modifying OAuth2 related settings specified below get working project quickly. 

We have also deployed this code so you can test it in action here.

 

There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret
  • you need to have at least a Linux environment with Apache2 with 
  • you need a Perl with following packages installed via CPAN
    • JSON
    • HTTP::Request::Common
    • LWP::UserAgent
    • Data::Dumper
    • HTML::Entities
    • CGI::Session

Let's assume you have a website located in /var/www/html folder.

Configure Apache cgi handler for Perl scripts

<Directory /var/www/html/oauth>
      Options Indexes FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      AddHandler cgi-script .pl
</Directory>

In order to complete integration follow instructions below

1) Visit https://github.com/SequencingDOTcom/OAuth2-code-with-demo repository

2) Clone repository locally to your environment

git clone https://github.com/SequencingDOTcom/OAuth2-code-with-demo.git

3) Copy Perl resources to your hosted folder

mkdir /var/www/html/oauth
cp OAuth2-code-with-demo/perl/* /var/www/html/oauth/

4) Now, edit configuration settings in /var/www/html/oauth/index.pl so to make them conform your OAuth2 application settings. Make sure that application name, secret and redirect URL matches. 

OAuth2 management interface is available in the developer center under "Manage OAuth2 secrets" section.

For our test feedme application mentioned the section and looking as shown below, 

index.pl should be changed as follows 

Source index.pl snippet Changed index.pl snippet
# @file
# Example of Sequencing API usage for external developers.
# ID of your oauth2 app (oauth2 client).
#
# You will be able to get this value from Sequencing website.
#
my $client_id = 'oAuth2 Demo Perl';
 
# Secret of your oauth2 app (oauth2 client).
#
# You will be able to get this value from Sequencing website. Keep this value
# private.
my $client_secret = 'z7EaaKQGzLGSqXGQ7yOJlcCqynIyYaKCaxahwWuC2YBAhoduP18jWLM5VtkWOWq9-kOhVoWtWmwE5aBjlpcsaA';
 
# Redirect URI of your oauth2 app, where it expects Sequencing oAuth2 to
# redirect browser.
my $redirect_uri = 'https://perl-oauth-demo.sequencing.com/Default/Authcallback';

 

# @file
# Example of Sequencing API usage for external developers.
# ID of your oauth2 app (oauth2 client).
#
# You will be able to get this value from Sequencing website.
#
my $client_id = 'feedme';
 
# Secret of your oauth2 app (oauth2 client).
#
# You will be able to get this value from Sequencing website. Keep this value
# private.
my $client_secret = 'RCGK_tcZliZw2z5BqCSr_r-psBTTGBqji_WWEyjNZnp8-eQ1hgle5d1IS_of_U7wkshNvCqXBs25B6Q7JL1EBA';
 
# Redirect URI of your oauth2 app, where it expects Sequencing oAuth2 to
# redirect browser.
my $redirect_uri = 'http://feedme.com/oauth/index.pl';

 

5) Point your browse to http://feedme.com/oauth/index.pl

It will trigger redirect to Sequencing authorization page

After entering credentials you will be presented with access approval which contains application details 

After clicking on "Yes (I authorize access)" result page will render (result.php) that contains list of sample files available in your account.

From the code perspective you need to note several important variables that are needed to communicate with Sequencing backend. Those are $access_token  obtained on line 185 of index.pl. We recommend storing them in user session and keeping safe.

OAuth2 integration using PHP5

Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your PHP based environment.


There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret
  • you need to have at least a LAMP environment with Apache2, PHP5 with curl module
Complete working example of a project that has all following steps done you can find in our GitHub repository.
You can just clone it and by modifying OAuth2 related settings specified below get working project quickly. 

We have also deployed this code so you can test it in action here.


Let's assume you have a website located in /var/www/html folder.


In order to complete integration follow instructions below

1) Visit https://github.com/SequencingDOTcom/OAuth2-code-with-demo repository
2) Clone repository locally to your environment

$ git clone https://github.com/SequencingDOTcom/OAuth2-code-with-demo.git

3) Copy PHP resources to your hosted folder

$ mkdir /var/www/html/oauth
$ cp OAuth2-code-with-demo/php/* /var/www/html/oauth/


4) Now, edit configuration settings in /var/www/html/oauth/index.php so to make them conform your OAuth2 application settings. Make sure that application name, secret and redirect URL matches. 
OAuth2 management interface is available in the developer center under "Manage OAuth2 secrets" section.

For our test feedme application mentioned the section and looking as shown below, 

index.php should be changed as follows

Source index.php snippet Changed index.php snippet
/**
 * ID of your oauth2 app (oauth2 client).
 *
 * You will be able to get this value from Sequencing website.
 */
$client_id = 'oAuth2 Demo PHP';
 
/**
 * Secret of your oauth2 app (oauth2 client).
 *
 * You will be able to get this value from Sequencing website. Keep this value
 * private.
 */
$client_secret = 'at867K7W88Pxrut1kEFZiOXh2Ij36q6dgEDBZyXte-rhYzBqrI_ay609awMD6ZEtGbuPHQnnW9zzncnOpxbdyg';
 
/**
 * Redirect URI of your oauth2 app, where it expects Sequencing oAuth2 to
 * redirect browser.
 */
$redirect_uri = 'https://php-oauth-demo.sequencing.com/index.php';

 

/**
 * ID of your oauth2 app (oauth2 client).
 *
 * You will be able to get this value from Sequencing website.
 */
$client_id = 'feedme';
 
/**
 * Secret of your oauth2 app (oauth2 client).
 *
 * You will be able to get this value from Sequencing website. Keep this value
 * private.
 */
$client_secret = 'RCGK_tcZliZw2z5BqCSr_r-psBTTGBqji_WWEyjNZnp8-eQ1hgle5d1IS_of_U7wkshNvCqXBs25B6Q7JL1EBA';
 
/**
 * Redirect URI of your oauth2 app, where it expects Sequencing oAuth2 to
 * redirect browser.
 */
$redirect_uri = 'http://feedme.com/oauth/index.php';

 

 

5) Point your browse to http://feedme.com/oauth/index.php
It will trigger redirect to Sequencing authorization page

After entering credentials you will be presented with access approval which contains application details 

After clicking on "Yes (I authorize access)" result page will render (result.php) that contains list of sample files available in your account.

From the code perspective you need to note several important variables that are needed to communicate with Sequencing backend. Those are $access_token and $refresh_token that are obtained on lines 102-103 of index.php. We recommend storing them in user session and keeping safe.

OAuth2 integration using Python

Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your Python based environment.
 

Complete working example of a project that has all following steps done you can find in our GitHub repository.
You can just clone it and by modifying OAuth2 related settings specified below get working project quickly. 

We have also deployed this code so you can test it in action here.


There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret
  • you need to have at least environment with Python 2.7

In order to test integration follow instructions below

1) Visit https://github.com/SequencingDOTcom/OAuth2-code-with-demo repository

2) Clone repository locally to your environment

git clone https://github.com/SequencingDOTcom/OAuth2-code-with-demo.git

3) Copy Python resources to your folder

$ mkdir /opt/oauth-site
$ cp OAuth2-code-with-demo/python-django/* /opt/oauth-site

4) Set up virtual environment and setup prerequisites

$ cd /opt/oauth-site
$ apt-get install python-virtualenv
$ virtualenv myvenv
$ source myvenv/bin/activate
$ pip install -r requirements.txt

5) Edit URL mapping in oauth2demo/urls.py, so urlpatterns look as follows

urlpatterns = [
    url(r'^$', views.auth),
    url(r'^sequencing/authorize', views.auth_callback),
    url(r'^sequencing/authorization-approved', views.api, name="api"),
]

6) Now, edit configuration settings in oauth2demo/appconfig.py so to make them conform your OAuth2 application settings. Make sure that application name, secret and redirect URL matches. 
OAuth2 management interface is available in the developer center under "Manage OAuth2 secrets" section.

For our test feedme application mentioned the section and looking as shown below

appconfig.py should be changed as follows 

Source appconfig.py snippet Changed appconfig.py snippet
"""
URI of Sequencing oAuth2 where you can request user to authorize your app.
"""
oauth2_authorization_uri = 'https://sequencing.com/oauth2/authorize'
 
"""
Sequencing API endpoint.
"""
api_uri = 'https://api.sequencing.com'
 
"""
Redirect URI of your oauth2 app, where it expects Sequencing oAuth2 to
redirect browser.
"""
redirect_uri = 'https://python-oauth-demo.sequencing.com/Default/Authcallback'
 
"""
Id of your oauth2 app (oauth2 client).
You will be able to get this value from Sequencing website.
"""
client_id = 'oAuth2 Demo Python'
 
"""
Secret of your oauth2 app (oauth2 client).
You will be able to get this value from Sequencing website.
Keep this value private.
 
"""
client_secret = 'cyqZOLZfVET_EsKv3f1xekpqe8FZDlG2rNwK5JZyMFkRisKpNC1s-IlM3hj6KlE4e2SsYRDM903Mj2T699fBCw'
 
"""
oAuth2 state.
It should be some random generated string. State you sent to authorize URI
must match the state you get, when browser is redirected to the redirect URI you provided.
"""
state = '900150983cd24fb0d6963f7d28e17f72'
"""
URI of Sequencing oAuth2 where you can request user to authorize your app.
"""
oauth2_authorization_uri = 'https://sequencing.com/oauth2/authorize'
 
"""
Sequencing API endpoint.
"""
api_uri = 'https://api.sequencing.com'
 
"""
Redirect URI of your oauth2 app, where it expects Sequencing oAuth2 to
redirect browser.
"""
redirect_uri = 'http://feedme.com/sequencing/authorize'
 
"""
Id of your oauth2 app (oauth2 client).
You will be able to get this value from Sequencing website.
"""
client_id = 'feedme'
 
"""
Secret of your oauth2 app (oauth2 client).
You will be able to get this value from Sequencing website.
Keep this value private.
"""
client_secret = 'RCGK_tcZliZw2z5BqCSr_r-psBTTGBqji_WWEyjNZnp8-eQ1hgle5d1IS_of_U7wkshNvCqXBs25B6Q7JL1EBA'
 
"""
oAuth2 state.
It should be some random generated string. State you sent to authorize URI
must match the state you get, when browser is redirected to the redirect URI you provided.
"""
state = '900150983cd24fb0d6963f7d28e17f72'

 

7) Run server

sudo /myvenv/bin/python manage.py runserver 80

 

8) Point your browse to http://feedme.com/sequencing/authorize
It will trigger redirect to Sequencing authorization page

After entering credentials you will be presented with access approval which contains application details

After clicking on "Yes (I authorize access)" result page will render list of sample files available in your account.

From the code perspective you need to note several important variables that are needed to communicate with Sequencing backend. Those are access_token and refresh_token that are obtained on lines 75-76 of oauthclient.py

We recommend storing them in user session and keeping safe.

OAuth2 integration using Swift

Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your Swift based environment.

Unless you have specific reason, please refer to "Master plugins" or "Sample applications" section as they provide kit for quick boot-straping mobile applications in all in one package.

 

We have developed a CocoaPod component to simplify using Swift library in your project. If you are new to CocoaPods, refer to the official guide.

There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret

In order to complete integration follow instructions below

 

Prepare environment

1) Open existing XCode project or create new one

2) create Podfile in your project directory:

$ pod init

3) uncomment following row (as this is Swift pod)

use_frameworks!

3) specify "sequencing-oauth-api-swift" pod parameters:

$ pod 'sequencing-oauth-api-swift', '~> 2.5.0'

4) install the dependency in your project using terminal

$ pod install

5) Use Xcode workspace instead of the project file

$ open *.xcworkspace

 

Configure authorization

1) Add Application Transport Security setting

  • open project settings > Info tab
  • add App Transport Security Settings row parameter (as Dictionary)
  • add subrow to App Transport Security Settings parameter as Exception Domains dictionary parameter
  • add subrow to Exception Domains parameter with sequencing.com string value
  • add subrow to App Transport Security Settings parameter with Allow Arbitrary Loads boolean value
  • set Allow Arbitrary Loads boolean value as YES

2) Create bridging header file. Select File > New > File > Header File > name it as

project-name-Bridging-Header.h

3) Add SQOAuthFramework class import in the bridging header file

#import <OAuth/SQOAuthFramework.h>

4) Register your bridging header file in the project settings. select your project > project target > Build Settings > Objective-C Bridging Header specify path for bridging header file

$(PROJECT_DIR)/project-name-Bridging-Header.h

For our test feedme application mentioned the section and looking as shown below, 

4) Register these parameters in OAuth module instance. Should be done once before authentication happens. 

SQOAuth.sharedInstance().registerApplicationParametersCliendID("feedme",
                                                      clientSecret: "at867K7W88Pxrut1kEFZiOXh2Ij36q6dgEDBZyXte-rhYzBqrI_ay609awMD6ZEtGbuPHQnnW9zzncnOpxbdyg",
                                                      redirectUri: "feedme://login",
                                                      scope: "demo,external",
                                                      delegate: <your delegate>,
                                                      viewControllerDelegate: <your VC delegate>)

where:

  • delegate - class instance that conforms to "SQAuthorizationProtocol" protocol
  • viewControllerDelegate - provide your class instance as UI delegate

5) Subscribe your class for Authorization protocol SQAuthorizationProtocol

func userIsSuccessfullyAuthorized(_ token: SQToken) -> Void { }
func userIsNotAuthorized() -> Void { }
func userDidCancelAuthorization() -> Void { }

6) Authorize your user via authorizeUser method

SQOAuth.sharedInstance().authorizeUser()

In method userIsSuccessfullyAuthorized you'll receive SQToken object, that contains following 5 properties with clear titles for usage:

accessToken:    String
expirationDate:    NSDate
tokenType:        String
scope:            String
refreshToken:    String

To receive up-to-date token use token: method from SQOAuth API (it returns the updated token): 

SQOAuth.sharedInstance().token({ (SQToken?, String?) in
})

Where SQToken is a instance of SQToken object, and accessToken is string

SQOAuth is already aware about possible token expiration and handles this all. Once you need a token using code snippet shown above and it will guarantee token validity.

OAuth2 terminology

OAuth2 terminology uses the word "secret" - it's no different from a key that identifies your application.

 

Overview

  • OAuth2 secrets are free for development use using the 'Free' subscription plan.
    • When an app and it's OAuth2 secret reaches the maximum # calls it will be temporarily inactivated.
    • To avoid inactivation or to re-activate a secret
      • go to My OAuth2 secrets, find the secret and click 'Edit'
      • choose an app subscription plan
      • under Payment Methods, select a saved card or add a new credit or debit card.
  • Monitor usage of your secrets by clicking on Apps and then Usage.
  • You can generate and use an unlimited number of OAuth2 secrets.
  • Each OAuth2 secret can only be used in a single app.
    • Using the same OAuth2 secret in more than one app is a security risk and a violation of our TOS.
    • Swapping OAuth2 secrets from one app to another is also a security risk and TOS violation.
  • OAuth2 secrets are confidential and should not be shared.

 

Redirect URI

The oAuth2 Redirect URI is used as the way for the OAuth2 provider (Sequencing.com) to send secure responses to the OAuth2 user (your app). The Redirect URI is either a http or https URL.

  • If your app is a mobile app (iOS or Android), you may use custom schema, for example: wmw://login
  • If your app will be installed directly on a Mac, Windows or Linux, type the word blank into the Redirect URI field
  • If your app is a browser (web) based app (ie will be displayed via a browser such as Chrome, Firefox, Safari, Edge, Opera, etc.), a Redirect URI is required. Please see instructions below.

Redirect URI requirements for browser-based apps:

  • The Redirect URI is the URL where the response to the authentication will be redirected. This should be the URL within your application that will receive the OAuth2 credentials.
  • Wildcard redirect_uri values are also accepted in the request as long as the base url matches the Redirect URI that is registered at the time the OAuth2 secret is generated.
  • The Redirect URI can be either HTTP or HTTPS, although we strongly recommend HTTPS.
  • Here's an example of a redirect URI: https://mysite.com/token.php

Interested in learning more? Check out this OAuth2 tutorial. Thanks Jakob!

 

Authentication URL

The Authentication URL is the URL your app should redirect the user to so that the app user can authenticate with Sequencing.com. This is necessary because the user must be registered at Sequencing.com.

Your app users do not need to have genetic data stored at Sequencing.com.  We've made it easy for all users to experience apps powered by Real-Time Personalization technology by providing fun sample data that is free for everyone to use. For example, your users can choose the genes of some interesting people, such as Homer (a white dude from the USA) or Ugg (a caveman that lived 45,000 years ago).*

You may use your own login during the development process to gain access to the sample files and data.

The authentication URL at Sequencing.com is

https://sequencing.com/oauth2/authorize?redirect_uri=[your-redirect-url]&response_type=code&state=[some-random-state]&client_id=[your-id]&scope=[space separated list of scopes]

Please note the following parts in the URL above (do not include the [brackets])

 

Authorization Code Token

If the user authentication is successful then the redirect will contain an authorization code.

Please grab the authorization in code and then make a GET request as follows:

  1. Base URL
    https://sequencing.com/oauth2/authorize
  2. Include the following in the header
    Authorization: Basic base64_encode([your-client-id] . ':' . [your-client-secret])
  3. Include the following in the body arguments such in form-url-encoded
    grant_type=authorization_code
    code=[the-code-you-got-from-above]
    redirect_uri=[your-redirect-url]

 

Access Token

When the call https://sequencing.com/oauth2/authorize is made with the correct information, the oAuth token will be returned. Grab this token in your code as it will be required for all API calls.

  • The API token must be sent with each API call made by your app to Sequencing.com.
  • The API token serves two purposes:
    • allows for secure API access
    • identifies the user 
      • Allows the app to access and receive user-specific files that are securely stored in the user's Sequencing.com account.

Once your app has the API access token, you can start making API calls using App Chains.

Send the authentication token within the authentication header and Sequencing.com's API will handle the token.

 

Refresh Access Token

If the OAuth access token has expired, it may be refreshed by making a request to the OAuth server and passing in the expired OAuth token. 

  • Base URL: https://sequencing.com/oauth2/authorize
  • Method: GET
  • Include the following in the header
    Authorization: Basic base64_encode([your-client-id] . ':' . [your-client-secret])
  • Include the following in the body arguments such in form-url-encoded
    grant_type=refresh_token
    refresh_token=OAuth Token

 where "OAuth Token" is your refresh token retrieved during authorization

*The genetic data for Ugg is from an actual caveman whose DNA was extracted from a frozen bone discovered by scientists. Scientists, however, haven't yet acquired the actual genetic data for Homer Simpson but we've made a close match. Homer's sample file is the genome of a white dude from Utah who is married with children.

+RTP AppChains API

App Chains are the easy way to code Real Time Personalization (RTP) into your app.

App chains allows you to personalize your app and provide a genetically tailored user experience.

  • Your app can now understand and treat each app user as the unique individual they are.

App chains are designed by coders, for coders.

  • They are easy to use and quick to implement.

You don't have to know anything about the genetics or the genetic code.

  • To use app chains and add RTP to your app, all you need to know is the software code you use everyday.

The searchable list of all App Chains, along with additional info and code snippets for each chain, can be accessed here -> https://sequencing.com/app-chains/

While there are already app chains to personalize most apps, if you need something but don't see an app chain for it, tell us! (ie email us: [email protected]).

Sequencing has code that implements all low level details of getting and processing AppChains results in following languages. Following languages are supported: 

You just need to pick code from our repository and drop it into your project.

 

Related

AppChains integration

This section contains language specific APIs description for AppChains.

In order to use AppChains API, you need to obtain OAuth token first. For all details please check here.

For following languages we have already code that you can simply integrate and reuse in your projects:

If your language is not on the list, let us know and we add implementation for it!

If you are interested in how our HTTP API for AppChain API work, please see details below.

 

1 Endpoints specification

In order to utilize all power of AppChains API you need to use following endpoints:

  1. AppChains submission endpoint
  2. AppChains result retrieval endpoint

AppChains support several operation types:

  • Single chain request - using this way you can only request single AppChain per specific genetic data file
  • Batch chain request - this way allows to request multiple different AppChains for different genetic data files

 

1.1 Single chain endpoints

 

1.1.1 Submit single AppChain request

  • Endpoint: https://api.sequencing.com/v2/StartApp
  • HTTP method: POST
  • Request format: JSON
  • Response format: JSON

 

Request headers specification

# Header name Header value Description
1 Authorization Bearer your_access_token

Header that allows to authenticate your request to Sequencing.com systems. 

Where "your_access_token" is a token received as a result of OAuth2 authentication. Check here for more details.

2 Content-Type application/json Data type specifier

 

Request body format specification

# Field name Data type Mandatory Notes
1 AppCode String yes

AppChain identifier. 

You may find more information here

2 Pars object[] yes

Array of object with following structure

# Field name Data type Notes
1 Name string Parameter name
2 Value string Parameter value

 

For requesting single AppChain one object should be passed with Name value "dataSourceId" and Value which is genetic file identifier. This identifier could be taken from File Selector API response. For more details check here (see "Response specification", field "Id").

 

Request body example

{
  "AppCode": "Chain88",
  "Pars": [
    {
      "Value": "227679",
      "Name": "dataSourceId"
    }
  ]
}

This request means following:

  • It asks to execute Chain with ID 88 against file with ID 227679
  • File with ID 227679 corresponds to sample genome available to all users "Homer (Sequencing.com Sample Genome)"
  • Chain88 corresponds to Vitamid D level assessment chain. Check here for more details

This endpoint may reply with App Chain result, however in case more time needed for processing, you will have to call "GetAppResults" endpoint for checking results.

Response body format specification

# Field name Data type Mandatory Notes
1 ResultProps ItemDataValue[] no

Results are represented as array of ItemDataValue objects (see description below).

May be empty/not set in case results are not ready yet. In this case you need to poll "GetAppResults" endpoint until result is available. See below for the endpoint details.

2 Status object yes Job status. Represented by Status object (see description below)

 

ItemDataValue object structure is shown below

# Field name Data type Mandatory Notes
1 Name string yes Result property name
2 Title string no Title value
3 Subtitle string no Subtitle value
4 Description string no Description text
5 Type string yes Result property type.

Possible values are:

  • PlainText
  • Pdf
6 Subtype string no Subtype property type
7 Value string yes Result property value
8 ViewTablesMd string no View table metadata in case of type is Viewtable

 

Status object structure is shown below

# Field name Data type Mandatory Notes
1 CompletedSuccesfully boolean yes Points on whether App Chain job succeeded or not.
3 IdJob long yes App Chain job unique identifier (identifies particular App Chain response)
4 Status string yes

Could take one of following values:

  • Completed
  • In progress
  • Canceled

 

Response example

{
  "ResultProps": [
    {
      "ChartSeries": [
        
      ],
      "Description": null,
      "Hidden": false,
      "Name": null,
      "SubTitle": null,
      "SubType": null,
      "Title": null,
      "Type": "Pdf",
      "Value": "425644",
      "ViewTablesMd": null
    },
    {
      "ChartSeries": [
        
      ],
      "Description": null,
      "Hidden": true,
      "Name": "result",
      "SubTitle": null,
      "SubType": null,
      "Title": null,
      "Type": "PlainText",
      "Value": "No",
      "ViewTablesMd": null
    },
    {
      "ChartSeries": [
        
      ],
      "Description": null,
      "Hidden": true,
      "Name": "RiskDescription",
      "SubTitle": null,
      "SubType": null,
      "Title": null,
      "Type": "PlainText",
      "Value": "NA",
      "ViewTablesMd": null
    },
    {
      "ChartSeries": [
        
      ],
      "Description": null,
      "Hidden": true,
      "Name": "SourceFileName",
      "SubTitle": null,
      "SubType": null,
      "Title": null,
      "Type": "PlainText",
      "Value": "Homer (Sequencing.com Sample Genome)",
      "ViewTablesMd": null
    }
  ],
  "Status": {
    "CompletedSuccesfully": true,
    "FinishDt": "\/Date(1488305938670+0000)\/",
    "IdJob": 425643,
    "Status": "Completed"
  }
}

Request submission example

curl -X POST -H "Authorization: Bearer your_access_token" -H "Content-Type: application/json" --data '{"AppCode": "Chain88","Pars":[{"Value": "227679","Name": "dataSourceId"}]}' https://api.sequencing.com/v2/StartApp

Where "your_access_token" is a token received as a result of OAuth2 authentication. 

 

1.1.2 Retrieve aingle AppChain result

  • Endpoint: https://api.sequencing.com/v2/GetAppResults
  • HTTP method: GET
  • Response format: JSON

Request headers specification

# Header name Header value Description
1 Authorization Bearer your_access_token

Header that allows to authenticate your request to Sequencing.com systems. 

Where "your_access_token" is a token received as a result of OAuth2 authentication. Check here for more details.

 

Request parameters specification

# Field name Data type Mandatory Notes
1 IdJob long yes

App Chain job unique identifier (identifies particular App Chain job). 

Should be taken from the "StartApp" endpoint response.

 

Response body format specification

Same as in section 1.1.1

 

Request submission example

curl -X GET  -H "Authorization: Bearer your_access_token" "https://api.sequencing.com/v2/GetAppResults?idJob=425643"

Where "your_access_token" is a token received as a result of OAuth2 authentication. 

 

1.1.3 Retrieve AppChain report file

  • Endpoint: https://api.sequencing.com/v2/GetReportFile
  • HTTP method: GET
  • Response format: octet/stream

Request headers specification

# Header name Header value Description
1 Authorization Bearer your_access_token

Header that allows to authenticate your request to Sequencing.com systems. 

Where "your_access_token" is a token received as a result of OAuth2 authentication. Check here for more details.

 

Request parameters specification

# Field name Data type Mandatory Notes
1 IdJob long yes

App Chain job unique identifier (identifies particular App Chain job). 

Should be taken from the "StartApp" endpoint response.

 

Request submission example

curl -X GET  -H "Authorization: Bearer your_access_token" "https://api.sequencing.com/v2/GetReportFile?idJob=425643"

Where "your_access_token" is a token received as a result of OAuth2 authentication. 

 

1.2 Batch chain endpoints

 

1.2.1 Submit batch AppChain request

  • Endpoint: https://api.sequencing.com/v2/StartAppBatch
  • HTTP method: POST
  • Request format: JSON
  • Response format: JSON

 

Request headers specification

Same as in section 1.1.1.

 

Request body format specification

# Field name Data type Mandatory Notes
2 Pars ChainRequest[] yes

Array of objects of ChainRequest type. See below.

 

ChainRequest object structure is shown below

# Field name Data type Mandatory Notes
1 AppCode String yes

AppChain identifier. 

You may find more information here

2 Pars object[] yes

Array of object with following structure

# Field name Data type Notes
1 Name string Parameter name
2 Value string Parameter value

 

For requesting single AppChain one object should be passed with Name value "dataSourceId" and Value which is genetic file identifier. This identifier could be taken from File Selector API response. For more details check here (see "Response specification", field "Id").

 

Request body example

{
  "Pars": [
    {
      "AppCode": "Chain88",
      "Pars": [
        {
          "Value": "227679",
          "Name": "dataSourceId"
        }
      ]
    },
    {
      "AppCode": "Chain9",
      "Pars": [
        {
          "Value": "227679",
          "Name": "dataSourceId"
        }
      ]
    }
  ]
}

This request means following:

  • It asks to execute:
    • Chain with ID 9 against file with ID 227679
    • Chain with ID 88 against file with ID 227679
  • File with ID 227679 corresponds to sample genome available to all users "Homer (Sequencing.com Sample Genome)"
  • Chain9 corresponds to Skin cancer risk assessment chain. Check here for more details
  • Chain88 corresponds to Vitamid D level assessment chain. Check here for more details

This endpoint may reply with App Chain result, however in case more time needed for processing, you will have to call "GetAppResults" endpoint for checking results.

 

Response body format specification

# Field name Data type Mandatory Notes
1 N/A BatchChainResult[] yes Array of BatchChainResult objects. See details below.

 

BatchChainResult object structure is shown below

# Field name Data type Mandatory Notes
1 Key String yes Contains App Chain identifier (i.e. Chain88)
2 Value object yes

Response object.

Fully corresponds to response of single App Chain retrieval endpoint described in section 1.1.1

 

Response example

[
  {
    "Key": "Chain88",
    "Value": {
      "ResultProps": [
        {
          "ChartSeries": [
            
          ],
          "Description": null,
          "Hidden": false,
          "Name": null,
          "SubTitle": null,
          "SubType": null,
          "Title": null,
          "Type": "Pdf",
          "Value": "425643",
          "ViewTablesMd": null
        },
        {
          "ChartSeries": [
            
          ],
          "Description": null,
          "Hidden": true,
          "Name": "result",
          "SubTitle": null,
          "SubType": null,
          "Title": null,
          "Type": "PlainText",
          "Value": "No",
          "ViewTablesMd": null
        },
        {
          "ChartSeries": [
            
          ],
          "Description": null,
          "Hidden": true,
          "Name": "RiskDescription",
          "SubTitle": null,
          "SubType": null,
          "Title": null,
          "Type": "PlainText",
          "Value": "NA",
          "ViewTablesMd": null
        },
        {
          "ChartSeries": [
            
          ],
          "Description": null,
          "Hidden": true,
          "Name": "SourceFileName",
          "SubTitle": null,
          "SubType": null,
          "Title": null,
          "Type": "PlainText",
          "Value": "Homer (Sequencing.com Sample Genome)",
          "ViewTablesMd": null
        }
      ],
      "Status": {
        "CompletedSuccesfully": true,
        "FinishDt": "\/Date(1488305938670+0000)\/",
        "IdJob": 425643,
        "Status": "Completed"
      }
    }
  },
  {
    "Key": "Chain9",
    "Value": {
      "ResultProps": [
        {
          "ChartSeries": [
            
          ],
          "Description": null,
          "Hidden": false,
          "Name": null,
          "SubTitle": null,
          "SubType": null,
          "Title": null,
          "Type": "Pdf",
          "Value": "425645",
          "ViewTablesMd": null
        },
        {
          "ChartSeries": [
            
          ],
          "Description": null,
          "Hidden": true,
          "Name": "result",
          "SubTitle": null,
          "SubType": null,
          "Title": null,
          "Type": "PlainText",
          "Value": "NA",
          "ViewTablesMd": null
        },
        {
          "ChartSeries": [
            
          ],
          "Description": null,
          "Hidden": true,
          "Name": "RiskDescription",
          "SubTitle": null,
          "SubType": null,
          "Title": null,
          "Type": "PlainText",
          "Value": "High",
          "ViewTablesMd": null
        },
        {
          "ChartSeries": [
            
          ],
          "Description": null,
          "Hidden": true,
          "Name": "SourceFileName",
          "SubTitle": null,
          "SubType": null,
          "Title": null,
          "Type": "PlainText",
          "Value": "Homer (Sequencing.com Sample Genome)",
          "ViewTablesMd": null
        }
      ],
      "Status": {
        "CompletedSuccesfully": true,
        "FinishDt": "\/Date(1488318127168+0000)\/",
        "IdJob": 425645,
        "Status": "Completed"
      }
    }
  }
]

Request submission example

curl -X POST -H "Authorization: Bearer your_access_token" -H "Content-Type: application/json" --data '{"Pars":[{"AppCode":"Chain88","Pars":[{"Value":"227679","Name":"dataSourceId"}]},{"AppCode":"Chain9","Pars":[{"Value":"227679","Name":"dataSourceId"}]}]}' https://api.sequencing.com/v2/StartAppBatch

Where "your_access_token" is a token received as a result of OAuth2 authentication. 

 

 

1.1.2 Retrieve aingle AppChain result

  • Endpoint: https://api.sequencing.com/v2/GetAppResultsBatch
  • HTTP method: POST
  • Request format: JSON
  • Response format: JSON

Request headers specification

Same as in section 1.1.1.

 

Request body format specification

# Field name Data type Mandatory Notes
1

JobIds

long[] yes

Array of App Chain job unique identifiers that identifies particular App Chain job. 

Should be taken from the "StartApp" endpoint response.

 

Request body example

{
  "JobIds": [
    425645,
    425643
  ]
}

 

Response body format specification

Same as in section 1.2.1

 

Request submission example

curl -X POST -H "Authorization: Bearer your_access_token" -H "Content-Type: application/json" --data '{"JobIds":[425645, 425643]}' https://api.sequencing.com/v2/GetAppResultsBatch

Where "your_access_token" is a token received as a result of OAuth2 authentication.

AppChains Integration using C#

Integration

Sequencing.com has already everything to simplify integration of AppChains API into your C# based project.

There are 2 ways of achiving this:

  • Get code from our GitHub repository and paste it into your project
  • Integrate using our Nuget artifacts

In case you decided to copy code directly from GitHub repository make sure you also get dependencies 

For Nuget, search and add "Sequencing.AppChainsSample" dependency. If you are new to Nuget, see detailed guide here.

 

C# module API

Method Purpose Arguments Description
public AppChains(string token, string chainsUrl, string beaconsUrl) Constructor Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required
public Report GetReport(string applicationMethodName, string datasourceId) Reporting API
  • applicationMethodName - name of data processing routine 
  • datasourceId - input data identifier 
 
public Dictionary<string, Report> GetReportBatch(Dictionary<string, string> appChainsParams) Batch reporting API

Dictionary with App Chain request parameters.

  • Key is chain identifier
  • Value is file identifier
 

 

Code snippet

Adding code to the project:

  • Add Newtonsoft.Json and RestSharp nuget packages into your project

For complete usage example, refer to our code in GitHub repository.

 

Single App Chain retrieval example

var chains = new AppChains("<your token>", "https://api.sequencing.com/v1", "https://beacon.sequencing.com/");
 
Report result = chains.GetReport("Chain9", "227680");
if (result.Succeeded == false)
    Console.WriteLine("Request has failed");
else
    Console.WriteLine("Request has succeeded");
foreach (Result r in result.getResults())
{
    ResultType type = r.getValue().getType();
 
    if (type == ResultType.TEXT)
    {
        var v = (TextResultValue) r.getValue();
        Console.WriteLine(" -> text result type {0} = {1}", r.getName(), v.Data);
    }
 
    if (type == ResultType.FILE)
    {
        var v = (FileResultValue) r.getValue();
        Console.WriteLine(" -> file result type {0} = {1}", r.getName(), v.Url);
        v.saveTo("<your token>", ".\\");
    }
}

 

Batch App Chain retrieval example

var chains = new AppChains("<your token>", "https://api.sequencing.com/v1", "https://beacon.sequencing.com/");

// retrieving multiple chain results
var appChainsParms = new Dictionary<string, string>();
appChainsParms["Chain9"] = "227680";
appChainsParms["Chain88"] = "227680";

var jobReports = chains.GetReportBatch(appChainsParms);
PrintReport("<your token goes here>", jobReports["Chain9"]);
PrintReport("<your token goes here>", jobReports["Chain88"]);

Integration using Nuget and Visual studio

Sequencing.com's Real-Time Personalization® (+RTP) API is available via Nuget to facilitate using Visual Studio to add +RTP into C#/.NET apps.

The NuGet plugin can be obtained from:

Package Installation guide

1. In Solution Explorer:

  • Click on project context menu
  • Select "Manage NuGet Packages for Solution"

Nuget Instructions Image 1

 

2. In the NuGet Packages window:

  • Select 'Browse' tab and enter package name "Sequencing.AppChainsSample"
  • Specify project where package will be installed
  • Click 'Install' button.

Nuget Instructions Image 2

 

Alternative Package Installation

1. Under 'Tools' tab select Tools→NuGet Package Manager→Package Manager Console

Nuget Instructions Image 4

 

2. Insert "Install-Package Sequencing.AppChainsSample" command and then press 'Enter'

Nuget Instructions Image 5

 

Questions or issues?

Sequencing.com's A-Team (App-Team) is here to help. Please submit a Support Request.

    AppChains Integration using Java

    Integration

    Sequencing.com has already everything to simplify integration of AppChains API into your Java based project.

    There are 2 ways of achiving this:

    • Get code from our GitHub repository and paste it into your project
    • Integrate using our Maven artifacts

    In case you decided to copy code directly from GitHub repository make sure you also get dependencies from our pom.xml

    For Maven, add following snippet to your pom.xml

    <dependency>
        <groupId>com.sequencing</groupId>
        <artifactId>appchains</artifactId>
        <version>1.0.9</version>
    </dependency>

     

    Java module API

    Method Purpose Arguments Description
    public AppChains(String token, String chainsHostname) Constructor Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required
    public Report getReport(String remoteMethodName, String applicationMethodName, String datasourceId) Reporting API
    • remoteMethodName - REST endpoint name, use "StartApp" 
    • applicationMethodName - name of data processing routine 
    • datasourceId - input data identifier 
     
    public Map<String, Report> getReportBatch(String remoteMethodName, Map<String, String> appChainsParams) Batch reporting API

    Map<String,String> with App Chain request parameters:

    • Key is chain identifier
    • Value is file identifier
     

     

    Code snippet

    Adding code to the project:

    • Add imports to your class (import com.sequencing.appchains.AppChains.*).

    For complete usage example, refer to our code in GitHub repository.

     

    Single App Chain retrieval example

    // Plain Java
    DefaultAppChainsImpl chains = new DefaultAppChainsImpl("<your token>", "api.sequencing.com");

    // Android
    // AndroidAppChainsImpl chains = new AndroidAppChainsImpl("<your token>", "api.sequencing.com");

    Report result = chains.getReport("StartApp", "<chain id>", "<file id>");
     
    if (result.isSucceeded() == false)
        System.out.println("Request has failed");
    else
        System.out.println("Request has succeeded");
     
    for (Result r : result.getResults())
    {
        ResultType type = r.getValue().getType();
     
        if (type == ResultType.TEXT)
        {
            TextResultValue v = (TextResultValue) r.getValue();
            System.out.println(String.format(" -> text result type %s = %s", r.getName(), v.getData()));
        }
    }

     

    Batch App Chain retrieval example

    // Plain Java
    DefaultAppChainsImpl chains = new DefaultAppChainsImpl("<your token>", "api.sequencing.com");

    // Android
    // AndroidAppChainsImpl chains = new AndroidAppChainsImpl("<your token>", "api.sequencing.com");

    // retrieving multiple chain results
    Map<String, String> appChainsParams = new HashMap<String, String>();
    appChainsParams.put("Chain9",  "227680");
    appChainsParams.put("Chain88", "227680");

    Map<String, Report> reportMap = chains.getReportBatch("StartAppBatch", appChainsParams);
    printReport(reportMap.get("Chain9"));
    printReport(reportMap.get("Chain88"));

    AppChains Integration using Objective-C

    Integration

    Sequencing.com has already everything to simplify integration of AppChains API into your Objective-C based project.

    There are 2 ways of achiving this:

    • Get code from our GitHub repository and paste it into your project
    • Integrate using our Cocoapod artifacts

    For Cocoapods integration please follow next steps

    1) If you are new to CocoaPods, check general "Getting started" guide

    2) Create Podfile in your project directory:

    $ pod init

    3) Specify following parameters in Podfile:

    pod 'sequencing-app-chains-api-objc', '~> 1.1.0'

    4) Install the dependency in your project:

    $ pod install

    5) Always open the Xcode workspace instead of the project file.

    $ open *.xcworkspace

     

    Objective-C module API

    Method Purpose Arguments Description
    - (instancetype)initWithToken:(NSString *)token Constructor  
    - (instancetype)initWithToken:(NSString *)token withHostName:(NSString *)hostName Constructor Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required
    - (void)getReportWithApplicationMethodName:(NSString *)applicationMethodName withDatasourceId:(NSString *)datasourceId withSuccessBlock:(void (^)(Report *result))success withFailureBlock:(void (^)(NSError *error))failure; Reporting API
    • applicationMethodName - name of data processing routine
    • datasourceId - input data identifier
    • success - callback executed on success operation, results with Report object
    • failure - callback executed on operation failure
     
    - (void)getBatchReportWithApplicationMethodName:(NSArray *)appChainsParams withSuccessBlock:(ReportsArray)success withFailureBlock:(void (^)(NSError *error))failure; Reporting API
    • appChainsParams - array of params for batch request
      Each param should be an array with items:
      first object: applicationMethodName
      last object: datasourceId
    • success - callback executed on success operation, results with array of dictionaries.
      Each dictionary has following keys and objects:
      appChainID - appChain ID string
      report - Report object
    • failure - callback executed on operation failure
     

     

    Code snippet

    Single App Chain retrieval example

    AppChains *appChains = [[AppChains alloc] initWithToken:@"<yourAccessToken>" withHostName:@"api.sequencing.com"];
    [appChains getReportWithApplicationMethodName:@"<chain id>"
            withDatasourceId:@"<file id>"
            withSuccessBlock:^(Report *result) {
                for (Result *obj in [result getResults]) {
                    ResultValue *frv = [obj getValue];
                    if ([frv getType] == kResultTypeText) {
                        NSLog(@"\nvalue %@ = %@\n", [obj getName], [(TextResultValue *)frv getData]);
                    }
                }
            }
            withFailureBlock:^(NSError *error) {
                NSLog(@"Error occured: %@", [error description]);
            }];

    Batch App Chain retrieval example

    AppChains *appChains = [[AppChains alloc] initWithToken:yourAccessToken withHostName:@"api.sequencing.com"];
        
    // parameters array for batch request as example
    NSArray *appChainsForRequest = @[
            @[@"<chain id>", @"<file id>"], 
            @[@"<chain id>", @"<file id>"]
            ];
        
    [appChains getBatchReportWithApplicationMethodName:appChainsForRequest
            withSuccessBlock:^(NSArray *reportResultsArray) {
                
                // @reportResultsArray - result of reports (Report object) for batch request, it's an array of dictionaries
                // each dictionary has following keys: "appChainID": appChainID string, "report": *Report object
                
                for (NSDictionary *appChainReportDict in reportResultsArray) {
                    
                    Report *result = [appChainReportDict objectForKey:@"report"];
                    NSString *appChainID = [appChainReportDict objectForKey:@"appChainID"];
                    
                    NSLog(@"\n\n appChainID: %@\n", appChainID);
                    
                    for (Result *obj in [result getResults]) {
                        ResultValue *frv = [obj getValue];
                        if ([frv getType] == kResultTypeText) {
                            NSLog(@"\nvalue %@ = %@\n", [obj getName], [(TextResultValue *)frv getData]);
                        }
                    }
                }
            }
            withFailureBlock:^(NSError *error) {
                NSLog(@"batch request error: %@", error);
            }];

    AppChains Integration using PHP

    Integration

    Sequencing.com has already everything to simplify integration of AppChains API into your PHP based project.

    In order to integrate it, get code from our GitHub repository and paste it into your project. Code is PHP5 compatible and is OO based.

     

    PHP module API

    Method Purpose Arguments Description
    public function __construct($token = null, $chainsHostname = null) Constructor Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required
    public function getReport($remoteMethodName, $applicationMethodName, $datasourceId) Reporting API
    • remoteMethodName - REST endpoint name, use "StartApp" 
    • applicationMethodName - name of data processing routine 
    • datasourceId - input data identifier 
     
    public function getBatchReport($remoteMethodName, $appChainParam) Batch reporting API
    • remoteMethodName - REST endpoint name, use "StartAppBatch" 
    • appChainParam - associative array where keys are chain identifiers and values are file identifiers  
     

     

    Code snippet

    Adding code to the project:

    • Add AppChains.php into your source folder and import (require_once("AppChains.php");) it in your PHP file.

    For complete usage example, refer to our code in GitHub repository.

    Single App Chain retrieval example

    $chains = new AppChains("<your token goes here>", "api.sequencing.com");
    $chainsResult = $chains->getReport("StartApp", "Chain88", "227680");
     
    if ($chainsResult->isSucceeded())
        echo "Request has succeeded\n";
    else
        echo "Request has failed\n";
     
    foreach ($chainsResult->getResults() as $r)
    {
        $type = $r->getValue()->getType();
     
        switch ($type)
        {
            case ResultType::TEXT:
                $v = $r->getValue();
                echo sprintf("-> text result type %s = %s\n", $r->getName(), $v->getData());
            break;
            case ResultType::FILE:
                $v = $r->getValue();
                echo sprintf(" -> file result type %s = %s\n", $r->getName(), $v->getUrl());
                $v->saveTo("d:\data");
            break;
        }
    }

    Batch App Chain retrieval example

    $chains = new AppChains("<your token goes here>", "api.sequencing.com");
     
    $chainsBatchResult = $chains->getBatchReport("StartAppBatch", array("Chain91" => "227680", "Chain88" => "227680"));
    foreach ($chainsBatchResult as $key => $value){
       echo "-> Chain ID:";
       echo $key;
       echo "\n";
       printReport($value);
    }

    AppChains Integration using Perl

    Integration

    Sequencing.com has already everything to simplify integration of AppChains API into your Perl based project.

    In order to integrate it, get code from our GitHub repository and paste it into your project. Code is Perl 5.10 compatible and is OO based.

     

    Perl module API

    Method Purpose Arguments Description
    sub new Constructor Use both arguments for creating chains instance in case reporting API is required
    sub getReport Reporting API
    • 1st arg - REST endpoint name, use "StartApp" 
    • 2nd arg - name of data processing routine 
    • 3rd arg - input data identifier 
     
    sub getBatchReport Batch reporting API
    • 1st arg - REST endpoint name, use "StartAppBatch" 
    • 2nd arg - hashref, key should be chain identifier, value - file identifier 
     

     

    Code snippet

    Adding code to the project:

    • Add AppChains.pm into your source folder and import AppChains in your Perl file (use AppChains;).

    For complete usage example, refer to our code in GitHub repository.

    my $chains = AppChains->new("<your token>", "api.sequencing.com");
    my $chainsResult = $chains->getReport("StartApp", "<chain id>", "<file id>");
     
    if ($chainsResult->isSucceeded()) {
        print "Request has succeeded\n";
    } else {
        print "Request has failed\n";
    }
     
    foreach (@{$chainsResult->getResults()})
    {
        my $type = $_->getValue()->getType();
     
        if ($type == ResultType->TEXT)
        {
            my $v = $_->getValue();
            print sprintf("-> text result type %s = %s\n", $_->getName(), $v->getData());
        }
        elsif ($type == ResultType->FILE)
        {
            my $v = $_->getValue();
            print sprintf(" -> file result type %s = %s\n", $_->getName(), $v->getUrl());
            $v->saveTo("/tmp");
        }
    }

    Batch App Chain retrieval example

    my $chains = AppChains->new("<your token goes here>", "api.sequencing.com");

    # batch result retrieval
    my %chainsSpec = ("Chain9" => "227680", "Chain88" => "227680");
    my $out = $chains->getBatchReport("StartAppBatch", \%chainsSpec);

    foreach (keys %$out)
    {
        my $cr = $out->{$_};
        print "-> Chain ID: " . $_ . "\n";
        handleAppChainResult($cr);
        print "\n\n";
    }

     

    AppChains Integration using Python

    Integration

    Sequencing.com has already everything to simplify integration of AppChains API into your Python based project.

    In order to integrate it, get code from our GitHub repository and paste it into your project. Code is Python 2.7 compatible.

     

    Python module API

    Method Purpose Arguments Description
    def __init__(self, token=None, hostname=None) Constructor Use both arguments for creating chains instance in case reporting API is required
    def getReport(self, remote_method_name, app_method_name, source_id) Reporting API
    • remote_method_name - REST endpoint name, use "StartApp" 
    • app_method_name - name of data processing routine 
    • source_id - input data file identifier. Can be acquired through FileSelector usage.
     
    def getReportBatch(self, remote_method_name, app_chain_param) Batch reporting API
    • remote_method_name - REST endpoint name, use "StartAppBatch" 
    • app_chain_param - hash with AppChains specification. Key - chain identifier, value - file identifier
     

     

    Code snippet

    Adding code to the project:

    • Add AppChains.py into your source folder and import AppChains (from AppChains import AppChains) in your Python file.

    For complete usage example, refer to our code in GitHub repository.

     

    Single App Chain retrieval example

    self.chains = AppChains('<your token>', 'api.sequencing.com')
    chains_result = self.chains.getReport('StartApp', '<chain id>', '<file id>')
    if chains_result.isSucceeded():
        print('Request has succeeded')
        else:
            print('Request has failed')
            for r in chains_result.getResults():
                file_type = r.getValue().getType()
                v = r.getValue()
                if file_type == 'TEXT':
                    print('-> text result type {} = {}'.format(
                        r.getName(), v.getData()))
                elif file_type == 'FILE':
                    print(' -> file result type {} = {}'.format(
                        r.getName(), v.getUrl()
                    ))
                    v.saveTo('/tmp')

    Batch App Chain retrieval example

    class UsageExample(object):
        token = '<your token goes here>'
        url = 'api.sequencing.com'

        def __init__(self):
            self.chains = AppChains(self.token, self.url)
            print(self.get_raw_report_test())
            self.get_report_batch_test()
        def get_report_batch_test(self):
            chains_results = self.chains.getReportBatch(
                'StartAppBatch', {'Chain85': '227680', 'Chain88': '227680'})
            for chains_result in chains_results:
                if chains_results[chains_result].isSucceeded():
                    print('Request has succeeded')
                else:
                    print('Request has failed')
                for r in chains_results[chains_result].getResults():
                    file_type = r.getValue().getType()
                    v = r.getValue()
                    if file_type == 'TEXT':
                        print('-> text result type {} = {}'.format(
                            r.getName(), v.getData()))
                    elif file_type == 'FILE':
                        print(' -> file result type {} = {}'.format(
                            r.getName(), v.getUrl()
                        ))
                        v.saveTo('/tmp')
    UsageExample()

     

    AppChains Integration using Swift

    Integration

    Sequencing.com has already everything to simplify integration of AppChains API into your Swift based project.

    There are 2 ways of achiving this:

    • Get code from our GitHub repository and paste it into your project
    • Integrate using our Cocoapod artifacts

    For Cocoapods integration please follow next steps

    1) If you are new to CocoaPods, check general "Getting started" guide

    2) Create Podfile in your project directory:

    $ pod init

    3) Specify following parameters in Podfile:

    pod 'sequencing-app-chains-api-swift', '~> 2.1.1'

    4) Install the dependency in your project:

    $ pod install

    5) Always open the Xcode workspace instead of the project file.

    $ open *.xcworkspace

    6) Create bridging header file. Select File > New > File > Header File > name it as

    project-name-Bridging-Header.h

    7) Add AppChains class import in the bridging header file

    #import <AppChainsLibrary/AppChains.h>

    8) Register your bridging header file in the project settings. Select your project > project target > Build Settings > Objective-C Bridging Header specify path for bridging header file

    $(PROJECT_DIR)/project-name-Bridging-Header.h

    Swift module API

    Method Purpose Arguments Description
    init(token: String, withHostName: String) Constructor  
    func getReportWithApplicationMethodName(applicationMethodName: String!, withDatasourceId: String!, withSuccessBlock: ((Report!) -> Void)!, withFailureBlock: ((NSError!) -> Void)!) Constructor
    • applicationMethodName - name of data processing routine
    • datasourceId - input data identifier
    • success - callback executed on success operation, results with Report object
    • failure - callback executed on operation failure
    Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required
    func getBatchReportWithApplicationMethodName(appChainsParams: [AnyObject]!, withSuccessBlock: ReportsArray!, withFailureBlock: ((NSError!) -> Void)!) Reporting API with batch request
    • appChainsParams - array of params for batch request.
      Each param should be an array with 2 items:
      first object: applicationMethodName
      last object: datasourceId
    • success - callback executed on success operation, results with ReportsArray as array of dictionaries.
      Each dictionary has following keys and objects:
      appChainID - appChain ID string
      report - Report object
    • failure - callback executed on operation failure
     

     

    Code snippet

    Single App Chain retrieval example

    let appChainsManager = AppChains.init(token: accessToken as String, withHostName: "api.sequencing.com")
    appChainsManager.getReportWithApplicationMethodName("<chain id>", withDatasourceId: "<file id>", withSuccessBlock: { (result) in
            let resultReport: Report = result as Report!
            
            if resultReport.isSucceeded() {    
                if resultReport.getResults() != nil {
                    for item: AnyObject in resultReport.getResults() {
                        
                        let resultObj = item as! Result
                        let resultValue: ResultValue = resultObj.getValue()
                        
                        if resultValue.getType() == ResultType.Text {
                            print(resultObj.getName() + " = " + (resultValue as! TextResultValue).getData())
                        }
                    }
                }
            } else {
                print("Error occured while getting genetic information")
            }
            
        }) { (error) in
            print("Error occured while getting genetic information. " + error.localizedDescription)
        }

     

    Batch App Chain retrieval example

    let appChainsManager = AppChains.init(token: accessToken as String, withHostName: "api.sequencing.com")
    let appChainsForRequest: NSArray = [ [ "<chain id>", "<file id>"], ["<chain id>", "<file id>" ] ]

    appChainsManager.getBatchReportWithApplicationMethodName(appChainsForRequest as [AnyObject], withSuccessBlock: { (resultsArray) in
            let reportResultsArray = resultsArray as NSArray
            for appChainReport in reportResultsArray {
                let appChainReportDict = appChainReport as! NSDictionary
                let resultReport: Report = appChainReportDict.objectForKey("report") as! Report;
                let appChainID: NSString = appChainReportDict.objectForKey("appChainID") as! NSString;
                
                print(appChainID)
                
                if resultReport.getResults() != nil {
                    for item: AnyObject in resultReport.getResults() {
                        
                        let resultObj = item as! Result
                        let resultValue: ResultValue = resultObj.getValue()
                        
                        if resultValue.getType() == ResultType.Text {
                            print(resultObj.getName() + " = " + (resultValue as! TextResultValue).getData())
                        }
                    }
                }  
            }
                
        }) { (error) in
            print("batch request error. " + error.localizedDescription)
            completion(appchainsResults: nil)
        }

    +RTP File selector API

    Using this API, apps will have the ability to retrieve information about the genetic data files from the app user's Sequencing.com account.

    Retrieved information contains also a file identifiers which may be used for AppChains and AppMarket APIs when building your own applications.

     

    Available implementations

    We provide implementations in following laguages/platforms:

     

     

     

    File selector API integration

    This API is represented by single endpoint, please find all details below.

     

    Available implementations

    We provide implementations in following laguages/platforms:

    If your language is not on the list, let us know and we add implementation for it!

    If you are interested on how File selector API works, please see protocol specification below.

     

    HTTP endpoint specification

    URLhttps://api.sequencing.com/DataSourceList

    HTTP method: GET

    Response format: JSON

     

    HTTP headers

    # Header name Header value Data type Mandatory Notes
    1 Authorization

    Bearer authorization_token

    string yes

    Header that allows to authenticate your request to Sequencing.com systems. 

    Where "authorization_token" is a token received as a result of OAuth2 authentication. Check here for more details.

    Request parameters

    # Parameter name Data type Allowed parameter values Mandatory Notes
    1 all string true no Requests files to be returned for all folders
    2 uploaded string true no Requests files to be returned for "My uploaded files"
    3 shared string true no Requests files to be returned for "Files shared with me"
    4 fromApps string true no Requests files to be returned for "Files saved from my apps"

    Any combination of request parameters parameters is allowed and there should be at least one specified.

    Since any combination of request parameters is possible, here are few valid examples:

    • My uploaded files & Files shared with me

    https://api.sequencing.com/DataSourceList?uploaded=true&shared=true

    • My uploaded files & Files saved from my apps:

    https://api.sequencing.com/DataSourceList?uploaded=true&fromApps=true

     

    Response specification

    Response if a list of objects of following structure

    # Response field Data type Mandatory Description
    1 Id string yes

    Unique file identifier.

    This identifier is used in other APIs like AppChains and App Market

    2 Name string yes File name with extension
    3 Ext string yes Genetic file extension i.e. vcf.gz, bam, ...
    4 FileCategory string yes

    File category.

    Could take values "Uploaded", "Community", "FromApps"

    5 FileType string yes File type. Could be "Sequence", "Other"
    6 FileSubType string yes File sub type
    7 FriendlyDesc1 string no Friendly description for a file
    8 FriendlyDesc2 string no Extended friendly description for a file
    9 Population string no Population
    10 Sex string no Sex, i.e. Male/Female
    11 DateAdded string yes Date file was added

     

    Response example

    [
      {
        "DateAdded": null,
        "Ext": "vcf.gz",
        "FileCategory": "Community",
        "FileSubType": "Other",
        "FileType": "Other",
        "FriendlyDesc1": "Homer",
        "FriendlyDesc2": "Pretty fly for a white guy",
        "Id": "227679",
        "Name": "Sample genome",
        "Population": "Caucasian (American)",
        "Sex": "Male",
        "WasUsedPreviously": false
      },
      {
        "DateAdded": null,
        "Ext": "vcf.gz",
        "FileCategory": "Community",
        "FileSubType": "Other",
        "FileType": "Other",
        "FriendlyDesc1": "Marge",
        "FriendlyDesc2": "Wise white woman and mother of three",
        "Id": "227682",
        "Name": "Sample genome",
        "Population": "Caucasian (American)",
        "Sex": "Female",
        "WasUsedPreviously": false
      },
      {
        "DateAdded": null,
        "Ext": "vcf.gz",
        "FileCategory": "Community",
        "FileSubType": "Other",
        "FileType": "Other",
        "FriendlyDesc1": "Bart",
        "FriendlyDesc2": "El Barto is 10 and the son of Homer and Marge",
        "Id": "237697",
        "Name": "Sample genome",
        "Population": "Caucasian (American)",
        "Sex": "Male",
        "WasUsedPreviously": false
      }
    ]

    In case token is not valid following response will be sent in a response

    {"Detail":null,"ExceptionType":"System.ServiceModel.FaultException","Message":"Invalid apiKey passed"}

    You may try following curl command to test API. Substitute "authorization_token" with the token you received as a result of OAuth2 authentication

    curl -H "Authorization: Bearer authorization_token" "https://api.sequencing.com/DataSourceList?all=true"

    File selector integration using Android

    Here we will show how to quickly integrate Sequencing File selector harnesses into your Android based application.

    Unless you have specific reason, please refer to "Master plugins" or "Sample applications" section as they provide kit for quick boot-straping mobile applications in all in one package.

     

    We have developed a Maven/Gradle component to simplify using component library in your project. If you don't have enough experience with Maven/Gradle, refer to gradle guides

    There are several prerequisites in order to complete the integration:

    • you need to have a Sequencing account
    • you need to have an OAuth2 application secret
    • you have valid OAuth2 authentication token 

    In order to complete integration follow instructions below.

    By following steps below you would get following UI

          

     

    Prepare environment

    1) Create a new Android Gradle based project (i.e. in Android Studio or Eclipse)

    2) File selector module prepared as separate module, but it depends on a SequencingOAuth2Client instance from oAuth module. File selector can execute request to server for files with SequencingOAuth2Client instance only. Thus you need 2 modules to be installed: oAuth module and File Selector module

    3) Add gradle dependencies

    dependencies {
        compile 'com.sequencing:file-selector:1.0.30'
        compile 'com.sequencing:android-oauth:1.0.22'
    }

    4) Add Gradle jcenter repository

    repositories {
       jcenter()
    }

    Integrate OAuth2

    Implement integration as per these instructions.

     

    Prepare file selector

    1) Add imports

    import com.sequencing.androidoauth.core.OAuth2Parameters;
    import com.sequencing.androidoauth.core.ISQAuthCallback;
    import com.sequencing.fileselector.core.ISQFileCallback;
    import com.sequencing.androidoauth.core.SQUIoAuthHandler;
    import com.sequencing.fileselector.core.SQUIFileSelectHandler;
    import com.sequencing.oauth.config.AuthenticationParameters;
    import com.sequencing.oauth.core.Token;

     

    2) Store SequencingOAuth2Client instance so it's accessible for further invocations

    3) Implement ISQFileCallback which is a callback using which your code gets aware of which file was selected

    /**
     * Callback for handling selected file
     * @param entity selected file entity
     * @param activity activity of file selector
     */
    void onFileSelected(FileEntity entity, Activity activity);

    4) Create SQUIFileSelectHandler instance that is handling file selection process

    5) Register your file selection handler by invoking selectFile method with stored SequencingOAuth2Client and callback. This will also start file selection process.

    6) When user selects any file and clics on "Continue" button in UI will be invoked user ISQFileCallback implementation and passed to him FileEntity object and current file selector activity. FileEntity is a Java bean with the structure described here.

    File selector integration using JavaScript

    This integration instructions will allow you to integrate file selector capabilities to any web application. This codebase doesn't depend on backend technology and is pure frontend Javascript implementation.

    Dependencies:

    • Bootstrap
    • JQuery 1.11.3+
    Complete working example of a JavaScript based selector could be found in our GitHub repository.
    You can just clone it and by setting OAuth2 token get working your project quickly. 

     

    Initial view

    • user can choose to view
      • list of sample files or
      • list of the user's file's that are stored at the user's Sequencing.com account 

    Sample files list

    • if user selects 'I want to select a sample file' then the list of sample files will appear
    • user can select one file 

    File selected

    • user selected sample file 'Sheila'
    • that genetic data in that file will then be used to provide personalized content to the app
    • sample files allow user to experience Real-Time Personalization even if they don't yet have their own genetic data

     

    Integration

    In order to integrate file selector into your application, please follow instructions below

    1) Include Bootstrap and jquery into your project

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" />

    2) Include file selector JS and CSS files from this repo

    • JS file: sequencing-file-selector.js
    • CSS file: style.css

    <script type="text/javascript" src="sequencing-file-selector.js"></script>
    <link href="style.css" rel="stylesheet" />

    3) Create a hidden input in your form:

    <input type="hidden" name="some-name" />

    4) Initialize the file selector on that form element, using this code:

    <script type="text/javascript">
        $(document).ready(function() {
            $('#sequencing-file-selector-example').sequencingFileSelector({
                accessToken: 'insert-your-oauth2-access-token-here'
            });
        });
    </script>

    Make sure to pass token instead of "insert-your-oauth2-access-token-here" placeholder.

    5) Get selected file ID

    File selector is a JQuery compatible component so once file is selected, selected file ID could be obtained by doing following Javascript call

    $('#sequencing-file-selector-example').val()

     

     

    File selector integration using Objective-C

    Here we will show how to quickly integrate Sequencing File selector harnesses into your Objective-C based application.

    Unless you have specific reason, please refer to "Master plugins" or "Sample applications" section as they provide kit for quick boot-straping mobile applications in all in one package.

     

    We have developed a CocoaPod component to simplify using Objective-C library in your project. If you are new to CocoaPods, refer to the official guide.

    There are several prerequisites in order to complete the integration:

    • you need to have a Sequencing account
    • you need to have an OAuth2 application secret
    • you have valid OAuth2 authentication token 

    In order to complete integration follow instructions below.

    By following steps below you would get following UI

       

       

     

    Prepare environment

    1) Open existing XCode project or create new one
    2) Create Podfile in your project directory:
    $ pod init
    3) specify following pod parameters in Podfile
    pod 'sequencing-file-selector-api-objc', '~> 1.3.2'
    4) Install the dependency in your project using terminal
    $ pod install
    5) Use Xcode workspace instead of the project file
    $ open *.xcworkspace
     

    Set up OAuth2 module

    Refer to the appropriate guide.
     

    Prepare file selector

     

    1) Add file selector protocol import in your class were you getting and handling file selector

    #import "SQFileSelectorProtocol.h"
    #import "SQFilesAPI.h"

    2) Subscribe your UIViewController to file selector protocol SQFileSelectorProtocol

    3) Implement methods from SQFileSelectorProtocol protocol

    - (void)selectedGeneticFile:(NSDictionary *)file {
    }
     
    - (void)errorWhileReceivingGeneticFiles:(NSError *)error {
    }

    - (void)closeButtonPressed {
    }

    4) call file selector via method showFilesWithTokenProvider: showCloseButton: previouslySelectedFileID: delegate:

    - (void)showFilesWithTokenProvider:(id<SQTokenAccessProtocol>)tokenProvider
                     showCloseButton:(BOOL)showCloseButton
                     previouslySelectedFileID:(NSString *)selectedFileID
                     delegate:(UIViewController<SQFileSelectorProtocol> *)delegate;

    where

    • tokenProvider - SQOAuth instance (could be acquired as [SQOAuth sharedInstance])
    • showCloseButton - provide BOOL value to specify if you want to have Close button in file selector dialog
    • selectedFileID - provide file ID if you want to specific file be pre-selected and focused
    • delegate - UIViewController class instance that conforms to "SQFileSelectorProtocol" protocol

     

    When user selects any file and clicks on "Continue" button in UI - selectedGeneticFile: method from SQFileSelectorProtocol will be called then. Selected file will be passed there as a parameter. In this method you may handle selected file.

    Each file is a NSDictionary object with keys and values format as specified here

    File selector integration using Swift

    Here we will show how to quickly integrate Sequencing File selector harnesses into your Swift based application.

    Unless you have specific reason, please refer to "Master plugins" or "Sample applications" section as they provide kit for quick boot-straping mobile applications in all in one package.


    We have developed a CocoaPod component to simplify using Swift library in your project. If you are new to CocoaPods, refer to the official guide.

    There are several prerequisites in order to complete the integration:

    • you need to have a Sequencing account
    • you need to have an OAuth2 application secret
    • you have valid OAuth2 authentication token 

    In order to complete integration follow instructions below.

    By following steps below you would get following UI

       

       

     

    Prepare environment

    1) Open existing XCode project or create new one
    2) Create Podfile in your project directory:

    $ pod init

    3) Uncomment following row (as this is Swift pod)

    use_frameworks!

    4) specify following pod parameters in Podfile
    pod 'sequencing-oauth-api-swift', '~> 2.0.2'
    5) Install the dependency in your project using terminal
    $ pod install
    6) Use Xcode workspace instead of the project file
    $ open *.xcworkspace

     

    Set up OAuth2 module

    Refer to the appropriate guide.
     

    Prepare file selector

    1) Create bridging header file. Select File > New > File > Header File > name it as
    project-name-Bridging-Header.h

    2) add SQOAuthFramework class import in the bridging header file
    #import <FileSelector/SQFileSelectorFramework.h>

    3) register your bridging header file in the project settings select your project > project target > Build Settings > Objective-C Bridging Header specify path for bridging header file
    $(PROJECT_DIR)/project-name-Bridging-Header.h


    Use file selector

    1) subscribe your class to file selector protocol SQFileSelectorProtocol

    2) implement methods from SQFileSelectorProtocol protocol

     func selectedGeneticFile(_ file: NSDictionary) -> Void {
     }
     
     func errorWhileReceivingGeneticFiles(_ error: Error!) {
     }
     
     func closeButtonPressed() -> Void {
     }

    3) call file selector via showFiles(withTokenProvider: showCloseButton: previouslySelectedFileID: delegate:) method

    SQFilesAPI.sharedInstance().showFiles(withTokenProvider: SQOAuth.sharedInstance(),
                                   showCloseButton: true,
                                   previouslySelectedFileID: nil,
                                   delegate: self)

    where

    • tokenProvider - instance of SQOAuth (could be acquired as SQOAuth.sharedInstance())
    • showCloseButton - provide BOOL value to specify if you want to have Close button added
    • selectedFileID - provide file ID if you want to specific file be preselected and focused
    • delegate - UIViewController instance that implements "SQFileSelectorProtocol" protocol implementation

    When user selects any file and clicks on "Continue" button in File Selector UI - selectedGeneticFile method from SQFileSelectorProtocol protocol will be called then. Selected file will be passed on as a parameter. In this method you can handle this selected file

    Each file is a NSDictionary object with keys and values format as specified here