Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.io.gff

File InterProScanHelper.java

 

Coverage histogram

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

Code metrics

8
18
4
1
138
61
11
0.61
4.5
4
2.75

Classes

Class Line # Actions
InterProScanHelper 35 18 11 9
0.770%
 

Contributing tests

This file is covered by 9 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.io.gff;
22   
23    import jalview.datamodel.AlignmentI;
24    import jalview.datamodel.SequenceFeature;
25    import jalview.datamodel.SequenceI;
26    import jalview.util.StringUtils;
27   
28    import java.io.IOException;
29    import java.util.List;
30    import java.util.Map;
31   
32    /**
33    * A handler to parse GFF in the format generated by InterProScan
34    */
 
35    public class InterProScanHelper extends Gff3Helper
36    {
37    private static final String INTER_PRO_SCAN = "InterProScan";
38   
39    private static final String SIGNATURE_DESC = "signature_desc";
40   
41    /**
42    * Process one GFF feature line (as modelled by SequenceFeature)
43    *
44    * @param seq
45    * the sequence with which this feature is associated
46    * @param gff
47    * the gff column data
48    * @param align
49    * the alignment we are adding GFF to
50    * @param newseqs
51    * any new sequences referenced by the GFF
52    * @param relaxedIdMatching
53    * if true, match word tokens in sequence names
54    * @return a sequence feature if one should be added to the sequence, else
55    * null (i.e. it has been processed in another way e.g. to generate a
56    * mapping)
57    * @throws IOException
58    */
 
59  0 toggle @Override
60    public SequenceFeature processGff(SequenceI seq, String[] gff,
61    AlignmentI align, List<SequenceI> newseqs,
62    boolean relaxedIdMatching) throws IOException
63    {
64    /*
65    * ignore the 'polypeptide' match of the whole sequence
66    */
67  0 if (".".equals(gff[SOURCE_COL]))
68    {
69  0 return null;
70    }
71   
72  0 return super.processGff(seq, gff, align, newseqs, relaxedIdMatching);
73    }
74   
75    /**
76    * An override that
77    * <ul>
78    * <li>uses Source (column 2) as feature type instead of the default column 3</li>
79    * <li>sets "InterProScan" as the feature group</li>
80    * <li>extracts "signature_desc" attribute as the feature description</li>
81    * </ul>
82    */
 
83  1 toggle @Override
84    protected SequenceFeature buildSequenceFeature(String[] gff,
85    Map<String, List<String>> attributes)
86    {
87  1 SequenceFeature sf = super.buildSequenceFeature(gff, SOURCE_COL,
88    INTER_PRO_SCAN, attributes);
89   
90    /*
91    * signature_desc is a more informative source of description
92    */
93  1 List<String> desc = attributes.get(SIGNATURE_DESC);
94  1 String description = StringUtils.listToDelimitedString(desc, ", ");
95  1 if (description.length() > 0)
96    {
97  1 sf.setDescription(description);
98    }
99   
100  1 return sf;
101    }
102   
103    /**
104    * Tests whether the GFF data looks like it was generated by InterProScan
105    *
106    * @param columns
107    * @return
108    */
 
109  24 toggle public static boolean recognises(String[] columns)
110    {
111  24 SequenceOntologyI so = SequenceOntologyFactory.getInstance();
112  24 String type = columns[TYPE_COL];
113  24 if (so.isA(type, SequenceOntologyI.PROTEIN_MATCH)
114    || (".".equals(columns[SOURCE_COL])
115    && so.isA(type, SequenceOntologyI.POLYPEPTIDE)))
116    {
117  1 return true;
118    }
119  23 return false;
120    }
121   
122    /**
123    * Overriden method, because InterProScan GFF has the target sequence id in
124    * GFF field 'ID' rather than the usual 'Target' :-O
125    */
 
126  1 toggle @Override
127    protected String findTargetId(String target,
128    Map<String, List<String>> set)
129    {
130  1 List<String> ids = set.get(ID);
131  1 if (ids == null || ids.size() != 1)
132    {
133  0 return null;
134    }
135  1 return ids.get(0);
136    }
137   
138    }