2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.seqfetcher;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26 import jalview.analysis.CrossRef;
27 import jalview.datamodel.AlignmentI;
28 import jalview.datamodel.DBRefEntry;
29 import jalview.datamodel.DBRefSource;
30 import jalview.util.DBRefUtils;
31 import jalview.ws.SequenceFetcher;
33 import java.util.ArrayList;
34 import java.util.List;
36 import org.junit.AfterClass;
37 import org.junit.BeforeClass;
38 import org.junit.Test;
44 public class DbRefFetcherTest
48 * @throws java.lang.Exception
51 public static void setUpBeforeClass() throws Exception
56 * @throws java.lang.Exception
59 public static void tearDownAfterClass() throws Exception
64 public void testStandardProtDbs()
66 String[] defdb = DBRefSource.PROTEINDBS;
67 List<DbSourceProxy> srces = new ArrayList<DbSourceProxy>();
68 for (String ddb : defdb)
70 SequenceFetcher sfetcher = new SequenceFetcher();
71 List<DbSourceProxy> srcesfordb = sfetcher.getSourceProxy(ddb);
73 if (srcesfordb != null)
75 srces.addAll(srcesfordb);
78 DbSourceProxy uniprot = null;
80 // append the selected sequence sources to the default dbs
81 for (DbSourceProxy s : srces)
83 if (s.getDbSource().equalsIgnoreCase(DBRefSource.UNIPROT))
88 if (s instanceof jalview.ws.dbsources.Uniprot)
95 assertTrue("Failed to find Uniprot source as first source amongst "
96 + srces.size() + " sources (source was at position " + i + ")",
97 uniprot != null && i < 2);
101 public void testEmblUniprotProductRecovery() throws Exception
103 String retrievalId = "CAA23748"; // "V00488";
104 DbSourceProxy embl = new SequenceFetcher().getSourceProxy(DBRefSource.EMBL).get(0);
105 assertNotNull("Couldn't find the EMBL retrieval client",embl);
106 AlignmentI alsq = embl.getSequenceRecords(retrievalId);
107 assertNotNull("Couldn't find the EMBL record " + retrievalId, alsq);
108 assertEquals("Didn't retrieve right number of records", 1, alsq.getHeight());
109 DBRefEntry[] dr = DBRefUtils.selectRefs(alsq.getSequenceAt(0).getDBRef(), DBRefSource.PROTEINSEQ);
111 assertEquals("Expected a single Uniprot cross reference", 1, dr.length);
112 AlignmentI sprods = CrossRef.findXrefSequences(alsq.getSequencesArray(), true, dr[0].getSource(), alsq.getDataset());
114 "Couldn't recover cross reference sequence from dataset. Was it ever added ?",