Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
add build step
Browse files Browse the repository at this point in the history
  • Loading branch information
kvdomingo committed Jan 27, 2022
1 parent 7cb7aca commit ec99d98
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 52 deletions.
18 changes: 17 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,23 @@ RUN sed -i "s/'_headers'/'headers'/" /usr/local/lib/python3.9/site-packages/revp

WORKDIR /primerdriver

ENTRYPOINT gunicorn primerx.wsgi -b 0.0.0.0:$PORT --log-file - --reload
ENTRYPOINT python manage.py migrate && gunicorn primerx.wsgi -b 0.0.0.0:$PORT --log-file - --reload

FROM base as make-linux

RUN apt-get update
RUN apt-get install upx-ucl libgfortran-10-dev libquadmath0 -y

ENV PYTHONDONTWRITEBYTECODE 1

COPY requirements.dev.txt /tmp/requirements.dev.txt
COPY requirements.txt /tmp/requirements.txt

RUN pip install --no-cache-dir -r /tmp/requirements.dev.txt

WORKDIR /primerdriver

ENTRYPOINT [ "sh", "build.sh" ]

FROM node:16-alpine as build

Expand Down
42 changes: 26 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@

You can access and download the CLI from the
[releases page](https://github.com/kvdomingo/primerdriver/releases).
Extract the files to your local machine and run the program via
Run the program in a terminal using
```shell
python -m primerdriver
primerdriver -h
```

This will automatically run the help program, which can also be accessed
by passing a `-h` flag. For first-time users, the program can be run in
interactive mode by passing the `-i` flag. This will walk you through
each option step-by-step. Batch design can be performed by
including [`primerdriver.py`](pdcli/primerdriver.py) as part of a shell script.
This will run the help program. For first-time users, the program can be run in
interactive mode by passing the `-i` flag:
```shell
primerdriver -i
```

This will walk you through each option step-by-step.
Batch design can be performed by including
[`primerdriver`](primerdriver/__main__.py) as part of a shell script.

## Web application
For a more interactive experience, the updated web application can be
accessed via https://primerdriver.vercel.app.
For a more interactive experience, visit the
[web application](https://primerdriver.kvdstudio.app).

## Documentation
The documentation is available at https://kvdomingo.github.io/primerdriver/.
Expand All @@ -44,7 +48,7 @@ A step by step series of examples that tell you how to get a
development environment running

1. Clone and extract the repo.
2. Install backend dependencies:
2. Create a virtual environment and install backend dependencies:
```shell
pip install -r requirements.dev.txt
```
Expand All @@ -59,14 +63,20 @@ docker compose up --build
Wait a few minutes for all the containers to start, then access the
local server in your browser at http://localhost:8000.

### Building from source
Run the script:
```shell
./build.sh
```

### Deployment
```bash
> git add .
> git commit -m <DESCRIPTIVE_COMMIT_MESSAGE>
> git push origin <GITHUB_BRANCH>
```shell
git add .
git commit -m "DESCRIPTIVE_COMMIT_MESSAGE"
git push origin your_feature_branch
```

where `GITHUB_BRANCH` should summarize the changes you are implementing
where `your_feature_branch` should summarize the changes you are implementing
(e.g., `feature/implementing-xxxx-feature`, `bugfix/crush-critical-yyyy-bug`).


Expand All @@ -77,7 +87,7 @@ where `GITHUB_BRANCH` should summarize the changes you are implementing
- **Carlo M. Lapid** - Project Adviser - [Email](mailto:[email protected])

## Versioning
This project complies with [SemVer](https://semver.org) for versioning. Fo
This project complies with [SemVer](https://semver.org) for versioning. For
all available versions, see
[tags](https://github.com/kvdomingo/primerdriver/tags).

Expand Down
5 changes: 5 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from primerdriver.__main__ import main


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

pyinstaller --clean -F --name primerdriver build.py
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ services:
env_file: ./web/app/.env
volumes:
- ./web:/web

make-linux:
build:
context: .
target: make-linux
image: kvdomingo/primerdriver-makelinux:latest
volumes:
- .:/primerdriver
20 changes: 17 additions & 3 deletions primerdriver/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@
from .output_handler import *


@logger.catch
def main():
parser = ArgumentParser()
print(
f"""
---. .------------.
||||\\ /||||||||||||||\\
Primer · Driver
\\|||||||||||/ \\|||||||
`---------` `------
PrimerDriver v{version}
(c) 2020 Kenneth V. Domingo & Numeriano Amer E. Gutierrez
"""
)

parser = ArgumentParser(prog="primerdriver")
parser.add_argument(
"-M",
"--mode",
Expand All @@ -29,7 +43,7 @@ def main():
if args.interactive:
args_dict = interactive_handler()
else:
args_dict = singleCommand_handler(args)
args_dict = single_command_handler(args)

res = PrimerDesign(**args_dict)
if args_dict["mode"].upper() == "CHAR":
Expand All @@ -41,7 +55,7 @@ def main():
interactive_saver(res.df)
else:
if res.savename is not None:
singleCommand_saver(res, res.df, res.savename)
single_command_saver(res, res.df, res.savename)

return 0

Expand Down
2 changes: 1 addition & 1 deletion primerdriver/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, sequence):
self.sequence = sequence.upper()

def check_sequence_length(self, length_range):
if len(self.sequence) >= length_range[0] and len(self.sequence) <= length_range[1]:
if length_range[0] <= len(self.sequence) <= length_range[1]:
return True
else:
return False
Expand Down
16 changes: 2 additions & 14 deletions primerdriver/input_handler.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from .primerclass import *
from .primer_design import *
from .version import __version__
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
from Bio.SeqRecord import SeqRecord


version = str(__version__)


def singleCommand_handler(args):
def single_command_handler(args):
args_dict = dict()
args_dict["mode"] = args.mode
if args.save:
Expand Down Expand Up @@ -67,14 +63,6 @@ def singleCommand_handler(args):

def interactive_handler():
args_dict = dict()
print("")
print(" ---. .------------.")
print(" ||||\ /||||||||||||||\ ")
print(" Primer · Driver")
print(" \|||||||||||/ \||||||| ")
print(" `---------` `------" "\n")
print(f"PrimerDriver v{version}")
print("(c) 2020 Kenneth V. Domingo & Numeriano Amer E. Gutierrez\n")
args_dict["mode"] = input("Enter primer mode [dna/pro/char]: ")
if args_dict["mode"].upper() == "DNA":
args_dict["sequence"] = input("Enter DNA sequence: ")
Expand Down
7 changes: 4 additions & 3 deletions primerdriver/output_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from loguru import logger
from pandas import concat
from datetime import datetime
from Bio import SeqIO
Expand Down Expand Up @@ -43,10 +44,10 @@ def interactive_saver(df):
df = concat([*df])
df.to_json(savename, indent=4)
else:
print("Unsupported filetype. Supported filetypes are: .csv, .html, .fasta, .json")
logger.error("Unsupported filetype. Supported filetypes are: .csv, .html, .fasta, .json")


def singleCommand_saver(res, df, savename):
def single_command_saver(res, df, savename):
if savename.endswith(".csv"):
df = concat([*df])
df.to_csv(savename)
Expand Down Expand Up @@ -78,5 +79,5 @@ def singleCommand_saver(res, df, savename):
df = concat([*df])
df.to_json(savename, indent=4)
else:
print("Unsupported filetype. Supported filetypes are: .csv, .html, .fasta, .json")
logger.error("Unsupported filetype. Supported filetypes are: .csv, .html, .fasta, .json")
return 1
7 changes: 3 additions & 4 deletions primerdriver/primerclass.py → primerdriver/primer_design.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from warnings import warn
from json import load, loads
from loguru import logger
from json import loads
from pandas import DataFrame
from tabulate import tabulate
from numpy import array
from Bio.Seq import Seq
from .checks import *


Expand Down Expand Up @@ -153,7 +152,7 @@ def characterize_primer(self, sequence, mutation_type, replacement, mismatched_b
if index - 1 < self.print_buffer:
print("\n", tabulate(array([col, dat]).T, headers=[f"Primer {index}"], tablefmt="orgtbl"), sep="")
elif index - 1 == self.print_buffer:
print("\nToo many results; truncating output...")
logger.info("Too many results; truncating output...")
dat = array([dat])
df = DataFrame(data=dat, columns=col, index=[index])
self.df = df
Expand Down
2 changes: 1 addition & 1 deletion primerdriver/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import io
from contextlib import redirect_stdout
from django.test import TestCase
from .primerclass import *
from .primer_design import *


class CharacterizeTestCase(TestCase):
Expand Down
4 changes: 2 additions & 2 deletions primerdriver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

__version__ = VersionInfo(
major=1,
minor=1,
patch=1,
minor=2,
patch=0,
)
3 changes: 1 addition & 2 deletions primerx/jinja2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from django.templatetags.static import static
from django.urls import reverse
from django.conf import settings
Expand All @@ -20,7 +19,7 @@ def environment(**options):
"settings": settings,
"static": static,
"url": reverse,
"web_version": f'(web {os.environ["HEROKU_RELEASE_VERSION"]})' if settings.ON_HEROKU else "",
"web_version": __version__,
}
)
return env
7 changes: 6 additions & 1 deletion primerx/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {}
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}

# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
Expand Down
1 change: 1 addition & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
black
django-revproxy
pyinstaller
Sphinx==3.5.1
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ django-cors-headers==3.8.0
django-heroku==0.3.1
djangorestframework==3.12.4
docutils==0.16
gunicorn==20.0.4
gunicorn==20.1.0
idna==2.10
imagesize==1.2.0
Jinja2==2.11.3
loguru
MarkupSafe==1.1.1
numpy==1.20.1
packaging==20.9
Expand Down
Empty file added sdm/migrations/__init__.py
Empty file.
11 changes: 9 additions & 2 deletions sdm/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
from rest_framework import status
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import AllowAny
from django.conf import settings
from primerdriver.primerclass import PrimerDesign
from primerdriver.primer_design import PrimerDesign
from primerdriver.checks import PrimerChecks
from primerdriver.version import __version__

BASE_DIR = settings.BASE_DIR


class PrimerDriverAPIView(APIView):
permission_classes = [AllowAny]

def post(self, request):
data = request.data
checks = PrimerChecks(data["sequence"])
Expand All @@ -34,16 +37,20 @@ def post(self, request):


class VersionView(APIView):
permission_classes = [AllowAny]

def get(self, request):
return Response(
data={
"program_version": str(__version__),
"web_version": f'(web {os.environ.get("HEROKU_RELEASE_VERSION")})' if settings.ON_HEROKU else "",
"web_version": str(__version__),
}
)


class ExpressionSystemsView(APIView):
permission_classes = [AllowAny]

def get(self, request):
return Response(
{
Expand Down
2 changes: 1 addition & 1 deletion web/app/src/components/Station.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Results from "./menu/Result";
const styles = {
appContainer: {
boxShadow: "none",
overflow: "scroll",
overflow: "auto",
height: "100vh",
},
};
Expand Down

0 comments on commit ec99d98

Please sign in to comment.