X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Falign_pair_seq;h=2b1a710af5951dae853dddbb4b074e8d448cec93;hb=6c1d90a31caa1fe54bedc965ba26940688a31ab0;hp=24b8c659bc2523a5eee247d677d89b07bced845b;hpb=30cc0713754e50b1e832cf166285f65b4cd575c2;p=biopieces.git diff --git a/bp_bin/align_pair_seq b/bp_bin/align_pair_seq index 24b8c65..2b1a710 100755 --- a/bp_bin/align_pair_seq +++ b/bp_bin/align_pair_seq @@ -1,6 +1,6 @@ -#!/usr/bin/env perl +#!/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,79 +18,43 @@ # 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 warnings; -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 ( $options, $in, $out, $count, $record, @records ); - -$options = Maasha::Biopieces::parse_options(); - -$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } ); -$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } ); - -$count = 0; - -while ( $record = Maasha::Biopieces::get_record( $in ) ) -{ - if ( defined $record->{ "SEQ" } and $count < 2 ) - { - push @records, $record; +options = Biopieces.options_parse(ARGV) - $count++; +Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| + entries = [] - if ( $count == 2 ) - { - $records[ 0 ]->{ 'SEQ' } = lc $records[ 0 ]->{ 'SEQ' }; - $records[ 1 ]->{ 'SEQ' } = lc $records[ 1 ]->{ 'SEQ' }; + input.each_record do |record| + if record[:SEQ_NAME] and record[:SEQ] + entries << Seq.new_bp(record) - my $matches = Maasha::AlignTwoSeq::align_two_seq( { 'Q_SEQ' => \$records[ 0 ]->{ 'SEQ' } , 'S_SEQ' => \$records[ 1 ]->{ 'SEQ' } }, [] ); - - print Dumper( $matches ); + if entries.size == 2 + Align.pair(entries[0], entries[1]) - Maasha::AlignTwoSeq::insert_indels( $matches, \$records[ 0 ]->{ 'SEQ' } ,\$records[ 1 ]->{ 'SEQ' } ); + entries.each do |entry| + output.puts entry.to_bp + end - map { Maasha::Biopieces::put_record( $_, $out ) } @records; - } - } + entries = [] + end else - { - Maasha::Biopieces::put_record( $record, $out ); - } -} - -Maasha::Biopieces::close_stream( $in ); -Maasha::Biopieces::close_stream( $out ); - - -# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - -BEGIN -{ - Maasha::Biopieces::status_set(); -} - - -END -{ - Maasha::Biopieces::status_log(); -} - + output.puts record + end + end +end # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<