# 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' },
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" );