import jalview.util.Comparison;
import jalview.util.MapList;
import jalview.util.MappingUtils;
+import jalview.util.StringUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
.codonTranslate(codon));
if (trans != null && !trans.equals(residue))
{
- String desc = residue + "->" + trans;
+ String residue3Char = StringUtils
+ .toSentenceCase(ResidueProperties.aa2Triplet.get(residue));
+ String trans3Char = StringUtils
+ .toSentenceCase(ResidueProperties.aa2Triplet.get(trans));
+ String desc = "p." + residue3Char + peptidePos + trans3Char;
// set score to 0f so 'graduated colour' option is offered! JAL-2060
SequenceFeature sf = new SequenceFeature(
SequenceOntologyI.SEQUENCE_VARIANT, desc, peptidePos,
*/
return 0;
}
+
+ /**
+ * Converts the string to all lower-case except the first character which is
+ * upper-cased
+ *
+ * @param s
+ * @return
+ */
+ public static String toSentenceCase(String s)
+ {
+ if (s == null)
+ {
+ return s;
+ }
+ if (s.length() <= 1)
+ {
+ return s.toUpperCase();
+ }
+ return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
+ }
}
assertEquals(1, StringUtils.compareVersions("12", "2"));
assertEquals(1, StringUtils.compareVersions("3.12.11", "3.2.4"));
}
+
+ @Test(groups = { "Functional" })
+ public void testToSentenceCase()
+ {
+ assertEquals("John", StringUtils.toSentenceCase("john"));
+ assertEquals("John", StringUtils.toSentenceCase("JOHN"));
+ assertEquals("John and james",
+ StringUtils.toSentenceCase("JOHN and JAMES"));
+ assertEquals("J", StringUtils.toSentenceCase("j"));
+ assertEquals("", StringUtils.toSentenceCase(""));
+ assertNull(StringUtils.toSentenceCase(null));
+ }
}