Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Lines: new module to replace Transform.Line_oriented

  • Loading branch information...
commit aa6116bd2aee6c83e5710c550b5ef66c98b9de0b 1 parent 56fc2c6
@agarwal agarwal authored
View
1  _oasis
@@ -50,6 +50,7 @@ Library biocaml
, Biocaml_histogram
, Biocaml_interval_tree
, Biocaml_jaspar
+ , Biocaml_lines
, Biocaml_math
, Biocaml_phred_score
, Biocaml_pwm
View
1  src/lib/biocaml.ml
@@ -12,6 +12,7 @@ module GenomeMap = Biocaml_genomeMap
module Gff = Biocaml_gff
module Histogram = Biocaml_histogram
module Jaspar = Biocaml_jaspar
+module Lines = Biocaml_lines
module Math = Biocaml_math
module Phred_score = Biocaml_phred_score
module Pwm = Biocaml_pwm
View
14 src/lib/biocaml_lines.ml
@@ -0,0 +1,14 @@
+open Biocaml_internal_pervasives
+
+type item = string
+
+let string_to_items s =
+ match String.split ~on:'\n' s with
+ | [] -> assert false
+ | [""] -> [], false
+ | lines ->
+ let n = List.length lines in
+ match List.nth lines (n - 1) with
+ | None -> assert false
+ | Some "" -> List.take lines (n - 1), true
+ | Some _ -> lines, false
View
12 src/lib/biocaml_lines.mli
@@ -0,0 +1,12 @@
+(** Lines of a file. The end of a line is indicated by a single
+ newline character. *)
+
+
+(** A single line, possibly empty, without the ending newline
+ character. *)
+type item = private string
+
+(** [string_to_items s] splits [s] on newline characters, returning
+ the resuling list of lines. The returned bool is true if the final
+ line ended with a newline or false otherwise. *)
+val string_to_items : string -> (item list * bool)
Please sign in to comment.
Something went wrong with that request. Please try again.