Skip to content

Commit

Permalink
Merge pull request #48 from cancervariants/eb-working
Browse files Browse the repository at this point in the history
Elastic Beanstalk Deployment
  • Loading branch information
korikuzma authored Feb 26, 2021
2 parents 3fbfe2b + bcfee3e commit b9aa617
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 74 deletions.
23 changes: 23 additions & 0 deletions .ebextensions/01_download_seqrepo.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
container_commands:
00_export_eb_env_var:
command: "export $(cat /opt/elasticbeanstalk/deployment/env | xargs)"
01_install_awscli:
command: "yum install -y awscli"
02_install_unzip:
command: "yum install -y unzip"
03_s3_download:
command: "aws s3 cp s3://${AWS_BUCKET_NAME}/${AWS_SEQREPO_OBJECT} ./variant/data/seqrepo.zip --region us-east-2"
04_unzip_seqrepo:
command: "unzip ./variant/data/seqrepo.zip -d ./variant/data"
05_seqrepo_permission:
command: "chmod -R 777 ./variant/data/seqrepo"
06_macosx_permission:
command: "chmod -R +wr ./variant/data/__MACOSX"
07_seqrepo_zip_permission:
command: "chmod +wr ./variant/data/seqrepo.zip"
08_remove_macosx:
command: "rm -R ./variant/data/__MACOSX"
09_remove_seqrepo_zip:
command: "rm ./variant/data/seqrepo.zip"
10_data_permission:
command: "chmod -R +wrx ./variant/data"
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ Pipfile.lock
pyproject.toml

# Jupyter Notebook
.ipynb_checkpoints/
.ipynb_checkpoints/

# Logs
*.log

# Zip
*.zip
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ python-dotenv = "*"
twine = "*"
werkzeug = "*"
"ga4gh.vrs" = {extras = ["extras"], version = "*"}
boto3 = "*"
setuptools = "*"
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
web: gunicorn -k uvicorn.workers.UvicornWorker main:app
14 changes: 10 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@
from variant.validators import Validate
from variant.translators import Translate
from variant.data_sources import SeqRepoAccess, TranscriptMappings
from variant.tokenizers import GeneSymbol
from variant.tokenizers.caches import GeneSymbolCache, AminoAcidCache
from variant.schemas import TranslationResponseSchema


app = FastAPI(docs_url='/variant', openapi_url='/variant/openapi.json')
tokenizer = Tokenize()
classifier = Classify()
seq_repo_access = SeqRepoAccess()
transcript_mappings = TranscriptMappings()
validator = Validate(seq_repo_access, transcript_mappings)
translator = Translate(seq_repo_access)
gene_symbol = GeneSymbol(GeneSymbolCache())
amino_acid_cache = AminoAcidCache()
validator = Validate(seq_repo_access, transcript_mappings, gene_symbol,
amino_acid_cache)
translator = Translate()


def custom_openapi():
Expand All @@ -39,8 +45,8 @@ def custom_openapi():
app.openapi = custom_openapi

translate_summary = "Translate a variant to a VRS compatible object."
translate_description = ("Translate a variant into VR-Spec (VRS) compatible "
"representations.")
translate_description = ("Translate a variant into Variation Representation "
"Specification (VRS) compatible representations.")
translate_response_description = "A response to a validly-formed query."
q_description = "Variant to translate."

