class PatScanError < StandardError; end;
class PatScan
- def initialize(options, tmpdir, file_pattern, file_patscan, cpus)
+ def initialize(options, tmpdir, file_pattern, cpus)
@options = options
@file_pattern = file_pattern
- @file_patscan = file_patscan
@cpus = cpus
@files_fasta = Dir.glob(File.join(tmpdir, "*.fna"))
end
def parse_results
+ files_result = Dir.glob(File.join(tmpdir, "*.out"))
+
matches = {}
- Fasta.open(@file_patscan, mode='r') do |ios|
- ios.each do |entry|
- if entry.seq_name =~ /^(\d+):\[(\d+),(\d+)\]$/
- name = $1.to_i
- start = $2.to_i - 1
- stop = $3.to_i - 1
- matches[name] = [start, stop - start + 1] unless matches.has_key? name
- else
- raise "Failed to parse sequence name: #{entry.seq_name}"
+ files_result.each do |file|
+ Fasta.open(file, mode='r') do |ios|
+ ios.each do |entry|
+ if entry.seq_name =~ /^(\d+):\[(\d+),(\d+)\]$/
+ name = $1.to_i
+ start = $2.to_i - 1
+ stop = $3.to_i - 1
+ matches[name] = [start, stop - start + 1] unless matches.has_key? name
+ else
+ raise "Failed to parse sequence name: #{entry.seq_name}"
+ end
end
end
end
tmpdir = "Tyt" # DEBUG TODO
file_records = File.join(tmpdir, "data.stream")
file_pattern = File.join(tmpdir, "pattern.txt")
-file_patscan = File.join(tmpdir, "patscan.out")
number_file = 0
number_seq = 0
out_fa.close if out_fa.respond_to? :close
end
-patscan = PatScan.new(options, tmpdir, file_pattern, file_patscan, options[:cpus])
+patscan = PatScan.new(options, tmpdir, file_pattern, options[:cpus])
patscan.run
-exit
matches = patscan.parse_results
number_seq = 0