]> git.donarmstrong.com Git - biopieces.git/commitdiff
added exon capabilities to calc_fixedstep
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 11 Dec 2008 05:05:17 +0000 (05:05 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 11 Dec 2008 05:05:17 +0000 (05:05 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@355 74ccb610-7750-0410-82ae-013aeee3265d

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

index 8a9bbb44363649bc9558ac8dfc6b26efa48a611d..4cbf81b8aa34aea6c9c9e944fb556129b62f3131 100644 (file)
@@ -2671,22 +2671,21 @@ sub script_calc_fixedstep
 
     # Returns nothing.
 
-    my ( $bed_file, $fh_in, $fh_out, $cols, $record, $file_hash, $chr, $bed_entry, $fixedstep_file, $fixedstep_entry );
+    my ( $bed_file, $fh_in, $fh_out, $record, $file_hash, $chr, $bed_entry, $fixedstep_file, $fixedstep_entry );
 
     $bed_file = "$BP_TMP/calc_fixedstep.bed";
     $fh_out   = Maasha::Filesys::file_write_open( $bed_file );
-    $cols     = 5; # we only need the first 5 BED columns
 
     while ( $record = get_record( $in ) ) 
     {
-        if ( $bed_entry = Maasha::UCSC::BED::biopiece2bed( $record, $cols ) ) {
-            Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh_out, $cols, $options->{ 'check' } );
+        if ( $bed_entry = Maasha::UCSC::BED::biopiece2bed( $record ) ) {
+            Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh_out, undef, $options->{ 'check' } );
         }
     }
 
     close $fh_out;
 
-    $file_hash = Maasha::UCSC::BED::bed_file_split_on_chr( $bed_file, $BP_TMP, $cols );
+    $file_hash = Maasha::UCSC::BED::bed_file_split_on_chr( $bed_file, $BP_TMP );
 
     unlink $bed_file;
 
index 2a0ff237c1ea0f8137a8b6533cdc4df3aa390e84..b8131bf83ab194d0dd32fc53ae1ffd376f514008 100644 (file)
@@ -257,9 +257,9 @@ sub fixedstep_calc_array
 
     # Returns a bitarray.
 
-    my ( $bed, $clones, @array );
+    my ( $bed, $clones, @begs, @lens, $i, @array );
 
-    while ( $bed = Maasha::UCSC::BED::bed_entry_get( $fh_in, 4 ) )
+    while ( $bed = Maasha::UCSC::BED::bed_entry_get( $fh_in ) )
     {
         if ( $use_score ) {
             $clones = $bed->[ score ];
@@ -269,7 +269,19 @@ sub fixedstep_calc_array
             $clones = 1;
         }
 
-        map { $array[ $_ ] += $clones } ( $bed->[ chromStart ] .. $bed->[ chromEnd ] - 1 );
+        if ( $bed->[ blockCount ] and $bed->[ blockCount ] > 1 )
+        {
+            @begs = split ",", $bed->[ blockStarts ];
+            @lens = split ",", $bed->[ blockSizes ];
+
+            for ( $i = 0; $i < @begs; $i++ ) {
+                map { $array[ $_ ] += $clones } ( $begs[ $i ] .. $begs[ $i ] + $lens[ $i ] - 1 );
+            }
+        }
+        else
+        {
+            map { $array[ $_ ] += $clones } ( $bed->[ chromStart ] .. $bed->[ chromEnd ] - 1 );
+        }
     }
 
     return wantarray ? @array : \@array;