]> git.donarmstrong.com Git - biopieces.git/commitdiff
minor fixes
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 8 Dec 2008 05:55:36 +0000 (05:55 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 8 Dec 2008 05:55:36 +0000 (05:55 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@342 74ccb610-7750-0410-82ae-013aeee3265d

code_c/Maasha/src/Makefile
code_c/Maasha/src/bed2fixedstep.c
code_c/Maasha/src/lib/barray.c
code_perl/Maasha/Biopieces.pm
code_perl/Maasha/UCSC.pm

index cee84b87504966f08778d1e5428e6cea6e8a0988..d1e8d844e0f60e26564966e73afc51e83e7ad3b2 100644 (file)
@@ -43,7 +43,6 @@ repeat-O-matic: repeat-O-matic.c
 clean:
        cd $(LIB_DIR) && ${MAKE} clean
        cd $(TEST_DIR) && ${MAKE} clean
-       rm bed2chrom_files
        rm bed2fixedstep
        rm bed2tag_contigs
        rm bed_sort
index bde5142b18c9592ee708a5dfe4d67d1a2de4d1fa..7c807df428289bb74a6a6cd50d9cfdd9ec51749c 100644 (file)
@@ -101,7 +101,7 @@ int main( int argc, char *argv[] )
                 printf( "fixedStep chrom=%s start=%zu step=1\n", chr, beg + 1 );
 
                 for ( j = beg; j <= end; j++ ) {
-                    printf( "%hd\n", ba->array[ j ] );
+                    printf( "%u\n", ba->array[ j ] );
                 }
             }
         }
index e23962c018ee04c0ce3aa7855616cbfb6708161b..9c9307923a0be64cb67ac4f9eb565550e237f034 100644 (file)
@@ -62,7 +62,7 @@ void barray_print( barray *ba )
 
     /* Debug function to print the content of a byte array. */
 
-    int i;
+    uint i;
 
     printf( "\nba->nmemb: %zu   ba->end: %zu\n", ba->nmemb, ba->end );
 
index 161f73d16eb39daa0d0f388f1082240bc10798ac..b0067b5f01baf2b54824ec8a8f88fd22e277fa32 100644 (file)
@@ -1110,6 +1110,7 @@ sub get_options
         }
     }
 
+    Maasha::Common::error( qq(no --database specified) )                if $script eq "remove_ucsc_tracks"  and not $options{ "database" };
     Maasha::Common::error( qq(no --database specified) )                if $script eq "create_blast_db"     and not $options{ "database" };
     Maasha::Common::error( qq(no --index_name specified) )              if $script =~ /create_vmatch_index/ and not $options{ "index_name" };
     Maasha::Common::error( qq(no --database or --genome specified) )    if $script eq "blast_seq" and not $options{ "genome" } and not $options{ "database" };
@@ -4911,9 +4912,7 @@ sub script_remove_ucsc_tracks
         put_record( $record, $out ) if not $options->{ 'no_stream' };
     }
 
-    # ---- locate track in config file ----
-
-    $fh_in = Maasha::Common::read_open( $options->{ 'config_file' } );
+    $fh_in = Maasha::Filesys::file_read_open( $options->{ 'config_file' } );
     
     while ( $track = Maasha::UCSC::ucsc_config_entry_get( $fh_in ) ) {
         push @tracks, $track;
@@ -4921,13 +4920,18 @@ sub script_remove_ucsc_tracks
 
     close $fh_in;
 
-    map { push @new_tracks, $_ if not exists $track_hash{ $_->{ 'track' } } } @tracks;
-
-    print STDERR qq(WARNING: track not found in config file: "$options->{ 'config_file' }"\n) if scalar @tracks == scalar @new_tracks;
+    foreach $track ( @tracks )
+    {
+        if ( not exists $track_hash{ $track->{ 'track' } } ) {
+            push @new_tracks, $track;
+        } else {
+            print STDERR qq(Removing track "$track->{ 'track' }" from config file.\n) if $options->{ 'verbose' };
+        }
+    }
 
     rename "$options->{ 'config_file' }", "$options->{ 'config_file' }~";
 
-    $fh_out = Maasha::Common::write_open( $options->{ 'config_file' } );
+    $fh_out = Maasha::Filesys::file_write_open( $options->{ 'config_file' } );
 
     map { Maasha::UCSC::ucsc_config_entry_put( $_, $fh_out ) } @new_tracks;
 
index 73558a9fe4cfa004070b95417daf796814cb957a..84663db27285ed6585c146891f3f4f75055d2ddb 100644 (file)
@@ -998,13 +998,13 @@ sub ucsc_update_config
 
     # Returns nothing.
 
-    my ( $file, %entry, $fh_out );
+    my ( $file, $entry, %new_entry, $fh_in, $fh_out, $was_found );
 
     $file = $ENV{ "HOME" } . "/ucsc/my_tracks.ra";
 
     Maasha::Filesys::file_copy( $file, "$file~" );   # create a backup
 
-    %entry = (
+    %new_entry = (
         database   => $options->{ 'database' },
         track      => $options->{ 'table' },
         shortLabel => $options->{ 'short_label' },
@@ -1017,13 +1017,29 @@ sub ucsc_update_config
         type       => $type,
     );
 
-    $entry{ 'mafTrack' }        = "multiz17way" if $type eq "type bed 6 +";
-    $entry{ 'maxHeightPixels' } = "50:50:11"    if $type eq "wig 0";
+    $new_entry{ 'mafTrack' }        = "multiz17way" if $type eq "type bed 6 +";
+    $new_entry{ 'maxHeightPixels' } = "50:50:11"    if $type eq "wig 0";
+
+    $fh_in  = Maasha::Filesys::file_read_open( "$file~" );
+    $fh_out = Maasha::Filesys::file_write_open( $file );
+
+    while ( $entry = ucsc_config_entry_get( $fh_in ) )
+    {
+        if ( $entry->{ 'database' } eq $new_entry{ 'database' } and $entry->{ 'track' } eq $new_entry{ 'track' } )
+        {
+            ucsc_config_entry_put( \%new_entry, $fh_out );
 
-    $fh_out = Maasha::Filesys::file_append_open( $file );
+            $was_found = 1;
+        }
+        else
+        {
+            ucsc_config_entry_put( $entry, $fh_out );
+        }
+    }
 
-    ucsc_config_entry_put( \%entry, $fh_out );
+    ucsc_config_entry_put( \%new_entry, $fh_out ) if not $was_found;
     
+    close $fh_in;
     close $fh_out;
 
     Maasha::Common::run( "ucscMakeTracks.pl", "-b > /dev/null 2>&1" );