Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 17:27:16 GMT
  2. Package jalview.ws.dbsources

File Xfam.java

 

Coverage histogram

../../../img/srcFileCovDistChart3.png
52% of files have more coverage

Code metrics

4
14
5
1
113
55
7
0.5
2.8
5
1.4

Classes

Class Line # Actions
Xfam 39 14 7
0.2608695626.1%
 

Contributing tests

This file is covered by 187 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.dbsources;
22   
23    import java.util.Locale;
24   
25    import jalview.bin.Console;
26    import jalview.datamodel.AlignmentI;
27    import jalview.datamodel.DBRefEntry;
28    import jalview.io.DataSourceType;
29    import jalview.io.FileFormat;
30    import jalview.io.FormatAdapter;
31    import jalview.ws.seqfetcher.DbSourceProxyImpl;
32   
33    /**
34    * Acts as a superclass for the Rfam and Pfam classes
35    *
36    * @author Lauren Michelle Lui
37    *
38    */
 
39    public abstract class Xfam extends DbSourceProxyImpl
40    {
 
41  56 toggle public Xfam()
42    {
43  56 super();
44    }
45   
46    /**
47    * the base URL for this Xfam-like service
48    *
49    * @return
50    */
51    protected abstract String getURLPrefix();
52   
53    @Override
54    public abstract String getDbVersion();
55   
56    abstract String getXfamSource();
57   
 
58  0 toggle @Override
59    public AlignmentI getSequenceRecords(String queries) throws Exception
60    {
61    // TODO: this is not a perfect implementation. We need to be able to add
62    // individual references to each sequence in each family alignment that's
63    // retrieved.
64  0 startQuery();
65    // TODO: trap HTTP 404 exceptions and return null
66  0 String xfamUrl = getURL(queries);
67   
68  0 Console.debug("XFAM URL for retrieval is: " + xfamUrl);
69   
70  0 AlignmentI rcds = new FormatAdapter().readFile(xfamUrl,
71    DataSourceType.URL, FileFormat.Stockholm);
72   
73  0 for (int s = 0, sNum = rcds.getHeight(); s < sNum; s++)
74    {
75  0 rcds.getSequenceAt(s).addDBRef(new DBRefEntry(getXfamSource(),
76    // getDbSource(),
77    getDbVersion(), queries.trim().toUpperCase(Locale.ROOT)));
78  0 if (!getDbSource().equals(getXfamSource()))
79    { // add the specific ref too
80  0 rcds.getSequenceAt(s).addDBRef(new DBRefEntry(getDbSource(),
81    getDbVersion(), queries.trim().toUpperCase(Locale.ROOT)));
82    }
83    }
84  0 stopQuery();
85  0 return rcds;
86    }
87   
 
88  4 toggle String getURL(String queries)
89    {
90  4 return getURLPrefix() + "/family/"
91    + queries.trim().toUpperCase(Locale.ROOT) + getURLSuffix();
92    }
93   
94    /**
95    * Pfam and Rfam provide alignments
96    */
 
97  10101 toggle @Override
98    public boolean isAlignmentSource()
99    {
100  10101 return true;
101    }
102   
103    /**
104    * default suffix to append the retrieval URL for this source.
105    *
106    * @return "" for most Xfam sources
107    */
 
108  0 toggle public String getURLSuffix()
109    {
110  0 return "";
111    }
112   
113    }