## org.irisa.genouest.logol.utils
Class LogolUtils

    java.lang.Object
      org.irisa.genouest.logol.utils.LogolUtils

    public class LogolUtils

extends java.lang.Object

Field Summary
`static int` `predCounter`
`static int` `varCounter` Incremental counter to get unique variable identifiers.

Constructor Summary
`LogolUtils()`

Method Summary
`static java.lang.String` `addParent(LogolVariable lvar, int id)`
`static void` `convert2Fasta(java.lang.String inputFile, java.lang.String outputFile)` Convert a Logol output XML file to fasta format
`static boolean` `copyFile(java.lang.String inFile, java.lang.String outFile)` Copy a file content to an other
`static int` `countGrammarModels(java.lang.String grammar, java.lang.String model)` Counts the number of models required to match the sequence
`static java.util.HashSet<java.lang.String>` `getAllUsedVariables(java.lang.String predicate)` Looks for variable references to know which variables are used in a predicate
`static java.util.HashSet<java.lang.String>` `getAllUserVariables(java.lang.String predicate)` Used by pre-analysis to get variables
`static java.lang.String` `getArray(java.lang.String sequence)` Generate a string array from a terminal e.g.
`static int` `getCounter()` Get a new varCounter value
`static java.util.HashSet<java.lang.String>` `getErrorVariables(java.lang.String predicate)` Looks for variable errors to know which variables are used in a predicate
`static java.lang.String` `getPostponedPredicateVariable()` Sends a temporary variable identifier for a postponed predicate.
`static java.lang.String` `getPredicateInput(java.lang.String predicate)` Get the first Before reference to get first intput
`static java.lang.String` `getPredicateOutput(java.lang.String predicate)` Get the last After reference to get last output
`static java.lang.String` `getPredicateVariable()` Sends a temporary variable identifier for a predicate.
`static java.lang.String` `getSavedVariables(java.lang.String data, int id, java.lang.String model)` Gets the saved variable reference for the input data string
`static java.lang.String` `getTemporaryVariable()` Sends a temporary variable identifier.
`static boolean` `moveFile(java.lang.String inFile, java.lang.String outFile)` Move a file to an other place or name
`static Expression` `percent2int(java.lang.String motif, java.lang.String percent)` Compute a percentage calculation on motif to get a size
`static void` `sendMail(java.util.Properties props, java.lang.String[] recipients, java.lang.String subject, java.lang.String message, java.lang.String from)` Sends a mail to a list of recipents
`static void` `showUsage(org.apache.commons.cli.Options usageOptions)` Show on output stream the usage based on a list of options
`static java.lang.Integer[][]` `splitSequence(int sequenceSize, int nbjobs, int minSplitSize, int maxSize, int nbModels)` Split a sequence in several sub sequences according to size and number of processor
`static void` `zipFiles(java.util.Vector<java.lang.String> filenames, java.lang.String outFilename)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### varCounter

    public static int varCounter

  Incremental counter to get unique variable identifiers.

### predCounter

    public static int predCounter

Constructor Detail

### LogolUtils

    public LogolUtils()

Method Detail

### getCounter

    public static int getCounter()

  Get a new varCounter value

  Returns:
    counter value

### percent2int

    public static Expression percent2int(java.lang.String motif,
                                         java.lang.String percent)

  Compute a percentage calculation on motif to get a size

  Parameters:
    `motif` - a prolog List to analyse
    `percent` - the percent variable or value
  Returns:
    an expression with required prolog and result variable name

### getTemporaryVariable

    public static java.lang.String getTemporaryVariable()

  Sends a temporary variable identifier. Id is incremented at each call.

  Returns:
    a temporary variable name

### getPredicateVariable

    public static java.lang.String getPredicateVariable()

  Sends a temporary variable identifier for a predicate. Id is incremented at each call.

  Returns:
    a predicate name

### getPostponedPredicateVariable

    public static java.lang.String getPostponedPredicateVariable()

  Sends a temporary variable identifier for a postponed predicate. Id is incremented at each call.

  Returns:
    a postponed predicate name

### addParent

    public static java.lang.String addParent(LogolVariable lvar,
                                             int id)

### getArray

    public static java.lang.String getArray(java.lang.String sequence)

  Generate a string array from a terminal e.g. a list of chars: "acgt" => ['a','c','g','t']

  Parameters:
    `sequence` - input terminal
  Returns:
    the string representation of the array

### getAllUserVariables

    public static java.util.HashSet<java.lang.String> getAllUserVariables(java.lang.String predicate)

  Used by pre-analysis to get variables

  Parameters:
    `predicate` -
  Returns:
    a Set of variables saved in grammar for the current predicate

### getSavedVariables

    public static java.lang.String getSavedVariables(java.lang.String data,
                                                     int id,
                                                     java.lang.String model)

  Gets the saved variable reference for the input data string

  Parameters:
    `data` -
    `id` - current id of variable, -1 if not applicable
    `model` - current model
  Returns:
    a List of data reference

### getErrorVariables

    public static java.util.HashSet<java.lang.String> getErrorVariables(java.lang.String predicate)

  Looks for variable errors to know which variables are used in a predicate

  Parameters:
    `predicate` - predicate string to analyse to get used variables
  Returns:
    Set of used variables (unique)

### getAllUsedVariables

    public static java.util.HashSet<java.lang.String> getAllUsedVariables(java.lang.String predicate)

  Looks for variable references to know which variables are used in a predicate

  Parameters:
    `predicate` - predicate string to analyse to get used variables
  Returns:
    Set of used variables (unique)

### getPredicateInput

    public static java.lang.String getPredicateInput(java.lang.String predicate)

  Get the first Before reference to get first intput

  Parameters:
    `predicate` - Predicate to analyse
  Returns:
    reference to the input variable

### getPredicateOutput

    public static java.lang.String getPredicateOutput(java.lang.String predicate)

  Get the last After reference to get last output

  Parameters:
    `predicate` - Predicate to analyse
  Returns:
    reference to the output variable

### showUsage

    public static void showUsage(org.apache.commons.cli.Options usageOptions)

  Show on output stream the usage based on a list of options

  Parameters:
    `usageOptions` - List of options

### convert2Fasta

    public static void convert2Fasta(java.lang.String inputFile,
                                     java.lang.String outputFile)

  Convert a Logol output XML file to fasta format

  Parameters:
    `inputFile` - Logol output
    `outputFile` - New fasta result file

### zipFiles

    public static void zipFiles(java.util.Vector<java.lang.String> filenames,
                                java.lang.String outFilename)

### sendMail

    public static void sendMail(java.util.Properties props,
                                java.lang.String[] recipients,
                                java.lang.String subject,
                                java.lang.String message,
                                java.lang.String from)
                         throws javax.mail.MessagingException

  Sends a mail to a list of recipents

  Parameters:
    `props` - Mail properties (see javax.mail), such as smtp host....
    `recipients` - List of "To:"
    `subject` - Subject of the message
    `message` - Message to send
    `from` - "From:" user to use
  Throws:
    `javax.mail.MessagingException`

### countGrammarModels

    public static int countGrammarModels(java.lang.String grammar,
                                         java.lang.String model)
                                  throws java.io.IOException,
                                         GrammarException

  Counts the number of models required to match the sequence

  Parameters:
    `grammar` - Logol Grammar file
    `model` - Model file
  Returns:
    Number of models found
  Throws:
    `java.io.IOException`
    `GrammarException`

### splitSequence

    public static java.lang.Integer[][] splitSequence(int sequenceSize,
                                                      int nbjobs,
                                                      int minSplitSize,
                                                      int maxSize,
                                                      int nbModels)

  Split a sequence in several sub sequences according to size and number of processor

  Parameters:
    `sequenceSize` - size of input sequence
    `nbjobs` - Max number of jobs (number of processors or number of drm jobs)
    `minSplitSize` - minimum size to split a sequence
    `maxSize` - Maximal size of a match
  Returns:
    An array of posision on sequence to create sub-sequences

### copyFile

    public static boolean copyFile(java.lang.String inFile,
                                   java.lang.String outFile)

  Copy a file content to an other

  Parameters:
    `inFile` - path to input
    `outFile` - path to output
  Returns:
    true if copy succeeded, false in case of error

### moveFile

    public static boolean moveFile(java.lang.String inFile,
                                   java.lang.String outFile)

  Move a file to an other place or name

  Parameters:
    `inFile` - input file
    `outFile` - output file
  Returns:
    true of move succeeded, else returns false