1 package jalview.datamodel;
3 import java.util.Collection;
4 import java.util.Collections;
5 import java.util.HashMap;
6 import java.util.HashSet;
9 import jalview.ws.datamodel.MappableContactMatrixI;
11 public class ContactMapHolder implements ContactMapHolderI
14 Map<Object, ContactMatrixI> contactmaps = new HashMap<>();
17 public Collection<ContactMatrixI> getContactMaps()
19 if (contactmaps != null && contactmaps.size() > 0)
21 // defensive copy, and return non redundant set of ContactMatrixI instances
22 return new HashSet<ContactMatrixI>(contactmaps.values());
24 return Collections.EMPTY_LIST;
28 public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
30 ContactMatrixI cm = contactmaps.get(_aa.annotationId);
35 if (cm instanceof MappableContactMatrixI)
37 if (_aa.sequenceRef != null)
39 return ((MappableContactMatrixI) cm)
40 .getMappableContactList(_aa.sequenceRef, column);
43 // TODO: could resolve sequence position to column position here
44 // TODO: what about for complexes - where contactMatrix may involve two or
46 return cm.getContactList(column);
50 public AlignmentAnnotation addContactList(ContactMatrixI cm)
53 AlignmentAnnotation aa = new AlignmentAnnotation(cm.getAnnotLabel(),
54 cm.getAnnotDescr(), new Annotation[0]);
55 aa.graph = AlignmentAnnotation.CONTACT_MAP;
56 aa.graphMin = cm.getMin();
57 aa.graphMax = cm.getMax();
59 aa.calcId = cm.getType();
61 contactmaps.put(aa.annotationId, cm);
62 // TODO: contact matrices could be intra or inter - more than one refseq
64 if (cm instanceof MappableContactMatrixI)
66 aa.setSequenceRef(((MappableContactMatrixI) cm).getReferenceSeq());
72 public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
74 return contactmaps == null ? null : contactmaps.get(ann.annotationId);
78 public void addContactListFor(AlignmentAnnotation annotation,
81 // update annotation with data from contact map
82 annotation.graphMin = cm.getMin();
83 annotation.graphMax = cm.getMax();
84 annotation.editable = false;
85 annotation.graph = AlignmentAnnotation.CONTACT_MAP;
86 annotation.calcId = cm.getType();
87 if (annotation.label == null || "".equals(annotation.label))
89 annotation.label = cm.getAnnotLabel();
92 if (annotation.description == null || "".equals(annotation.description))
94 annotation.description = cm.getAnnotDescr();
96 contactmaps.put(annotation.annotationId, cm);