369
375
# seek_parameter("x|y",$hash,$anotherhash);
370
376
my ( $param_name, @data_structs ) = @_;
371
377
my @target_string = split( /\|/, $param_name );
372
379
start_timer("parameter_seek");
373
380
for my $str (@target_string) {
374
381
for my $struct (@data_structs) {
375
382
if ( ref($struct) eq "ARRAY" ) {
376
383
for my $substruct (@$struct) {
377
if (exists $substruct->{param} && defined $substruct->{param}{$str}) {
384
if (exists $substruct->{param} &&
385
exists $substruct->{param}{$str} && ($not_def_ok || defined $substruct->{param}{$str})) {
378
386
stop_timer("parameter_seek");
379
387
return $substruct->{param}{$str};
381
if (exists $substruct->{$str} && defined $substruct->{$str}) {
389
if (exists $substruct->{$str} && ($not_def_ok || defined $substruct->{$str})) {
382
390
stop_timer("parameter_seek");
383
391
return $substruct->{$str};
386
394
} elsif ( ref($struct) eq "HASH" ) {
387
if (exists $struct->{param} && defined $struct->{param}{$str}) {
395
if (exists $struct->{param} &&
396
exists $struct->{param}{$str} &&
397
($not_def_ok || defined $struct->{param}{$str})) {
388
398
stop_timer("parameter_seek");
389
399
return $struct->{param}{$str};
391
if (exists $struct->{$str} && defined $struct->{$str}) {
401
if (exists $struct->{$str} && ($not_def_ok || defined $struct->{$str})) {
392
402
stop_timer("parameter_seek");
393
403
return $struct->{$str};
432
442
# look for the file in various directories
433
my @dir_1 = (getcwd,$FindBin::RealBin);
443
# v0.63 added configuration directory to dir_1
444
my @dir_1 = grep($_,getcwd,Circos::Configuration::fetch_conf("configdir"),$FindBin::RealBin);
434
445
my @dir_2 = qw(. .. ../.. ../../..);
435
446
my @dir_3 = qw(. etc data);
437
448
my $file = $params{file};
438
449
# remove any comma-delimited elements from the file
439
450
$file =~ s/,.*//;
440
451
printdebug_group("io","locating file",$file,"role",$params{name});
442
453
if (! defined $file) {
443
454
confess "Attempted to locate an undefined file name for [$params{name}]";
447
if ($file =~ /^\//) {
458
if (file_name_is_absolute($file)) {
448
459
@path = ($EMPTY_STR);
450
461
# first add any custom path directories
464
475
printdebug_group("io","trying path",@path);
465
476
for my $path (@path) {
466
my $file_path = catfile($path,$file);
477
my $file_path = $path ? catfile($path,$file) : $file;
467
478
printdebug_group("io","trying $file_path");
468
479
if ( -e $file_path) {
469
480
if (! -r $file_path) {
566
577
return map { ($_,$x{$_}) } grep(defined $x{$_}, keys %x);
580
# return the distance between the span
581
# [x1,y1] and [x2,y2]
582
# if the spans overlap, the distance is negative
584
my ($x1,$y1,$x2,$y2) = @_;
585
# flip the coordinates if they are reversed
586
($x1,$y1) = ($y1,$x1) if $x1 > $y1;
587
($x2,$y2) = ($y2,$x2) if $x2 > $y2;
588
# flip intervals so that x1,y1 is always to the left
589
($x1,$y1,$x2,$y2) = ($x2,$y2,$x1,$y1) if ($x1 > $x2);
612
die "did not calculate distance between intervals [$x1,$y1] and [$x2,$y2] correctly." unless defined $d;
616
for my $i (0..100000) {
617
my @coords = map { sprintf("%.1f",100*rand()) } (0..3);
618
my $s1 = Set::IntSpan->new(sprintf("%d-%d",sort {$a <=> $b} ($coords[0]*1000,$coords[1]*1000)));
619
my $s2 = Set::IntSpan->new(sprintf("%d-%d",sort {$a <=> $b} ($coords[2]*1000,$coords[3]*1000)));
620
my $int = $s1->intersect($s2)->cardinality;
621
my $d = span_distance(@coords);
623
$int = ($int-1)/1000 if $int;
624
if ($int && (-$d - $int) > 0.002) {
628
$int = min ( abs($coords[0] - $coords[2]),
629
abs($coords[0] - $coords[3]),
630
abs($coords[1] - $coords[2]),
631
abs($coords[1] - $coords[3]) );
632
if ($d - $int > 0.002) {
636
printinfo(@coords,$d,$int);
570
641
my ($x,$y,%args) = @_;
571
642
if (! defined $x) {
607
678
return if $x eq 0 || $x =~ /^no?$/i;
682
my ($hash,@path) = @_;
683
return $hash if ! @path;
684
my $key = shift @path;
685
if(! exists $hash->{$key}) {
686
fatal_error("system","hash_leaf_undef",$key);
688
return get_hash_leaf($hash->{$key},@path);
610
692
# -------------------------------------------------------------------
611
693
# parse into a hash option string like
612
694
# var1=value1,var2=value2,...