From f8b363c6188e35f892e6d5e680b6cf2fbcf068f5 Mon Sep 17 00:00:00 2001 From: Alex Rubinsteyn Date: Thu, 8 Feb 2024 13:02:15 -0500 Subject: [PATCH] got rid of last uses of six --- mhctools/__init__.py | 2 ++ mhctools/base_commandline_predictor.py | 5 ++--- mhctools/base_predictor.py | 12 ++++-------- mhctools/binding_prediction.py | 6 +----- mhctools/cleanup_context.py | 3 --- mhctools/common.py | 8 +------- mhctools/iedb.py | 8 ++------ mhctools/input_file_formats.py | 3 --- mhctools/logging.py | 12 +++++++++++- mhctools/mhcflurry.py | 3 --- mhctools/mixmhcpred.py | 4 ---- mhctools/netchop.py | 2 -- mhctools/netmhc.py | 4 ---- mhctools/netmhc3.py | 2 -- mhctools/netmhc4.py | 4 ---- mhctools/netmhc_cons.py | 2 -- mhctools/netmhc_pan.py | 3 --- mhctools/netmhc_pan28.py | 2 -- mhctools/netmhc_pan3.py | 3 --- mhctools/netmhc_pan4.py | 2 -- mhctools/netmhc_pan41.py | 4 ---- mhctools/netmhcii_pan.py | 4 ---- mhctools/parsing.py | 2 -- mhctools/process_helpers.py | 4 +--- mhctools/random_predictor.py | 3 --- requirements.txt | 8 +++----- setup.py | 3 --- 27 files changed, 27 insertions(+), 91 deletions(-) diff --git a/mhctools/__init__.py b/mhctools/__init__.py index 7efd1f5..129aa71 100644 --- a/mhctools/__init__.py +++ b/mhctools/__init__.py @@ -47,6 +47,8 @@ "NetMHCpan41", "NetMHCpan4_BA", "NetMHCpan4_EL", + "NetMHCpan41_BA", + "NetMHCpan41_EL", "NetMHCIIpan", "NetMHCIIpan3", "NetMHCIIpan4", diff --git a/mhctools/base_commandline_predictor.py b/mhctools/base_commandline_predictor.py index 5f0ec9b..5297827 100644 --- a/mhctools/base_commandline_predictor.py +++ b/mhctools/base_commandline_predictor.py @@ -18,7 +18,6 @@ from subprocess import check_output import tempfile -from six import string_types from typechecks import require_string, require_integer, require_iterable_of from mhcnames import normalize_allele_name, AlleleParseError @@ -128,14 +127,14 @@ def __init__( require_string(allele_flag, "Allele flag") self.allele_flag = allele_flag - require_iterable_of(peptide_mode_flags, string_types) + require_iterable_of(peptide_mode_flags, str) self.peptide_mode_flags = peptide_mode_flags if tempdir_flag is not None: require_string(tempdir_flag, "Temporary directory flag") self.tempdir_flag = tempdir_flag - require_iterable_of(extra_flags, string_types) + require_iterable_of(extra_flags, str) self.extra_flags = extra_flags require_integer( diff --git a/mhctools/base_predictor.py b/mhctools/base_predictor.py index 975f26f..0e53b5a 100644 --- a/mhctools/base_predictor.py +++ b/mhctools/base_predictor.py @@ -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 @@ -12,11 +10,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import import logging from collections import defaultdict -from six import string_types from typechecks import require_iterable_of from mhcnames import normalize_allele_name @@ -68,11 +64,11 @@ def __init__( """ # I find myself often constructing a predictor with just one allele # so as a convenience, allow user to not wrap that allele as a list - if isinstance(alleles, string_types): + if type(alleles) is str: alleles = alleles.split(',') self.alleles = self._check_hla_alleles(alleles, valid_alleles) - if isinstance(default_peptide_lengths, int): + if type(default_peptide_lengths) is int: default_peptide_lengths = [default_peptide_lengths] require_iterable_of(default_peptide_lengths, int) self.default_peptide_lengths = default_peptide_lengths @@ -156,7 +152,7 @@ def _check_peptide_inputs(self, peptides): """ Check peptide sequences to make sure they are valid for this predictor. """ - require_iterable_of(peptides, string_types) + require_iterable_of(peptides, str) check_X = not self.allow_X_in_peptides check_lower = not self.allow_lowercase_in_peptides check_min_length = self.min_peptide_length is not None @@ -188,7 +184,7 @@ def predict_subsequences( and an optional list of peptide lengths, returns a BindingPredictionCollection. """ - if isinstance(sequence_dict, string_types): + if isinstance(sequence_dict, str): sequence_dict = {"seq": sequence_dict} elif isinstance(sequence_dict, (list, tuple)): sequence_dict = {seq: seq for seq in sequence_dict} diff --git a/mhctools/binding_prediction.py b/mhctools/binding_prediction.py index 87bcc7e..930cc21 100644 --- a/mhctools/binding_prediction.py +++ b/mhctools/binding_prediction.py @@ -1,5 +1,3 @@ -# Copyright (c) 2014-2019. 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 @@ -12,8 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import - import numpy as np from serializable import Serializable @@ -40,7 +36,7 @@ def __init__( score : float Continuous prediction of peptide-MHC binding where larger values indicate either higher affinity or higher probability. For affinity - predictors this can be 1-log(IC50)/log(max_IC50) For mass spec + predictors this can be 1-log(IC50)/log(max_IC50). For mass spec predictors this can be the probability of detection. percentile_rank : float diff --git a/mhctools/cleanup_context.py b/mhctools/cleanup_context.py index 6b6817b..eeb9274 100644 --- a/mhctools/cleanup_context.py +++ b/mhctools/cleanup_context.py @@ -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 @@ -12,7 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import import logging import os import shutil diff --git a/mhctools/common.py b/mhctools/common.py index 60d8721..bb386b4 100644 --- a/mhctools/common.py +++ b/mhctools/common.py @@ -1,5 +1,3 @@ -# Copyright (c) 2014-2019. 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 @@ -12,17 +10,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import - -from six import string_types - def seq_to_str(obj, sep=","): """ Given a sequence convert it to a comma separated string. If, however, the argument is a single object, return its string representation. """ - if isinstance(obj, string_types): + if type(obj) is str: return obj elif isinstance(obj, (list, tuple)): return sep.join([str(x) for x in obj]) diff --git a/mhctools/iedb.py b/mhctools/iedb.py index 73cf2d9..7a4f2b1 100644 --- a/mhctools/iedb.py +++ b/mhctools/iedb.py @@ -1,5 +1,3 @@ -# Copyright (c) 2014-2019. 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 @@ -12,15 +10,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import import io # pylint: disable=import-error -from six.moves.urllib.request import urlopen, Request +from urllib.request import urlopen, Request # pylint: disable=import-error -from six.moves.urllib.parse import urlencode +from urllib.parse import urlencode -from six import string_types import pandas as pd import numpy as np diff --git a/mhctools/input_file_formats.py b/mhctools/input_file_formats.py index 7533d9a..d65085d 100644 --- a/mhctools/input_file_formats.py +++ b/mhctools/input_file_formats.py @@ -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 @@ -12,7 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import import tempfile def make_writable_tempfile(prefix_number, prefix_name, suffix): diff --git a/mhctools/logging.py b/mhctools/logging.py index 333ea3d..0d9aa0d 100644 --- a/mhctools/logging.py +++ b/mhctools/logging.py @@ -1,4 +1,14 @@ -from __future__ import print_function, division, absolute_import +# 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 logging import logging.config diff --git a/mhctools/mhcflurry.py b/mhctools/mhcflurry.py index 31ebf0e..fa3fa46 100644 --- a/mhctools/mhcflurry.py +++ b/mhctools/mhcflurry.py @@ -1,5 +1,3 @@ -# Copyright (c) 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 @@ -12,7 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import import logging from numpy import nan diff --git a/mhctools/mixmhcpred.py b/mhctools/mixmhcpred.py index 348b2fd..32feedb 100644 --- a/mhctools/mixmhcpred.py +++ b/mhctools/mixmhcpred.py @@ -1,5 +1,3 @@ -# Copyright (c) 2019. 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 @@ -12,8 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import - import pandas as pd from tempfile import mkdtemp, NamedTemporaryFile from os.path import join, exists diff --git a/mhctools/netchop.py b/mhctools/netchop.py index 2722b65..4932f3b 100644 --- a/mhctools/netchop.py +++ b/mhctools/netchop.py @@ -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 diff --git a/mhctools/netmhc.py b/mhctools/netmhc.py index 5c64c93..df77a33 100644 --- a/mhctools/netmhc.py +++ b/mhctools/netmhc.py @@ -1,5 +1,3 @@ -# Copyright (c) 2015-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 @@ -12,8 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import - from subprocess import check_output import os diff --git a/mhctools/netmhc3.py b/mhctools/netmhc3.py index c0e70e8..c27aeb0 100644 --- a/mhctools/netmhc3.py +++ b/mhctools/netmhc3.py @@ -1,5 +1,3 @@ -# Copyright (c) 2015-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 diff --git a/mhctools/netmhc4.py b/mhctools/netmhc4.py index b4eee23..966a9af 100644 --- a/mhctools/netmhc4.py +++ b/mhctools/netmhc4.py @@ -1,5 +1,3 @@ -# Copyright (c) 2015-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 @@ -12,8 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import - from .base_commandline_predictor import BaseCommandlinePredictor from .parsing import parse_netmhc4_stdout diff --git a/mhctools/netmhc_cons.py b/mhctools/netmhc_cons.py index 5565b01..d152d05 100644 --- a/mhctools/netmhc_cons.py +++ b/mhctools/netmhc_cons.py @@ -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 diff --git a/mhctools/netmhc_pan.py b/mhctools/netmhc_pan.py index 1551ce8..1076d93 100644 --- a/mhctools/netmhc_pan.py +++ b/mhctools/netmhc_pan.py @@ -1,5 +1,3 @@ -# Copyright (c) 2016-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 @@ -12,7 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import import logging from subprocess import check_output import os diff --git a/mhctools/netmhc_pan28.py b/mhctools/netmhc_pan28.py index 14829e5..5ff9f31 100644 --- a/mhctools/netmhc_pan28.py +++ b/mhctools/netmhc_pan28.py @@ -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 diff --git a/mhctools/netmhc_pan3.py b/mhctools/netmhc_pan3.py index 111d0ac..8079405 100644 --- a/mhctools/netmhc_pan3.py +++ b/mhctools/netmhc_pan3.py @@ -1,5 +1,3 @@ -# Copyright (c) 2016-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 @@ -12,7 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import from .base_commandline_predictor import BaseCommandlinePredictor from .parsing import parse_netmhcpan3_stdout diff --git a/mhctools/netmhc_pan4.py b/mhctools/netmhc_pan4.py index 230099a..0578a82 100644 --- a/mhctools/netmhc_pan4.py +++ b/mhctools/netmhc_pan4.py @@ -1,5 +1,3 @@ -# Copyright (c) 2016-2019. 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 diff --git a/mhctools/netmhc_pan41.py b/mhctools/netmhc_pan41.py index c9b49e1..a4b46f3 100644 --- a/mhctools/netmhc_pan41.py +++ b/mhctools/netmhc_pan41.py @@ -1,5 +1,3 @@ -# Copyright (c) 2016-2023. 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 @@ -12,8 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import - from .base_commandline_predictor import BaseCommandlinePredictor from .parsing import parse_netmhc41_stdout from functools import partial diff --git a/mhctools/netmhcii_pan.py b/mhctools/netmhcii_pan.py index deee96c..f1fa604 100644 --- a/mhctools/netmhcii_pan.py +++ b/mhctools/netmhcii_pan.py @@ -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 @@ -12,8 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import - from functools import partial import logging import os diff --git a/mhctools/parsing.py b/mhctools/parsing.py index 26d07ae..910a642 100644 --- a/mhctools/parsing.py +++ b/mhctools/parsing.py @@ -1,5 +1,3 @@ -# Copyright (c) 2014-2019. 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 diff --git a/mhctools/process_helpers.py b/mhctools/process_helpers.py index 363707c..cee764b 100644 --- a/mhctools/process_helpers.py +++ b/mhctools/process_helpers.py @@ -1,5 +1,3 @@ -# Copyright (c) 2014. 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 @@ -20,7 +18,7 @@ from multiprocessing import cpu_count # pylint: disable=import-error -from six.moves.queue import Queue +from queue import Queue logger = logging.getLogger(__name__) diff --git a/mhctools/random_predictor.py b/mhctools/random_predictor.py index 5481dba..7bb3c77 100644 --- a/mhctools/random_predictor.py +++ b/mhctools/random_predictor.py @@ -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 @@ -12,7 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function, division, absolute_import import random from .base_predictor import BasePredictor diff --git a/requirements.txt b/requirements.txt index 7f2b0ec..b6393a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,8 @@ -numpy>=1.7 +numpy>=1.7,<2.0 pandas>=0.13.1 -pyensembl>=1.0.3 +pyensembl>=1.0.3, varcode>=0.5.9 -six>=1.9.0 pylint>=1.4.4 -nose>=1.3.6 -sercol>=0.0.2 +sercol>=0.0.2,<1.0.0 mhcflurry>=2.0.0 mhcnames>=0.3.2 diff --git a/setup.py b/setup.py index f8c1ad3..df4f7e2 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -# Copyright (c) 2014-2019. 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 @@ -60,7 +58,6 @@ 'pandas>=0.13.1', 'varcode>=0.5.9', 'pyensembl>=1.0.3', - 'six>=1.9.0', 'sercol>=0.0.2', 'mhcflurry>=2.0.0', 'mhcnames>=0.3.2',