From f1fa4478e76cb0ab70ee38d2281415ac4c6a0b6d Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 1 Dec 2009 10:17:08 +0000 Subject: [PATCH] renamed KISS browser to Biopiece browser git-svn-id: http://biopieces.googlecode.com/svn/trunk@784 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/read_kiss | 6 +- bp_bin/upload_to_KISS | 10 +-- bp_bin/{upload_to_ucsc => upload_to_bbrowser} | 0 code_perl/Maasha/KISS.pm | 68 ++++++++++++++++--- 4 files changed, 66 insertions(+), 18 deletions(-) rename bp_bin/{upload_to_ucsc => upload_to_bbrowser} (100%) diff --git a/bp_bin/read_kiss b/bp_bin/read_kiss index 043f08a..74720af 100755 --- a/bp_bin/read_kiss +++ b/bp_bin/read_kiss @@ -30,7 +30,7 @@ use warnings; use strict; use Maasha::Biopieces; use Maasha::Filesys; -use Maasha::KISS::IO; +use Maasha::KISS; # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -58,9 +58,9 @@ if ( $options->{ 'data_in' } ) $num = 1; - while ( $entry = Maasha::KISS::IO::kiss_entry_get( $data_in ) ) + while ( $entry = Maasha::KISS::kiss_entry_get( $data_in ) ) { - if ( $record = Maasha::KISS::IO::kiss2biopiece( $entry ) ) { + if ( $record = Maasha::KISS::kiss2biopiece( $entry ) ) { Maasha::Biopieces::put_record( $record, $out ); } diff --git a/bp_bin/upload_to_KISS b/bp_bin/upload_to_KISS index bb5c208..2a700f1 100755 --- a/bp_bin/upload_to_KISS +++ b/bp_bin/upload_to_KISS @@ -29,7 +29,7 @@ use warnings; use strict; use Maasha::Common; -use Maasha::KISS::IO; +use Maasha::KISS; use Maasha::Biopieces; use Maasha::Fasta; use Maasha::Filesys; @@ -74,7 +74,7 @@ if ( $options->{ 'track_name' } ) while ( $record = Maasha::Biopieces::get_record( $in ) ) { - if ( $entry = Maasha::KISS::IO::biopiece2kiss( $record ) ) + if ( $entry = Maasha::KISS::biopiece2kiss( $record ) ) { if ( not exists $fh_hash{ $entry->{ 'S_ID' } } ) { $fh_hash{ $entry->{ 'S_ID' } } = Maasha::Filesys::file_write_open( "$tmp_dir/$entry->{ 'S_ID' }" ); @@ -82,7 +82,7 @@ if ( $options->{ 'track_name' } ) $fh_out = $fh_hash{ $entry->{ 'S_ID' } }; - Maasha::KISS::IO::kiss_entry_put( $entry, $fh_out ); + Maasha::KISS::kiss_entry_put( $entry, $fh_out ); } Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" }; @@ -118,8 +118,8 @@ if ( $options->{ 'track_name' } ) Maasha::Filesys::file_copy( "$tmp_dir/$key", "$dst_dir/track_data.kiss" ); - Maasha::KISS::IO::kiss_sort( "$dst_dir/track_data.kiss" ); - Maasha::KISS::IO::kiss_index( "$dst_dir/track_data.kiss" ); + Maasha::KISS::kiss_sort( "$dst_dir/track_data.kiss" ); + Maasha::KISS::kiss_index( "$dst_dir/track_data.kiss" ); unlink "$tmp_dir/$key"; } diff --git a/bp_bin/upload_to_ucsc b/bp_bin/upload_to_bbrowser similarity index 100% rename from bp_bin/upload_to_ucsc rename to bp_bin/upload_to_bbrowser diff --git a/code_perl/Maasha/KISS.pm b/code_perl/Maasha/KISS.pm index 290468a..f15dc88 100644 --- a/code_perl/Maasha/KISS.pm +++ b/code_perl/Maasha/KISS.pm @@ -123,20 +123,23 @@ sub kiss_entry_put defined $entry->{ 'S_END' } ) { + Maasha::Common::error( qq(Bad S_BEG value: $entry->{ 'S_BEG' } < 0 ) ) if $entry->{ 'S_BEG' } < 0; + Maasha::Common::error( qq(Bad S_END value: $entry->{ 'S_END' } < $entry->{ 'S_BEG' }) ) if $entry->{ 'S_END' } < $entry->{ 'S_BEG' }; + $fh ||= \*STDOUT; $fields[ S_ID ] = $entry->{ 'S_ID' }; $fields[ S_BEG ] = $entry->{ 'S_BEG' }; $fields[ S_END ] = $entry->{ 'S_END' }; - $fields[ Q_ID ] = $entry->{ 'Q_ID' }; - $fields[ SCORE ] = $entry->{ 'SCORE' }; - $fields[ STRAND ] = $entry->{ 'STRAND' }; - $fields[ HITS ] = $entry->{ 'HITS' }; - $fields[ ALIGN ] = $entry->{ 'ALIGN' }; - $fields[ BLOCK_COUNT ] = $entry->{ 'BLOCK_COUNT' }; - $fields[ BLOCK_BEGS ] = $entry->{ 'BLOCK_BEGS' }; - $fields[ BLOCK_LENS ] = $entry->{ 'BLOCK_LENS' }; - $fields[ BLOCK_TYPE ] = $entry->{ 'BLOCK_TYPE' }; + $fields[ Q_ID ] = $entry->{ 'Q_ID' } || "."; + $fields[ SCORE ] = $entry->{ 'SCORE' } || "."; + $fields[ STRAND ] = $entry->{ 'STRAND' } || "."; + $fields[ HITS ] = $entry->{ 'HITS' } || "."; + $fields[ ALIGN ] = $entry->{ 'ALIGN' } || "."; + $fields[ BLOCK_COUNT ] = $entry->{ 'BLOCK_COUNT' } || "."; + $fields[ BLOCK_BEGS ] = $entry->{ 'BLOCK_BEGS' } || "."; + $fields[ BLOCK_LENS ] = $entry->{ 'BLOCK_LENS' } || "."; + $fields[ BLOCK_TYPE ] = $entry->{ 'BLOCK_TYPE' } || "."; print $fh join( "\t", @fields ), "\n"; } @@ -447,7 +450,52 @@ sub kiss_index_get_blocks } -sub kiss_align +sub kiss_align_enc +{ + # Martin A. Hansen, November 2009. + + # Encodes alignment descriptors for two + # aligned sequences. + + my ( $s_seq, # Subject sequence reference + $q_seq, # Query sequence reference + $offset, # alternate offset - OPTIONAL + ) = @_; + + # Returns a list + + my ( $i, $s, $q, @align ); + + Maasha::Common::error( "Sequence lengths don't match" ) if length ${ $s_seq } != length ${ $q_seq }; + + $offset ||= 0; + + for ( $i = 0; $i < length ${ $s_seq }; $i++ ) + { + $s = uc substr ${ $s_seq }, $i, 1; + $q = uc substr ${ $q_seq }, $i, 1; + + if ( $s eq '-' and $q eq '-' ) + { + # do nothing + } + elsif ( $s eq $q ) + { + $offset++; + } + else + { + push @align, "$offset:$s>$q"; + + $offset++ if not $s eq '-'; + } + } + + return wantarray ? @align : \@align; +} + + +sub kiss_align_dec { # Martin A. Hansen, November 2009. -- 2.39.5