Repository: haddocking/haddock3
Issue: fix handling of restr_fname attribute in refinement modules

pdb models now have a `restr_fname` attribute (PR #563), which specifies which restraint file has been used to generate them.Refinement modules can receive in input two (or more) models at the same time (for example in the `refine-complex` example) that should be merged together.

In this case we should just set the attribute to `None`, to remove any ambiguity. If any restraint file is defined, then it must be used on the merged model.

Changed files:
src/haddock/modules/refinement/emref/__init__.py, src/haddock/modules/refinement/mdref/__init__.py, src/haddock/modules/refinement/flexref/__init__.py

diff --git a/src/haddock/modules/refinement/emref/__init__.py b/src/haddock/modules/refinement/emref/__init__.py
index 12a2c0d8..b2cbde3c 100644
--- a/src/haddock/modules/refinement/emref/__init__.py
+++ b/src/haddock/modules/refinement/emref/__init__.py
@@ -49,7 +49,12 @@ class HaddockModule(BaseCNSModule):
             self.log("[Warning] sampling_factor is larger than 100")
         
         # checking the ambig_fname:
-        prev_ambig_fnames = [model.restr_fname for model in models_to_refine]
+        try:
+            prev_ambig_fnames = [mod.restr_fname for mod in models_to_refine]
+        except Exception as e:  # noqa:F841
+            # cannot extract restr_fname info from tuples
+            prev_ambig_fnames = [None for model in models_to_refine]
+
         ambig_fnames = self.get_ambig_fnames(prev_ambig_fnames)
 
         model_idx = 0
diff --git a/src/haddock/modules/refinement/flexref/__init__.py b/src/haddock/modules/refinement/flexref/__init__.py
index e412b881..abbadb56 100644
--- a/src/haddock/modules/refinement/flexref/__init__.py
+++ b/src/haddock/modules/refinement/flexref/__init__.py
@@ -49,7 +49,12 @@ class HaddockModule(BaseCNSModule):
             self.log("[Warning] sampling_factor is larger than 100")
 
         # checking the ambig_fname:
-        prev_ambig_fnames = [model.restr_fname for model in models_to_refine]
+        try:
+            prev_ambig_fnames = [mod.restr_fname for mod in models_to_refine]
+        except Exception as e:  # noqa:F841
+            # cannot extract restr_fname info from tuples
+            prev_ambig_fnames = [None for model in models_to_refine]
+
         ambig_fnames = self.get_ambig_fnames(prev_ambig_fnames)
 
         model_idx = 0
diff --git a/src/haddock/modules/refinement/mdref/__init__.py b/src/haddock/modules/refinement/mdref/__init__.py
index 61055f8f..3452f223 100644
--- a/src/haddock/modules/refinement/mdref/__init__.py
+++ b/src/haddock/modules/refinement/mdref/__init__.py
@@ -49,7 +49,12 @@ class HaddockModule(BaseCNSModule):
             self.log("[Warning] sampling_factor is larger than 100")
         
         # checking the ambig_fname:
-        prev_ambig_fnames = [model.restr_fname for model in models_to_refine]
+        try:
+            prev_ambig_fnames = [mod.restr_fname for mod in models_to_refine]
+        except Exception as e:  # noqa:F841
+            # cannot extract restr_fname info from tuples
+            prev_ambig_fnames = [None for mod in models_to_refine]
+
         ambig_fnames = self.get_ambig_fnames(prev_ambig_fnames)
 
         model_idx = 0