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).getMappableContactList(_aa.sequenceRef, column);
40 // TODO: could resolve sequence position to column position here
41 // TODO: what about for complexes - where contactMatrix may involve two or
43 return cm.getContactList(column);
47 public AlignmentAnnotation addContactList(ContactMatrixI cm)
50 AlignmentAnnotation aa = new AlignmentAnnotation(cm.getAnnotLabel(),
51 cm.getAnnotDescr(), new Annotation[0]);
52 aa.graph = AlignmentAnnotation.CONTACT_MAP;
53 aa.graphMin = cm.getMin();
54 aa.graphMax = cm.getMax();
56 aa.calcId = cm.getType();
58 contactmaps.put(aa.annotationId, cm);
59 // TODO: contact matrices could be intra or inter - more than one refseq
61 if (cm instanceof MappableContactMatrixI)
63 aa.setSequenceRef(((MappableContactMatrixI) cm).getReferenceSeq());
69 public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
71 return contactmaps == null ? null : contactmaps.get(ann.annotationId);
75 public void addContactListFor(AlignmentAnnotation annotation,
78 // update annotation with data from contact map
79 annotation.graphMin = cm.getMin();
80 annotation.graphMax = cm.getMax();
81 annotation.editable = false;
82 annotation.graph = AlignmentAnnotation.CONTACT_MAP;
83 annotation.calcId = cm.getType();
84 if (annotation.label == null || "".equals(annotation.label))
86 annotation.label = cm.getAnnotLabel();
89 if (annotation.description == null || "".equals(annotation.description))
91 annotation.description = cm.getAnnotDescr();
93 contactmaps.put(annotation.annotationId, cm);