-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added tests and github action for setup and testing
- Loading branch information
Floris vanderFlier
committed
Oct 17, 2024
1 parent
bf6d883
commit bce7eb5
Showing
6 changed files
with
177 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
on: "push" | ||
name: setup-and-test | ||
|
||
jobs: | ||
uv-example: | ||
name: python | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v3 | ||
|
||
- name: "Set up Python" | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: ".python-version" | ||
|
||
- name: Install the project | ||
run: uv sync --all-extras --dev | ||
|
||
- name: Run tests | ||
# For example, using `pytest` | ||
run: uv run pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,49 @@ | ||
AA_ALPHABET = list("ACDEFGHIKLMNPQRSTVWY") | ||
AA_ALPHABET_GREMLIN = list("ARNDCQEGHILKMFPSTWYV-") | ||
THREE_TO_SINGLE_LETTER_CODES = { | ||
"ALA": "A", | ||
"ARG": "R", | ||
"ASN": "N", | ||
"ASP": "D", | ||
"CYS": "C", | ||
"GLN": "Q", | ||
"GLU": "E", | ||
"GLY": "G", | ||
"HIS": "H", | ||
"ILE": "I", | ||
"LEU": "L", | ||
"LYS": "K", | ||
"MET": "M", | ||
"PHE": "F", | ||
"PRO": "P", | ||
"SER": "S", | ||
"THR": "T", | ||
"TRP": "W", | ||
"TYR": "Y", | ||
"VAL": "V", | ||
} | ||
SINGLE_TO_THREE_LETTER_CODES = { | ||
"A": "ALA", | ||
"R": "ARG", | ||
"N": "ASN", | ||
"D": "ASP", | ||
"C": "CYS", | ||
"Q": "GLN", | ||
"E": "GLU", | ||
"G": "GLY", | ||
"H": "HIS", | ||
"I": "ILE", | ||
"L": "LEU", | ||
"K": "LYS", | ||
"M": "MET", | ||
"F": "PHE", | ||
"P": "PRO", | ||
"S": "SER", | ||
"T": "THR", | ||
"W": "TRP", | ||
"Y": "TYR", | ||
"V": "VAL", | ||
} | ||
UNIPROT_ACCESSION_PATTERN = ( | ||
r"[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import numpy as np | ||
import pytest | ||
import pandas as pd | ||
|
||
from utilin.encode.one_hot import encode_sequences_one_hot | ||
|
||
|
||
def test_encode_sequences_one_hot_default(): | ||
sequences = ["ACD", "GHK"] | ||
expected_output = np.array([ | ||
[ | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
], | ||
[ | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
] | ||
]) | ||
output = encode_sequences_one_hot(sequences) | ||
assert np.array_equal(output, expected_output) | ||
|
||
|
||
def test_encode_sequences_one_hot_gremlin(): | ||
sequences = ["A-", "CY"] | ||
expected_output = np.array([ | ||
[ | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] | ||
], | ||
[ | ||
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0] | ||
] | ||
]) | ||
output = encode_sequences_one_hot(sequences, aa_alphabet="gremlin") | ||
assert np.array_equal(output, expected_output) | ||
|
||
|
||
def test_encode_empty_sequences(): | ||
sequences = [] | ||
expected_output = np.array([]) | ||
output = encode_sequences_one_hot(sequences) | ||
assert np.array_equal(output, expected_output) | ||
|
||
|
||
def test_encode_pandas_sequences_one_hot(): | ||
sequences = pd.Series(["AC"]) | ||
expected_output = np.array([ | ||
[ | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
] | ||
]) | ||
output = encode_sequences_one_hot(sequences) | ||
assert np.array_equal(output, expected_output) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.