From f2e52ac07216e1fa3a5d1975e6afd6bc03d6a946 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 23 Jun 2016 14:09:44 +0100 Subject: [PATCH] JAL-2110 JAL-1551 formatting --- test/jalview/analysis/CrossRefTest.java | 47 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/test/jalview/analysis/CrossRefTest.java b/test/jalview/analysis/CrossRefTest.java index c2d7ca6..0c3e4d5 100644 --- a/test/jalview/analysis/CrossRefTest.java +++ b/test/jalview/analysis/CrossRefTest.java @@ -396,7 +396,7 @@ public class CrossRefTest dna1.addDBRef(new DBRefEntry("UNIPROT", "0", "P00314")); final SequenceI pep1 = new Sequence("Q9ZTS2", "MYQLIRSSW"); final SequenceI pep2 = new Sequence("P00314", "MRKLLAASG"); - + /* * argument false suppresses adding DAS sources * todo: define an interface type SequenceFetcherI and mock that @@ -473,7 +473,7 @@ public class CrossRefTest */ final SequenceI pep1 = new Sequence("UNIPROT|P15056", "MAAL"); final SequenceI pep2 = new Sequence("UNIPROT|H7C5K3", "QALF"); - + /* * argument false suppresses adding DAS sources * todo: define an interface type SequenceFetcherI and mock that @@ -485,7 +485,7 @@ public class CrossRefTest { return true; } - + @Override public SequenceI[] getSequences(List refs, boolean dna) { @@ -493,7 +493,7 @@ public class CrossRefTest } }; SequenceFetcherFactory.setSequenceFetcher(mockFetcher); - + /* * find UNIPROT xrefs for gene and transcripts * verify that @@ -503,8 +503,7 @@ public class CrossRefTest */ SequenceI[] seqs = new SequenceI[] { gene, braf001, braf002 }; AlignmentI al = new Alignment(seqs); - Alignment xrefs = new CrossRef(seqs, al) -.findXrefSequences("UNIPROT", + Alignment xrefs = new CrossRef(seqs, al).findXrefSequences("UNIPROT", true); assertEquals(2, xrefs.getHeight()); assertSame(pep1, xrefs.getSequenceAt(0)); @@ -550,14 +549,14 @@ public class CrossRefTest p0ce20.addDBRef(new DBRefEntry("EMBL", "0", "J03321")); p0ce20.addDBRef(new DBRefEntry("EMBL", "0", "X06707")); p0ce20.addDBRef(new DBRefEntry("EMBL", "0", "X07547")); - + /* * EMBL sequences to be 'fetched', complete with dbrefs and mappings * to their protein products (CDS location and translations are provided * in EMBL XML); these should be matched to, and replaced with, * the corresponding uniprot sequences after fetching */ - + /* * J03321 with mappings to P0CE19 and P0CE20 */ @@ -565,7 +564,8 @@ public class CrossRefTest DBRefEntry dbref1 = new DBRefEntry("UNIPROT", "0", "P0CE19"); MapList mapList = new MapList(new int[] { 1, 12 }, new int[] { 1, 4 }, 3, 1); - Mapping map = new Mapping(new Sequence("UNIPROT|P0CE19", "KPFG"), mapList); + Mapping map = new Mapping(new Sequence("UNIPROT|P0CE19", "KPFG"), + mapList); // add a dbref to the mapped to sequence - should get copied to p0ce19 map.getTo().addDBRef(new DBRefEntry("PIR", "0", "S01875")); dbref1.setMap(map); @@ -575,7 +575,7 @@ public class CrossRefTest dbref2.setMap(new Mapping(new Sequence("UNIPROT|P0CE20", "PFGK"), new MapList(mapList))); j03321.addDBRef(dbref2); - + /* * X06707 with mappings to P0CE19 and P0CE20 */ @@ -590,7 +590,7 @@ public class CrossRefTest 1); dbref4.setMap(new Mapping(new Sequence("UNIPROT|P0CE20", "PFGK"), map3)); x06707.addDBRef(dbref4); - + /* * M19487 with mapping to P0CE19 and Q46432 */ @@ -616,7 +616,7 @@ public class CrossRefTest dbref8.setMap(new Mapping(new Sequence("UNIPROT|B0BCM4", "KPFG"), new MapList(map2))); x07547.addDBRef(dbref8); - + /* * mock sequence fetcher to 'return' the EMBL sequences * TODO: Mockito would allow .thenReturn().thenReturn() here, @@ -626,27 +626,34 @@ public class CrossRefTest */ SequenceFetcher mockFetcher = new SequenceFetcher(false) { - int call = 0; + int call = 0; + @Override public boolean isFetchable(String source) { return true; } + @Override public SequenceI[] getSequences(List refs, boolean dna) { call++; - if (call == 1) { - assertEquals("Expected 3 embl seqs in first fetch", 3, refs.size()); - return new SequenceI[] { j03321, x06707, m19487 }; - } else { - assertEquals("Expected 1 embl seq in second fetch", 1, refs.size()); - return new SequenceI[] { x07547 }; + if (call == 1) + { + assertEquals("Expected 3 embl seqs in first fetch", 3, + refs.size()); + return new SequenceI[] { j03321, x06707, m19487 }; + } + else + { + assertEquals("Expected 1 embl seq in second fetch", 1, + refs.size()); + return new SequenceI[] { x07547 }; } } }; SequenceFetcherFactory.setSequenceFetcher(mockFetcher); - + /* * find EMBL xrefs for Uniprot seqs and verify that * - the EMBL xref'd sequences are retrieved without duplicates -- 1.7.10.2