X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FSequenceAnnotationReport.java;h=95bd1cc2ca4008a1cfe4248467e7628ff5ab5429;hb=5d003f492184b893aa4c2f437c6021626b573c45;hp=62b723dba3425af6fd5f6500c79e97b9b79b0793;hpb=9d2408483e451285fd555c3cd6e0273977acbaa7;p=jalview.git diff --git a/src/jalview/io/SequenceAnnotationReport.java b/src/jalview/io/SequenceAnnotationReport.java index 62b723d..95bd1cc 100644 --- a/src/jalview/io/SequenceAnnotationReport.java +++ b/src/jalview/io/SequenceAnnotationReport.java @@ -20,12 +20,12 @@ */ package jalview.io; -import java.util.Locale; - +import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import jalview.api.FeatureColourI; @@ -59,7 +59,7 @@ public class SequenceAnnotationReport private static String linkImageURL; - // public static final String[][] PRIMARY_SOURCES moved to DBRefSource.java + // public static final String[][] PRIMARY_SOURCES moved to DBRefSource.java /* * Comparator to order DBRefEntry by Source + accession id (case-insensitive), @@ -91,32 +91,32 @@ public class SequenceAnnotationReport { return 1; } - int comp = s1 == null ? -1 : (s2 == null ? 1 : s1 - .compareToIgnoreCase(s2)); + int comp = s1 == null ? -1 + : (s2 == null ? 1 : s1.compareToIgnoreCase(s2)); if (comp == 0) { String a1 = ref1.getAccessionId(); String a2 = ref2.getAccessionId(); - comp = a1 == null ? -1 : (a2 == null ? 1 : a1 - .compareToIgnoreCase(a2)); + comp = a1 == null ? -1 + : (a2 == null ? 1 : a1.compareToIgnoreCase(a2)); } return comp; } -// private boolean isPrimarySource(String source) -// { -// for (String[] primary : DBRefSource.PRIMARY_SOURCES) -// { -// for (String s : primary) -// { -// if (source.equals(s)) -// { -// return true; -// } -// } -// } -// return false; -// } + // private boolean isPrimarySource(String source) + // { + // for (String[] primary : DBRefSource.PRIMARY_SOURCES) + // { + // for (String s : primary) + // { + // if (source.equals(s)) + // { + // return true; + // } + // } + // } + // return false; + // } }; private boolean forTooltip; @@ -150,9 +150,9 @@ public class SequenceAnnotationReport * @param minmax * @param maxlength */ - public int appendFeatures(final StringBuilder sb, - int residuePos, List features, - FeatureRendererModel fr, int maxlength) + public int appendFeatures(final StringBuilder sb, int residuePos, + List features, FeatureRendererModel fr, + int maxlength) { for (int i = 0; i < features.size(); i++) { @@ -209,12 +209,27 @@ public class SequenceAnnotationReport * if this is a virtual features, convert begin/end to the * coordinates of the sequence it is mapped to */ - int[] beginRange = null; - int[] endRange = null; + int[] beginRange = null; // feature start in local coordinates + int[] endRange = null; // feature end in local coordinates if (mf != null) { - beginRange = mf.getMappedPositions(begin, begin); - endRange = mf.getMappedPositions(end, end); + if (feature.isContactFeature()) + { + /* + * map start and end points individually + */ + beginRange = mf.getMappedPositions(begin, begin); + endRange = begin == end ? beginRange + : mf.getMappedPositions(end, end); + } + else + { + /* + * map the feature extent + */ + beginRange = mf.getMappedPositions(begin, end); + endRange = beginRange; + } if (beginRange == null || endRange == null) { // something went wrong @@ -397,21 +412,19 @@ public class SequenceAnnotationReport { for (List urllink : createLinksFrom(null, urlstring)) { - sb.append("
" - + (urllink.get(0).toLowerCase(Locale.ROOT) - .equals(urllink.get(1).toLowerCase(Locale.ROOT)) ? urllink - .get(0) : (urllink.get(0) + ":" + urllink - .get(1))) + sb.append("
" + + (urllink.get(0).toLowerCase(Locale.ROOT).equals( + urllink.get(1).toLowerCase(Locale.ROOT)) + ? urllink.get(0) + : (urllink.get(0) + ":" + + urllink.get(1))) + "
"); } } catch (Exception x) { - System.err.println("problem when creating links from " - + urlstring); + System.err.println( + "problem when creating links from " + urlstring); x.printStackTrace(); } } @@ -480,6 +493,7 @@ public class SequenceAnnotationReport sb.append(tmp); maxWidth = Math.max(maxWidth, tmp.length()); } + sb.append("\n"); SequenceI ds = sequence; while (ds.getDatasetSequence() != null) { @@ -490,6 +504,7 @@ public class SequenceAnnotationReport { maxWidth = Math.max(maxWidth, appendDbRefs(sb, ds, summary)); } + sb.append("\n"); /* * add non-positional features if wanted @@ -521,12 +536,19 @@ public class SequenceAnnotationReport protected int appendDbRefs(final StringBuilder sb, SequenceI ds, boolean summary) { - List dbrefs = ds.getDBRefs(); - if (dbrefs == null) + List dbrefs, dbrefset = ds.getDBRefs(); + + if (dbrefset == null) { return 0; } + // PATCH for JAL-3980 defensive copy + + dbrefs = new ArrayList(); + + dbrefs.addAll(dbrefset); + // note this sorts the refs held on the sequence! dbrefs.sort(comparator); boolean ellipsis = false; @@ -563,7 +585,7 @@ public class SequenceAnnotationReport countForSource++; if (countForSource == 1 || !summary) { - sb.append("
"); + sb.append("
\n"); } if (countForSource <= MAX_REFS_PER_SOURCE || !summary) { @@ -571,7 +593,7 @@ public class SequenceAnnotationReport lineLength += accessionId.length() + 1; if (countForSource > 1 && summary) { - sb.append(", ").append(accessionId); + sb.append(",\n ").append(accessionId); lineLength++; } else @@ -589,11 +611,11 @@ public class SequenceAnnotationReport } if (moreSources) { - sb.append("
").append(source).append(COMMA).append(ELLIPSIS); + sb.append("
\n").append(source).append(COMMA).append(ELLIPSIS); } if (ellipsis) { - sb.append("
("); + sb.append("
\n("); sb.append(MessageManager.getString("label.output_seq_details")); sb.append(")"); } @@ -605,8 +627,8 @@ public class SequenceAnnotationReport SequenceI sequence, boolean showDbRefs, boolean showNpFeats, FeatureRendererModel fr) { - int maxWidth = createSequenceAnnotationReport(tip, sequence, - showDbRefs, showNpFeats, fr, true); + int maxWidth = createSequenceAnnotationReport(tip, sequence, showDbRefs, + showNpFeats, fr, true); if (maxWidth > 60) {