Skip to content

Commit

Permalink
refactor test code
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwengers committed Oct 24, 2023
1 parent ec327a6 commit 7397830
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 66 deletions.
4 changes: 2 additions & 2 deletions test/test_args.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from inspect import Parameter
import os
import pytest

from pathlib import Path
from subprocess import run

import pytest

from .conftest import FILES, SKIP_PARAMETERS


Expand Down
1 change: 1 addition & 0 deletions test/test_bakta_proteins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest


FILES = [
'test.tsv',
'test.hypotheticals.tsv',
Expand Down
4 changes: 0 additions & 4 deletions test/test_crispr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from pathlib import Path
from subprocess import run

import pytest


CRISPR_ARRAYS = [
{
Expand All @@ -19,8 +17,6 @@
]




def test_crispr_arrays(tmpdir):
proc = run(
[
Expand Down
2 changes: 0 additions & 2 deletions test/test_edge_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from pathlib import Path
from subprocess import run

import pytest

from bakta import constants as bc


Expand Down
10 changes: 4 additions & 6 deletions test/test_nt_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
from pathlib import Path
from subprocess import run

import pytest

cds = 'TTGACTACGCCATTGAAAAAGATTGTGATTGTCGGCGGCGGTGCTGGTGGGCTGGAAATGGCAACACAGCTGGGGCATAAGCTGGGACGCAAGAAAAAAGCCAAAATTACGCTGGTCGATCGTAACCACAGCCATCTGTGGAAACCGCTGCTGCACGAAGTGGCGACTGGCTCGCTTGATGAAGGCGTCGATGCGTTGAGCTATCTGGCCCATGCGCGCAATCATGGTTTCCAGTTCCAGCTGGGTTCCGTCATTGATATTGATCGTGAAGCGAAAACAATCACTATTGCAGAACTGCGCGATGAGAAAGGTGAACTGCTGGTTCCGGAACGTAAAATCGCCTATGACACCCTGGTAATGGCGCTGGGTAGCACCTCTAACGATTTCAATACGCCAGGTGTCAAAGAGAACTGCATTTTCCTCGATAACCCGCACCAGGCGCGTCGCTTTCACCAGGAGATGCTGAATCTCTTCCTGAAATACTCCGCCAACCTGGGCGCAAATGGCAAAGTGAACATTGCGATTGTCGGCGGCGGCGCGACGGGTGTAGAACTCTCCGCTGAATTGCACAACGCGGTCAAGCAACTGCACAGCTACGGTTACAAAGGCCTGACCAACGAAGCCCTGAACGTAACGCTGGTAGAAGCGGGAGAACGTATTTTGCCTGCATTACCGCCACGTATCTCTGCTGCGGCCCACAACGAGCTAACGAAACTTGGCGTTCGCGTGCTGACGCAAACCATGGTCACCAGTGCTGATGAAGGCGGCCTGCACACTAAAGATGGCGAATATATTGAGGCTGATCTGATGGTGTGGGCAGCCGGGATCAAAGCGCCAGACTTCCTGAAAGATATCGGTGGTCTTGAAACTAACCGTATCAACCAGCTGGTGGTGGAACCGACGCTGCAAACCACCCGCGATCCAGACATTTACGCTATTGGCGACTGCGCGTCATGCCCGCGTCCGGAAGGGGGCTTTGTTCCGCCGCGTGCTCAGGCTGCACACCAGATGGCGACTTGCGCAATGAACAACATTCTGGCGCAGATGAATGGTAAGCCGCTGAAAAATTATCAGTATAAAGATCATGGTTCGCTGGTATCGCTGTCGAACTTCTCCACCGTTGGTAGCCTGATGGGTAACCTGACGCGCGGCTCAATGATGATTGAAGGACGAATTGCGCGCTTTGTATATATCTCGCTATACCGAATGCATCAGATTGCGCTGCATGGTTACTTTAAAACCGGATTAATGATGCTGGTGGGGAGTATTAACCGCGTTATCCGTCCGCGTTTGAAGTTGCATTAA'
sorf = 'ATGGTGAATACCGGCGGCAATAAACGTCAGGTGCCGGCGAAACGTCAGAATCGTGGCTCCCGTAATTCCAAAGATGATGGCGGCTAA'
CDS = 'TTGACTACGCCATTGAAAAAGATTGTGATTGTCGGCGGCGGTGCTGGTGGGCTGGAAATGGCAACACAGCTGGGGCATAAGCTGGGACGCAAGAAAAAAGCCAAAATTACGCTGGTCGATCGTAACCACAGCCATCTGTGGAAACCGCTGCTGCACGAAGTGGCGACTGGCTCGCTTGATGAAGGCGTCGATGCGTTGAGCTATCTGGCCCATGCGCGCAATCATGGTTTCCAGTTCCAGCTGGGTTCCGTCATTGATATTGATCGTGAAGCGAAAACAATCACTATTGCAGAACTGCGCGATGAGAAAGGTGAACTGCTGGTTCCGGAACGTAAAATCGCCTATGACACCCTGGTAATGGCGCTGGGTAGCACCTCTAACGATTTCAATACGCCAGGTGTCAAAGAGAACTGCATTTTCCTCGATAACCCGCACCAGGCGCGTCGCTTTCACCAGGAGATGCTGAATCTCTTCCTGAAATACTCCGCCAACCTGGGCGCAAATGGCAAAGTGAACATTGCGATTGTCGGCGGCGGCGCGACGGGTGTAGAACTCTCCGCTGAATTGCACAACGCGGTCAAGCAACTGCACAGCTACGGTTACAAAGGCCTGACCAACGAAGCCCTGAACGTAACGCTGGTAGAAGCGGGAGAACGTATTTTGCCTGCATTACCGCCACGTATCTCTGCTGCGGCCCACAACGAGCTAACGAAACTTGGCGTTCGCGTGCTGACGCAAACCATGGTCACCAGTGCTGATGAAGGCGGCCTGCACACTAAAGATGGCGAATATATTGAGGCTGATCTGATGGTGTGGGCAGCCGGGATCAAAGCGCCAGACTTCCTGAAAGATATCGGTGGTCTTGAAACTAACCGTATCAACCAGCTGGTGGTGGAACCGACGCTGCAAACCACCCGCGATCCAGACATTTACGCTATTGGCGACTGCGCGTCATGCCCGCGTCCGGAAGGGGGCTTTGTTCCGCCGCGTGCTCAGGCTGCACACCAGATGGCGACTTGCGCAATGAACAACATTCTGGCGCAGATGAATGGTAAGCCGCTGAAAAATTATCAGTATAAAGATCATGGTTCGCTGGTATCGCTGTCGAACTTCTCCACCGTTGGTAGCCTGATGGGTAACCTGACGCGCGGCTCAATGATGATTGAAGGACGAATTGCGCGCTTTGTATATATCTCGCTATACCGAATGCATCAGATTGCGCTGCATGGTTACTTTAAAACCGGATTAATGATGCTGGTGGGGAGTATTAACCGCGTTATCCGTCCGCGTTTGAAGTTGCATTAA'
SORF = 'ATGGTGAATACCGGCGGCAATAAACGTCAGGTGCCGGCGAAACGTCAGAATCGTGGCTCCCGTAATTCCAAAGATGATGGCGGCTAA'


def test_bakta_cds_nt_sequence(tmpdir):
Expand All @@ -30,7 +28,7 @@ def test_bakta_cds_nt_sequence(tmpdir):

for feat in results['features']:
if(feat['contig'] != 'dummy'):
assert feat['nt'] == cds
assert feat['nt'] == CDS


def test_bakta_sorf_nt_sequence(tmpdir):
Expand All @@ -53,4 +51,4 @@ def test_bakta_sorf_nt_sequence(tmpdir):
results = json.load(fh)

for feat in results['features']:
assert feat['nt'] == sorf
assert feat['nt'] == SORF
24 changes: 12 additions & 12 deletions test/test_sORF.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@
from bakta.features import s_orf as bu


contig_1 = {
CONTIG_1 = {
'id': 1,
'description': 'no sORFs',
'sequence': 'GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG'
}
contig_2 = {
CONTIG_2 = {
'id': 2,
'description': 'out of limits',
'sequence': 'ATGAAAAAATAGGGGATGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGTAG'
}
contig_3 = {
CONTIG_3 = {
'id': 3,
'description': 'two sORFs',
'sequence': 'ATGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGTAGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGATGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGTAG'
}

genome_1 = {
'contigs': [contig_1]
GENOME_1 = {
'contigs': [CONTIG_1]
}
genome_2 = {
'contigs': [contig_2]
GENOME_2 = {
'contigs': [CONTIG_2]
}
genome_3 = {
'contigs': [contig_3]
GENOME_3 = {
'contigs': [CONTIG_3]
}


@pytest.mark.parametrize(
"genome, expected",
[
(genome_1, 0),
(genome_2, 0),
(genome_3, 2)
(GENOME_1, 0),
(GENOME_2, 0),
(GENOME_3, 2)
]
)
def test_sORF(genome, expected):
Expand Down
24 changes: 12 additions & 12 deletions test/test_sig_peps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
from bakta.features import signal_peptides as bsp


one_twentyone_fwd = {'start': 1, 'stop': 21, 'strand': '+'}
one_twentyone_rev = {'start': 1, 'stop': 21, 'strand': '-'}
four_fifteen_fwd = {'start': 4, 'stop': 15, 'strand': '+'}
four_fifteen_rev = {'start': 4, 'stop': 15, 'strand': '-'}
ONE_TWENTYONE_FWD = {'start': 1, 'stop': 21, 'strand': '+'}
ONE_TWENTYONE_REV = {'start': 1, 'stop': 21, 'strand': '-'}
FOUR_FIFTEEN_FWD = {'start': 4, 'stop': 15, 'strand': '+'}
FOUR_FIFTEEN_REV = {'start': 4, 'stop': 15, 'strand': '-'}


@pytest.mark.parametrize(
"orf, start_aa, stop_aa, expected",
[
# Forward strand
(one_twentyone_fwd, 1, 3, (1,9)), # ORF spans whole sequence length, signal peptide starts at AA 1
(one_twentyone_fwd, 2, 7, (4,21)), # ORF spans whole sequence length, signal peptide stops at last AA
(four_fifteen_fwd, 1, 3, (4,12)), # ORF does not span whole sequence length, signal peptide starts at AA 1
(four_fifteen_fwd, 2, 4, (7,15)), # ORF does not span whole sequence length, signal peptide stops at last AA
(ONE_TWENTYONE_FWD, 1, 3, (1,9)), # ORF spans whole sequence length, signal peptide starts at AA 1
(ONE_TWENTYONE_FWD, 2, 7, (4,21)), # ORF spans whole sequence length, signal peptide stops at last AA
(FOUR_FIFTEEN_FWD, 1, 3, (4,12)), # ORF does not span whole sequence length, signal peptide starts at AA 1
(FOUR_FIFTEEN_FWD, 2, 4, (7,15)), # ORF does not span whole sequence length, signal peptide stops at last AA
# Reverse strand
(one_twentyone_rev, 1, 3, (13,21)), # ORF spans whole sequence length, signal peptide starts at AA 1
(one_twentyone_rev, 3, 7, (1,15)), # ORF spans whole sequence length, signal peptide stops at last AA
(four_fifteen_rev, 1, 2, (10,15)), # ORF does not span whole sequence length, signal peptide starts at AA 1
(four_fifteen_rev, 2, 3, (7,12)) # ORF does not span whole sequence length, signal peptide in the middle of ORF
(ONE_TWENTYONE_REV, 1, 3, (13,21)), # ORF spans whole sequence length, signal peptide starts at AA 1
(ONE_TWENTYONE_REV, 3, 7, (1,15)), # ORF spans whole sequence length, signal peptide stops at last AA
(FOUR_FIFTEEN_REV, 1, 2, (10,15)), # ORF does not span whole sequence length, signal peptide starts at AA 1
(FOUR_FIFTEEN_REV, 2, 3, (7,12)) # ORF does not span whole sequence length, signal peptide in the middle of ORF
]
)
def test_start_stop(orf, start_aa, stop_aa, expected):
Expand Down
56 changes: 28 additions & 28 deletions test/test_user_proteins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,74 +12,74 @@
SEQUENCE = 'MRADEEPGDLSAVAQDYLKVIWTAQEWSQDKVSTKMLAERIGVSASTASESIRKLAEQGLVDHEKYGAVTLTDSGRRAALAMVRRHRLLETFLVNELGYRWDEVHDEA'


aa_min = {
AA_MIN = {
'id': 'min',
'description': '~~~product~~~',
'sequence': SEQUENCE
}
aa_min_gene = {
AA_MIN_GENE = {
'id': 'min',
'description': 'gene~~~product~~~',
'sequence': SEQUENCE
}
aa_min_dbxref = {
AA_MIN_DBXREF = {
'id': 'min',
'description': 'gene~~~product~~~db-1:id-1',
'sequence': SEQUENCE
}
aa_min_dbxrefs = {
AA_MIN_DBXREFS = {
'id': 'min',
'description': 'gene~~~product~~~db-1:id-1,db-2:id-2',
'sequence': SEQUENCE
}
aa_full = {
AA_FULL = {
'id': 'full',
'description': '90.0~~~80.0~~~80.0~~~gene~~~product~~~db-1:id-1,db-2:id-2',
'sequence': SEQUENCE
}


aa_wrong_1 = {
AA_WRONG_1 = {
'id': 'low-cols',
'description': '~~~product',
'sequence': SEQUENCE
}
aa_wrong_2 = {
AA_WRONG_2 = {
'id': 'high-cols',
'description': '90~~~80~~~80~~~gene~~~product~~~dbxref:dbxref~~~',
'sequence': SEQUENCE
}
aa_wrong_3 = {
AA_WRONG_3 = {
'id': 'no-product',
'description': 'gene~~~~~~dbxref:dbxref',
'sequence': SEQUENCE
}
aa_wrong_4 = {
AA_WRONG_4 = {
'id': 'no-product-full',
'description': '90~~~80~~~80~~~gene~~~~~~dbxref:dbxref',
'sequence': SEQUENCE
}
aa_wrong_5 = {
AA_WRONG_5 = {
'id': 'wrong-dbxref',
'description': 'gene~~~product~~~dbxrefdbxref',
'sequence': SEQUENCE
}
aa_wrong_6 = {
AA_WRONG_6 = {
'id': 'wrong-dbxref-full',
'description': '90~~~80~~~80~~~gene~~~product~~~dbxrefdbxref',
'sequence': SEQUENCE
}
aa_wrong_7 = {
AA_WRONG_7 = {
'id': 'wrong-id',
'description': 'ninety~~~80~~~80~~~gene~~~product~~~dbxref:dbxref',
'sequence': SEQUENCE
}
aa_wrong_8 = {
AA_WRONG_8 = {
'id': 'wrong-min-query-cov',
'description': '90~~~eighty~~~80~~~gene~~~product~~~dbxref:dbxref',
'sequence': SEQUENCE
}
aa_wrong_9 = {
AA_WRONG_9 = {
'id': 'wrong-min-model-cov',
'description': '90~~~80~~~eighty~~~gene~~~product~~~dbxref:dbxref',
'sequence': SEQUENCE
Expand All @@ -89,15 +89,15 @@
@pytest.mark.parametrize(
"parameters",
[
(aa_wrong_1),
(aa_wrong_2),
(aa_wrong_3),
(aa_wrong_4),
(aa_wrong_5),
(aa_wrong_6),
(aa_wrong_7),
(aa_wrong_8),
(aa_wrong_9)
AA_WRONG_1,
AA_WRONG_2,
AA_WRONG_3,
AA_WRONG_4,
AA_WRONG_5,
AA_WRONG_6,
AA_WRONG_7,
AA_WRONG_8,
AA_WRONG_9
]
)
def test_wrong_user_proteins_io(tmpdir, parameters):
Expand All @@ -114,11 +114,11 @@ def test_wrong_user_proteins_io(tmpdir, parameters):
@pytest.mark.parametrize(
"parameters",
[
(aa_min),
(aa_min_gene),
(aa_min_dbxref),
(aa_min_dbxrefs),
(aa_full)
AA_MIN,
AA_MIN_GENE,
AA_MIN_DBXREF,
AA_MIN_DBXREFS,
AA_FULL
]
)
def test_user_proteins_io(parameters, tmpdir):
Expand Down

0 comments on commit 7397830

Please sign in to comment.