Expand Down
17 changes: 11 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ biocommons.seqrepo==0.6.3
biopython==1.78
bioutils==0.5.2.post3
bleach==3.3.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
boto3==1.17.14
botocore==1.20.14; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
bs4==0.0.1
canonicaljson==1.4.0; python_version ~= '3.5'
certifi==2020.12.5
Expand Down Expand Up @@ -58,7 +60,7 @@ httptools==0.1.1
humanfriendly==9.1
identify==1.5.14; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
idna==2.10
importlib-metadata==3.4.0
importlib-metadata==3.5.0
inflection==0.5.1; python_version >= '3.5'
iniconfig==1.1.1
iniherit==0.3.9
Expand All @@ -69,14 +71,16 @@ isort==5.7.0
itsdangerous==1.1.0
jedi==0.18.0
jinja2==2.11.3
jmespath==0.10.0; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
json5==0.9.5
jsonschema==3.2.0
jupyter-client==6.1.11; python_version >= '3.5'
jupyter-core==4.7.1; python_version >= '3.6'
jupyter-server==1.4.0; python_version >= '3.6'
jupyter-packaging==0.7.12; python_version >= '3.6'
jupyter-server==1.4.1; python_version >= '3.6'
jupyterlab-pygments==0.1.2
jupyterlab-server==2.3.0; python_version >= '3.6'
jupyterlab==3.0.8
jupyterlab==3.0.9
keyring==22.0.1; python_version >= '3.6'
lazy-object-proxy==1.5.2
lxml==4.6.2
Expand Down Expand Up @@ -117,7 +121,7 @@ pydocstyle==5.1.1; python_version >= '3.5'
pyee==8.1.0
pyflakes==2.2.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pygments==2.8.0; python_version >= '3.5'
pylint==2.7.0
pylint==2.7.1
pyparsing==2.4.7
pyppeteer==0.2.5
pyquery==1.4.3
Expand All @@ -131,11 +135,12 @@ python-jsonschema-objects==0.3.10
pytz==2021.1
pyyaml==5.4.1
pyzmq==22.0.3; python_version >= '3.6'
readme-renderer==28.0
readme-renderer==29.0
requests-html==0.10.0
requests-toolbelt==0.9.1
requests==2.25.1
rfc3986==1.4.0
s3transfer==0.3.4
send2trash==1.5.0
seqrepo==0.0.0
simplegeneric==0.8.1
Expand All @@ -146,7 +151,7 @@ snowballstemmer==2.1.0
soupsieve==2.2
sqlparse==0.4.1; python_version >= '3.5'
starlette==0.13.6; python_version >= '3.6'
tabulate==0.8.8
tabulate==0.8.9
terminado==0.9.2; python_version >= '3.6'
testpath==0.4.4
text-unidecode==1.3
Expand Down
13 changes: 9 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ biocommons.seqrepo==0.6.3
biopython==1.78
bioutils==0.5.2.post3
bleach==3.3.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
boto3==1.17.14
botocore==1.20.14; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
bs4==0.0.1
canonicaljson==1.4.0; python_version ~= '3.5'
certifi==2020.12.5
Expand All @@ -38,7 +40,7 @@ hgvs==1.5.1
httptools==0.1.1
humanfriendly==9.1
idna==2.10
importlib-metadata==3.4.0
importlib-metadata==3.5.0
inflection==0.5.1; python_version >= '3.5'
iniherit==0.3.9
ipython-genutils==0.2.0
Expand All @@ -47,6 +49,7 @@ isort==5.7.0
itsdangerous==1.1.0
jedi==0.18.0
jinja2==2.11.3
jmespath==0.10.0; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
jsonschema==3.2.0
keyring==22.0.1; python_version >= '3.6'
lazy-object-proxy==1.5.2
Expand All @@ -73,28 +76,30 @@ py==1.10.0
pydantic==1.7.3
pyee==8.1.0
pygments==2.8.0; python_version >= '3.5'
pylint==2.7.0
pylint==2.7.1
pyparsing==2.4.7
pyppeteer==0.2.5
pyquery==1.4.3
pyrsistent==0.17.3; python_version >= '3.5'
pysam==0.16.0.1
python-dateutil==2.8.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
python-dotenv==0.15.0
python-jsonschema-objects==0.3.10
pyyaml==5.4.1
readme-renderer==28.0
readme-renderer==29.0
requests-html==0.10.0
requests-toolbelt==0.9.1
requests==2.25.1
rfc3986==1.4.0
s3transfer==0.3.4
seqrepo==0.0.0
simplegeneric==0.8.1
simplejson==3.17.2; python_version >= '2.5' and python_version not in '3.0, 3.1, 3.2, 3.3'
six==1.15.0
soupsieve==2.2
sqlparse==0.4.1; python_version >= '3.5'
starlette==0.13.6; python_version >= '3.6'
tabulate==0.8.8
tabulate==0.8.9
text-unidecode==1.3
toml==0.10.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
tqdm==4.57.0
Expand Down
19 changes: 12 additions & 7 deletions tests/translators/test_amino_acid_substitution.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
"""Module for testing Protein Substitution Translator."""
"""Module for testing amino acid Substitution Translator."""
import unittest
from variant.classifiers import AminoAcidSubstitutionClassifier
from variant.translators import AminoAcidSubstitution
from variant.validators import AminoAcidSubstitution as AASUB_V
from .translator_base import TranslatorBase
from variant.tokenizers import GeneSymbol
from variant.tokenizers.caches import GeneSymbolCache, AminoAcidCache
from variant.data_sources import SeqRepoAccess, TranscriptMappings
from variant import SEQREPO_DATA_PATH, TRANSCRIPT_MAPPINGS_PATH


