1 package jalview.datamodel;
3 import jalview.ws.params.InvalidArgumentException;
5 import java.util.ArrayList;
8 public class ContactMatrix implements ContactMatrixI
11 * are contacts reflexive ?
13 boolean symmetric = true;
15 public ContactMatrix(boolean symmetric)
17 this.symmetric = symmetric;
20 List<List<Float>> contacts = null;
22 int width = 0, numcontacts = 0;
24 float min = 0f, max = 0f;
26 public void addContact(int left, int right, float strength)
28 if (left < 0 || right < 0)
30 throw new Error(new InvalidArgumentException(
31 "Cannot have negative indices for contact left=" + left
32 + " right=" + right + " strength=" + strength));
46 // TODO: use sparse list for efficiency ?
47 contacts = new ArrayList<List<Float>>();
49 List<Float> clist = contacts.get(left);
52 clist = new ArrayList<Float>();
53 contacts.set(left, clist);
55 Float last = clist.set(right, strength);
56 // TODO: if last is non null, may need to recompute range
57 checkBounds(strength);
64 private void checkBounds(float strength)
78 public ContactListI getContactList(final int column)
80 if (column < 0 || column >= width)
85 return new ContactListImpl(new ContactListProviderI()
90 public int getContactHeight()
97 public double getContactAt(int column)
105 clist = contacts.get(p);
106 cl = clist.get(column);
110 clist = contacts.get(column);
116 clist = contacts.get(p);
117 cl = clist.get(column);
121 // return 0 not NaN ?
124 return cl.doubleValue();
130 public float getMin()
136 public float getMax()
142 public boolean hasReferenceSeq()
144 // TODO Auto-generated method stub
149 public SequenceI getReferenceSeq()
151 // TODO Auto-generated method stub