/** * Convert string, if it is in camelCase, to individual words with each word starting with a * capital letter */ public static String convertCamelCase(String input) { String[] parts = StringUtils.splitByCharacterTypeCamelCase(input); String convertedStr = StringUtils.join(parts, " "); convertedStr = StringUtils.capitalize(convertedStr).trim(); return convertedStr; }
/** * Get the number of amino acids in given sequence, excluding the ones only partially present * * @param sequence * @return Number of amino acids * @throws Exception */ public static int getNumFullAminoAcids(String sequence) { String[] tokens = StringUtils.splitByCharacterTypeCamelCase(sequence); if (tokens.length < 1) return 0; int numFullAas = tokens.length; if (tokens[0].length() < 3) numFullAas--; if (tokens[tokens.length - 1].length() < 3) numFullAas--; return numFullAas; }
/** * Get the label to display in the webapp for this field. If there is no label, returns the name * of the field instead. * * @return A human readable label. */ public String getDisplayName() { if (label != null) { return label; } else { String[] parts = StringUtils.splitByCharacterTypeCamelCase(fieldName); String[] ucFirstParts = new String[parts.length]; for (int i = 0; i < parts.length; i++) { ucFirstParts[i] = StringUtils.capitalize(parts[i]); } return StringUtils.join(ucFirstParts, " "); } }
private String toUnderscoreSeparated(String camelCase) { String[] array = StringUtils.splitByCharacterTypeCamelCase(camelCase); StringBuffer buf = new StringBuffer(); for (int i = 0; i < array.length; i++) { String s = array[i]; buf.append(s.substring(0, 1).toLowerCase()); buf.append(s.substring(1)); if (i != array.length - 1) { buf.append("_"); } } return buf.toString(); }
/** * Get the number of amino acids in given sequence, including the ones only partially present * * @param sequence * @return Number of amino acids * @throws Exception */ public static Integer getNumPartAminoAcids(String sequence) { String[] tokens = StringUtils.splitByCharacterTypeCamelCase(sequence); return tokens.length; }