class TestAminoAcidSubstitutionTranslator(TranslatorBase, unittest.TestCase):
"""A class to test the Protein Substitution Translator."""
"""A class to test the amino acid Substitution Translator."""

def classifier_instance(self):
"""Return protein substitution instance."""
"""Return amino acid substitution instance."""
return AminoAcidSubstitutionClassifier()

def validator_instance(self):
"""Return protein substitution instance."""
"""Return amino acid substitution instance."""
return AASUB_V(SeqRepoAccess(SEQREPO_DATA_PATH),
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH))
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH),
GeneSymbol(GeneSymbolCache()),
AminoAcidCache()
)

def translator_instance(self):
"""Return protein substitution instance."""
"""Return amino acid substitution instance."""
return AminoAcidSubstitution()

def fixture_name(self):
"""Return the fixture name for protein substitution."""
"""Return the fixture name for amino acid substitution."""
return 'amino_acid_substitution'
21 changes: 13 additions & 8 deletions tests/translators/test_polypeptide_truncation.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
"""Module for testing Protein Substitution Translator."""
"""Module for testing polypeptide truncation Translator."""
import unittest
from variant.classifiers import PolypeptideTruncationClassifier
from variant.translators import PolypeptideTruncation
from variant.validators import PolypeptideTruncation as PT_V
from .translator_base import TranslatorBase
from variant.tokenizers import GeneSymbol
from variant.tokenizers.caches import GeneSymbolCache, AminoAcidCache
from variant.data_sources import SeqRepoAccess, TranscriptMappings
from variant import SEQREPO_DATA_PATH, TRANSCRIPT_MAPPINGS_PATH


class TestPolypeptideTruncationTranslator(TranslatorBase, unittest.TestCase):
"""A class to test the Protein Substitution Translator."""
"""A class to test the polypeptide truncation Translator."""

def classifier_instance(self):
"""Return protein substitution instance."""
"""Return polypeptide truncation instance."""
return PolypeptideTruncationClassifier()

def validator_instance(self):
"""Return protein substitution instance."""
"""Return polypeptide truncation instance."""
return PT_V(SeqRepoAccess(SEQREPO_DATA_PATH),
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH))
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH),
GeneSymbol(GeneSymbolCache()),
AminoAcidCache()
)

def translator_instance(self):
"""Return protein substitution instance."""
"""Return polypeptide truncation instance."""
return PolypeptideTruncation()

def fixture_name(self):
"""Return the fixture name for protein substitution."""
return 'amino_acid_substitution'
"""Return the fixture name for polypeptide truncation."""
return 'polypeptide_truncation'
23 changes: 14 additions & 9 deletions tests/translators/test_silent_mutation.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
"""Module for testing Protein Substitution Translator."""
"""Module for testing Silent Mutation Translator."""
import unittest
from variant.classifiers import SilentMutationClassifier
from variant.translators import SilentMutation
from variant.validators import SilentMutation as SM_V
from .translator_base import TranslatorBase
from variant.tokenizers import GeneSymbol
from variant.tokenizers.caches import GeneSymbolCache, AminoAcidCache
from variant.data_sources import SeqRepoAccess, TranscriptMappings
from variant import SEQREPO_DATA_PATH, TRANSCRIPT_MAPPINGS_PATH


