Module Cgr.Misc


module Misc: Cgr_misc
Miscellaneous functions.

val warning : string -> unit
warning message displays a given warning message.
val split_string : string -> char list -> string list
Separate the given string according to the given list of characters.
val no_blanks : string -> string
no_blanks s return the given string without any blank characters, i.e. '\n' '\r' ' ' '\t'.
val is_prefix : string -> string -> bool
is_prefix pattern s returns true if string s begins with pattern.
val split_list : int -> 'a list -> 'a list list
split_list len l splits the given list l in a list of lists, each of length len, except eventually the last one.
val tex_escape : string -> string
val load_file : (Pervasives.in_channel -> 'a) -> string -> 'a
load_file f file opens file and use f to read from this file. Then file is closed and the value is returned.
val store_file : (Pervasives.out_channel -> 'a -> unit) -> string -> 'a -> unit
store_file f file v opens file and uses f to write value v to the file. Then closes file.
val group_by_2 : 'a list -> ('a * 'a) list
group_by_2 l returns a list of pairs from the given list.
Raises Failure if the number of elements if not even.
val group_by_4 : 'a list -> ('a * 'a * 'a * 'a) list
group_by_4 l returns a list of 4-uplets from the given list.
Raises Failure if the number of elements if not a multiple of 4.
val print_list : Pervasives.out_channel -> ('a -> string) -> 'a list -> unit
print_list out_channel string_of_ele list prints the given list of elements in the given channel, with a newline after each one; string_of_ele is used to get a string from an element.
val print_array : Pervasives.out_channel -> ('a -> string) -> 'a array -> unit
Same as Misc.print_list but for arrays.
val safe_main : (unit -> unit) -> unit
safe_main f calls f () but handles Sys_error and Failure exceptions by exiting with error code 1.
val in_channel_is_file : Pervasives.in_channel -> bool
in_channel_is_file channel returns true if the given in_channel corresponds to a file.
val out_channel_is_file : Pervasives.out_channel -> bool
out_channel_is_file channel returns true if the given out_channel corresponds to a file.
val list_chop : int -> 'a list -> 'a list
list_chop n l returns the n first elements of list l or the whole list if n >= List.length l.
val list_inter : 'a list -> 'a list -> 'a list
list_inter l1 l2 returns intersection of elements of the given lists.
val iter_lines : (string -> unit) -> Pervasives.in_channel -> unit
iter_lines f in_channel reads in_channel line by line, applying f to each one.
Author(s): Fabrice Lefessant
Version: 1.0
val float_list_average : float list -> float
float_list_average l returns the average from the given list of floats.
val group_dists_results : (string, float) Cgr_distances.dist_matrix ->
(string, float) Cgr_distances.dist_matrix
val make_list : int -> 'a -> 'a list
make_list n ele builds a list of n elements ele.
Author(s): Maxence Guesdon
Version: 1.0
val group_dists_results_by_species : (string, float) Cgr_distances.dist_matrix ->
Cgr_types.species list -> (string, float) Cgr_distances.dist_matrix
group_dists_results_by_species results species groups the given dist results by the given species.
val keep_alpha_nums : string -> string
Return the given string where only alphanums char are kept.
Version: 1.0
val group_for_dists_to_species : (string, float) Cgr_distances.dist_matrix ->
Cgr_types.species list -> (string, float) Cgr_distances.dist_matrix
group_for_dists_to_species dm species returns, for each element the distance to the given list of species .
val file_md5sum : string -> string
file_md5sum file returns the md5sum from the content of the given file.
val md5sum : string -> string
md5sum file returns the md5sum computed on the given string.
val cache_file : string -> string -> string
cache_file file ext returns the name of a cache file for file with extension ext. If a cache directory is specified in Global.cache_dir, then the file is built with the md5sum of the file and the extension. Otherwise, the extension of the given file is replaced by the given one to obtain the cache file. If Global.cache_file_extention is set, the given extension is ignored and the one in Global.cache_file_extention is used.
val iter_file_lines : (string -> unit) -> string -> unit
iter_file_lines f filename reads filename line by line, applying f to each one.
Author(s): Fabrice Lefessant
Version: 1.0
Raises Sys_error if the file could not be opened.
val species_list_of_file : string -> Cgr_types.species list
species_list_of_file file read a list of species from the given file.
val markov_probs_of_string : string -> Cgr_types.markov_probs
val string_of_markov_probs : Cgr_types.markov_probs -> string
val probs_of_string : string -> Cgr_types.probs
val string_of_probs : Cgr_types.probs -> string
val power : int -> int -> int
power n p returns np.
val nroot : int -> int -> int
nroot n p returns n1/p.
val make_int_list : low:int -> high:int -> int list
make_int_list low high builds a list of integers, from low to high.
Author(s): Maxence Guesdon
Version: 1.0
Returns an empty list if low > high.
val file_of_value : string -> 'a -> unit
file_of_value filename v writes a value v to filename using output_value.
Author(s): Fabrice Lefessant
Version: 1.0
Raises Sys_error if the file could not be opened.
val value_of_file : string -> 'a
value_of_file filename reads a value from filename using input_value.
Author(s): Fabrice Lefessant
Version: 1.0
Raises Sys_error if the file could not be opened.
val progress_step : (string -> unit) -> int -> int -> unit
val string_of_opt : string option -> string
string_of_opt s_opt returns the empty string if s_opt = None or s if s_opt = Some s.
Version: 1.0
val opt_of_string : string -> string option
opt_of_string s returns None if the string if empty (length is 0) or Some s.
Version: 1.0
val list_remove_doubles : ?pred:('a -> 'a -> bool) -> 'a list -> 'a list
list_remove_doubles ?pred l remove doubles in the given list l, according to the optional equality function pred. Default equality function is (=).
Author(s): Maxence Guesdon
Version: 1.0
val string_of_file : string -> string
string_of_file filename returns the content of filename in the form of one string.
Author(s): Maxence Guesdon
Version: 1.0
Raises Sys_error if the file could not be opened.
val file_of_string : file:string -> string -> unit
file_of_string ~file str creates a file named filename whose content is str.
Author(s): Fabrice Lefessant
Version: 1.1
Raises Sys_error if the file could not be opened.
val string_of_date : ?fr:bool -> ?wday:bool -> ?hours:bool -> ?secs:bool -> float -> string
Return a string to represent the given date.
Version: 1.0
fr : is false by default but can be set to true to get the date in french rather than in english.
wday : indicates whether do display the week day. Default is false.
hours : indicates whether do display the hour. Default is true.
secs : indicates whether do display the seconds if hours is true. Default is false.
val map_opt : ('a -> 'b) -> 'a option -> 'b option
val list_diff : ?pred:('a -> 'a -> bool) -> 'a list -> 'a list -> 'a list
list_diff l1 l2 returns the list l1 - l2.
Author(s): Maxence Guesdon
Version: 1.0
pred : can be sued to specify the equality predicate (default is (=)).
module Find: sig .. end
Finding files.
val wget : url:string -> file:string -> unit
wget ~url ~file uses the wget command to retrieve the given url and store the contents to the given file.
Raises Failure if an error occurs.
val try_finalize : ('a -> 'b) -> 'a -> ('c -> unit) -> 'c -> 'b
try_finalize f x g y applies f to x and return the result or raises an exception, but in all cases g is applied to y before returning or raising the exception.
Author(s): Didier Rémy
Version: 1.0
val strip_string : string -> string
strip_string s removes all leading and trailing spaces from the given string.
Author(s): Maxence Guesdon
Version: 1.0
val size_of_int : int -> string
To pretty-print a file size (in bytes).