From 89f62b210bafac2a3341ce3fa9a360d5ea6c1c3c Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Wed, 28 Oct 2015 11:34:34 +0000 Subject: [PATCH] JAL-1887 JAL-1479 bugfix for incorrect start/end for aligned sequence mapping, and a bit of StructureSelectionManager refactoring for SIFTs --- .../structure/StructureSelectionManager.java | 38 +++++++++++++++++--- src/jalview/{io => ws/sifts}/SiftsClient.java | 0 test/jalview/{io => ws/sifts}/SiftsClientTest.java | 0 3 files changed, 34 insertions(+), 4 deletions(-) rename src/jalview/{io => ws/sifts}/SiftsClient.java (100%) rename test/jalview/{io => ws/sifts}/SiftsClientTest.java (100%) diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 0b3696c..38e7db3 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -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); diff --git a/src/jalview/io/SiftsClient.java b/src/jalview/ws/sifts/SiftsClient.java similarity index 100% rename from src/jalview/io/SiftsClient.java rename to src/jalview/ws/sifts/SiftsClient.java diff --git a/test/jalview/io/SiftsClientTest.java b/test/jalview/ws/sifts/SiftsClientTest.java similarity index 100% rename from test/jalview/io/SiftsClientTest.java rename to test/jalview/ws/sifts/SiftsClientTest.java -- 1.7.10.2