Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 15:05:32 GMT
  2. Package jalview.ext.ensembl

File EnsemblGenome.java

 

Coverage histogram

../../../img/srcFileCovDistChart7.png
29% of files have more coverage

Code metrics

4
15
7
1
129
62
9
0.6
2.14
7
1.29

Classes

Class Line # Actions
EnsemblGenome 38 15 9
0.692307769.2%
 

Contributing tests

This file is covered by 3 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.ext.ensembl;
22   
23    import jalview.datamodel.SequenceFeature;
24    import jalview.datamodel.SequenceI;
25    import jalview.io.gff.SequenceOntologyI;
26   
27    import java.util.ArrayList;
28    import java.util.List;
29   
30    /**
31    * A client to fetch genomic sequence from Ensembl
32    *
33    * TODO: not currently used - delete?
34    *
35    * @author gmcarstairs
36    *
37    */
 
38    public class EnsemblGenome extends EnsemblSeqProxy
39    {
40    /*
41    * fetch transcript features on genomic sequence (to identify the transcript
42    * regions) and cds, exon and variation features (to retain)
43    */
44    private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
45    EnsemblFeatureType.transcript, EnsemblFeatureType.exon,
46    EnsemblFeatureType.cds, EnsemblFeatureType.variation };
47   
48    /**
49    * Default constructor (to use rest.ensembl.org)
50    */
 
51  3 toggle public EnsemblGenome()
52    {
53  3 super();
54    }
55   
56    /**
57    * Constructor given the target domain to fetch data from
58    *
59    * @param d
60    */
 
61  0 toggle public EnsemblGenome(String d)
62    {
63  0 super(d);
64    }
65   
 
66  0 toggle @Override
67    public String getDbName()
68    {
69  0 return "ENSEMBL (Genomic)";
70    }
71   
 
72  0 toggle @Override
73    protected EnsemblSeqType getSourceEnsemblType()
74    {
75  0 return EnsemblSeqType.GENOMIC;
76    }
77   
 
78  0 toggle @Override
79    protected EnsemblFeatureType[] getFeaturesToFetch()
80    {
81  0 return FEATURES_TO_FETCH;
82    }
83   
84    /**
85    * Answers true unless the feature type is 'transcript' (or a sub-type of
86    * transcript in the Sequence Ontology), or has a parent other than the given
87    * accession id. Transcript features are only retrieved in order to identify
88    * the transcript sequence range, and are redundant information on the
89    * transcript sequence itself.
90    */
 
91  6 toggle @Override
92    protected boolean retainFeature(SequenceFeature sf, String accessionId)
93    {
94  6 if (isTranscript(sf.getType()))
95    {
96  3 return false;
97    }
98  3 return featureMayBelong(sf, accessionId);
99    }
100   
101    /**
102    * Answers a list of sequence features (if any) whose type is 'transcript' (or
103    * a subtype of transcript in the Sequence Ontology), and whose ID is the
104    * accession we are retrieving.
105    * <p>
106    * Note we also include features of type "NMD_transcript_variant", although
107    * not strictly 'transcript' in the SO, as they used in Ensembl as if they
108    * were.
109    */
 
110  2 toggle @Override
111    protected List<SequenceFeature> getIdentifyingFeatures(SequenceI seq,
112    String accId)
113    {
114  2 List<SequenceFeature> result = new ArrayList<>();
115  2 List<SequenceFeature> sfs = seq.getFeatures().getFeaturesByOntology(
116    SequenceOntologyI.TRANSCRIPT,
117    SequenceOntologyI.NMD_TRANSCRIPT_VARIANT);
118  2 for (SequenceFeature sf : sfs)
119    {
120  9 String id = (String) sf.getValue(JSON_ID);
121  9 if (accId.equals(id))
122    {
123  6 result.add(sf);
124    }
125    }
126  2 return result;
127    }
128   
129    }