# Welcome to NGX Portal Application

### Prerequisites:
 * [Java SDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html), version 1.8 or higher.
 * [Gradle](https://gradle.org/install/), 4.x or higher.
 * [Node.js](https://nodejs.org/en/download/current/), 8.x or higher.
 * [Angular CLI](https://angular.io/cli), 7.x or higher.

### To run application for the first time (without uploaded data):
 * [Setup AWS Services](#aws-services-setup).
 * Set environment variables with required values:
     - `NGX_AWS_KEY` - AWS access key;
     - `NGX_AWS_SECRET` - AWS access secret;
     - `NGX_AWS_REGION` - AWS region;
     - `NGX_S3_BUCKET` - AWS S3 bucket to store data;
     - `NGX_ATHENA_DB` - AWS Athena DB name;
     - `NGX_ATHENA_REGION` - AWS Athena region;
     - `NGX_ATHENA_RESULTS_BUCKET` - AWS Athena results bucket ([_aws-athena-query-results-ACCOUNT_ID-REGION_](https://docs.aws.amazon.com/athena/latest/ug/querying.html#saving-query-results)).
 * Run `./gradlew clean build` to build `.war` file.
 * Deploy created `.war` file on Tomcat root.
 * Upload GWAS data.
 * Upload Phenotype data.
 * Upload Genotype data (can take up to 30 hours).
 * Create AWS Athena table for Genotype data (`V1_Genotype_data.sql`), replacing `<NGX_ATHENA_BUCKET>` and `<NGX_ATHENA_DB>` with responsive values.
 * Run partitioning on genotype data (`V2_Genotype_partition.sql`), replacing `<NGX_ATHENA_DB>` with your Athena DB name.
 
### To run application with uploaded data:
 * Run `./gradlew clean build` to build `.war` file.
 * Deploy created `.war` file on Tomcat root.
 
### AWS Services Setup:
 * Create AWS S3 bucket to store NGX Portal data.
 * Create database on AWS Athena (`V0_Ngx_athena_DB.sql`), replacing `<NGX_ATHENA_DB>` with your Athena DB name (e.g., `ngx_athena`).
