-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathruby-otf-vcf.rb
executable file
·68 lines (49 loc) · 1.45 KB
/
ruby-otf-vcf.rb
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
require 'java'
require 'lib/jar/htsjdk-1.119.jar' #http://sourceforge.net/projects/picard/files/latest/download?source=files
require 'lib/jar/bzip2.jar' #wget http://www.kohsuke.org/bzip2/bzip2.jar
require 'rdf'
require 'rdf/ntriples'
require 'sparql'
require 'securerandom'
# require 'lib/indexing'
require 'lib/otf'
pool = OTF::FilePool.new
ARGV[0].split(',').each do |file|
pool.add file
end
# unless File.exists?("#{file_name}.fsidx")
# print "Creting Index for text search..."
# index = ::FsIndex::Index.new file_name
# end
query = File.open(ARGV[1]).read
# file = java.io.File.new(ARGV[0])
# fileidx = java.io.File.new("#{ARGV[0]}.tbi")
# vcf = VCFFileReader.new(file, fileidx, true)
triplets = []
chr = nil
start = nil
stop = nil
vcf_parameters = File.open(ARGV[2]).read
chr, start, final = OTF::Query.get_parameters(query, vcf_parameters)
chr_val = chr.last.to_s
start_val = start.last.to_s
final_val = final.last.to_s
repository = RDF::Graph.new
if chr_val && start_val && final_val
pool.readers.each do |vcf_reader|
vcf_reader.query(chr_val, start_val.to_i, final_val.to_i).each do |vc|
OTF::VCF.new(vc, YAML.load_file(ARGV[3])).to_rdf.each do |vcf_statement|
repository << vcf_statement
# puts vcf_statement.inspect
end
end
end
end
#repository.each do |s|
# puts s.inspect
#end
# repository.graphs.enum_triple do |t|
# puts t
# end
puts SPARQL.execute(query, repository, options={}).inspect