Merge commit 'alpha/update_2_12_for_2_11_2_series_merge^2' into HEAD
[jalview.git] / src / jalview / structure / StructureSelectionManager.java
index 5b432f5..bd3d7b3 100644 (file)
@@ -103,6 +103,15 @@ public class StructureSelectionManager implements ApplicationSingletonI
   }
 
   /**
+   * Private constructor as all 'singleton' instances are managed here or by
+   * ApplicationSingletonProvider
+   */
+  private StructureSelectionManager()
+  {
+    selectionManagers = new IdentityHashMap<>();
+  }
+
+  /**
    * Answers an instance of this class for the current application (Java or JS
    * 'applet') scope, and scoped to the specified context
    * 
@@ -136,14 +145,6 @@ public class StructureSelectionManager implements ApplicationSingletonI
     return instance;
   }
 
-  /**
-   * Private constructor as all 'singleton' instances are managed here or by
-   * ApplicationSingletonProvider
-   */
-  private StructureSelectionManager()
-  {
-    selectionManagers = new IdentityHashMap<>();
-  }
 
   /**
    * @return true if will try to use external services for processing secondary
@@ -433,7 +434,17 @@ public class StructureSelectionManager implements ApplicationSingletonI
         registerPDBFile(pdb.getId().trim(), pdbFile);
       }
       // if PDBId is unavailable then skip SIFTS mapping execution path
-      isMapUsingSIFTs = isMapUsingSIFTs && pdb.isPPDBIdAvailable();
+      // TODO: JAL-3868 need to know if structure is actually from 
+      // PDB (has valid PDB ID and has provenance suggesting it 
+      // actually came from PDB)
+      boolean isProtein = false;
+      for (SequenceI s:sequenceArray) {
+        if (s.isProtein()) {
+          isProtein = true;
+          break;
+        }
+      }
+      isMapUsingSIFTs = isMapUsingSIFTs && pdb.isPPDBIdAvailable() && !pdb.getId().startsWith("AF-") && isProtein;
 
     } catch (Exception ex)
     {
@@ -561,15 +572,14 @@ public class StructureSelectionManager implements ApplicationSingletonI
                     pdb, maxChain, sqmpping, maxAlignseq, siftsClient);
             seqToStrucMapping.add(siftsMapping);
             maxChain.makeExactMapping(siftsMapping, seq);
-            maxChain.transferRESNUMFeatures(seq, "IEA: SIFTS");// FIXME: is this
-                                                       // "IEA:SIFTS" ?
+            maxChain.transferRESNUMFeatures(seq, "IEA: SIFTS");
             maxChain.transferResidueAnnotation(siftsMapping, null);
             ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0));
 
           } catch (SiftsException e)
           {
             // fall back to NW alignment
-            System.err.println(e.getMessage());
+            Cache.log.error(e.getMessage());
             StructureMapping nwMapping = getNWMappings(seq, pdbFile,
                     targetChainId, maxChain, pdb, maxAlignseq);
             seqToStrucMapping.add(nwMapping);
@@ -1274,39 +1284,43 @@ public class StructureSelectionManager implements ApplicationSingletonI
   {
     if (mappings != null)
     {
-    mappings.clear();
+      mappings.clear();
     }
     if (seqmappings != null)
     {
-    seqmappings.clear();
+      seqmappings.clear();
     }
     if (sel_listeners != null)
     {
-    sel_listeners.clear();
+      sel_listeners.clear();
     }
     if (listeners != null)
     {
-    listeners.clear();
+      listeners.clear();
     }
     if (commandListeners != null)
     {
-    commandListeners.clear();
+      commandListeners.clear();
     }
     if (view_listeners != null)
     {
-    view_listeners.clear();
+      view_listeners.clear();
     }
     if (pdbFileNameId != null)
     {
-    pdbFileNameId.clear();
+      pdbFileNameId.clear();
     }
     if (pdbIdFileName != null)
     {
-    pdbIdFileName.clear();
+      pdbIdFileName.clear();
     }
   }
 
-  public void addSelectionListener(SelectionListener selecter)
+  public List<SelectionListener> getListeners() {
+    return sel_listeners;
+  }
+  
+   public void addSelectionListener(SelectionListener selecter)
   {
     if (!sel_listeners.contains(selecter))
     {