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
23 return new HashSet<ContactMatrixI>(contactmaps.values());
25 return Collections.EMPTY_LIST;
29 public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
31 ContactMatrixI cm = contactmaps.get(_aa.annotationId);
36 if (cm instanceof MappableContactMatrixI)
38 if (_aa.sequenceRef != null)
40 return ((MappableContactMatrixI) cm)
41 .getMappableContactList(_aa.sequenceRef, column);
44 // TODO: could resolve sequence position to column position here
45 // TODO: what about for complexes - where contactMatrix may involve two or
47 return cm.getContactList(column);
51 public AlignmentAnnotation addContactList(ContactMatrixI cm)
54 AlignmentAnnotation aa = new AlignmentAnnotation(cm.getAnnotLabel(),
55 cm.getAnnotDescr(), new Annotation[0]);
56 aa.graph = AlignmentAnnotation.CONTACT_MAP;
57 aa.graphMin = cm.getMin();
58 aa.graphMax = cm.getMax();
60 aa.calcId = cm.getType();
62 contactmaps.put(aa.annotationId, cm);
63 // TODO: contact matrices could be intra or inter - more than one refseq
65 if (cm instanceof MappableContactMatrixI)
67 aa.setSequenceRef(((MappableContactMatrixI) cm).getReferenceSeq());
73 public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
75 return contactmaps == null ? null : contactmaps.get(ann.annotationId);
79 public void addContactListFor(AlignmentAnnotation annotation,
82 // update annotation with data from contact map
83 annotation.graphMin = cm.getMin();
84 annotation.graphMax = cm.getMax();
85 annotation.editable = false;
86 annotation.graph = AlignmentAnnotation.CONTACT_MAP;
87 annotation.calcId = cm.getType();
88 if (annotation.label == null || "".equals(annotation.label))
90 annotation.label = cm.getAnnotLabel();
93 if (annotation.description == null || "".equals(annotation.description))
95 annotation.description = cm.getAnnotDescr();
97 contactmaps.put(annotation.annotationId, cm);