package jalview.datamodel;
import jalview.datamodel.features.FeatureLocationI;
+import jalview.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision$
+ * A class that models a single contiguous feature on a sequence. If flag
+ * 'contactFeature' is true, the start and end positions are interpreted instead
+ * as two contact points.
*/
public class SequenceFeature implements FeatureLocationI
{
// private key for ENA location designed not to conflict with real GFF data
private static final String LOCATION = "!Location";
+ private static final String ROW_DATA = "<tr><td>%s</td><td>%s</td></tr>";
+
/*
* map of otherDetails special keys, and their value fields' delimiter
*/
static
{
INFO_KEYS.put("CSQ", ",");
+ // todo capture second level metadata (CSQ FORMAT)
+ // and delimiter "|" so as to report in a table within a table?
}
/*
}
/**
- * Answers a formatted text report of feature details
+ * Answers an html-formatted report of feature details
*
* @return
*/
public String getDetailsReport()
{
StringBuilder sb = new StringBuilder(128);
- if (begin == end)
+ sb.append("<br>");
+ sb.append("<table>");
+ 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("%s %d %s", type, begin, description));
- }
- else
- {
- sb.append(String.format("%s %d-%d %s", type, begin, end, description));
+ sb.append(String.format(ROW_DATA, "Score", score));
}
if (featureGroup != null)
{
- sb.append(" (").append(featureGroup).append(")");
+ sb.append(String.format(ROW_DATA, "Group", featureGroup));
}
- sb.append("\n\n");
if (otherDetails != null)
{
/*
* split selected INFO data by delimiter over multiple lines
*/
- sb.append(key).append("\n");
String delimiter = INFO_KEYS.get(key);
- sb.append(entry.getValue().toString().replace(delimiter, "\n"));
+ String[] values = entry.getValue().toString().split(delimiter);
+ for (String value : values)
+ {
+ sb.append("<tr><td>").append(key).append("</td><td>")
+ .append(value)
+ .append("</td></tr>");
+ }
}
else
- {
- sb.append(key + "=" + entry.getValue().toString() + "\n");
+ { // tried <td title="key"> but it failed to provide a tooltip :-(
+ sb.append("<tr><td>").append(key).append("</td><td>");
+ sb.append(entry.getValue().toString()).append("</td></tr>");
}
}
}
+ sb.append("</table>");
+
String text = sb.toString();
return text;
}