class TestAminoAcidSubstitutionTranslator(TranslatorBase, unittest.TestCase):
"""A class to test the Protein Substitution Translator."""
class TestSilentMutationTranslator(TranslatorBase, unittest.TestCase):
"""A class to test the silent mutation Translator."""

def classifier_instance(self):
"""Return protein substitution instance."""
"""Return silent mutation instance."""
return SilentMutationClassifier()

def validator_instance(self):
"""Return protein substitution instance."""
"""Return silent mutation instance."""
return SM_V(SeqRepoAccess(SEQREPO_DATA_PATH),
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH))
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH),
GeneSymbol(GeneSymbolCache()),
AminoAcidCache()
)

def translator_instance(self):
"""Return protein substitution instance."""
"""Return silent mutation instance."""
return SilentMutation()

def fixture_name(self):
"""Return the fixture name for protein substitution."""
return 'amino_acid_substitution'
"""Return the fixture name for silent mutation."""
return 'silent_mutation'
6 changes: 5 additions & 1 deletion tests/validators/test_amino_acid_substitution.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from variant.validators import AminoAcidSubstitution
from variant.classifiers import AminoAcidSubstitutionClassifier
from .validator_base import ValidatorBase
from variant.tokenizers import GeneSymbol
from variant.tokenizers.caches import GeneSymbolCache, AminoAcidCache
from variant.data_sources import TranscriptMappings, SeqRepoAccess
from variant import SEQREPO_DATA_PATH, TRANSCRIPT_MAPPINGS_PATH

Expand All @@ -13,7 +15,9 @@ class TestAminoAcidSubstitutionValidator(ValidatorBase, unittest.TestCase):
def validator_instance(self):
"""Return amino acid substitution instance."""
return AminoAcidSubstitution(SeqRepoAccess(SEQREPO_DATA_PATH),
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH)) # noqa: E501
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH), # noqa: E501
GeneSymbol(GeneSymbolCache()),
AminoAcidCache())

def classifier_instance(self):
"""Return the protein substitution classifier instance."""
Expand Down
16 changes: 10 additions & 6 deletions tests/validators/test_polypeptide_truncation.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
"""Module for testing Amino Acid Substitution Validator."""
"""Module for testing Polypeptide Truncation Validator."""
import unittest
from variant.validators import PolypeptideTruncation
from variant.classifiers import PolypeptideTruncationClassifier
from .validator_base import ValidatorBase
from variant.tokenizers import GeneSymbol
from variant.tokenizers.caches import GeneSymbolCache, AminoAcidCache
from variant.data_sources import TranscriptMappings, SeqRepoAccess
from variant import SEQREPO_DATA_PATH, TRANSCRIPT_MAPPINGS_PATH


class TestPolypeptideTruncationValidator(ValidatorBase, unittest.TestCase):
"""A class to test the Protein Substitution Validator."""
"""A class to test the Polypeptide Truncation Validator."""

def validator_instance(self):
"""Return amino acid substitution instance."""
"""Return Polypeptide Truncation instance."""
return PolypeptideTruncation(SeqRepoAccess(SEQREPO_DATA_PATH),
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH)) # noqa: E501
TranscriptMappings(TRANSCRIPT_MAPPINGS_PATH), # noqa: E501
GeneSymbol(GeneSymbolCache()),
AminoAcidCache())

def classifier_instance(self):
"""Return the protein substitution classifier instance."""
"""Return the Polypeptide Truncation classifier instance."""
return PolypeptideTruncationClassifier()

def fixture_name(self):
"""Return the fixture name for protein substitution."""
"""Return the fixture name for Polypeptide Truncation."""
return 'polypeptide_truncation'
Loading

0 comments on commit b9aa617

Please sign in to comment.