JAL-2375 JAL-2376 First commit of implementation for Phyre2 result browsing, template...
[jalview.git] / src / jalview / structure / StructureSelectionManager.java
index 65fd5e7..066a6d1 100644 (file)
@@ -39,6 +39,7 @@ import jalview.io.DataSourceType;
 import jalview.io.StructureFile;
 import jalview.util.MappingUtils;
 import jalview.util.MessageManager;
+import jalview.ws.phyre2.Phyre2Client;
 import jalview.ws.sifts.SiftsClient;
 import jalview.ws.sifts.SiftsException;
 import jalview.ws.sifts.SiftsSettings;
@@ -78,6 +79,8 @@ public class StructureSelectionManager
 
   private long progressSessionId;
 
+  private boolean mappingForPhyre2Model;
+
   /*
    * Set of any registered mappings between (dataset) sequences.
    */
@@ -497,7 +500,7 @@ public class StructureSelectionManager
       }
 
       List<StructureMapping> seqToStrucMapping = new ArrayList<StructureMapping>();
-      if (isMapUsingSIFTs && seq.isProtein())
+      if (!isMappingForPhyre2Model() && isMapUsingSIFTs && seq.isProtein())
       {
         setProgressBar(null);
         setProgressBar(MessageManager
@@ -530,6 +533,9 @@ public class StructureSelectionManager
                                                         // "IEA:Jalview" ?
             maxChain.transferResidueAnnotation(nwMapping, sqmpping);
             ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0));
+          } catch (Exception e)
+          {
+            e.printStackTrace();
           }
         }
         else
@@ -545,6 +551,9 @@ public class StructureSelectionManager
             } catch (SiftsException e)
             {
               System.err.println(e.getMessage());
+            } catch (Exception e)
+            {
+              e.printStackTrace();
             }
           }
           if (!foundSiftsMappings.isEmpty())
@@ -569,6 +578,17 @@ public class StructureSelectionManager
           }
         }
       }
+      else if (isMappingForPhyre2Model())
+      {
+        setProgressBar(null);
+        setProgressBar(MessageManager
+                .getString("status.obtaining_mapping_with_phyre2_template_alignment"));
+        StructureMapping phyre2ModelMapping = new Phyre2Client(pdb)
+                .getStructureMapping(seq, pdbFile, " ");
+
+        seqToStrucMapping.add(phyre2ModelMapping);
+        ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0));
+      }
       else
       {
         setProgressBar(null);
@@ -613,10 +633,10 @@ public class StructureSelectionManager
   private StructureMapping getStructureMapping(SequenceI seq,
           String pdbFile, String targetChainId, StructureFile pdb,
           PDBChain maxChain, jalview.datamodel.Mapping sqmpping,
-          AlignSeq maxAlignseq) throws SiftsException
+          AlignSeq maxAlignseq) throws Exception
   {
     StructureMapping curChainMapping = siftsClient
-            .getSiftsStructureMapping(seq, pdbFile, targetChainId);
+            .getStructureMapping(seq, pdbFile, targetChainId);
     try
     {
       PDBChain chain = pdb.findChain(targetChainId);
@@ -1356,4 +1376,15 @@ public class StructureSelectionManager
     return seqmappings;
   }
 
+  public boolean isMappingForPhyre2Model()
+  {
+    return mappingForPhyre2Model;
+  }
+
+  public void setMappingForPhyre2Model(boolean mappingForPhyre2Model)
+  {
+    this.mappingForPhyre2Model = mappingForPhyre2Model;
+  }
+
+
 }