X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Falign_pair_seq;h=2b1a710af5951dae853dddbb4b074e8d448cec93;hb=6b4c2afa4b4b581a9c36083a1d059e846ee4b560;hp=1f92640b15704b64900ebf52d4def7bdfc57a255;hpb=3424045c3eb23ca9da6241f33cdfa1dd629373db;p=biopieces.git diff --git a/bp_bin/align_pair_seq b/bp_bin/align_pair_seq index 1f92640..2b1a710 100755 --- a/bp_bin/align_pair_seq +++ b/bp_bin/align_pair_seq @@ -1,6 +1,6 @@ -#!/usr/bin/env perl -w +#!/usr/bin/env ruby -# Copyright (C) 2007-2009 Martin A. Hansen. +# Copyright (C) 2007-2012 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 @@ -18,83 +18,45 @@ # http://www.gnu.org/copyleft/gpl.html - -# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - -# Align sequences in the stream. - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +# This program is part of the Biopieces framework (www.biopieces.org). -use strict; -use Maasha::Biopieces; -use Maasha::AlignTwoSeq; -use Data::Dumper; +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +# Find similar sequences between query sequences from the stream and a database. # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +require 'pp' +require 'maasha/biopieces' +require 'maasha/align' -my ( $run_time_beg, $run_time_end, $options, $in, $out, $count, $record, @records ); +options = Biopieces.options_parse(ARGV) -$options = Maasha::Biopieces::parse_options(); +Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| + entries = [] -$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } ); -$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } ); + input.each_record do |record| + if record[:SEQ_NAME] and record[:SEQ] + entries << Seq.new_bp(record) -$count = 0; + if entries.size == 2 + Align.pair(entries[0], entries[1]) -while ( $record = Maasha::Biopieces::get_record( $in ) ) -{ - if ( defined $record->{ "SEQ" } and $count < 2 ) - { - push @records, $record; + entries.each do |entry| + output.puts entry.to_bp + end - $count++; - - if ( $count == 2 ) - { - $records[ 0 ]->{ 'SEQ' } = lc $records[ 0 ]->{ 'SEQ' }; - $records[ 1 ]->{ 'SEQ' } = lc $records[ 1 ]->{ 'SEQ' }; - - my $matches = Maasha::AlignTwoSeq::align_two_seq( \$records[ 0 ]->{ 'SEQ' } ,\$records[ 1 ]->{ 'SEQ' } ); - - Maasha::AlignTwoSeq::insert_indels( $matches, \$records[ 0 ]->{ 'SEQ' } ,\$records[ 1 ]->{ 'SEQ' } ); - - map { Maasha::Biopieces::put_record( $_, $out ) } @records; - } - } + entries = [] + end else - { - Maasha::Biopieces::put_record( $record, $out ); - } -} - - -# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - -BEGIN -{ - $run_time_beg = Maasha::Biopieces::run_time(); - - Maasha::Biopieces::log_biopiece(); -} - - -END -{ - Maasha::Biopieces::close_stream( $in ); - Maasha::Biopieces::close_stream( $out ); - - $run_time_end = Maasha::Biopieces::run_time(); - - Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options ); -} - + output.puts record + end + end +end # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< __END__ -