-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmappability_filter
executable file
·68 lines (50 loc) · 1.44 KB
/
mappability_filter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /usr/bin/env ruby
#
# Vivek Rai
# vivekrai@umich.edu
# (c) Parker Lab
#
# July 26, 2018
#
require 'optparse'
require 'ostruct'
options = OpenStruct.new
blacklist = {
'hg19' => [
'/lab/data/reference/human/hg19/annot/wgEncodeDacMapabilityConsensusExcludable.bed.gz',
'/lab/data/reference/human/hg19/annot/wgEncodeDukeMapabilityRegionsExcludable.bed.gz'
],
'mm9' => [
'/lab/work/vivekrai/data/reference/mouse/mm9/annot/mm9.blacklist.bed'
]
}
pargs = OptionParser.new do |opts|
opts.banner = <<~BANNER
USAGE: mappability_filter [BED] [-w] [-b]
Accepts input from a BED file (.gz allowed) or STDIN. Prints to STDOUT.
BANNER
# opts.on('-w', '--whitelist', Array, "Whitelist BED files") do |v|
# options.whitelist = options.whitelist.push(v)
# end
opts.on('-g', '--genome', "Genome (mm9, hg19)") do |v|
options.genome = v
puts(v)
if v.nil? or v.empty?
options.genome = 'hg19'
end
end
opts.on('-b', '--blacklist', Array, "=MANDATORY", "Blacklist BED files") do |v|
options.blacklist = v
end
end.parse!
blacklist = blacklist[options.genome].push(options.blacklist)
input = (STDIN.tty?) ? pargs.first : 'stdin'
#check_bedtools = `which bedtools`
#if check_bedtools.empty?
# STDERR.syswrite "ERROR: bedtools not found. Exiting!"
# exit(1)
STDERR.syswrite <<-MSG
Using blacklists:
- #{blacklist.join "\n- "}
MSG
STDOUT.syswrite `intersectBed -a #{input} -b #{options.blacklist.join ' '} -v`