--- /dev/null
+#!/usr/bin/env perl
+
+# Copyright (C) 2007-2009 Martin A. Hansen.
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Find genes in sequences in stream.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+use warnings;
+use strict;
+use Data::Dumper;
+use Maasha::Common;
+use Maasha::Biopieces;
+use Maasha::Filesys;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $options, $in, $out, $record, $tmp_dir, $tmp_file, $fh_out, $fh_in, $entry, $chunk, @lines, $line, $s_id, $type, $s_beg, $s_end, $strand, @fields );
+
+$options = Maasha::Biopieces::parse_options();
+
+$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
+$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
+
+$tmp_dir = Maasha::Biopieces::get_tmpdir();
+$tmp_file = "$tmp_dir/tmp.seq";
+$fh_out = Maasha::Filesys::file_write_open( $tmp_file );
+
+while ( $record = Maasha::Biopieces::get_record( $in ) )
+{
+ if ( $entry = Maasha::Fasta::biopiece2fasta( $record ) ) {
+ Maasha::Fasta::put_entry( $entry, $fh_out );
+ }
+
+ Maasha::Biopieces::put_record( $record, $out );
+}
+
+Maasha::Common::run( "draft_prodigal.pl", "< $tmp_file > $tmp_file.out 2> /dev/null" );
+
+$fh_in = Maasha::Filesys::file_read_open( "$tmp_file.out" );
+
+$/ = "//\n";
+
+while ( $chunk = <$fh_in> )
+{
+ chomp $chunk;
+
+ @lines = split /\n/, $chunk;
+
+ $line = shift @lines;
+
+ if ( $line =~ /.*>(.+)/ )
+ {
+ $s_id = $1;
+
+ foreach $line ( @lines )
+ {
+ @fields = split " ", $line;
+
+ $type = $fields[ 0 ];
+
+ if ( $fields[ 1 ] =~ /complement/ ) {
+ $strand = "-";
+ } else {
+ $strand = "+";
+ }
+
+ if ( $fields[ 1 ] =~ /(\d+)\.\.>?(\d+)/ )
+ {
+ $s_beg = $1;
+ $s_end = $2;
+ }
+ else
+ {
+ Maasha::Common::error( qq(BAD locator: $line) );
+ }
+
+ $record = {
+ S_ID => $s_id,
+ S_BEG => $s_beg - 1,
+ S_END => $s_end - 1,
+ Q_ID => $type,
+ STRAND => $strand,
+ };
+
+ Maasha::Biopieces::put_record( $record, $out );
+ }
+ }
+ else
+ {
+ Maasha::Commom::error( qq(BAD definition: $line) );
+ }
+}
+
+close $fh_in;
+
+$/ = "\n";
+
+Maasha::Biopieces::close_stream( $in );
+Maasha::Biopieces::close_stream( $out );
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+BEGIN
+{
+ Maasha::Biopieces::status_set();
+}
+
+
+END
+{
+ Maasha::Biopieces::status_log();
+}
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+__END__