Merge branch 'spike/JAL-2040_JAL-2137_phyre2' into features/JAL-2040_JAL-2137_phyre2
[jalview.git] / src / jalview / structure / StructureSelectionManager.java
index 7db85ff..c90b3c8 100644 (file)
@@ -32,6 +32,7 @@ import jalview.datamodel.Annotation;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SearchResults;
 import jalview.datamodel.SequenceI;
+import jalview.ext.jmol.JmolParser;
 import jalview.gui.IProgressIndicator;
 import jalview.io.AppletFormatAdapter;
 import jalview.io.StructureFile;
@@ -326,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).
@@ -347,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
@@ -384,14 +383,16 @@ public class StructureSelectionManager
     boolean isMapUsingSIFTs = SiftsSettings.isMapWithSifts();
     try
     {
-        pdb = new jalview.ext.jmol.JmolParser(addTempFacAnnot, parseSecStr,
-                secStructServices, pdbFile, protocol);
+      pdb = new JmolParser(pdbFile, protocol);
 
       if (pdb.getId() != null && pdb.getId().trim().length() > 0
               && AppletFormatAdapter.FILE.equals(protocol))
       {
         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();
+  }
+
 }