Merge branch 'spike/JAL-2040_JAL-2137_phyre2' into features/JAL-2040_JAL-2137_phyre2
[jalview.git] / src / jalview / structure / StructureSelectionManager.java
index 7b103be..c90b3c8 100644 (file)
@@ -327,7 +327,6 @@ public class StructureSelectionManager
     return setMapping(true, sequence, targetChains, pdbFile, protocol);
   }
 
-
   /**
    * create sequence structure mappings between each sequence and the given
    * pdbFile (retrieved via the given protocol).
@@ -348,8 +347,7 @@ public class StructureSelectionManager
    */
   synchronized public StructureFile setMapping(boolean forStructureView,
           SequenceI[] sequenceArray, String[] targetChainIds,
-          String pdbFile,
-          String protocol)
+          String pdbFile, String protocol)
   {
     /*
      * There will be better ways of doing this in the future, for now we'll use
@@ -392,6 +390,9 @@ public class StructureSelectionManager
       {
         registerPDBFile(pdb.getId().trim(), pdbFile);
       }
+      // if PDBId is unavailable then skip SIFTS mapping execution path
+      isMapUsingSIFTs = pdb.isPPDBIdAvailable();
+
     } catch (Exception ex)
     {
       ex.printStackTrace();
@@ -538,8 +539,7 @@ public class StructureSelectionManager
             try
             {
               StructureMapping siftsMapping = getStructureMapping(seq,
-                      pdbFile,
-                      chain.id, pdb, chain, sqmpping, maxAlignseq);
+                      pdbFile, chain.id, pdb, chain, sqmpping, maxAlignseq);
               foundSiftsMappings.add(siftsMapping);
             } catch (SiftsException e)
             {
@@ -614,24 +614,23 @@ public class StructureSelectionManager
           PDBChain maxChain, jalview.datamodel.Mapping sqmpping,
           AlignSeq maxAlignseq) throws SiftsException
   {
-      StructureMapping curChainMapping = siftsClient
-              .getSiftsStructureMapping(seq, pdbFile, targetChainId);
-      try
-      {
+    StructureMapping curChainMapping = siftsClient
+            .getSiftsStructureMapping(seq, pdbFile, targetChainId);
+    try
+    {
       PDBChain chain = pdb.findChain(targetChainId);
       if (chain != null)
       {
         chain.transferResidueAnnotation(curChainMapping, sqmpping);
       }
-      } catch (Exception e)
-      {
-        e.printStackTrace();
-      }
-      return curChainMapping;
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+    return curChainMapping;
   }
 
-  private StructureMapping getNWMappings(SequenceI seq,
-          String pdbFile,
+  private StructureMapping getNWMappings(SequenceI seq, String pdbFile,
           String maxChainId, PDBChain maxChain, StructureFile pdb,
           AlignSeq maxAlignseq)
   {
@@ -1356,4 +1355,9 @@ public class StructureSelectionManager
     return seqmappings;
   }
 
+  public static StructureSelectionManager getStructureSelectionManager()
+  {
+    return instances.values().iterator().next();
+  }
+
 }