Skip to content

Commit

Permalink
switching from nose to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
iskandr committed Feb 24, 2024
1 parent 48b0682 commit d2617c6
Show file tree
Hide file tree
Showing 18 changed files with 182 additions and 26 deletions.
11 changes: 11 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
14 changes: 13 additions & 1 deletion tests/test_binding_prediction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from mhctools.binding_prediction import BindingPrediction
from nose.tools import eq_
from .common import eq_

def test_binding_prediction_fields():
bp = BindingPrediction(
Expand Down
14 changes: 13 additions & 1 deletion tests/test_binding_prediction_collection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
from nose.tools import eq_
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from mhctools import BindingPrediction, BindingPredictionCollection
from .common import eq_

def test_collection_to_dataframe():
bp = BindingPrediction(
Expand Down
17 changes: 15 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
from mhctools.cli.script import parse_args, run_predictor
from nose.tools import eq_
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import tempfile
from os import remove

from mhctools.cli.script import parse_args, run_predictor
from .common import eq_

def test_peptides_without_subsequences():
peptide = "SIINFEKLQY"
args = parse_args([
Expand Down
15 changes: 14 additions & 1 deletion tests/test_cli_parsing_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
from nose.tools import eq_

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from mhctools.cli.parsing_helpers import parse_int_list
from .common import eq_

def test_parse_int_list():
# int by itself
Expand Down
13 changes: 12 additions & 1 deletion tests/test_iedb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
from nose.tools import assert_raises
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from mhctools import IedbNetMHCpan
from .common import assert_raises


DEFAULT_ALLELE = 'HLA-A*02:01'
Expand Down
2 changes: 0 additions & 2 deletions tests/test_known_class1_epitopes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Copyright (c) 2014-2017. Mount Sinai School of Medicine
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand Down
2 changes: 0 additions & 2 deletions tests/test_known_class2_epitopes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Copyright (c) 2014-2017. Mount Sinai School of Medicine
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand Down
12 changes: 12 additions & 0 deletions tests/test_mhc_formats.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from mhctools.parsing import (
parse_netmhcpan28_stdout,
parse_netmhcpan3_stdout,
Expand Down
22 changes: 13 additions & 9 deletions tests/test_mhcflurry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

from nose.tools import eq_, nottest
from .common import eq_
from numpy import testing

from mhcflurry import Class1AffinityPredictor
Expand All @@ -14,14 +26,6 @@
}


def skip_if_py2(function):
if sys.version_info[0] < 3:
print("MHCflurry requires python 3. Skipping test.")
return nottest(function)
return function


@skip_if_py2
def test_mhcflurry():
predictor = MHCflurry(alleles=[DEFAULT_ALLELE])
binding_predictions = predictor.predict_subsequences(
Expand Down
15 changes: 13 additions & 2 deletions tests/test_mixmhcpred.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from tempfile import NamedTemporaryFile
from os import remove
from mhctools.mixmhcpred import parse_mixmhcpred_results
from nose.tools import eq_
from .common import eq_

example_output = """Peptide\tScore_bestAllele\tBestAllele\t%Rank_bestAllele\tScore_A0201\t%Rank_A0201
MLDDFSAGA\t0.182093\tA0201\t0.3\t0.182093\t0.3
Expand Down
12 changes: 12 additions & 0 deletions tests/test_netchop.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from numpy import testing

from mhctools import NetChop
Expand Down
13 changes: 13 additions & 0 deletions tests/test_netmhc_cons.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


from mhctools import NetMHCcons
from mhcnames import normalize_allele_name

Expand Down
14 changes: 13 additions & 1 deletion tests/test_netmhc_pan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
from nose.tools import eq_
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .common import eq_

from mhctools import NetMHCpan

Expand Down
2 changes: 1 addition & 1 deletion tests/test_netmhc_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from nose.tools import raises, eq_

from mhctools import NetMHC, NetMHC3, NetMHC4
from mhcnames import normalize_allele_name
from .common import raises, eq_


def run_class_with_executable(mhc_class, mhc_executable):
Expand Down
14 changes: 13 additions & 1 deletion tests/test_netmhcii_pan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
from nose.tools import eq_
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .common import eq_

from mhctools import NetMHCIIpan
from mhcnames import normalize_allele_name
Expand Down
14 changes: 13 additions & 1 deletion tests/test_peptide_lengths.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""
Class I predictors typically allow 8mer or longer peptides, whereas
Expand All @@ -6,7 +18,7 @@
"""

from mhctools import NetMHCIIpan, NetMHC
from nose.tools import eq_, assert_raises
from .common import eq_, assert_raises


def test_class2_9mer_success():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_random.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

from nose.tools import eq_
from mhctools import RandomBindingPredictor
from .common import eq_


alleles = [
Expand Down

0 comments on commit d2617c6

Please sign in to comment.