Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A command-line tool to generate SBGN images for PC pathways #1443

Merged
merged 10 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ src/scripts/jsonld/*
/nohup.out
src/*.gmt
downloads/*
public/img/pathways/*
!/**/.gitkeep
36 changes: 36 additions & 0 deletions Dockerfile.syblars
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM node:14.21.3

# Environment variables
ENV NODE_OPTIONS=--max_old_space_size=8192

# Create an unprivileged user w/ home directory
RUN groupadd appuser \
&& useradd --gid appuser --shell /bin/bash --create-home appuser

# Create app directory
RUN mkdir -p /home/appuser/app

# Copy in source code
RUN cd /home/appuser/app && git clone https://github.com/iVis-at-Bilkent/syblars.git
WORKDIR /home/appuser/app/syblars

# Install app dependencies
# Puppeteer requirements
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libxtst6 gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \
--no-install-recommends

RUN npm clean-install

# Expose port
EXPOSE 3000

# Change ownership of the app to the unprivileged user
RUN chown appuser:appuser -R /home/appuser/app
USER appuser

# set server start as entry point
ENTRYPOINT npm run start

38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ The following environment variables can be used to configure the server (also do
- `PC_URL`: Pathway Commons homepage URL (default: 'http://www.pathwaycommons.org/'; cPath2 service should be there available at /pc2/ path)
- `NCBI_API_KEY`: NCBI E-Utilities API key ([read more](https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/))
- `FACTOID_URL`: the Factoid app URL (default: 'http://unstable.factoid.baderlab.org/')
- `SBGN_IMG_SERVICE_BASE_URL`: URL for service that converts SBGN to an image (i.e. [Syblars](http://syblars.cs.bilkent.edu.tr/); default is `http://localhost:9090/`)
- `SBGN_IMG_PATH`: cli tool `snapshot` output folder for images (default: `public/img/pathways`)

## Run targets

Expand Down Expand Up @@ -66,7 +68,7 @@ docker build --build-arg NODE_ENV=production -t app-ui .
Run the container:

```
docker run -it --rm -p 12345:3000 -e "NODE_ENV=production" --name "app-ui" app-ui
docker run -it --rm -p 3000:3000 -e "NODE_ENV=production" --name "app-ui" app-ui
```

Notes:
Expand All @@ -93,25 +95,15 @@ PC repository on Docker Hub).
To run the app using the pathwaycommons/app-ui:master image, execute:

```sh
docker-compose up -d
docker-compose up -d webapp
```

Access the app instance at port `9090` (can be specified in the docker-compose.yml).
Access the app instance at port `3000` (can be specified in the docker-compose.yml).

Notes:
- References:
- [Getting started with Docker Compose](https://docs.docker.com/compose/gettingstarted/)

### Custom build/rebuild/run with Docker Compose

Create .env file in this directory and define there yours: NODE_ENV, PC_URL, FACTOID_URL, PORT options;
execute:

```sh
docker-compose -f dev-compose.yml build
docker-compose -f dev-compose.yml up -d
```


## Testing

Expand All @@ -121,6 +113,26 @@ can run `npm run test ./test/path/to/test` to run specific tests.
[Chai](http://chaijs.com/) is included to make the tests easier to read and write.


## Scripts

### Command line tools

The `scripts/cli.js` file contains app-ui command line tools:
- `source`: Download and extract a file to `downloads` folder
- `snapshot`: Generate PNG images for pathways listed in a PC GMT-formatted file
- Requires an instance of [Syblars](http://syblars.cs.bilkent.edu.tr/) accessible at a location defined by the configuration variable `SBGN_IMG_SERVICE_BASE_URL` (see `docker-compose.yml` service `syblars`)
- Images will be placed in directory `SBGN_IMG_PATH` (default: `public/img/pathways`)

Usage: To generate a PNG of an SBGN representation for each pathway declared in the GMT file at `downloads/PathwayCommons12.All.hgnc.gmt`:

```sh
$ docker-compose up -d syblars
$ SERVER_FETCH_TIMEOUT="60000" node src/scripts/cli.js snapshot --file PathwayCommons12.All.hgnc.gmt
```
NB: The default timeout of fetch is normally quite brief (5 seconds).

In this way, images will be served via expressJS at `img/pathways/:id`, where `id` is the pathway URI with anything that is not a letter (a-z) or digit (0-9) is replaced with underscores (`_`).

## Developing a feature and making a pull request

Students who work on the repo should follow these instructions for each feature that they work on:
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ services:
FACTOID_URL:
networks:
- app-ui-network
syblars:
image: pathwaycommons/syblars:${SYBLARS_IMAGE_TAG:-latest}
restart: unless-stopped
container_name: syblars
ports:
- "${SYBLARS_PORT:-9090}:3000"
networks:
- app-ui-network

networks:
app-ui-network:
Expand Down
46 changes: 43 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@
"winston": "^2.4.0"
},
"devDependencies": {
"async-retry": "^1.3.3",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"chai": "^4.1.2",
"commander": "^11.1.0",
"cross-env": "^5.0.5",
"cssnano": "^3.10.0",
"echo-cli": "^1.0.8",
Expand Down
Empty file added public/img/pathways/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ let defaults = {
UNIPROT_API_BASE_URL: 'https://www.ebi.ac.uk/proteins/api',
DOI_BASE_URL: 'https://doi.org/',
ORCID_BASE_URL: 'https://orcid.org/',
SBGN_IMG_SERVICE_BASE_URL: 'http://localhost:9090/',
SBGN_IMG_PATH: 'public/img/pathways',
PC_IMAGE_CACHE_MAX_SIZE: 10000,
PC_CACHE_MAX_SIZE: 1000,
PUB_CACHE_MAX_SIZE: 1000000,
Expand Down
Loading