1 package jalview.datamodel;
3 import java.util.Collection;
4 import java.util.Collections;
5 import java.util.HashMap;
8 import jalview.ws.datamodel.MappableContactMatrixI;
10 public class ContactMapHolder implements ContactMapHolderI
13 Map<Object, ContactMatrixI> contactmaps = new HashMap<>();
16 public Collection<ContactMatrixI> getContactMaps()
18 if (contactmaps != null && contactmaps.size() > 0)
20 return contactmaps.values();
22 return Collections.EMPTY_LIST;
26 public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
28 ContactMatrixI cm = contactmaps.get(_aa.annotationId);
33 if (cm instanceof MappableContactMatrixI)
35 if (_aa.sequenceRef != null)
37 return ((MappableContactMatrixI) cm)
38 .getMappableContactList(_aa.sequenceRef, column);
41 // TODO: could resolve sequence position to column position here
42 // TODO: what about for complexes - where contactMatrix may involve two or
44 return cm.getContactList(column);
48 public AlignmentAnnotation addContactList(ContactMatrixI cm)
51 AlignmentAnnotation aa = new AlignmentAnnotation(cm.getAnnotLabel(),
52 cm.getAnnotDescr(), new Annotation[0]);
53 aa.graph = AlignmentAnnotation.CONTACT_MAP;
54 aa.graphMin = cm.getMin();
55 aa.graphMax = cm.getMax();
57 aa.calcId = cm.getType();
59 contactmaps.put(aa.annotationId, cm);
60 // TODO: contact matrices could be intra or inter - more than one refseq
62 if (cm instanceof MappableContactMatrixI)
64 aa.setSequenceRef(((MappableContactMatrixI) cm).getReferenceSeq());
70 public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
72 return contactmaps == null ? null : contactmaps.get(ann.annotationId);
76 public void addContactListFor(AlignmentAnnotation annotation,
79 // update annotation with data from contact map
80 annotation.graphMin = cm.getMin();
81 annotation.graphMax = cm.getMax();
82 annotation.editable = false;
83 annotation.graph = AlignmentAnnotation.CONTACT_MAP;
84 annotation.calcId = cm.getType();
85 if (annotation.label == null || "".equals(annotation.label))
87 annotation.label = cm.getAnnotLabel();
90 if (annotation.description == null || "".equals(annotation.description))
92 annotation.description = cm.getAnnotDescr();
94 contactmaps.put(annotation.annotationId, cm);