From c98347f145e9e938ca97fad69a1d1d3bd3e44bd2 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Wed, 4 Nov 2009 20:07:13 +0000 Subject: [PATCH] corrected ALIGN implementation git-svn-id: http://biopieces.googlecode.com/svn/trunk@747 74ccb610-7750-0410-82ae-013aeee3265d --- code_perl/Maasha/KISS/IO.pm | 38 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/code_perl/Maasha/KISS/IO.pm b/code_perl/Maasha/KISS/IO.pm index a24f696..f7fa8d9 100644 --- a/code_perl/Maasha/KISS/IO.pm +++ b/code_perl/Maasha/KISS/IO.pm @@ -24,6 +24,8 @@ package Maasha::KISS::IO; # Routines for parsing and emitting KISS records. +# http://code.google.com/p/biopieces/wiki/KissFormat + # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -53,28 +55,6 @@ use constant { BLOCK_TYPE => 11, }; -# 0 1 2 -# 012345678901234567890 -# --------------------- S.aur complete genome -# -===__===- TAG_000001 -# 0123456789 -# -# S_ID = 'S.aur complete genome' -# S_BEG = 3 -# S_END = 12 -# Q_ID = 'TAG_000001' -# SCORE => 1 -# STRAND => + -# HITS => 31 -# ALIGN => 0:A>T,3:G>C -# BLOCK_COUNT => 2 -# BLOCK_BEGS => 1,6 -# BLOCK_LENS => 3,3 -# BLOCK_TYPE => 1,1 -# -# -# 'S.aur complete genome' 3 12 'TAG_000001' 1 + 31 2 1,6 3,3 1,1 - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -309,11 +289,13 @@ sub kiss_align # Returns a string. - my ( $align, $pos, $s_symbol, $q_symbol, $s_seq, $q_seq ); + my ( $align, $pos, $s_symbol, $q_symbol, $s_seq, $q_seq, $insertions ); $s_seq = substr ${ $s_seqref }, $entry->{ 'S_BEG' }, $entry->{ 'S_END' } - $entry->{ 'S_BEG' } + 1; $q_seq = $s_seq; + $insertions = 0; + foreach $align ( split /,/, $entry->{ 'ALIGN' } ) { if ( $align =~ /(\d+):(.)>(.)/ ) @@ -324,16 +306,18 @@ sub kiss_align if ( $s_symbol eq '-' ) # insertion { - substr $s_seq, $pos, 0, $s_symbol; - substr $q_seq, $pos, 0, $q_symbol; + substr $s_seq, $pos + $insertions, 0, $s_symbol; + substr $q_seq, $pos + $insertions, 0, $q_symbol; + + $insertions++; } elsif ( $q_symbol eq '-' ) # deletion { - substr $q_seq, $pos, 1, $q_symbol; + substr $q_seq, $pos + $insertions, 1, $q_symbol; } else # mismatch { - substr $q_seq, $pos, 1, $q_symbol; + substr $q_seq, $pos + $insertions, 1, $q_symbol; } } else -- 2.39.2