From 93729e53ed66f44f7b8a19492dfbf2a5b974345c Mon Sep 17 00:00:00 2001
From: Tim O'Donnell <timodonnell@gmail.com>
Date: Tue, 20 Feb 2018 11:22:19 -0500
Subject: [PATCH] fix

---
 mhcflurry/class1_neural_network.py                 | 7 +++++++
 mhcflurry/select_allele_specific_models_command.py | 5 +++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/mhcflurry/class1_neural_network.py b/mhcflurry/class1_neural_network.py
index 735f0a7f..9e6bc8b0 100644
--- a/mhcflurry/class1_neural_network.py
+++ b/mhcflurry/class1_neural_network.py
@@ -353,6 +353,13 @@ class Class1NeuralNetwork(object):
         result['prediction_cache'] = None
         return result
 
+    def __setstate__(self, state):
+        """
+        Deserialize. For pickle support.
+        """
+        self.__dict__.update(state)
+        self.prediction_cache = weakref.WeakKeyDictionary()
+
     def peptides_to_network_input(self, peptides):
         """
         Encode peptides to the fixed-length encoding expected by the neural
diff --git a/mhcflurry/select_allele_specific_models_command.py b/mhcflurry/select_allele_specific_models_command.py
index 722c82ab..18fb6e51 100644
--- a/mhcflurry/select_allele_specific_models_command.py
+++ b/mhcflurry/select_allele_specific_models_command.py
@@ -153,6 +153,8 @@ def run(argv=sys.argv[1:]):
 
             df = df.loc[~df._excluded]
             print("Reduced data to: %s" % (str(df.shape)))
+
+        metadata_dfs["model_selection_data"] = df
     else:
         df = None
 
@@ -195,8 +197,7 @@ def run(argv=sys.argv[1:]):
         print("Attempting to create directory: %s" % args.out_models_dir)
         os.mkdir(args.out_models_dir)
         print("Done.")
-
-    metadata_dfs["model_selection_data"] = df
+    
     result_predictor = Class1AffinityPredictor(metadata_dataframes=metadata_dfs)
 
     worker_pool = worker_pool_with_gpu_assignments_from_args(args)
-- 
GitLab