Skip to content

Commit

Permalink
got rid of last uses of six
Browse files Browse the repository at this point in the history
  • Loading branch information
iskandr committed Feb 8, 2024
1 parent 770724f commit f8b363c
Show file tree
Hide file tree
Showing 27 changed files with 27 additions and 91 deletions.
2 changes: 2 additions & 0 deletions mhctools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"NetMHCpan41",
"NetMHCpan4_BA",
"NetMHCpan4_EL",
"NetMHCpan41_BA",
"NetMHCpan41_EL",
"NetMHCIIpan",
"NetMHCIIpan3",
"NetMHCIIpan4",
Expand Down
5 changes: 2 additions & 3 deletions mhctools/base_commandline_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down
12 changes: 4 additions & 8 deletions mhctools/base_predictor.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 All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
6 changes: 1 addition & 5 deletions mhctools/binding_prediction.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions mhctools/cleanup_context.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 All @@ -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
Expand Down
8 changes: 1 addition & 7 deletions mhctools/common.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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])
Expand Down
8 changes: 2 additions & 6 deletions mhctools/iedb.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions mhctools/input_file_formats.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 All @@ -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):
Expand Down
12 changes: 11 additions & 1 deletion mhctools/logging.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions mhctools/mhcflurry.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions mhctools/mixmhcpred.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions mhctools/netchop.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
4 changes: 0 additions & 4 deletions mhctools/netmhc.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
2 changes: 0 additions & 2 deletions mhctools/netmhc3.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 0 additions & 4 deletions mhctools/netmhc4.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
2 changes: 0 additions & 2 deletions mhctools/netmhc_cons.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
3 changes: 0 additions & 3 deletions mhctools/netmhc_pan.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions mhctools/netmhc_pan28.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
3 changes: 0 additions & 3 deletions mhctools/netmhc_pan3.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions mhctools/netmhc_pan4.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 0 additions & 4 deletions mhctools/netmhc_pan41.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions mhctools/netmhcii_pan.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 All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions mhctools/parsing.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions mhctools/process_helpers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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__)

Expand Down
3 changes: 0 additions & 3 deletions mhctools/random_predictor.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 All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit f8b363c

Please sign in to comment.