Class ForesterUtil

java.lang.Object
org.forester.util.ForesterUtil

public final class ForesterUtil extends Object
  • Field Details

  • Method Details

    • appendSeparatorIfNotEmpty

      public static final void appendSeparatorIfNotEmpty(StringBuffer sb, char separator)
    • calcColor

      public static final Color calcColor(double value, double min, double max, Color minColor, Color maxColor)
      This calculates a color. If value is equal to min the returned color is minColor, if value is equal to max the returned color is maxColor, otherwise a color 'proportional' to value is returned.
      Parameters:
      value - the value
      min - the smallest value
      max - the largest value
      minColor - the color for min
      maxColor - the color for max
      Returns:
      a Color
    • calcColor

      public static final Color calcColor(double value, double min, double max, double mean, Color minColor, Color maxColor, Color meanColor)
      This calculates a color. If value is equal to min the returned color is minColor, if value is equal to max the returned color is maxColor, if value is equal to mean the returned color is meanColor, otherwise a color 'proportional' to value is returned -- either between min-mean or mean-max
      Parameters:
      value - the value
      min - the smallest value
      max - the largest value
      mean - the mean/median value
      minColor - the color for min
      maxColor - the color for max
      meanColor - the color for mean
      Returns:
      a Color
    • calculateOverlap

      public static int calculateOverlap(Domain domain, List<Boolean> covered_positions)
    • collapseWhiteSpace

      public static final String collapseWhiteSpace(String s)
    • collection2file

      public static final void collection2file(File file, Collection<?> data, String separator) throws IOException
      Throws:
      IOException
    • collection2writer

      public static final void collection2writer(Writer writer, Collection<?> data, String separator) throws IOException
      Throws:
      IOException
    • colorToHex

      public static final String colorToHex(Color color)
    • copyFile

      public static void copyFile(File in, File out) throws IOException
      Throws:
      IOException
    • countChars

      public static final int countChars(String str, char c)
    • createBufferedWriter

      public static final BufferedWriter createBufferedWriter(File file) throws IOException
      Throws:
      IOException
    • createBufferedWriter

      public static final BufferedWriter createBufferedWriter(String name) throws IOException
      Throws:
      IOException
    • createEasyWriter

      public static final EasyWriter createEasyWriter(File file) throws IOException
      Throws:
      IOException
    • createEasyWriter

      public static final BufferedWriter createEasyWriter(String name) throws IOException
      Throws:
      IOException
    • createFileForWriting

      public static final File createFileForWriting(String name) throws IOException
      Throws:
      IOException
    • ensurePresenceOfDate

      public static final void ensurePresenceOfDate(PhylogenyNode node)
    • ensurePresenceOfDistribution

      public static final void ensurePresenceOfDistribution(PhylogenyNode node)
    • ensurePresenceOfSequence

      public static void ensurePresenceOfSequence(PhylogenyNode node)
    • ensurePresenceOfTaxonomy

      public static void ensurePresenceOfTaxonomy(PhylogenyNode node)
    • fatalError

      public static void fatalError(String message)
    • fatalError

      public static void fatalError(String prg_name, String message)
    • fatalErrorIfFileNotReadable

      public static void fatalErrorIfFileNotReadable(File file)
    • fatalErrorIfFileNotReadable

      public static void fatalErrorIfFileNotReadable(String prg_name, File file)
    • file22dArray

      public static String[][] file22dArray(File file) throws IOException
      Throws:
      IOException
    • file2array

      public static String[] file2array(File file) throws IOException
      Throws:
      IOException
    • file2list

      public static final List<String> file2list(File file) throws IOException
      Throws:
      IOException
    • file2set

      public static final SortedSet<String> file2set(File file) throws IOException
      Throws:
      IOException
    • getCurrentDateTime

      public static final String getCurrentDateTime()
    • getFileSeparator

      public static final String getFileSeparator()
    • getFirstLine

      public static final String getFirstLine(Object source) throws FileNotFoundException, IOException
      Throws:
      FileNotFoundException
      IOException
    • getForesterLibraryInformation

      public static final String getForesterLibraryInformation()
    • getLineSeparator

      public static final String getLineSeparator()
    • guessMolecularSequenceType

      public static final MolecularSequence.TYPE guessMolecularSequenceType(String mol_seq)
    • increaseCountingMap

      public static final void increaseCountingMap(Map<String,Integer> counting_map, String item_name)
    • isEmpty

      public static final boolean isEmpty(List<?> l)
    • isEmpty

      public static final boolean isEmpty(Set<?> s)
    • isEmpty

      public static final boolean isEmpty(String s)
    • isEngulfed

      public static boolean isEngulfed(Domain domain, List<Boolean> covered_positions)
      Returns true is Domain domain falls in an uninterrupted stretch of covered positions.
      Parameters:
      domain -
      covered_positions -
      Returns:
    • isEqual

      public static final boolean isEqual(double a, double b)
    • isEven

      public static final boolean isEven(int n)
    • isIntersecting

      public static final boolean isIntersecting(String[] a, String[] b)
      This determines whether String[] a and String[] b have at least one String in common (intersect). Returns false if at least one String[] is null or empty.
      Parameters:
      a - a String[] b a String[]
      Returns:
      true if both a and b or not empty or null and contain at least one element in common false otherwise
    • isLargerOrEqualToZero

      public static final double isLargerOrEqualToZero(double d)
    • isMac

      public static final boolean isMac()
    • isNull

      public static final boolean isNull(BigDecimal s)
    • isReadableFile

      public static final String isReadableFile(File f)
    • isReadableFile

      public static final String isReadableFile(String s)
    • isWindows

      public static final boolean isWindows()
    • isWritableFile

      public static final String isWritableFile(File f)
    • limitRangeForColor

      public static final int limitRangeForColor(int i)
      Helper for method "stringToColor".

      (Last modified: 12/20/03)

    • listToSortedCountsMap

      public static final SortedMap<Object,Integer> listToSortedCountsMap(List<?> list)
    • map2file

      public static final void map2file(File file, Map<?,?> data, String entry_separator, String data_separator) throws IOException
      Throws:
      IOException
    • map2writer

      public static final void map2writer(Writer writer, Map<?,?> data, String entry_separator, String data_separator) throws IOException
      Throws:
      IOException
    • mapToStringBuffer

      public static final StringBuffer mapToStringBuffer(Map<Object,Object> map, String key_value_separator)
    • normalizeString

      public static final String normalizeString(String s, int length, boolean left_pad, char pad_char)
    • obtainColorDependingOnTaxonomyGroup

      public static final Color obtainColorDependingOnTaxonomyGroup(String tax_group)
    • obtainNormalizedTaxonomyGroup

      public static final String obtainNormalizedTaxonomyGroup(String tax)
    • obtainReader

      public static final BufferedReader obtainReader(Object source) throws IOException, FileNotFoundException
      Throws:
      IOException
      FileNotFoundException
    • outOfMemoryError

      public static final void outOfMemoryError(OutOfMemoryError e)
    • pad

      public static final StringBuffer pad(double number, int size, char pad, boolean left_pad)
    • pad

      public static final StringBuffer pad(String string, int size, char pad, boolean left_pad)
    • pad

      public static final StringBuffer pad(StringBuffer string, int size, char pad, boolean left_pad)
    • parseDouble

      public static final double parseDouble(String str) throws ParseException
      Throws:
      ParseException
    • parseInt

      public static final int parseInt(String str) throws ParseException
      Throws:
      ParseException
    • printArray

      public static final void printArray(Object[] a)
    • printCountingMap

      public static final void printCountingMap(Map<String,Integer> counting_map)
    • printErrorMessage

      public static final void printErrorMessage(String prg_name, String message)
    • printProgramInformation

      public static final void printProgramInformation(String prg_name, String prg_version, String date)
    • printProgramInformation

      public static final void printProgramInformation(String prg_name, String prg_version, String date, String email, String www)
    • printProgramInformation

      public static final void printProgramInformation(String prg_name, String desc, String prg_version, String date, String email, String www, String based_on)
    • printWarningMessage

      public static final void printWarningMessage(String prg_name, String message)
    • programMessage

      public static final void programMessage(String prg_name, String message)
    • readUrl

      public static List<String> readUrl(String url_str) throws IOException
      Throws:
      IOException
    • removeOverlappingDomains

      public static Protein removeOverlappingDomains(int max_allowed_overlap, boolean remove_engulfed_domains, Protein protein)
      Example regarding engulfment: ------------0.1 ----------0.2 --0.3 => domain with 0.3 is ignored -----------0.1 ----------0.2 --0.3 => domain with 0.3 is ignored ------------0.1 ----------0.3 --0.2 => domains with 0.3 and 0.2 are _not_ ignored
      Parameters:
      max_allowed_overlap - maximal allowed overlap (inclusive) to be still considered not overlapping (zero or negative value to allow any overlap)
      remove_engulfed_domains - to remove domains which are completely engulfed by coverage of domains with better support
      protein -
      Returns:
    • removeSuffix

      public static final String removeSuffix(String file_name)
    • removeWhiteSpace

      public static final String removeWhiteSpace(String s)
      Removes all white space from String s.
      Returns:
      String s with white space removed
    • replaceIllegalNhxCharacters

      public static final String replaceIllegalNhxCharacters(String nhx)
    • round

      public static final double round(double value, int decimal_place)
    • roundToInt

      public static final int roundToInt(double d)
      Rounds d to an int.
    • roundToInt

      public static final int roundToInt(float f)
    • roundToShort

      public static final short roundToShort(double d)
    • sanitizeString

      public static final String sanitizeString(String s)
    • santitizeStringForNH

      public static final StringBuilder santitizeStringForNH(String data)
    • seqIsLikelyToBeAa

      public static boolean seqIsLikelyToBeAa(String s)
    • stringArrayToString

      public static final String stringArrayToString(String[] a)
    • stringArrayToString

      public static final String stringArrayToString(String[] a, String separator)
    • stringListToArray

      public static final String[] stringListToArray(List<String> list)
    • stringListToString

      public static final String stringListToString(List<String> l, String separator)
    • stringSetToArray

      public static final String[] stringSetToArray(Set<String> strings)
    • unexpectedFatalError

      public static final void unexpectedFatalError(Error e)
    • unexpectedFatalError

      public static final void unexpectedFatalError(Exception e)
    • unexpectedFatalError

      public static final void unexpectedFatalError(String message)
    • unexpectedFatalError

      public static final void unexpectedFatalError(String prg_name, Exception e)
    • unexpectedFatalError

      public static final void unexpectedFatalError(String prg_name, String message)
    • unexpectedFatalError

      public static final void unexpectedFatalError(String prg_name, String message, Exception e)
    • updateProgress

      public static final void updateProgress(double progress_percentage)
    • updateProgress

      public static final void updateProgress(int i, DecimalFormat f)
    • wordWrap

      public static final String wordWrap(String str, int width)