From 3b243b522acf62d04fb4fa103729598ebe3caa4b Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 11 Nov 2016 13:42:06 +0000 Subject: [PATCH] JAL-2295 JAL-2269 JAL-2319 mockable SIFTS file, fix to mapping details --- src/jalview/ws/sifts/SiftsClient.java | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/jalview/ws/sifts/SiftsClient.java b/src/jalview/ws/sifts/SiftsClient.java index 2afcfe4..5bd0b89 100644 --- a/src/jalview/ws/sifts/SiftsClient.java +++ b/src/jalview/ws/sifts/SiftsClient.java @@ -74,6 +74,12 @@ import MCview.PDBChain; public class SiftsClient implements SiftsClientI { + /* + * for use in mocking out file fetch for tests only + * - reset to null after testing! + */ + private static File mockSiftsFile; + private Entry siftsEntry; private StructureFile pdb; @@ -187,6 +193,14 @@ public class SiftsClient implements SiftsClientI */ public static File getSiftsFile(String pdbId) throws SiftsException { + /* + * return mocked file if it has been set + */ + if (mockSiftsFile != null) + { + return mockSiftsFile; + } + String siftsFileName = SiftsSettings.getSiftDownloadDirectory() + pdbId.toLowerCase() + ".xml.gz"; File siftsFile = new File(siftsFileName); @@ -511,13 +525,13 @@ public class SiftsClient implements SiftsClientI if (os != null) { MappingOutputPojo mop = new MappingOutputPojo(); - mop.setSeqStart(pdbStart); - mop.setSeqEnd(pdbEnd); + mop.setSeqStart(seqStart); + mop.setSeqEnd(seqEnd); mop.setSeqName(seq.getName()); mop.setSeqResidue(matchedSeq); - mop.setStrStart(seqStart); - mop.setStrEnd(seqEnd); + mop.setStrStart(pdbStart); + mop.setStrEnd(pdbEnd); mop.setStrName(structId); mop.setStrResidue(targetStrucSeqs.toString()); @@ -1091,4 +1105,9 @@ public class SiftsClient implements SiftsClientI return siftsEntry.getDbVersion(); } + public static void setMockSiftsFile(File file) + { + mockSiftsFile = file; + } + } -- 1.7.10.2