From d28248d897dffb80e9dd8a403faca8415044ae58 Mon Sep 17 00:00:00 2001
From: Tim O'Donnell <timodonnell@gmail.com>
Date: Fri, 6 Sep 2019 09:39:57 -0400
Subject: [PATCH] theano on python 2.7 fixes; pylint fixes

---
 downloads-generation/allele_sequences/filter_sequences.py  | 2 +-
 .../allele_sequences/make_allele_sequences.py              | 2 +-
 mhcflurry/class1_neural_network.py                         | 7 ++++---
 mhcflurry/train_pan_allele_models_command.py               | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/downloads-generation/allele_sequences/filter_sequences.py b/downloads-generation/allele_sequences/filter_sequences.py
index 282fdd53..2d92a0b9 100644
--- a/downloads-generation/allele_sequences/filter_sequences.py
+++ b/downloads-generation/allele_sequences/filter_sequences.py
@@ -8,7 +8,7 @@ import argparse
 
 import mhcnames
 
-import Bio.SeqIO
+import Bio.SeqIO  # pylint: disable=import-error
 
 
 def normalize(s, disallowed=["MIC", "HFE"]):
diff --git a/downloads-generation/allele_sequences/make_allele_sequences.py b/downloads-generation/allele_sequences/make_allele_sequences.py
index 899eb42d..d984dd34 100644
--- a/downloads-generation/allele_sequences/make_allele_sequences.py
+++ b/downloads-generation/allele_sequences/make_allele_sequences.py
@@ -13,7 +13,7 @@ import pandas
 
 import mhcnames
 
-import Bio.SeqIO
+import Bio.SeqIO  # pylint: disable=import-error
 
 
 def normalize_simple(s):
diff --git a/mhcflurry/class1_neural_network.py b/mhcflurry/class1_neural_network.py
index f23ca977..31a433b2 100644
--- a/mhcflurry/class1_neural_network.py
+++ b/mhcflurry/class1_neural_network.py
@@ -1126,6 +1126,7 @@ class Class1NeuralNetwork(object):
 
         """
         import keras
+        import keras.backend as K
         from keras.layers import Input
         from keras.models import Model
 
@@ -1162,7 +1163,7 @@ class Class1NeuralNetwork(object):
             # Merging an ensemble of pan-allele architectures
             network = networks[0]
             peptide_input = Input(
-                shape=tuple(int(x) for x in network.inputs[0].shape[1:]),
+                shape=tuple(int(x) for x in K.int_shape(network.inputs[0])[1:]),
                 dtype='float32',
                 name='peptide')
             allele_input = Input(
@@ -1366,7 +1367,7 @@ class Class1NeuralNetwork(object):
                   l is the allele sequence length,
                   m is the length of the vectors used to represent amino acids
         """
-        from keras.models import model_from_json
+        from keras.models import clone_model
         reshaped = allele_representations.reshape(
             (allele_representations.shape[0], -1))
         original_model = self.network()
@@ -1392,7 +1393,7 @@ class Class1NeuralNetwork(object):
             # Network surgery required. Make a new network with this layer's
             # dimensions changed. Kind of a hack.
             layer.input_dim = reshaped.shape[0]
-            new_model = model_from_json(original_model.to_json())
+            new_model = clone_model(original_model)
 
             # copy weights for other layers over
             for layer in new_model.layers:
diff --git a/mhcflurry/train_pan_allele_models_command.py b/mhcflurry/train_pan_allele_models_command.py
index a985539d..c1b015e4 100644
--- a/mhcflurry/train_pan_allele_models_command.py
+++ b/mhcflurry/train_pan_allele_models_command.py
@@ -270,7 +270,7 @@ def run(argv=sys.argv[1:]):
             return main(args)
         except Exception as e:
             print(e)
-            import ipdb
+            import ipdb  # pylint: disable=import-error
             ipdb.set_trace()
             raise
     else:
-- 
GitLab