Skip to content

Commit

Permalink
bio/Bedtools: added merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pveber committed Feb 7, 2021
1 parent 03f1d9f commit f2c6cda
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/bio/bedtools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,48 @@ let bamtobed ?bed12 ?split ?splitD ?ed ?tag ?cigar bam =
opt "-i" dep bam ;
]
]


let strand_arg x =
string (
match x with
| `plus -> "+"
| `minus -> "-"
)

let operation_arg x =
string (
match x with
| `sum -> "sum"
| `min -> "min"
| `max -> "max"
| `absmin -> "absmin"
| `mean -> "mean"
| `median -> "median"
| `collapse -> "collapse"
| `distinct -> "distinct"
| `count -> "count"
| `count_distinct -> "count_distinct"
)

let concat_beds_dep = function
| [] -> string ""
| xs ->
seq ~sep:"" [
string "<(cat " ;
list ~sep:" " dep xs ;
string "| sort -k1,1 -k2,2n)"
]

let merge ?s ?_S ?d ?c ?o beds =
Workflow.shell ~descr:"bedtools.merge" ~img [
cmd "bedtools" ~stdout:dest [
string "merge" ;
option (flag string "-s") s ;
option (opt "-S" strand_arg) _S ;
option (opt "-d" int) d ;
option (opt "-c" (list ~sep:"," int)) c ;
option (opt "-o" (list ~sep:"," operation_arg)) o ;
opt "-i" concat_beds_dep beds ;
]
]
18 changes: 18 additions & 0 deletions lib/bio/bedtools.mli
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,21 @@ val closest :
'a file ->
#bed3 file list ->
'a file

val merge :
?s:bool ->
?_S:[ `minus | `plus ] ->
?d:int ->
?c:int list ->
?o:[ `absmin
| `collapse
| `count
| `count_distinct
| `distinct
| `max
| `mean
| `median
| `min
| `sum ] list ->
#bed3 file list ->
#bed3 file

0 comments on commit f2c6cda

Please sign in to comment.