From: Jim Procter Date: Tue, 11 Sep 2018 12:29:37 +0000 (+0100) Subject: Merge branch 'develop' into releases/Release_2_11_Branch X-Git-Tag: Release_2_11_0~19^2^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=20a4d7ddb86ee996f2b6617a0470922b83354c35;p=jalview.git Merge branch 'develop' into releases/Release_2_11_Branch JAL-3091 bring 2.11 onto release 2.10.5 to simplify merge --- 20a4d7ddb86ee996f2b6617a0470922b83354c35 diff --cc help/html/releases.html index df1ddcd,efe6520..3eaf234 --- a/help/html/releases.html +++ b/help/html/releases.html @@@ -67,122 -67,31 +67,146 @@@ li:before + + +
+ 2.11.0
+ 8/09/2018
+
+ +
+ + +
+
+ + +
+ + +
+ 2.10.5
10/09/2018
+
+ +
+ + + Development + +
+
+ + + Java 10 Issues Resolved + +
+ + +
2.10.4b1
diff --cc src/jalview/datamodel/SequenceFeature.java index f17bd33,34565c6..7052f34 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@@ -20,9 -20,13 +20,14 @@@ */ package jalview.datamodel; + import jalview.datamodel.features.FeatureAttributeType; + import jalview.datamodel.features.FeatureAttributes; import jalview.datamodel.features.FeatureLocationI; + import jalview.datamodel.features.FeatureSourceI; + import jalview.datamodel.features.FeatureSources; + import jalview.util.StringUtils; +import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@@ -536,22 -597,142 +598,160 @@@ public class SequenceFeature implement { return begin == 0 && end == 0; } + + /** + * Answers an html-formatted report of feature details + * + * @return + */ + public String getDetailsReport() + { + FeatureSourceI metadata = FeatureSources.getInstance() + .getSource(source); + + StringBuilder sb = new StringBuilder(128); + sb.append("
"); + sb.append(""); + sb.append(String.format(ROW_DATA, "Type", type, "")); + sb.append(String.format(ROW_DATA, "Start/end", begin == end ? begin + : begin + (isContactFeature() ? ":" : "-") + end, "")); + String desc = StringUtils.stripHtmlTags(description); + sb.append(String.format(ROW_DATA, "Description", desc, "")); + if (!Float.isNaN(score) && score != 0f) + { + sb.append(String.format(ROW_DATA, "Score", score, "")); + } + if (featureGroup != null) + { + sb.append(String.format(ROW_DATA, "Group", featureGroup, "")); + } + + if (otherDetails != null) + { + TreeMap ordered = new TreeMap<>( + String.CASE_INSENSITIVE_ORDER); + ordered.putAll(otherDetails); + + for (Entry entry : ordered.entrySet()) + { + String key = entry.getKey(); + if (ATTRIBUTES.equals(key)) + { + continue; // to avoid double reporting + } + + Object value = entry.getValue(); + if (value instanceof Map) + { + /* + * expand values in a Map attribute across separate lines + * copy to a TreeMap for alphabetical ordering + */ + Map values = (Map) value; + SortedMap sm = new TreeMap<>( + String.CASE_INSENSITIVE_ORDER); + sm.putAll(values); + for (Entry e : sm.entrySet()) + { + sb.append(String.format(ROW_DATA, key, e.getKey().toString(), e + .getValue().toString())); + } + } + else + { + // tried
but it failed to provide a tooltip :-( + String attDesc = null; + if (metadata != null) + { + attDesc = metadata.getAttributeName(key); + } + String s = entry.getValue().toString(); + if (isValueInteresting(key, s, metadata)) + { + sb.append(String.format(ROW_DATA, key, attDesc == null ? "" + : attDesc, s)); + } + } + } + } + sb.append("
"); + + String text = sb.toString(); + return text; + } + + /** + * Answers true if we judge the value is worth displaying, by some heuristic + * rules, else false + * + * @param key + * @param value + * @param metadata + * @return + */ + boolean isValueInteresting(String key, String value, + FeatureSourceI metadata) + { + /* + * currently suppressing zero values as well as null or empty + */ + if (value == null || "".equals(value) || ".".equals(value) + || "0".equals(value)) + { + return false; + } + + if (metadata == null) + { + return true; + } + + FeatureAttributeType attType = metadata.getAttributeType(key); + if (attType != null + && (attType == FeatureAttributeType.Float || attType + .equals(FeatureAttributeType.Integer))) + { + try + { + float fval = Float.valueOf(value); + if (fval == 0f) + { + return false; + } + } catch (NumberFormatException e) + { + // ignore + } + } + + return true; // default to interesting + } + + /** + * Sets the feature source identifier + * + * @param theSource + */ + public void setSource(String theSource) + { + source = theSource; + } } + +class SFSortByEnd implements Comparator +{ + @Override + public int compare(SequenceFeature a, SequenceFeature b) + { + return a.getEnd() - b.getEnd(); + } +} + +class SFSortByBegin implements Comparator +{ + @Override + public int compare(SequenceFeature a, SequenceFeature b) + { + return a.getBegin() - b.getBegin(); + } +}