Clover icon

Coverage Report

  1. Project Clover database Mon Sep 2 2024 17:57:51 BST
  2. Package jalview.datamodel

File ContactListImpl.java

 

Coverage histogram

../../img/srcFileCovDistChart9.png
13% of files have more coverage

Code metrics

16
35
8
1
133
94
17
0.49
4.38
8
2.12

Classes

Class Line # Actions
ContactListImpl 33 35 17
0.830508583.1%
 

Contributing tests

This file is covered by 21 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.datamodel;
22   
23    import java.awt.Color;
24   
25    import jalview.renderer.ContactGeometry.contactInterval;
26   
27    /**
28    * helper class to compute min/max/mean for a range on a contact list
29    *
30    * @author jprocter
31    *
32    */
 
33    public class ContactListImpl implements ContactListI
34    {
35    ContactListProviderI clist;
36   
 
37  0 toggle public static ContactListI newContactList(ContactListProviderI list)
38    {
39  0 return new ContactListImpl(list);
40    }
41   
 
42  7508 toggle public ContactListImpl(ContactListProviderI list)
43    {
44  7508 clist = list;
45    }
46   
 
47  0 toggle @Override
48    public int getPosition()
49    {
50  0 return clist.getPosition();
51    }
52   
 
53  4625595 toggle @Override
54    public double getContactAt(int column)
55    {
56  4625597 return clist.getContactAt(column);
57    }
58   
 
59  4286392 toggle @Override
60    public int getContactHeight()
61    {
62  4286392 return clist.getContactHeight();
63    }
64   
 
65  139000 toggle @Override
66    public ContactRange getRangeFor(int from_column, int to_column)
67    {
68    // TODO: consider caching ContactRange for a particular call ?
69  139000 if (clist instanceof ContactListI)
70    {
71    // clist may implement getRangeFor in a more efficient way, so use theirs
72  0 return ((ContactListI) clist).getRangeFor(from_column, to_column);
73    }
74  138999 if (from_column < 0)
75    {
76  0 from_column = 0;
77    }
78  138999 if (to_column >= getContactHeight())
79    {
80  0 to_column = getContactHeight() - 1;
81    }
82  138999 ContactRange cr = new ContactRange();
83  138995 cr.setFrom_column(from_column);
84  138991 cr.setTo_column(to_column);
85  138991 double tot = 0;
86  553768 for (int i = from_column; i <= to_column; i++)
87    {
88  414764 double contact = getContactAt(i);
89  414784 tot += contact;
90  414824 if (i == from_column)
91    {
92  138991 cr.setMin(contact);
93  138991 cr.setMax(contact);
94  138992 cr.setMinPos(i);
95  138991 cr.setMaxPos(i);
96    }
97    else
98    {
99  275844 if (cr.getMax() < contact)
100    {
101  63170 cr.setMax(contact);
102  63171 cr.setMaxPos(i);
103    }
104  275845 if (cr.getMin() < contact)
105    {
106  63171 cr.setMin(contact);
107  63171 cr.setMinPos(i);
108    }
109    }
110    }
111  138995 if (tot > 0 && to_column > from_column)
112    {
113  114620 cr.setMean(tot / (1 + to_column - from_column));
114    }
115    else
116    {
117  24375 cr.setMean(tot);
118    }
119  138994 return cr;
120    }
121   
 
122  138952 toggle @Override
123    public int[] getMappedPositionsFor(int cStart, int cEnd)
124    {
125  138952 return clist.getMappedPositionsFor(cStart, cEnd);
126    }
127   
 
128  3473 toggle @Override
129    public Color getColourForGroup()
130    {
131  3473 return clist.getColourForGroup();
132    }
133    }