]> git.donarmstrong.com Git - biopieces.git/commitdiff
tada
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 29 Sep 2008 03:34:22 +0000 (03:34 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 29 Sep 2008 03:34:22 +0000 (03:34 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@272 74ccb610-7750-0410-82ae-013aeee3265d

code_c/Maasha/src/bipartite_scan.c
code_perl/Maasha/Biopieces.pm

index 3646676d8abeac181ba5c41742d1f27ccbe08518..86f3b8a70ada2227855ea821bbaa7a9befe6d2dd 100644 (file)
@@ -33,7 +33,7 @@ uint     *count_array_new( size_t nmemb );
 void      scan_seq( char *seq, size_t seq_len, uint *count_array );
 void      rescan_seq( char *seq, size_t seq_len, uint *count_array, size_t cutoff );
 void      scan_list( list_sl *list, uint *count_array );
-void      rescan_list( list_sl *list, uint *count_array, size_t pos, size_t cutoff );
+void      rescan_list( list_sl *list, uint *count_array, size_t pos, size_t cutoff, uint *output_array );
 bitblock *bitblock_new();
 uint      blocks2motif( uchar bin1, uchar bin2, ushort dist );
 void      count_array_print( uint *count_array, size_t nmemb, size_t cutoff );
@@ -292,6 +292,9 @@ void rescan_seq( char *seq, size_t seq_len, uint *count_array, size_t cutoff )
     node_sl *new_node    = NULL;
     node_sl *old_node    = NULL;
     list_sl *list        = list_sl_new();
+    uint *output_array   = NULL;
+
+    output_array         = mem_get_zero( sizeof( uint ) * ( seq_len + 1 ) );
 
     for ( i = 0; seq[ i ]; i++ )
     {
@@ -336,7 +339,7 @@ void rescan_seq( char *seq, size_t seq_len, uint *count_array, size_t cutoff )
             {
                 // bitblock_list_print( list );   /* DEBUG */
 
-                rescan_list( list, count_array, i, cutoff );
+                rescan_list( list, count_array, i, cutoff, output_array );
 
                 mem_free( &list->first->val );
 
@@ -350,10 +353,16 @@ void rescan_seq( char *seq, size_t seq_len, uint *count_array, size_t cutoff )
     {
         // bitblock_list_print( list );  /* DEBUG */
 
-        rescan_list( list, count_array, i, cutoff );
+        rescan_list( list, count_array, i, cutoff, output_array );
     }
 
     list_sl_destroy( &list );
+
+    for ( i = 0; i < seq_len; i++ ) {
+        printf( "%zu\t%u\n", i, output_array[ i ] );
+    }
+
+    free( output_array );
 }
 
 
@@ -407,7 +416,7 @@ void scan_list( list_sl *list, uint *count_array )
 }
 
 
-void rescan_list( list_sl *list, uint *count_array, size_t pos, size_t cutoff )
+void rescan_list( list_sl *list, uint *count_array, size_t pos, size_t cutoff, uint *output_array )
 {
     /* Martin A. Hansen, September 2008 */
 
@@ -421,6 +430,7 @@ void rescan_list( list_sl *list, uint *count_array, size_t pos, size_t cutoff )
     bitblock *block1     = NULL;
     bitblock *block2     = NULL;
     int       i          = 0;
+    int       k          = 0;
     ushort    dist       = 0;
     uint      motif_bin  = 0;
     uint      j          = 0;
@@ -455,8 +465,15 @@ void rescan_list( list_sl *list, uint *count_array, size_t pos, size_t cutoff )
 
                 count = count_array[ motif_bin ];
 
-                if ( count > cutoff ) {
-                    printf( "%zu\t%u\t%u\n", pos + j, motif_bin, count );
+                if ( count > cutoff )
+                {
+                    // printf( "%zu\t%u\t%u\n", pos + j, motif_bin, count );
+
+                    for ( k = 0; k < BLOCK_SIZE_NT - 1; k++ )
+                    {
+                        output_array[ pos - j + k - BLOCK_SIZE_NT ]    += count;
+                        output_array[ pos + k - dist - BLOCK_SIZE_NT ] += count;
+                    }
                 }
             }
 
index 820005bb639db752ce0af7dd02566848d49c2884..edaccbb6b4e988a0f3fc08d91ee1d6b37595c440 100644 (file)
@@ -946,7 +946,7 @@ sub get_options
             group|g=s
             priority|p=f
             use_score|u
-            visibility|v=s
+            visibility|V=s
             color|c=s
             chunk_size|C=s
         );
@@ -955,7 +955,7 @@ sub get_options
     push @options, qw(
         stream_in|I=s
         stream_out|O=s
-        verbose
+        verbose|v
         help|?
     );
 
@@ -4477,14 +4477,17 @@ sub script_plot_phastcons_profiles
     $phastcons_file  = Maasha::Config::genome_phastcons( $options->{ "genome" } );
     $phastcons_index = Maasha::Config::genome_phastcons_index( $options->{ "genome" } );
 
-    $index           = Maasha::UCSC::phastcons_index_retrieve( $phastcons_index );
+    $index           = Maasha::UCSC::fixedstep_index_retrieve( $phastcons_index );
     $fh_phastcons    = Maasha::Common::read_open( $phastcons_file );
 
     while ( $record = get_record( $in ) ) 
     {
         if ( $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "CHR_END" } )
         {
-            $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" } );
 
             push @{ $AoA }, [ @{ $scores } ];
         }