]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed ugly bug
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 25 Sep 2008 02:06:09 +0000 (02:06 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 25 Sep 2008 02:06:09 +0000 (02:06 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@270 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/Biopieces.pm
code_perl/Maasha/UCSC.pm

index 6c38e430698324319052305b5c1c3afcf5fd84dc..820005bb639db752ce0af7dd02566848d49c2884 100644 (file)
@@ -3133,15 +3133,15 @@ sub script_get_genome_phastcons
     {
         if ( $record->{ "REC_TYPE" } eq "BED" )
         {
-            $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "CHR" }, $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "flank" } );
+            $scores = Maasha::UCSC::fixedstep_index_lookup( $index, $fh_phastcons, $record->{ "CHR" }, $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "flank" } );
         }
         elsif ( $record->{ "REC_TYPE" } eq "PSL" )
         {
-            $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $options->{ "flank" } );
+            $scores = Maasha::UCSC::fixedstep_index_lookup( $index, $fh_phastcons, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $options->{ "flank" } );
         }
         elsif ( $record->{ "REC_TYPE" } eq "BLAST" )
         {
-            $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $options->{ "flank" } );
+            $scores = Maasha::UCSC::fixedstep_index_lookup( $index, $fh_phastcons, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $options->{ "flank" } );
         }
 
         $record->{ "PHASTCONS" } = join ",", @{ $scores } if @{ $scores };
index 01cb884c7903a3ea62ee8222a5349d97be1101c4..303b6b7038f257e97040f312580718923efdfe02 100644 (file)
@@ -39,24 +39,24 @@ use Maasha::Calc;
 use Maasha::Matrix;
 
 use constant {
-    CHR_BEG      => 0,
-    NEXT_CHR_BEG => 1,
+    FS_CHR_BEG      => 0,
+    FS_NEXT_CHR_BEG => 1,
+    FS_CHR_END      => 2,
+    FS_INDEX_BEG    => 3,
+    FS_INDEX_LEN    => 4,
+
+    CHR          => 0,
+    CHR_BEG      => 1,
     CHR_END      => 2,
-    INDEX_BEG    => 3,
-    INDEX_LEN    => 4,
-
-    CHR        => 0,
-    CHR_BEG    => 1,
-    CHR_END    => 2,
-    Q_ID       => 3,
-    SCORE      => 4,
-    STRAND     => 5,
-    THICK_BEG  => 6,
-    THICK_END  => 7,
-    ITEMRGB    => 8,
-    BLOCKCOUNT => 9,
-    BLOCKSIZES => 10,
-    Q_BEGS     => 11,
+    Q_ID         => 3,
+    SCORE        => 4,
+    STRAND       => 5,
+    THICK_BEG    => 6,
+    THICK_END    => 7,
+    ITEMRGB      => 8,
+    BLOCKCOUNT   => 9,
+    BLOCKSIZES   => 10,
+    Q_BEGS       => 11,
 };
 
 @ISA = qw( Exporter );
@@ -1067,10 +1067,10 @@ sub fixedstep_index_create
     foreach $chr ( keys %index )
     {
         for ( $i = 0; $i < @{ $index{ $chr } } - 1; $i++ ) {
-            $index{ $chr }->[ $i ]->[ NEXT_CHR_BEG ] = $index{ $chr }->[ $i + 1 ]->[ 0 ];
+            $index{ $chr }->[ $i ]->[ FS_NEXT_CHR_BEG ] = $index{ $chr }->[ $i + 1 ]->[ 0 ];
         }
 
-        $index{ $chr }->[ -1 ]->[ NEXT_CHR_BEG ] = $index{ $chr }->[ -1 ]->[ CHR_END ] + 1;
+        $index{ $chr }->[ -1 ]->[ FS_NEXT_CHR_BEG ] = $index{ $chr }->[ -1 ]->[ FS_CHR_END ] + 1;
     }
 
     return wantarray ? %index : \%index;
@@ -1137,7 +1137,7 @@ sub fixedstep_index_lookup
     $chr_beg -= $flank;
     $chr_end += $flank;
 
-#    print "chr_beg->$chr_beg   chr_end->$chr_end   flank->$flank\n";
+    # print "chr_beg->$chr_beg   chr_end->$chr_end   flank->$flank\n";
 
     if ( exists $index->{ $chr } )
     {
@@ -1164,14 +1164,14 @@ sub fixedstep_index_lookup
 
         if ( $index_beg == $index_end )
         {
-            $beg = Maasha::Calc::max( $chr_beg, $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] );
-            $end = Maasha::Calc::min( $chr_end, $index->{ $chr }->[ $index_end ]->[ CHR_END ] );
+            $beg = Maasha::Calc::max( $chr_beg, $index->{ $chr }->[ $index_beg ]->[ FS_CHR_BEG ] );
+            $end = Maasha::Calc::min( $chr_end, $index->{ $chr }->[ $index_end ]->[ FS_CHR_END ] );
         
-            if ( $beg <= $index->{ $chr }->[ $index_beg ]->[ CHR_END ] and $end >= $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] )
+            if ( $beg <= $index->{ $chr }->[ $index_beg ]->[ FS_CHR_END ] and $end >= $index->{ $chr }->[ $index_beg ]->[ FS_CHR_BEG ] )
             {
                 @vals = split "\n", Maasha::Common::file_read(
                     $fh,
-                    $index->{ $chr }->[ $index_beg ]->[ INDEX_BEG ] + 6 * ( $beg - $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ),
+                    $index->{ $chr }->[ $index_beg ]->[ FS_INDEX_BEG ] + 6 * ( $beg - $index->{ $chr }->[ $index_beg ]->[ FS_CHR_BEG ] ),
                     6 * ( $end - $beg + 1 ),
                 );
             }
