ngs_server 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +30 -3
- data/bin/ngs_server +71 -9
- data/lib/ngs_server/version.rb +1 -1
- data/lib/ngs_server.rb +7 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -41,6 +41,19 @@ invoke file: genotypes.vcf.gz with coordinates 1073361 to 1238825 on chromosome
|
|
41
41
|
|
42
42
|
* http://0.0.0.0:4569/json/vcf/genotypes.vcf.gz?segment=1&min=1073361&max=1238825
|
43
43
|
|
44
|
+
## find data
|
45
|
+
|
46
|
+
find data sources that have been added
|
47
|
+
|
48
|
+
# ngs_server find <dir> <regex>
|
49
|
+
ngs_server find . * # return everything
|
50
|
+
|
51
|
+
# return found data as link to view in Rover
|
52
|
+
ngs_server find . "*bam" -r 1:1:100000
|
53
|
+
|
54
|
+
# specify server url that ngs_server is running on
|
55
|
+
# so the correct links to sources will be generated
|
56
|
+
ngs_server find . "*bam" -r 1:1:100000 -s http://mydataserver.com
|
44
57
|
|
45
58
|
## Example
|
46
59
|
# create data directory
|
@@ -55,9 +68,23 @@ invoke file: genotypes.vcf.gz with coordinates 1073361 to 1238825 on chromosome
|
|
55
68
|
ngs_server add example-data/
|
56
69
|
|
57
70
|
# start server
|
58
|
-
ngs_server start -
|
71
|
+
ngs_server start -d
|
59
72
|
|
73
|
+
# find data
|
74
|
+
ngs_server find . "*bam"
|
75
|
+
|
76
|
+
# generate Rover url to view data
|
77
|
+
# -r chr:min:max
|
78
|
+
ngs_server find . "*bam" -r 22:14596532:14699000
|
79
|
+
# and then just paste the generate url into a browser
|
80
|
+
|
81
|
+
# to make things quicker you can open the link from
|
82
|
+
# the command line in Google Chrome (Mac only, but linux is similar)
|
83
|
+
open -a "Google Chrome" $(ngs_server find . "*bam" -r 22:14596532:14699000)
|
84
|
+
|
85
|
+
# to see the pure json that ngs_server sends
|
60
86
|
# paste following url in browser
|
61
|
-
# to download region of bam as json in web browser
|
62
87
|
# http://0.0.0.0:4569/json/bam/example-data/small.bam?min=14596532&max=14699000&segment=22
|
63
|
-
|
88
|
+
|
89
|
+
# stop server
|
90
|
+
ngs_server stop
|
data/bin/ngs_server
CHANGED
@@ -14,6 +14,10 @@
|
|
14
14
|
|
15
15
|
options = {}
|
16
16
|
command = ""
|
17
|
+
extensions = {
|
18
|
+
".bam" => "bam",
|
19
|
+
".gz" => "vcf"
|
20
|
+
}
|
17
21
|
|
18
22
|
optparse = OptionParser.new do |opts|
|
19
23
|
opts.banner = "Usage: ngs_server start|stop|add [options]"
|
@@ -41,6 +45,15 @@
|
|
41
45
|
options[:daemonize] = "-d";
|
42
46
|
end
|
43
47
|
|
48
|
+
opts.on( '-r', '--rover REGION:MIN:MAX', 'returns link to Rover to display all matches' ) do |f|
|
49
|
+
options[:rover] = f;
|
50
|
+
end
|
51
|
+
|
52
|
+
options[:serverurl] = "http://0.0.0.0:" + options[:port]
|
53
|
+
opts.on( '-s', '--serverurl URL', 'the url for the server to access the data' ) do |f|
|
54
|
+
options[:serverurl] = f;
|
55
|
+
end
|
56
|
+
|
44
57
|
# opts.on( '-C', '--config', 'configuration file for Thin server' ) do |f|
|
45
58
|
# options[:config] = f;
|
46
59
|
# end
|
@@ -49,8 +62,7 @@
|
|
49
62
|
|
50
63
|
optparse.parse!
|
51
64
|
command = ARGV[0]
|
52
|
-
|
53
|
-
|
65
|
+
|
54
66
|
|
55
67
|
if (command == 'start')
|
56
68
|
# ngsrun options
|
@@ -66,15 +78,65 @@
|
|
66
78
|
#NgsServer.run!
|
67
79
|
elsif (command == 'stop')
|
68
80
|
rackup_path = File.join(path, '../lib/config.ru')
|
81
|
+
puts "Stopping Ngs_Server ..."
|
69
82
|
`thin -R #{rackup_path} -p #{options[:port]} stop`
|
70
83
|
elsif (command == 'add')
|
71
|
-
# source_path = File.absolute_path(ARGV[1])
|
72
|
-
# puts source_path
|
73
|
-
# file_name = File.basename(source_path)
|
74
|
-
# puts file_name
|
75
|
-
# data_dir_path = File.join(path,'../data', file_name)
|
76
|
-
# puts data_dir_path
|
77
|
-
# `ln -s #{source_path} #{data_dir_path}`
|
78
84
|
ngsadd ARGV[1]
|
85
|
+
elsif (command == 'find')
|
86
|
+
|
87
|
+
data_path = File.join(path, '../data')
|
88
|
+
|
89
|
+
if ARGV[1]
|
90
|
+
dir = ARGV[1]
|
91
|
+
else
|
92
|
+
dir = "."
|
93
|
+
end
|
94
|
+
|
95
|
+
if ARGV[2]
|
96
|
+
expr = ARGV[2]
|
97
|
+
else
|
98
|
+
expr = "*"
|
99
|
+
end
|
100
|
+
|
101
|
+
Dir.chdir(data_path)
|
102
|
+
sources = `find -L #{dir} -iname "#{expr}"`.split("\n")
|
103
|
+
|
104
|
+
curated_sources = Array.new
|
105
|
+
sources.each do |source|
|
106
|
+
if (File.extname(source) == ".bam" || File.extname(File.basename(source, ".gz")) == ".vcf")
|
107
|
+
curated_sources.push source
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
if (!options[:rover].nil?)
|
113
|
+
rover_url = "http://chmille4.github.com/Rover/index.html"
|
114
|
+
|
115
|
+
names_url = "names=" + curated_sources.join(',')
|
116
|
+
|
117
|
+
data_urls = []
|
118
|
+
curated_sources.each do |s|
|
119
|
+
str = options[:serverurl] + "/json/"
|
120
|
+
str += extensions[ File.extname(s) ] + "/"
|
121
|
+
str += s
|
122
|
+
data_urls.push(str)
|
123
|
+
end
|
124
|
+
data_url = "urls=" + data_urls.join(',')
|
125
|
+
|
126
|
+
segment, min, max = options[:rover].split(":")
|
127
|
+
segment_url = "segment=" + segment
|
128
|
+
min_url = "min=" + min
|
129
|
+
max_url = "max=" + max
|
130
|
+
|
131
|
+
display_url = "display=" + Array.new(curated_sources.size) { |i| "collapse" }.join(',')
|
132
|
+
types_url = "types=" + Array.new(curated_sources.size) { |i| "" }.join(',')
|
133
|
+
|
134
|
+
params_url = [names_url, data_url, segment_url, min_url, max_url, display_url, types_url].join('&')
|
135
|
+
|
136
|
+
puts rover_url + "?" + params_url
|
137
|
+
else
|
138
|
+
puts curated_sources
|
139
|
+
end
|
140
|
+
|
79
141
|
end
|
80
142
|
|
data/lib/ngs_server/version.rb
CHANGED
data/lib/ngs_server.rb
CHANGED
@@ -40,14 +40,19 @@ class MyNgsServer < Sinatra::Base
|
|
40
40
|
|
41
41
|
end
|
42
42
|
|
43
|
-
get '/json/sources
|
43
|
+
get '/json/sources/*' do |path|
|
44
44
|
|
45
45
|
# turn off json content type so a preflight cors doesn't need to be done
|
46
46
|
# content_type :json
|
47
47
|
response['Access-Control-Allow-Origin'] = '*';
|
48
48
|
|
49
|
+
extension = File.basename(path)
|
50
|
+
dirpath = File.dirname(path)
|
51
|
+
|
52
|
+
private_dir = "private"
|
53
|
+
|
49
54
|
# invoke with eg: base_url/json/vcf/file=ALL.2of4intersection.20100804.sites.vcf.gz?min=6992179&max=6992190&segment=1
|
50
|
-
list = `find -L #{datapath} -name '*#{
|
55
|
+
list = `find -L #{datapath}/#{dirpath} -not \\( -name private -prune \\) -name '*#{extension}' | awk -F#{datapath}/ '{print $2}'`
|
51
56
|
list.split("\n").to_json
|
52
57
|
|
53
58
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ngs_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "0.
|
5
|
+
version: "0.7"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chase Miller
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-01-
|
13
|
+
date: 2012-01-31 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|