diff --git a/.gitignore b/.gitignore
index d661735ae..7a7282ac9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,12 +22,12 @@ parquettest.sh
.idea/
workfiles/
chr20/
-mango-cli/src/main/webapp/resources/node_modules/pileup/dist/lib/
-mango-cli/src/main/webapp/resources/node_modules/pileup/dist/main/
-mango-cli/src/main/webapp/resources/node_modules/pileup/dist/test/
-mango-cli/src/main/webapp/resources/node_modules/pileup/dist/test.js
-mango-cli/src/main/webapp/resources/node_modules/pileup/dist/pileup.js
-mango-cli/src/main/webapp/resources/node_modules/pileup/dist/pileup.js.map
-mango-cli/src/main/webapp/resources/node_modules/pileup/dist/node_modules/
-mango-cli/src/main/webapp/resources/node_modules/pileup/node_modules/
-chr20/
+mango-play-*
+mango-play/public/resources/node_modules/pileup/dist/lib/
+mango-play/public/resources/node_modules/pileup/dist/main/
+mango-play/public/resources/node_modules/pileup/dist/test/
+mango-play/public/resources/node_modules/pileup/dist/test.js
+mango-play/public/resources/node_modules/pileup/dist/pileup.js
+mango-play/public/resources/node_modules/pileup/dist/pileup.js.map
+mango-play/public/resources/node_modules/pileup/dist/node_modules/
+mango-play/public/resources/node_modules/pileup/node_modules/
diff --git a/.gitmodules b/.gitmodules
index be9ae56a0..f79f524fb 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
-[submodule "mango-cli/src/main/webapp/resources/pileup.js"]
- path = mango-cli/src/main/webapp/resources/pileup.js
+[submodule "mango-play/public/resources/pileup.js"]
+ path = mango-play/public/resources/pileup.js
url = https://github.com/akmorrow13/pileup.js.git
diff --git a/README.md b/README.md
index 4085d215e..c1064d138 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-#mango
+# mango
A scalable genome browser built on top of the [ADAM](https://github.com/bigdatagenomics/adam) genomics processing engine. Apache 2 licensed.
@@ -30,7 +30,9 @@ mango is packaged via [appassembler](http://mojo.codehaus.org/appassembler/appas
Running an example script:
```
-From the main folder of mango, run ./example-files/run-example.sh to see a demonstration of chromosome 17, region 7500000-7515000.
+From the main folder of mango, run ./scripts/run-example.sh to see a demonstration of chromosome 17, region 7500000-7515000.
+```
+**Note:** In local mode, relative paths are referenced from the mango-play submodule. To reference your own files, put in the absolute path.
```
For help launching the script, run `bin/mango-submit -h`
````
diff --git a/bin/compute-mango-classpath.sh b/bin/compute-mango-classpath.sh
index bd0317723..406f5a18e 100755
--- a/bin/compute-mango-classpath.sh
+++ b/bin/compute-mango-classpath.sh
@@ -28,8 +28,8 @@ REPO="$SCRIPT_DIR/repo"
# Fallback to source repo
if [ ! -f $MANGO_CMD ]; then
-MANGO_CMD="$SCRIPT_DIR/mango-cli/target/appassembler/bin/mango"
-REPO="$SCRIPT_DIR/mango-cli/target/appassembler/repo"
+MANGO_CMD="$SCRIPT_DIR/mango-play/target/appassembler/bin/mango"
+REPO="$SCRIPT_DIR/mango-play/target/appassembler/repo"
fi
if [ ! -f "$MANGO_CMD" ]; then
diff --git a/bin/compute-spark-jars.sh b/bin/compute-spark-jars.sh
new file mode 100755
index 000000000..32344313e
--- /dev/null
+++ b/bin/compute-spark-jars.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+#
+# Licensed to Big Data Genomics (BDG) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The BDG licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+set -e
+if [ -z "${SPARK_HOME}" ]; then
+ export SPARK_HOME="$(cd "`dirname "$0"`"/..; pwd)"
+fi
+
+. "${SPARK_HOME}"/bin/load-spark-env.sh
+
+# Find the java binary
+if [ -n "${JAVA_HOME}" ]; then
+ RUNNER="${JAVA_HOME}/bin/java"
+else
+ if [ `command -v java` ]; then
+ RUNNER="java"
+ else
+ echo "JAVA_HOME is not set" >&2
+ exit 1
+ fi
+fi
+
+# Find assembly jar
+SPARK_ASSEMBLY_JAR=
+if [ -f "${SPARK_HOME}/RELEASE" ]; then
+ ASSEMBLY_DIR="${SPARK_HOME}/lib"
+else
+ ASSEMBLY_DIR="${SPARK_HOME}/assembly/target/scala-$SPARK_SCALA_VERSION"
+fi
+
+GREP_OPTIONS=
+num_jars="$(ls -1 "$ASSEMBLY_DIR" | grep "^spark-assembly.*hadoop.*\.jar$" | wc -l)"
+if [ "$num_jars" -eq "0" -a -z "$SPARK_ASSEMBLY_JAR" -a "$SPARK_PREPEND_CLASSES" != "1" ]; then
+ echo "Failed to find Spark assembly in $ASSEMBLY_DIR." 1>&2
+ echo "You need to build Spark before running this program." 1>&2
+ exit 1
+fi
+if [ -d "$ASSEMBLY_DIR" ]; then
+ ASSEMBLY_JARS="$(ls -1 "$ASSEMBLY_DIR" | grep "^spark-assembly.*hadoop.*\.jar$" || true)"
+ if [ "$num_jars" -gt "1" ]; then
+ echo "Found multiple Spark assembly jars in $ASSEMBLY_DIR:" 1>&2
+ echo "$ASSEMBLY_JARS" 1>&2
+ echo "Please remove all but one jar." 1>&2
+ exit 1
+ fi
+fi
+
+echo "${ASSEMBLY_DIR}/${ASSEMBLY_JARS}"
diff --git a/bin/mango-install.sh b/bin/mango-install.sh
new file mode 100755
index 000000000..f4a7c9ae5
--- /dev/null
+++ b/bin/mango-install.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+#
+# Licensed to Big Data Genomics (BDG) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The BDG licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+set -e
+
+SCRIPT_DIR="$(cd `dirname $0`/..; pwd)"
+
+# build mango-play distribution
+mvn -f $SCRIPT_DIR play2:dist -pl mango-play
+
+# unzip new dist directory
+unzip -o "$SCRIPT_DIR/mango-play/target/mango-play-0.0.1-SNAPSHOT-dist.zip" -d $SCRIPT_DIR
diff --git a/bin/mango-submit b/bin/mango-submit
index e4a4d8c80..92fcfe069 100755
--- a/bin/mango-submit
+++ b/bin/mango-submit
@@ -74,13 +74,29 @@ if [ -z "$SPARK_SUBMIT" ]; then
fi
echo "Using SPARK_SUBMIT=$SPARK_SUBMIT"
-# submit the job to Spark
-"$SPARK_SUBMIT" \
- --class org.bdgenomics.mango.cli.VizReads \
- --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \
- --conf spark.kryo.registrator=org.bdgenomics.mango.serialization.MangoKryoRegistrator \
- --conf spark.dynamicAllocation.executorIdleTimeout=10d \
- --conf spark.driver.memory=5g \
- $SPARK_ARGS \
- $MANGO_CLI_JAR \
- $MANGO_ARGS
+# exports
+export SPARK_ARGS=$SPARK_ARGS
+export MANGO_MAIN_JAR=$MANGO_CLI_JAR
+export MANGO_ARGS=$MANGO_ARGS
+
+# generate application key
+APP_KEY=$(openssl rand -base64 15)
+export APPLICATION_SECRET=$APP_KEY
+
+SCRIPT_DIR="$(cd `dirname $0`/..; pwd)"
+
+# get version of mango from maven. This will be used to fetch the
+# most recently installed mango-play distribution
+MANGO_VERSION=`echo -e 'setns x=http://maven.apache.org/POM/4.0.0\ncat /x:project/x:version/text()' | xmllint --shell $SCRIPT_DIR/pom.xml | grep -v /`
+
+classpath="$SCRIPT_DIR/mango-play-$MANGO_VERSION/lib/*"
+
+# Get list of provided jars for spark
+SPARK_JARS=$("$SCRIPT_DIR"/bin/compute-spark-jars.sh)
+
+# modify classpath to include spark and hadoop
+# spark must come second do to dependency conflicts
+classpath="$classpath:$SPARK_JARS"
+
+# this is copied from playframework's autogenerated start script
+exec java $* -cp "$classpath" play.core.server.NettyServer $scriptdir
diff --git a/mango-cli/pom.xml b/mango-cli/pom.xml
deleted file mode 100644
index 043f806d7..000000000
--- a/mango-cli/pom.xml
+++ /dev/null
@@ -1,217 +0,0 @@
-
-