From: Don G. <don...@us...> - 2007-10-15 16:19:29
|
Update of /cvsroot/gmod/schema/GMODTools/lib/Bio/GMOD In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv29196/lib/Bio/GMOD Modified Files: Config2.pm Log Message: no_csomesplit change for genomes with many scaffolds; validate chado variables; config updates Index: Config2.pm =================================================================== RCS file: /cvsroot/gmod/schema/GMODTools/lib/Bio/GMOD/Config2.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Config2.pm 28 Dec 2005 02:22:07 -0000 1.5 --- Config2.pm 15 Oct 2007 16:19:29 -0000 1.6 *************** *** 439,442 **** --- 439,443 ---- $DEBUG= delete $opts->{debug} if (defined $opts->{debug}); + my $replacekeys= delete $opts->{replace} || 0; ##print STDERR "Config2::readConfig in=$file\n" if $DEBUG; *************** *** 447,451 **** my $conf1 = $self->readConfigFile($file, $opts, 0); ! $self->appendHash($confhash, $conf1, 0) if ($conf1); ## $self->{filename}= $file; --- 448,452 ---- my $conf1 = $self->readConfigFile($file, $opts, 0); ! $self->appendHash($confhash, $conf1, $replacekeys) if ($conf1); ## $self->{filename}= $file; *************** *** 467,471 **** my $inc1= delete $$conf1{include}; if($inc1) { push(@inc, (ref($inc1) =~ /ARRAY/) ? @$inc1 : ($inc1)); } ! $self->appendHash($confhash, $conf1, 0); } $saveConfigOk=0 unless($readConfigOk); --- 468,472 ---- my $inc1= delete $$conf1{include}; if($inc1) { push(@inc, (ref($inc1) =~ /ARRAY/) ? @$inc1 : ($inc1)); } ! $self->appendHash($confhash, $conf1, $replacekeys); } $saveConfigOk=0 unless($readConfigOk); *************** *** 478,481 **** --- 479,523 ---- + sub updateVariables + { + my $self = shift; + my( $confhash, $opts)= @_; + $DEBUG= delete $opts->{debug} if (defined $opts->{debug}); + $confhash = $self->{'conf'} unless(ref $confhash); # always exists ? + $confhash = {} unless(ref $confhash); + my $env= (ref $opts and ref $opts->{Variables}) ? $opts->{Variables} : $Variables; + _update1Value( $confhash, $env); + return $confhash; + } + + + sub _update1Value + { + my($val,$env)= @_; + + if( ref($val) eq 'HASH') { + foreach my $tag (sort keys %$val) { + $$val{$tag} = _update1Value( $$val{$tag}, $env); + } + + } elsif( ref($val) eq 'ARRAY') { + foreach (@$val){ $_= _update1Value( $_, $env); } + + } else { + while ( $val =~ m/\$\{(\w+)\}/g) { + my $var=$1; + my $enval= $env->{$var}; #only if defined, leave otherwise + if (defined $enval) { + if($enval =~ m/\$\{(\w+)\}/) { $enval= _update1Value( $enval, $env); } + print STDERR "UPVAL1: \$\{$var\} => $enval\n" if $DEBUG; + $val =~ s/\$\{$var\}/$enval/; + } + } + } + + return $val; + } + + =head2 showConfig($confhash, $opts) |