1 package jalview.datamodel;
3 import java.util.Collection;
4 import java.util.Collections;
5 import java.util.HashMap;
8 public class ContactMapHolder implements ContactMapHolderI
11 Map<Object, ContactMatrixI> contactmaps = new HashMap<>();
14 public Collection<ContactMatrixI> getContactMaps()
16 if (contactmaps != null && contactmaps.size() > 0)
18 return contactmaps.values();
20 return Collections.EMPTY_LIST;
24 public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
26 ContactMatrixI cm = contactmaps.get(_aa.annotationId);
31 // TODO: could resolve sequence position to column position here
32 // TODO: what about for complexes - where contactMatrix may involve two or
34 return cm.getContactList(column);
38 public AlignmentAnnotation addContactList(ContactMatrixI cm)
41 AlignmentAnnotation aa = new AlignmentAnnotation(cm.getAnnotLabel(),
42 cm.getAnnotDescr(), new Annotation[0]);
43 aa.graph = AlignmentAnnotation.CONTACT_MAP;
44 aa.graphMin = cm.getMin();
45 aa.graphMax = cm.getMax();
47 aa.calcId = cm.getType();
49 contactmaps.put(aa.annotationId, cm);
50 // TODO: contact matrices could be intra or inter - more than one refseq
52 if (cm.hasReferenceSeq())
54 aa.setSequenceRef(cm.getReferenceSeq());
60 public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
62 return contactmaps == null ? null : contactmaps.get(ann.annotationId);
66 public void addContactListFor(AlignmentAnnotation annotation,
69 // update annotation with data from contact map
70 annotation.graphMin = cm.getMin();
71 annotation.graphMax = cm.getMax();
72 annotation.editable = false;
73 annotation.graph = AlignmentAnnotation.CONTACT_MAP;
74 annotation.calcId = cm.getType();
75 if (annotation.label == null || "".equals(annotation.label))
77 annotation.label = cm.getAnnotLabel();
80 if (annotation.description == null || "".equals(annotation.description))
82 annotation.description = cm.getAnnotDescr();
84 contactmaps.put(annotation.annotationId, cm);