From: martinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Date: Tue, 9 Dec 2008 04:17:24 +0000 (+0000)
Subject: added splice to get_genome_seq
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=aaf181a544ebd64b428453740af5f07236dd3feb;p=biopieces.git

added splice to get_genome_seq

git-svn-id: http://biopieces.googlecode.com/svn/trunk@346 74ccb610-7750-0410-82ae-013aeee3265d
---

diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm
index 41199b3..3d5d994 100644
--- a/code_perl/Maasha/Biopieces.pm
+++ b/code_perl/Maasha/Biopieces.pm
@@ -511,6 +511,7 @@ sub get_options
             len|l=s
             flank|f=s
             mask|m
+            splice|s
         );
     }
     elsif ( $script eq "get_genome_align" )
@@ -2988,7 +2989,7 @@ sub script_get_genome_seq
 
     # Returns nothing.
 
-    my ( $record, $genome, $genome_file, $index_file, $index, $fh, $index_head, $index_beg, $index_len, $beg, $len, %lookup_hash, @begs, @lens, $i );
+    my ( $record, $genome, $genome_file, $index_file, $index, $fh, $index_head, $index_beg, $index_len, $beg, $len, %lookup_hash, @begs, @lens, $i, $seq );
 
     $options->{ "flank" } ||= 0;
 
@@ -3094,18 +3095,31 @@ sub script_get_genome_seq
 
             if ( $options->{ "mask" } )
             {
-                if ( $record->{ "BLOCKCOUNT" } > 1 ) # uppercase hit block segments and lowercase the rest.
+                if ( $record->{ "BLOCK_COUNT" } > 1 ) # uppercase hit block segments and lowercase the rest.
                 {
                     $record->{ "SEQ" } = lc $record->{ "SEQ" };
                 
                     @begs = split ",", $record->{ "Q_BEGS" };
-                    @lens = split ",", $record->{ "BLOCKSIZES" };
+                    @lens = split ",", $record->{ "BLOCK_LENS" };
 
                     for ( $i = 0; $i < @begs; $i++ ) {
                         substr $record->{ "SEQ" }, $begs[ $i ], $lens[ $i ], uc substr $record->{ "SEQ" }, $begs[ $i ], $lens[ $i ];
                     }
                 }
             }
+            elsif ( $options->{ "splice" } )
+            {
+                if ( $record->{ "BLOCK_COUNT" } > 1 ) # splice block sequences
+                {
+                    $seq  = "";
+                    @begs = split ",", $record->{ "Q_BEGS" };
+                    @lens = split ",", $record->{ "BLOCK_LENS" };
+
+                    for ( $i = 0; $i < @begs; $i++ ) {
+                        $seq .= substr $record->{ "SEQ" }, $begs[ $i ], $lens[ $i ];
+                    }
+                }
+            }
         }
 
         put_record( $record, $out );