Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 14:43:25 GMT
  2. Package jalview.ws

File SequenceFetcher.java

 

Coverage histogram

../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

8
22
4
1
133
65
8
0.36
5.5
4
2

Classes

Class Line # Actions
SequenceFetcher 46 22 8
0.970588297.1%
 

Contributing tests

This file is covered by 199 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.ws;
22   
23    import jalview.bin.ApplicationSingletonProvider;
24    import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
25    import jalview.ext.ensembl.EnsemblGene;
26    import jalview.ws.dbsources.EBIAlfaFold;
27    import jalview.ws.dbsources.EmblCdsSource;
28    import jalview.ws.dbsources.EmblSource;
29    import jalview.ws.dbsources.Pdb;
30    import jalview.ws.dbsources.PfamFull;
31    import jalview.ws.dbsources.PfamSeed;
32    import jalview.ws.dbsources.RfamSeed;
33    import jalview.ws.dbsources.TDBeacons;
34    import jalview.ws.dbsources.Uniprot;
35    import jalview.ws.seqfetcher.ASequenceFetcher;
36    import jalview.ws.seqfetcher.DbSourceProxy;
37   
38    import java.util.ArrayList;
39    import java.util.Collections;
40    import java.util.List;
41   
42    /**
43    * This implements the run-time discovery of sequence database clients.
44    *
45    */
 
46    public class SequenceFetcher extends ASequenceFetcher implements ApplicationSingletonI
47    {
48    /*
49    * set a mock fetcher here for testing only - reset to null afterwards
50    */
51    private static SequenceFetcher mockFetcher;
52   
53    /**
54    * Set the instance object to use (intended for unit testing with mock
55    * objects).
56    *
57    * Be sure to reset to null in the tearDown method of any tests!
58    *
59    * @param sf
60    */
 
61  1 toggle public static void setMockFetcher(SequenceFetcher sf)
62    {
63  1 mockFetcher = sf;
64    }
65   
66    /**
67    * Returns a new SequenceFetcher singleton, or a mock object if one has been
68    * set.
69    *
70    * @return
71    */
 
72  8229 toggle public static SequenceFetcher getInstance()
73    {
74  8229 return mockFetcher != null ? mockFetcher
75    : ApplicationSingletonProvider.getInstance(SequenceFetcher.class);
76    }
77   
78    /**
79    * Thread safe construction of database proxies TODO: extend to a configurable
80    * database plugin mechanism where classes are instantiated by reflection and
81    * queried for their DbRefSource and version association.
82    *
83    */
 
84  17 toggle public SequenceFetcher()
85    {
86  17 addDBRefSourceImpl(EnsemblGene.class);
87    // addDBRefSourceImpl(EnsemblGenomes.class);
88  17 addDBRefSourceImpl(EmblSource.class);
89  17 addDBRefSourceImpl(EmblCdsSource.class);
90  17 addDBRefSourceImpl(Uniprot.class);
91    // not a sequence source yet
92    // addDBRefSourceImpl(TDBeacons.class);
93  17 addDBRefSourceImpl(Pdb.class);
94  17 addDBRefSourceImpl(PfamFull.class);
95  17 addDBRefSourceImpl(PfamSeed.class);
96  17 addDBRefSourceImpl(RfamSeed.class);
97    // Technically not a database cross reference we fetch directly
98    // Useful for AlphaFold debugging
99    // addDBRefSourceImpl(EBIAlfaFold.class);
100    }
101   
102    /**
103    * return an ordered list of database sources excluding alignment only
104    * databases
105    */
 
106  8230 toggle public String[] getNonAlignmentSources()
107    {
108  8230 String[] srcs = this.getSupportedDb();
109  8230 List<String> src = new ArrayList<>();
110   
111  74070 for (int i = 0; i < srcs.length; i++)
112    {
113  65840 boolean accept = true;
114  65840 for (DbSourceProxy dbs : getSourceProxy(srcs[i]))
115    {
116    // Skip the alignment databases for the moment - they're not useful for
117    // verifying a single sequence against its reference source
118  65840 if (dbs.isAlignmentSource())
119    {
120  24690 accept = false;
121  24690 break;
122    }
123    }
124  65840 if (accept)
125    {
126  41150 src.add(srcs[i]);
127    }
128    }
129   
130  8230 Collections.sort(src, String.CASE_INSENSITIVE_ORDER);
131  8230 return src.toArray(new String[src.size()]);
132    }
133    }