@@ -1182,21 +1182,21 @@ sub fixedstep_index_lookup
         }
         else
         {
-            $beg = Maasha::Calc::max( $chr_beg, $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] );
+            $beg = Maasha::Calc::max( $chr_beg, $index->{ $chr }->[ $index_beg ]->[ FS_CHR_BEG ] );
 
 #            print Dumper( $beg, $index->{ $chr }->[ $index_beg ] );
-#            print Dumper( "next", $index->{ $chr }->[ $index_beg ]->[ NEXT_CHR_BEG ] );
+#            print Dumper( "next", $index->{ $chr }->[ $index_beg ]->[ FS_NEXT_CHR_BEG ] );
 
             #      beg         next
             #      v           v
             #  |||||||||.......
 
-            if ( $beg <= $index->{ $chr }->[ $index_beg ]->[ CHR_END ] )
+            if ( $beg <= $index->{ $chr }->[ $index_beg ]->[ FS_CHR_END ] )
             {
                 @vals = split "\n", Maasha::Common::file_read(
                     $fh,
-                    $index->{ $chr }->[ $index_beg ]->[ INDEX_BEG ] + 6 * ( $beg - $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ),
-                    6 * ( $index->{ $chr }->[ $index_beg ]->[ CHR_END ] - $beg + 1 ),
+                    $index->{ $chr }->[ $index_beg ]->[ FS_INDEX_BEG ] + 6 * ( $beg - $index->{ $chr }->[ $index_beg ]->[ FS_CHR_BEG ] ),
+                    6 * ( $index->{ $chr }->[ $index_beg ]->[ FS_CHR_END ] - $beg + 1 ),
                 );
 
                 for ( $c = 0; $c < @vals; $c++ ) {
@@ -1204,18 +1204,18 @@ sub fixedstep_index_lookup
                 } 
             }
 
-            $end = Maasha::Calc::min( $chr_end, $index->{ $chr }->[ $index_end ]->[ CHR_END ] );
+            $end = Maasha::Calc::min( $chr_end, $index->{ $chr }->[ $index_end ]->[ FS_CHR_END ] );
 
-            if ( $end <= $index->{ $chr }->[ $index_end ]->[ CHR_END ] )
+            if ( $end <= $index->{ $chr }->[ $index_end ]->[ FS_CHR_END ] )
             {
                 @vals = split "\n", Maasha::Common::file_read(
                     $fh,
-                    $index->{ $chr }->[ $index_end ]->[ INDEX_BEG ],
-                    6 * ( $end - $index->{ $chr }->[ $index_end ]->[ CHR_BEG ] + 1 ),
+                    $index->{ $chr }->[ $index_end ]->[ FS_INDEX_BEG ],
+                    6 * ( $end - $index->{ $chr }->[ $index_end ]->[ FS_CHR_BEG ] + 1 ),
                 );
 
                 for ( $c = 0; $c < @vals; $c++ ) {
-                    $scores->[ $c + $index->{ $chr }->[ $index_end ]->[ CHR_BEG ] - $chr_beg ] = $vals[ $c ];
+                    $scores->[ $c + $index->{ $chr }->[ $index_end ]->[ FS_CHR_BEG ] - $chr_beg ] = $vals[ $c ];
                 }
             }
 
@@ -1223,12 +1223,12 @@ sub fixedstep_index_lookup
             {
                 @vals = split "\n", Maasha::Common::file_read(
                     $fh,
-                    $index->{ $chr }->[ $i ]->[ INDEX_BEG ],
-                    6 * ( $index->{ $chr }->[ $i ]->[ CHR_END ] - $index->{ $chr }->[ $i ]->[ CHR_BEG ] + 1 ),
+                    $index->{ $chr }->[ $i ]->[ FS_INDEX_BEG ],
+                    6 * ( $index->{ $chr }->[ $i ]->[ FS_CHR_END ] - $index->{ $chr }->[ $i ]->[ FS_CHR_BEG ] + 1 ),
                 );
 
                 for ( $c = 0; $c < @vals; $c++ ) {
-                    $scores->[ $c + $index->{ $chr }->[ $i ]->[ CHR_BEG ] - $chr_beg ] = $vals[ $c ];
+                    $scores->[ $c + $index->{ $chr }->[ $i ]->[ FS_CHR_BEG ] - $chr_beg ] = $vals[ $c ];
                 } 
             }
         }