From e11f106e72c82ba93d96f02e690c7aa8e6636970 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Mon, 8 Dec 2008 05:55:36 +0000 Subject: [PATCH] minor fixes git-svn-id: http://biopieces.googlecode.com/svn/trunk@342 74ccb610-7750-0410-82ae-013aeee3265d --- code_c/Maasha/src/Makefile | 1 - code_c/Maasha/src/bed2fixedstep.c | 2 +- code_c/Maasha/src/lib/barray.c | 2 +- code_perl/Maasha/Biopieces.pm | 18 +++++++++++------- code_perl/Maasha/UCSC.pm | 28 ++++++++++++++++++++++------ 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/code_c/Maasha/src/Makefile b/code_c/Maasha/src/Makefile index cee84b8..d1e8d84 100644 --- a/code_c/Maasha/src/Makefile +++ b/code_c/Maasha/src/Makefile @@ -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 diff --git a/code_c/Maasha/src/bed2fixedstep.c b/code_c/Maasha/src/bed2fixedstep.c index bde5142..7c807df 100644 --- a/code_c/Maasha/src/bed2fixedstep.c +++ b/code_c/Maasha/src/bed2fixedstep.c @@ -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 ] ); } } } diff --git a/code_c/Maasha/src/lib/barray.c b/code_c/Maasha/src/lib/barray.c index e23962c..9c93079 100644 --- a/code_c/Maasha/src/lib/barray.c +++ b/code_c/Maasha/src/lib/barray.c @@ -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 ); diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index 161f73d..b0067b5 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -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; diff --git a/code_perl/Maasha/UCSC.pm b/code_perl/Maasha/UCSC.pm index 73558a9..84663db 100644 --- a/code_perl/Maasha/UCSC.pm +++ b/code_perl/Maasha/UCSC.pm @@ -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" ); -- 2.39.5