X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FSequenceAnnotationReport.java;h=f2f0657e60b85d32bb1aeac893304a68cea17337;hb=e51f922b88b1f316e27cf4c19eef437ff592d74d;hp=1f92428ab9aaa1a63889d611611c5d26b1ab68fe;hpb=81c8008cff0d9a265e0fbe979b17b173e9e4fc0a;p=jalview.git diff --git a/src/jalview/io/SequenceAnnotationReport.java b/src/jalview/io/SequenceAnnotationReport.java index 1f92428..f2f0657 100644 --- a/src/jalview/io/SequenceAnnotationReport.java +++ b/src/jalview/io/SequenceAnnotationReport.java @@ -23,6 +23,8 @@ package jalview.io; import jalview.api.FeatureColourI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; +import jalview.datamodel.GeneLociI; +import jalview.datamodel.MappedFeatures; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.util.MessageManager; @@ -62,17 +64,17 @@ public class SequenceAnnotationReport * Comparator to order DBRefEntry by Source + accession id (case-insensitive), * with 'Primary' sources placed before others, and 'chromosome' first of all */ - private static Comparator comparator = new Comparator() + private static Comparator comparator = new Comparator<>() { @Override public int compare(DBRefEntry ref1, DBRefEntry ref2) { - if (ref1.isChromosome()) + if (ref1 instanceof GeneLociI) { return -1; } - if (ref2.isChromosome()) + if (ref2 instanceof GeneLociI) { return 1; } @@ -125,19 +127,33 @@ public class SequenceAnnotationReport * Append text for the list of features to the tooltip * * @param sb - * @param rpos + * @param residuePos * @param features * @param minmax */ - public void appendFeatures(final StringBuilder sb, int rpos, + public void appendFeatures(final StringBuilder sb, int residuePos, List features, FeatureRendererModel fr) { - if (features != null) + for (SequenceFeature feature : features) { - for (SequenceFeature feature : features) - { - appendFeature(sb, rpos, fr, feature); - } + appendFeature(sb, residuePos, fr, feature, null); + } + } + + /** + * Appends text for mapped features (e.g. CDS feature for peptide or vice versa) + * + * @param sb + * @param residuePos + * @param mf + * @param fr + */ + public void appendFeatures(StringBuilder sb, int residuePos, + MappedFeatures mf, FeatureRendererModel fr) + { + for (SequenceFeature feature : mf.features) + { + appendFeature(sb, residuePos, fr, feature, mf); } } @@ -150,7 +166,8 @@ public class SequenceAnnotationReport * @param feature */ void appendFeature(final StringBuilder sb, int rpos, - FeatureRendererModel fr, SequenceFeature feature) + FeatureRendererModel fr, SequenceFeature feature, + MappedFeatures mf) { if (feature.isContactFeature()) { @@ -210,14 +227,24 @@ public class SequenceAnnotationReport FeatureColourI fc = fr.getFeatureColours().get(feature.getType()); if (fc != null && fc.isColourByAttribute()) { - String attName = fc.getAttributeName(); + String[] attName = fc.getAttributeName(); String attVal = feature.getValueAsString(attName); if (attVal != null) { - sb.append("; ").append(attName).append("=").append(attVal); + sb.append("; ").append(String.join(":", attName)).append("=") + .append(attVal); } } } + + if (mf != null) + { + String variants = mf.findProteinVariants(feature); + if (!variants.isEmpty()) + { + sb.append(" ").append(variants); + } + } } } @@ -301,7 +328,7 @@ public class SequenceAnnotationReport */ Collection> createLinksFrom(SequenceI seq, String link) { - Map> urlSets = new LinkedHashMap>(); + Map> urlSets = new LinkedHashMap<>(); UrlLink urlLink = new UrlLink(link); if (!urlLink.isValid()) { @@ -372,7 +399,7 @@ public class SequenceAnnotationReport .getNonPositionalFeatures()) { int sz = -sb.length(); - appendFeature(sb, 0, fr, sf); + appendFeature(sb, 0, fr, sf, null); sz += sb.length(); maxWidth = Math.max(maxWidth, sz); }