From: gmungoc
Date: Thu, 7 Jun 2018 08:55:54 +0000 (+0100)
Subject: JAL-2920 wrap description in if it includes
X-Git-Tag: Release_2_10_5~55
X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=743af46c3c50e67706009be4360fa504bfcd4fdc;p=jalview.git
JAL-2920 wrap description in if it includes
---
diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java
index c311ea9..167cd97 100644
--- a/src/jalview/ws/dbsources/Uniprot.java
+++ b/src/jalview/ws/dbsources/Uniprot.java
@@ -309,7 +309,9 @@ public class Uniprot extends DbSourceProxyImpl
/*
* append variant in standard format if present
* e.g. p.Arg59Lys
+ * multiple variants are split over lines using
*/
+ boolean asHtml = false;
if (orig != null && !orig.isEmpty() && variants != null
&& !variants.isEmpty())
{
@@ -356,7 +358,8 @@ public class Uniprot extends DbSourceProxyImpl
}
if (++p != variants.size())
{
- sb.append("\n");
+ sb.append("
");
+ asHtml = true;
}
else
{
@@ -369,6 +372,11 @@ public class Uniprot extends DbSourceProxyImpl
{
sb.append(description);
}
+ if (asHtml)
+ {
+ sb.insert(0, "");
+ sb.append("");
+ }
return sb.toString();
}
diff --git a/test/jalview/ws/dbsources/UniprotTest.java b/test/jalview/ws/dbsources/UniprotTest.java
index 67d5d62..e927023 100644
--- a/test/jalview/ws/dbsources/UniprotTest.java
+++ b/test/jalview/ws/dbsources/UniprotTest.java
@@ -154,19 +154,22 @@ public class UniprotTest
assertEquals(42, sf.getBegin());
assertEquals(42, sf.getEnd());
Assert.assertEquals(Uniprot.getDescription(sf),
- "p.Met42Leu" + "\n" + "p.Met42LeuMetVal Foo");
+ "p.Met42Leu" + "
"
+ + "p.Met42LeuMetVal Foo");
sf = features.get(7);
assertEquals(42, sf.getBegin());
assertEquals(43, sf.getEnd());
Assert.assertEquals(Uniprot.getDescription(sf),
- "p.MetLeu42LeuLeu" + "\n" + "p.MetLeu42LeuMetVal Foo");
+ "p.MetLeu42LeuLeu" + "
"
+ + "p.MetLeu42LeuMetVal Foo");
sf = features.get(8);
assertEquals(42, sf.getBegin());
assertEquals(45, sf.getEnd());
Assert.assertEquals(Uniprot.getDescription(sf),
- "p.MLML42LeuLeu" + "\n" + "p.MLML42LMVK Foo Too");
+ "p.MLML42LeuLeu" + "
"
+ + "p.MLML42LMVK Foo Too");
/*
* Check cross-references
@@ -253,8 +256,9 @@ public class UniprotTest
uf.setVariation(vars);
assertEquals("p.Lys23Tyr Hello", Uniprot.getDescription(uf));
+ // multiple variants generate an html description over more than one line
vars.add("W");
- assertEquals("p.Lys23Tyr\np.Lys23Trp Hello",
+ assertEquals("p.Lys23Tyr
p.Lys23Trp Hello",
Uniprot.getDescription(uf));
/*