Clover icon

Coverage Report

  1. Project Clover database Fri Nov 15 2024 13:56:46 GMT
  2. Package jalview.ws.seqfetcher

File DbSourceProxyImpl.java

 

Coverage histogram

../../../img/srcFileCovDistChart4.png
48% of files have more coverage

Code metrics

6
19
12
1
161
81
15
0.79
1.58
12
1.25

Classes

Class Line # Actions
DbSourceProxyImpl 36 19 15
0.3513513535.1%
 

Contributing tests

This file is covered by 230 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.seqfetcher;
22   
23    import jalview.api.FeatureSettingsModelI;
24    import jalview.datamodel.AlignmentI;
25    import jalview.io.DataSourceType;
26    import jalview.io.FileFormatI;
27    import jalview.io.FormatAdapter;
28    import jalview.io.IdentifyFile;
29   
30    /**
31    * common methods for implementations of the DbSourceProxy interface.
32    *
33    * @author JimP
34    *
35    */
 
36    public abstract class DbSourceProxyImpl implements DbSourceProxy
37    {
38   
39    boolean queryInProgress = false;
40   
41    protected StringBuffer results = null;
42   
 
43  220 toggle public DbSourceProxyImpl()
44    {
45    }
46   
47    /*
48    * (non-Javadoc)
49    *
50    * @see jalview.ws.DbSourceProxy#getRawRecords()
51    */
 
52  0 toggle @Override
53    public StringBuffer getRawRecords()
54    {
55  0 return results;
56    }
57   
58    /*
59    * (non-Javadoc)
60    *
61    * @see jalview.ws.DbSourceProxy#queryInProgress()
62    */
 
63  0 toggle @Override
64    public boolean queryInProgress()
65    {
66  0 return queryInProgress;
67    }
68   
69    /**
70    * call to set the queryInProgress flag
71    *
72    */
 
73  0 toggle protected void startQuery()
74    {
75  0 queryInProgress = true;
76    }
77   
78    /**
79    * call to clear the queryInProgress flag
80    *
81    */
 
82  0 toggle protected void stopQuery()
83    {
84  0 queryInProgress = false;
85    }
86   
87    /**
88    * create an alignment from raw text file...
89    *
90    * @param result
91    * @return null or a valid alignment
92    * @throws Exception
93    */
 
94  0 toggle protected AlignmentI parseResult(String result) throws Exception
95    {
96  0 AlignmentI sequences = null;
97  0 FileFormatI format = new IdentifyFile().identify(result,
98    DataSourceType.PASTE);
99  0 if (format != null)
100    {
101  0 sequences = new FormatAdapter().readFile(result.toString(),
102    DataSourceType.PASTE, format);
103    }
104  0 return sequences;
105    }
106   
107    /**
108    * Returns the first accession id in the query (up to the first accession id
109    * separator), or the whole query if there is no separator or it is not found
110    */
 
111  6 toggle @Override
112    public String getAccessionIdFromQuery(String query)
113    {
114  6 String sep = getAccessionSeparator();
115  6 if (sep == null)
116    {
117  0 return query;
118    }
119  6 int sepPos = query.indexOf(sep);
120  6 return sepPos == -1 ? query : query.substring(0, sepPos);
121    }
122   
123    /**
124    * Default is only one accession id per query - override if more are allowed.
125    */
 
126  0 toggle @Override
127    public int getMaximumQueryCount()
128    {
129  0 return 1;
130    }
131   
132    /**
133    * Returns false - override to return true for DNA coding data sources
134    */
 
135  0 toggle @Override
136    public boolean isDnaCoding()
137    {
138  0 return false;
139    }
140   
141    /**
142    * Answers false - override as required in subclasses
143    */
 
144  13575 toggle @Override
145    public boolean isAlignmentSource()
146    {
147  13575 return false;
148    }
149   
 
150  0 toggle @Override
151    public String getDescription()
152    {
153  0 return "";
154    }
155   
 
156  2 toggle @Override
157    public FeatureSettingsModelI getFeatureColourScheme()
158    {
159  2 return null;
160    }
161    }