JAL-1887 JAL-1479 bugfix for incorrect start/end for aligned sequence mapping, and...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 28 Oct 2015 11:34:34 +0000 (11:34 +0000)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 28 Oct 2015 11:34:34 +0000 (11:34 +0000)
src/jalview/structure/StructureSelectionManager.java
src/jalview/ws/sifts/SiftsClient.java [moved from src/jalview/io/SiftsClient.java with 100% similarity]
test/jalview/ws/sifts/SiftsClientTest.java [moved from test/jalview/io/SiftsClientTest.java with 100% similarity]

index 0b3696c..38e7db3 100644 (file)
@@ -33,9 +33,10 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SearchResults;
 import jalview.datamodel.SequenceI;
 import jalview.io.AppletFormatAdapter;
-import jalview.io.SiftsClient;
 import jalview.util.MappingUtils;
 import jalview.util.MessageManager;
+import jalview.ws.sifts.SiftsClient;
+import jalview.ws.sifts.SiftsException;
 
 import java.io.PrintStream;
 import java.util.ArrayList;
@@ -470,9 +471,17 @@ public class StructureSelectionManager
       if (isMapViaSIFTs)
       {
         SiftsClient siftsClient = new SiftsClient(pdb.id);
-        seqToStrucMapping = siftsClient.getSiftsStructureMapping(seq,
-                pdbFile, maxChainId);
-        // TODO if SIFTs mapping fails.. then fallback to NW alignment
+        try
+        {
+          seqToStrucMapping = siftsClient.getSiftsStructureMapping(seq,
+                  pdbFile, maxChainId);
+        } catch (SiftsException e)
+        {
+          System.err
+                  .println(">>>>>>> SIFTs mapping could not be obtained... Now mapping with NW alignment");
+          seqToStrucMapping = getNWMappings(seq, pdbFile, maxChainId,
+                  maxChain, pdb, maxAlignseq);
+        }
       }
       else
       {
@@ -494,6 +503,12 @@ public class StructureSelectionManager
           AlignSeq maxAlignseq)
   {
     final StringBuilder mappingDetails = new StringBuilder(128);
+    mappingDetails.append(NEWLINE).append("PDB Sequence is :")
+            .append(NEWLINE).append("Sequence = ")
+            .append(maxChain.sequence.getSequenceAsString());
+    mappingDetails.append(NEWLINE).append("No of residues = ")
+            .append(maxChain.residues.size()).append(NEWLINE)
+            .append(NEWLINE);
     PrintStream ps = new PrintStream(System.out)
     {
       @Override
@@ -510,6 +525,21 @@ public class StructureSelectionManager
     };
 
     maxAlignseq.printAlignment(ps);
+
+    mappingDetails.append(NEWLINE).append("PDB start/end ");
+    mappingDetails.append(String.valueOf(maxAlignseq.seq2start))
+            .append(" ");
+    mappingDetails.append(String.valueOf(maxAlignseq.seq2end));
+    mappingDetails.append(NEWLINE).append("SEQ start/end ");
+    mappingDetails.append(
+            String.valueOf(maxAlignseq.seq1start + (seq.getStart() - 1)))
+            .append(" ");
+    mappingDetails.append(String.valueOf(maxAlignseq.seq1end
+            + (seq.getStart() - 1)));
+    mappingDetails.append(NEWLINE);
+    mappingDetails
+            .append("Mapping inferred with Needleman & Wunsch alignment");
+    mappingDetails.append(NEWLINE);
     maxChain.makeExactMapping(maxAlignseq, seq);
     jalview.datamodel.Mapping sqmpping = maxAlignseq
             .getMappingFromS1(false);