X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FSequenceAnnotationReport.java;h=a287cb8254fe04a84f4ec84c137912251b40424d;hb=c0501eaa85c0594f9275766f64de8ea44a59c368;hp=a4c489572e885a216e8e9308af3c53392fffaee1;hpb=c6018dc0dc12720e13b75850a5303279ac7094b7;p=jalview.git
diff --git a/src/jalview/io/SequenceAnnotationReport.java b/src/jalview/io/SequenceAnnotationReport.java
index a4c4895..a287cb8 100644
--- a/src/jalview/io/SequenceAnnotationReport.java
+++ b/src/jalview/io/SequenceAnnotationReport.java
@@ -20,14 +20,17 @@
*/
package jalview.io;
-import java.util.Arrays;
+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;
+import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.GeneLociI;
@@ -58,9 +61,7 @@ public class SequenceAnnotationReport
private static String linkImageURL;
- private static final String[][] PRIMARY_SOURCES = new String[][] {
- DBRefSource.CODINGDBS, DBRefSource.DNACODINGDBS,
- DBRefSource.PROTEINDBS };
+ // public static final String[][] PRIMARY_SOURCES moved to DBRefSource.java
/*
* Comparator to order DBRefEntry by Source + accession id (case-insensitive),
@@ -82,8 +83,8 @@ public class SequenceAnnotationReport
}
String s1 = ref1.getSource();
String s2 = ref2.getSource();
- boolean s1Primary = isPrimarySource(s1);
- boolean s2Primary = isPrimarySource(s2);
+ boolean s1Primary = DBRefSource.isPrimarySource(s1);
+ boolean s2Primary = DBRefSource.isPrimarySource(s2);
if (s1Primary && !s2Primary)
{
return -1;
@@ -104,20 +105,20 @@ public class SequenceAnnotationReport
return comp;
}
- private boolean isPrimarySource(String source)
- {
- for (String[] primary : 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;
@@ -291,10 +292,12 @@ public class SequenceAnnotationReport
* truncate overlong descriptions unless they contain an href
* before the truncation point (as truncation could leave corrupted html)
*/
- int linkindex = description.toLowerCase().indexOf(" -1
&& linkindex < MAX_DESCRIPTION_LENGTH;
- if (description.length() > MAX_DESCRIPTION_LENGTH && !hasLink)
+ if (
+ // BH suggestion maxlength == 0 &&
+ description.length() > MAX_DESCRIPTION_LENGTH && !hasLink)
{
description = description.substring(0, MAX_DESCRIPTION_LENGTH)
+ ELLIPSIS;
@@ -413,16 +416,16 @@ public class SequenceAnnotationReport
{
for (List urllink : createLinksFrom(null, urlstring))
{
- sb.append("
"
- + (urllink.get(0).toLowerCase()
- .equals(urllink.get(1).toLowerCase()) ? urllink
+ + (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)
{
@@ -496,16 +499,31 @@ public class SequenceAnnotationReport
sb.append(tmp);
maxWidth = Math.max(maxWidth, tmp.length());
}
+ sb.append("\n");
SequenceI ds = sequence;
while (ds.getDatasetSequence() != null)
{
ds = ds.getDatasetSequence();
}
+ /*
+ * add any annotation scores
+ */
+ AlignmentAnnotation[] anns = ds.getAnnotation();
+ for (int i = 0; anns != null && i < anns.length; i++)
+ {
+ AlignmentAnnotation aa = anns[i];
+ if (aa != null && aa.hasScore() && aa.sequenceRef != null)
+ {
+ sb.append("
").append(aa.label).append(": ")
+ .append(aa.getScore());
+ }
+ }
if (showDbRefs)
{
maxWidth = Math.max(maxWidth, appendDbRefs(sb, ds, summary));
}
+ sb.append("\n");
/*
* add non-positional features if wanted
@@ -521,6 +539,20 @@ public class SequenceAnnotationReport
maxWidth = Math.max(maxWidth, sz);
}
}
+ if (sequence.getAnnotation("Search Scores") != null)
+ {
+ sb.append("
");
+ String eValue = " E-Value: "
+ + sequence.getAnnotation("Search Scores")[0].getEValue();
+ String bitScore = " Bit Score: "
+ + sequence.getAnnotation("Search Scores")[0].getBitScore();
+ sb.append(eValue);
+ sb.append("
");
+ sb.append(bitScore);
+ maxWidth = Math.max(maxWidth, eValue.length());
+ maxWidth = Math.max(maxWidth, bitScore.length());
+ }
+ sb.append("
");
sb.append("");
return maxWidth;
}
@@ -537,14 +569,20 @@ public class SequenceAnnotationReport
protected int appendDbRefs(final StringBuilder sb, SequenceI ds,
boolean summary)
{
- DBRefEntry[] 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!
- Arrays.sort(dbrefs, comparator);
+ dbrefs.sort(comparator);
boolean ellipsis = false;
String source = null;
String lastSource = null;
@@ -579,7 +617,7 @@ public class SequenceAnnotationReport
countForSource++;
if (countForSource == 1 || !summary)
{
- sb.append("
");
+ sb.append("
\n");
}
if (countForSource <= MAX_REFS_PER_SOURCE || !summary)
{
@@ -587,7 +625,7 @@ public class SequenceAnnotationReport
lineLength += accessionId.length() + 1;
if (countForSource > 1 && summary)
{
- sb.append(", ").append(accessionId);
+ sb.append(",\n ").append(accessionId);
lineLength++;
}
else
@@ -605,11 +643,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(")");
}