+ * @param feature
+ * @return
+ */
+ static String getDescription(FeatureType feature)
+ {
+ String orig = feature.getOriginal();
+ List<String> variants = feature.getVariation();
+ StringBuilder sb = new StringBuilder();
+
+ /*
+ * append variant in standard format if present
+ * e.g. p.Arg59Lys
+ * multiple variants are split over lines using <br>
+ */
+ boolean asHtml = false;
+ if (orig != null && !orig.isEmpty() && variants != null
+ && !variants.isEmpty())
+ {
+ int p = 0;
+ for (String var : variants)
+ {
+ // TODO proper HGVS nomenclature for delins structural variations
+ // http://varnomen.hgvs.org/recommendations/protein/variant/delins/
+ // for now we are pragmatic - any orig/variant sequence longer than
+ // three characters is shown with single-character notation rather than
+ // three-letter notation
+ sb.append("p.");
+ if (orig.length() < 4)
+ {
+ for (int c = 0, clen = orig.length(); c < clen; c++)
+ {
+ char origchar = orig.charAt(c);
+ String orig3 = ResidueProperties.aa2Triplet.get("" + origchar);
+ sb.append(orig3 == null ? origchar
+ : StringUtils.toSentenceCase(orig3));
+ }
+ }
+ else
+ {
+ sb.append(orig);
+ }
+
+ LocationType location = feature.getLocation();
+ PositionType start = location.getPosition() == null
+ ? location.getBegin()
+ : location.getPosition();
+ sb.append(Integer.toString(start.getPosition().intValue()));
+
+ if (var.length() < 4)
+ {
+ for (int c = 0, clen = var.length(); c < clen; c++)
+ {
+ char varchar = var.charAt(c);
+ String var3 = ResidueProperties.aa2Triplet.get("" + varchar);
+
+ sb.append(var3 != null ? StringUtils.toSentenceCase(var3)
+ : "" + varchar);
+ }
+ }
+ else
+ {
+ sb.append(var);
+ }
+ if (++p != variants.size())
+ {
+ sb.append("<br/> ");
+ asHtml = true;
+ }
+ else
+ {
+ sb.append(" ");
+ }
+ }
+ }
+ String description = feature.getDescription();
+ if (description != null)
+ {
+ sb.append(description);
+ }
+ if (asHtml)
+ {
+ sb.insert(0, "<html>");
+ sb.append("</html>");
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * A helper method that searches the list of properties for one with the given
+ * key, and if found returns the property value, else returns null
+ *
+ * @param properties
+ * @param key
+ * @return