3 # Copyright (C) 2007-2013 Martin A. Hansen.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # http://www.gnu.org/copyleft/gpl.html
21 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
23 # This program is part of the Biopieces framework (www.biopieces.org).
25 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
27 # Assemble ordered overlapping pair-end sequences in the stream.
29 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
31 require 'maasha/biopieces'
32 require 'maasha/fastq'
36 casts << {:long=>'overlap', :short=>'o', :type=>'uint', :mandatory=>false, :default=>1, :allowed=>nil, :disallowed=>"0"}
38 options = Biopieces.options_parse(ARGV, casts)
40 tmpdir = Biopieces.mktmpdir
41 file_in1 = File.join(tmpdir, "in1.fq")
42 file_in2 = File.join(tmpdir, "in2.fq")
43 file_out = File.join(tmpdir, "out.fq")
45 io_in1 = Fastq.open(file_in1, 'w')
46 io_in2 = Fastq.open(file_in2, 'w')
53 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
54 input.each_record do |record|
55 if record[:SEQ_NAME] and record[:SEQ] and record[:SCORES]
56 entry = Seq.new_bp(record)
59 when /^(.+)\/(\d)$/ # Illumina 1.5
63 when /^(.+) (\d):/ # Illumina 1.8
68 $stderr.puts "WARNING: Unmatched sequence name: #{entry.seq_name}"
79 if name1 != nil and name1 == name2
80 io_in1.puts entry1.to_fastq
81 io_in2.puts entry2.to_fastq
93 cmd << " -o #{options[:overlap]}"
94 cmd << " -f #{file_in1}"
95 cmd << " -r #{file_in2}"
96 cmd << " > #{file_out}"
97 cmd << " 2> /dev/null" unless options[:verbose]
99 $stderr.puts cmd if options[:verbose]
103 raise RunTimeError "Error: command failed: #{cmd}" unless $?.success?
105 Fastq.open(file_out) do |ios|
107 output.puts entry.to_bp
113 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<