Skip to content

Commit

Permalink
merge commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjohnwright committed Apr 15, 2019
2 parents 9624263 + 2ff5674 commit 249ab1c
Show file tree
Hide file tree
Showing 24 changed files with 873 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .ebextensions/.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
option_settings:
- option_name: WB_DB_URI
value: datomic:ddb://us-east-1/WS269/wormbase
value: datomic:ddb://us-east-1/WS270/wormbase
- option_name: _JAVA_OPTIONS
value: "-Xmx14g"
2 changes: 1 addition & 1 deletion .ebextensions/aws-autoscaling.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ option_settings:
UpperThreshold: 70
aws:autoscaling:launchconfiguration:
BlockDeviceMappings: /dev/xvdcz=:12:true:gp2
EC2KeyName: eb-d2c
EC2KeyName: eb_wormbase_rest
IamInstanceProfile: aws-elasticbeanstalk-ec2-role
InstanceType: m4.xlarge
MonitoringInterval: 5 minute
Expand Down
2 changes: 1 addition & 1 deletion .ebextensions/elasticbeanstalk-environment.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ option_settings:
aws:elasticbeanstalk:sns:topics:
Notification Endpoint: [email protected]
Notification Protocol: email
Notification Topic ARN: arn:aws:sns:us-east-1:357210185381:ElasticBeanstalkNotifications-Environment-datomic-to-catalyst
Notification Topic ARN: arn:aws:sns:us-east-1:357210185381:ElasticBeanstalkNotifications-Environment-rest
Notification Topic Name: null
2 changes: 1 addition & 1 deletion Dockerrun.aws.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"AWSEBDockerrunVersion": 1,
"Image": {
"Name": "357210185381.dkr.ecr.us-east-1.amazonaws.com/wormbase/datomic-to-catalyst:0.8.4",
"Name": "357210185381.dkr.ecr.us-east-1.amazonaws.com/wormbase/rest:0.8.3",
"Update": "true"
},
"Ports": [
Expand Down
82 changes: 70 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
NAME := wormbase/datomic-to-catalyst
VERSION ?= $(shell git describe --abbrev=0 --tags)
#VERSION = "latest"
NAME := wormbase/rest
VERSION ?= "0.8.3"
EBX_CONFIG := .ebextensions/.config
WB_DB_URI ?= $(shell sed -rn 's|value:(.*)|\1|p' \
${EBX_CONFIG} | tr -d " " | head -n 1)
Expand All @@ -10,6 +9,7 @@ DEPLOY_JAR := app.jar
PORT := 3000
WB_ACC_NUM := 357210185381
FQ_TAG := ${WB_ACC_NUM}.dkr.ecr.us-east-1.amazonaws.com/${NAME}:${VERSION}
FQ_TAG_LATEST := ${WB_ACC_NUM}.dkr.ecr.us-east-1.amazonaws.com/${NAME}:latest
WB_FTP_URL := ftp://ftp.wormbase.org/pub/wormbase/releases/${WS_VERSION}

define print-help
Expand Down Expand Up @@ -43,30 +43,52 @@ docker-tag: $(call print-help,docker-tag,\
@docker tag ${NAME}:${VERSION} \
${WB_ACC_NUM}.dkr.ecr.us-east-1.amazonaws.com/${NAME}


.PHONY: docker-tag-latest
docker-tag-latest: $(call print-help,docker-tag,\
"Tag the image with current git revision \
and ':latest' alias")
@docker tag ${NAME}:latest ${FQ_TAG_LATEST}

.PHONY: docker-push-ecr
docker-push-ecr: docker-ecr-login $(call print-help,docker-push-ecr,\
"Push the image tagged with the \
current git revision to ECR")
@docker push ${FQ_TAG}

.PHONY: docker-push-ecr-latest
docker-push-ecr-latest: docker-ecr-login $(call print-help,docker-push-ecr,\
"Push the image tagged with the \
current git revision to ECR")
@docker push ${FQ_TAG_LATEST}

.PHONY: eb-create
eb-create: $(call print-help,eb-create,\
"Create an ElasticBeanStalk environment using \
the Docker platofrm.")
@eb create datomic-to-catalyst-${WS_VERSION} \
@eb create rest-${WS_VERSION} \
--region=us-east-1 \
--tags="CreatedBy=${AWS_EB_PROFILE},Role=RestAPI" \
--cname="wormbase-rest-${LOWER_WS_VERSION}"

.PHONY: eb-create-staging
eb-create-staging: $(call print-help,eb-create,\
"Create an ElasticBeanStalk environment using \
the Docker platofrm.")
@eb create rest-staging \
--region=us-east-1 \
--tags="CreatedBy=${AWS_EB_PROFILE},Role=RestAPI" \
--cname="datomic-to-catalyst-${LOWER_WS_VERSION}"
--cname="wormbase-rest-staging"

.PHONY: eb-env
eb-setenv: $(call print-help,eb-env,\
.PHONY: eb-setenv
eb-setenv: $(call print-help,eb-setenv,\
"Set enviroment variables for the \
ElasticBeanStalk environment")
eb setenv WB_DB_URI="${WB_DB_URI}" \
_JAVA_OPTIONS="-Xmx14g" \
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
-e "datomic-to-catalyst"
-e "rest"

.PHONY: eb-local
eb-local: docker-ecr-login $(call print-help,eb-local,\
Expand All @@ -86,11 +108,24 @@ build: docker/${DEPLOY_JAR} \
aws_access_key_id=${AWS_ACCESS_KEY_ID} \
--rm ./docker/

.PHONY: build-staging
build-staging: docker/${DEPLOY_JAR} \
$(call print-help,build,\
"Build the docker images from using the current git revision.")
@docker build -t ${NAME}:latest \
--build-arg uberjar_path=${DEPLOY_JAR} \
--build-arg \
aws_secret_access_key=${AWS_SECRET_ACCESS_KEY} \
--build-arg \
aws_access_key_id=${AWS_ACCESS_KEY_ID} \
--rm ./docker/

.PHONY: run
run: $(call print-help,run,"Run the application in docker (locally).")
docker run \
--name datomic-to-catalyst \
--name wormbase-rest \
--publish-all=true \
--restart=always \
--publish ${PORT}:${PORT} \
--detach \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
Expand All @@ -99,14 +134,37 @@ run: $(call print-help,run,"Run the application in docker (locally).")
-e PORT=${PORT} \
${NAME}:${VERSION}

.PHONY: run-latest
run-latest: $(call print-help,run,"Run the application in docker (locally).")
docker run \
--name wormbase-rest \
--publish-all=true \
--restart=always \
--publish ${PORT}:${PORT} \
--detach \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
-e WB_DB_URI=${WB_DB_URI} \
-e PORT=${PORT} \
${NAME}:latest

.PHONY: docker-build
docker-build: clean build \
$(call print-help,docker-build, "Create docker container")
$(call print-help,docker-build, "Create docker container")

docker-clean: $(call print-help,docker-clean,\
"Stop and remove the docker container (if running).")
@docker stop datomic-to-catalyst
@docker rm datomic-to-catalyst
@docker stop wormbase-rest
@docker rm wormbase-rest

.PHONY: dockerrun-latest
dockerrun-latest: $(call print-help,dockerrun-latest, "Change docker run file to point to latest")
@sed -i -r 's/rest:[^"]+/rest:'"latest"'/g' Dockerrun.aws.json

.PHONY: staging-deploy
staging-deploy:
eb use rest-staging
eb deploy --region us-east-1 --timeout 10

.PHONY: clean
clean: $(call print-help,clean,"Remove the locally built JAR file.")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# datomic-to-catalyst
# wormbase-rest

- Provide interface to datomic database to WormBase website.

Expand All @@ -14,7 +14,7 @@
Run following commands and test each step happens correctly.

```bash
export WB_DB_URI="datomic:ddb://us-east-1/WS269/wormbase"
export WB_DB_URI="datomic:ddb://us-east-1/WS270/wormbase"
lein ring server-headless 8130
lein do eastwood, test
make docker-build
Expand All @@ -33,7 +33,7 @@ eb deploy
## Setting environment variables

```bash
export WB_DB_URI="datomic:ddb://us-east-1/WS269/wormbase"
export WB_DB_URI="datomic:ddb://us-east-1/WS270/wormbase"
```

## Starting server in development
Expand Down
32 changes: 32 additions & 0 deletions jenkins-ci-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

# Output of unit tests; path cannot contain spaces:
export REST_TEST_LOG=/tmp/jenkins_rest_test_log_`date '+%s'`.log

export PATH="${HOME}/.local/bin:$PATH";

echo $PATH
env

# make the jar
make clean && make docker/app.jar

# build container
make build-staging

# Unit tests: WormBase API and REST API
#make build-run-test | tee $TEST_LOG

# tag container
make docker-tag-latest

# push containers to AWS ECR
make docker-push-ecr-latest

# deploy container
make dockerrun-latest
cat Dockerrun.aws.json
git add Dockerrun.aws.json
git commit -m "use latest wormbase/rest container" # only needed locally and subsequent build will discard this commit
make staging-deploy
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(defproject wormbase/rest-api "0.8.4"
:description
"REST API for retrieving data from datomic on a per widget basis"
:url "https://github.com/WormBase/datomic-to-catalyst"
:url "https://github.com/WormBase/wormbase-rest"
:min-lein-version "2.7.0"
:sign-releases false
:dependencies
Expand Down Expand Up @@ -62,7 +62,7 @@
:source-paths ["dev"]
:jvm-opts ["-Xmx1G"]
:env
{:wb-db-uri "datomic:ddb://us-east-1/WS269/wormbase"
{:wb-db-uri "datomic:ddb://us-east-1/WS270/wormbase"
:swagger-validator-url "http://localhost:8002"}
:plugins
[[jonase/eastwood "0.2.3"
Expand Down
25 changes: 2 additions & 23 deletions src/rest_api/classes/expr_pattern/widgets/overview.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[clojure.string :as str]
[pseudoace.utils :as pace-utils]
[rest-api.classes.generic-fields :as generic]
[rest-api.classes.picture.core :as picture-fns]
[rest-api.formatters.object :as obj :refer [pack-obj]]))

(defn- index-of
Expand Down Expand Up @@ -43,29 +44,7 @@
{:format extension
:name (str/join "/" [id basename])
:class "/img-static/pictures"}))
:external_source (not-empty
(pace-utils/vmap
:template
(:picture/acknowledgement-template picture)

:template-items
(not-empty
(pace-utils/vmap
:Article_URL
(when-let [ah (:picture/article-url picture)]
(let [d (:picture.article-url/database ah)]
{:db (:database/id d)
:text (:database/name d)}))

:Journal_URL
(when-let [d (:picture/journal-url picture)]
{:db (:database/id d)
:text (:database/name d)})

:Publisher_URL
(when-let [d (:picture/publisher-url picture)]
{:db (:database/id d)
:text (:database/name d)})))))
:external_source (picture-fns/external-sources picture)
:group_id id
:id (:picture/id picture)})))
:description "Curated images of the expression pattern"})
Expand Down
2 changes: 1 addition & 1 deletion src/rest_api/classes/feature.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
{:overview overview/widget
:history history/widget
:associations associations/widget
;:molecular_details molecular-details/widget
:molecular_details molecular-details/widget
:evidence evidence/widget
:location location/widget}})
28 changes: 15 additions & 13 deletions src/rest_api/classes/feature/widgets/molecular_details.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
[rest-api.classes.generic-functions :as generic-functions]
[rest-api.classes.generic-fields :as generic]))

; This was being displayed instead of the sequence if the sequence was not in the database
;{:flanks flanks ; section tested with WBsf000519
; :seq seq-obj
; :method method
; :sequences [{:sequence five-prime-flank
; :comment "flanking sequence (upstream)"}
; {:sequence three-prime-flank
; :comment "flanking sequence (downstream)"}]}

(defn sequence-context [f]
{:data (when-let [s (:locatable/parent f)]
(let [five-prime-flank (:feature.flanking-sequences/five-prime (:feature/flanking-sequences f))
three-prime-flank (:feature.flanking-sequences/three-prime (:feature/flanking-sequences f))
flanks [five-prime-flank three-prime-flank]
seq-obj (pack-obj s)
method (-> f :locatable/method :method/id)]
(if (or (some #(= method %) ["SL1" "SL2" "polyA_site" "history feature"])
(not (contains? f :locatable/min)))
{:flanks flanks ; section tested with WBsf000519
:seq seq-obj
:method method
:sequences [{:sequence five-prime-flank
:comment "flanking sequence (upstream)"}
{:sequence three-prime-flank
:comment "flanking sequence (downstream)"}]}
(when (not (or (some #(= method %) ["SL1" "SL2" "polyA_site" "history feature"])
(not (contains? f :locatable/min))))
(let [refseqobj (sequence-fns/genomic-obj f) ;tested with WBsf019129
positive-strand-wide (sequence-fns/get-sequence
(conj
Expand All @@ -30,7 +32,7 @@
:stop (+ (max (count five-prime-flank) (count three-prime-flank)) (:stop refseqobj))}))
strand (if (and (str/includes? positive-strand-wide five-prime-flank)
(str/includes? positive-strand-wide three-prime-flank))
"positive" "negative")
"+" "-")
padding 30
positive-sequence-raw (sequence-fns/get-sequence
(conj
Expand All @@ -52,13 +54,13 @@
:sequences {:positive_strand
{:features
[{:type "feature"
:start padding
:stop (+ padding (count feature-seq))}]
:start (+ 1 padding)
:stop (+ padding (count feature-seq))}]
:sequence positive-sequence}
:negative_strand
{:features
[{:type "feature"
:start padding
:start (+ 1 padding)
:stop (+ padding feature-length)}]
:sequence negative-sequence}}}))))
:description "sequences flanking the feature"})
Expand Down
Loading

0 comments on commit 249ab1c

Please sign in to comment.