Package ubic.basecode.util
Class StringUtil
java.lang.Object
ubic.basecode.util.StringUtil
- Author:
- pavlidis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic StringcommonPrefix(Collection<String> strings) Given a set of strings, identify any prefix they have in common.static StringcommonSuffix(Collection<String> strings) Given a set of strings, identify any suffix they have in common.static booleanChecks a string to find "strange" character, used by phenocarta to check evidence descriptionstatic String[]static StringMade by Nicolasstatic booleanisLatinLetter(char c) static StringMimics themake.namesmethod in R for a single string.static String[]Mimics themake.namesmethod in R.static String[]makeUnique(String[] strings) Mimics themake.uniquemethod in R.static StringDeprecated.static String[]makeValidForR(String[] strings) Deprecated.usemakeNames(String[], boolean)insteadstatic LongtwoStringHashKey(String stringi, String stringj)
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
append
- Parameters:
appendee- The string to be added toappendant- The string to add to the end of the appendeeseparator- The string to put between the joined strings, if necessary.- Returns:
- appendee + separator + separator unless appendee is empty, in which case the appendant is returned.
-
commonPrefix
Given a set of strings, identify any prefix they have in common.- Parameters:
strings-- Returns:
- the common prefix, null if there isn't one.
-
commonSuffix
Given a set of strings, identify any suffix they have in common.- Parameters:
strings-- Returns:
- the commons suffix, null if there isn't one.
-
containsValidCharacter
Checks a string to find "strange" character, used by phenocarta to check evidence description- Parameters:
the- string to check- Returns:
- return false if something strange was found
-
csvSplit
- Parameters:
line-- Returns:
-
cvs2tsv
Made by Nicolas- Parameters:
a- line in a file cvs format- Returns:
- the same line but in tsv format
-
isLatinLetter
public static boolean isLatinLetter(char c) -
makeValidForR
Deprecated.usemakeNames(String[], boolean)insteadMimics themake.namesmethod in R (character.c) to make valid variables names; we use this for column headers in some output files.This was modified in 1.1.26 to match the behavior of R more closely, if not exactly.
- Parameters:
s- a string to be made valid for R- Returns:
- modified string
-
makeValidForR
Deprecated.usemakeNames(String[], boolean)insteadMimics themake.namesmethod in R when using with a vector of strings and the unique argument set to TRUE. -
makeNames
Mimics themake.namesmethod in R.- Parameters:
strings- a list of strings to be made valid for Runique- if true, will ensure that the names are unique by appending a number to duplicates as permakeUnique(String[])
-
makeNames
Mimics themake.namesmethod in R for a single string. -
makeUnique
Mimics themake.uniquemethod in R.Duplicated values in the input array will be suffixed with a dot and a number, starting from 1.
-
twoStringHashKey
- Parameters:
stringi-stringj-- Returns:
-
makeNames(String[], boolean)instead