This file is indexed.

/usr/share/perl5/Circos/Debug.pm is in circos 0.55-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package Circos::Debug;

=pod

=head1 NAME

Circos::Debug - debugging routines for Circos

=head1 SYNOPSIS

This module is not meant to be used directly.

=head1 DESCRIPTION

Circos is an application for the generation of publication-quality,
circularly composited renditions of genomic data and related
annotations.

Circos is particularly suited for visualizing alignments, conservation
and intra and inter-chromosomal relationships. However, Circos can be
used to plot any kind of 2D data in a circular layout - its use is not
limited to genomics. Circos' use of lines to relate position pairs
(ribbons add a thickness parameter to each end) is effective to
display relationships between objects or positions on one or more
scales.

All documentation is in the form of tutorials at L<http://www.circos.ca/tutorials>.

=cut

# -------------------------------------------------------------------

use strict;
use warnings;

use base 'Exporter';
our @EXPORT = qw(start_timer stop_timer format_timer report_timer printerror printdebug printdebug_group printdumper printwarning printinfo printout debug_or_group);

use Carp qw( carp confess croak );
use Data::Dumper;
use FindBin;
use Memoize;
use Time::HiRes qw(gettimeofday tv_interval);

use lib "$FindBin::RealBin";
use lib "$FindBin::RealBin/../lib";
use lib "$FindBin::RealBin/lib";

use Circos::Constants;
#use Circos::Configuration qw(%CONF);

# -------------------------------------------------------------------
sub list_as_string {
    my $empty_text = $Circos::Configuration::CONF{debug_empty_text} || "_emptylist_";
    return $empty_text if ! @_;
    my $sep        = $Circos::Configuration::CONF{debug_word_separator} || " ";
    my $undef_text = $Circos::Configuration::CONF{debug_undef_text} || "_undef_";
    return join($sep, map { defined $_ ? $_ : $undef_text } @_);
}

# -------------------------------------------------------------------
sub debuginfo {
    my $info = <<ENDINFO;
If you are having trouble diagnosing this error, use Circos' debugging facility to follow the program as it is running.

To turn on summary debugging messages, use -debug. 

  circos ... -debug

  or

  circos ... -debug_group summary 

To extend debugging to other components, use -debug_group. 

  circos ... -debug_group summary 
  circos ... -debug_group summary,timer
  circos ... -debug_group summary,timer,io
  circos ... -debug_group summary,timer,io,color

To show *all* debugging, use

  circos ... -debug_group _all

To generate a dump of data parsed from the configuration file, use -cdump.

For more information about debugging, including a list of all the debug component names, see

  http://circos.ca/tutorials/lessons/configuration/debugging/

ENDINFO
}

# -------------------------------------------------------------------
sub errorheader {
    my %args   = @_;
    my $width  = $args{width} || 50;
    my $margin_width = $args{margin} || 2;
    my $delim  = $args{delim} || "*";
    my $text   = $args{text}  || "error";
    my $hdr    = $delim x $width;
    my $margin = " " x $margin_width;
    substr($hdr,(length($hdr) - length($text) - $margin_width*2)/2,length($text)+2*$margin_width) = $margin.$text.$margin;

    return $hdr;
}

# -------------------------------------------------------------------
sub printerror {
    printinfo();
    printinfo(errorheader());
    printinfo();
    printinfo(@_);
    printinfo(errorheader(text=>"debugging"));
    printinfo();
    printinfo(debuginfo());
}

# -------------------------------------------------------------------
sub printdebug {
    if($Circos::Configuration::CONF{debug}) {
	printinfo('debug', @_);
    }
}

# -------------------------------------------------------------------
{
    my $t = [gettimeofday];
    sub printdebug_group {
	my ($group,@msg) = @_;
	if(debug_or_group($group)) {
	    printinfo('debuggroup',$group,sprintf("%.2fs",tv_interval($t)),@msg);
	}
    }
}

sub format_timer {
    my $t = shift;
    return sprintf("%.3f s",tv_interval($t));
}

{
    my $timers    = {};
    my @lasttimer = ();
    sub start_timer {
	my $timer = shift;
	return if $timers->{$timer}{start};
	$timers->{$timer}{start}   = [gettimeofday];
	$timers->{$timer}{elapsed} ||= 0;
	push @lasttimer, $timer;
    }
    sub stop_timer {
	my $timer = shift;
	if(! defined $timer) {
	    $timer = pop @lasttimer;
	}
	return unless defined $timers->{$timer}{start};
	@lasttimer = grep($_ ne $timer, @lasttimer);
	$timers->{$timer}{elapsed} += tv_interval( $timers->{$timer}{start} );
	delete $timers->{$timer}{start};
    }
    sub report_timer {
	my $timer = shift;
	my @timers;
	if(! defined $timer) {
	    @timers = sort keys %$timers;
	} else {
	    @timers = ($timer);
	}
	for my $t (@timers) {
	    stop_timer($t);
	    if(defined $timers->{$t}{elapsed}) {
	      printdebug_group("timer","report",$t,sprintf("%.3f s",$timers->{$t}{elapsed}));
	    } else {
	      # no such timer
	    }
	  }
      }
  }

# -------------------------------------------------------------------
sub debug_or_group {
    my $group = shift;
    return if 
	! defined $Circos::Configuration::CONF{debug_group} &&
	! defined $Circos::Configuration::CONF{debug};
    confess "No group defined." if ! defined $group;
    #printdumper(\%Circos::Configuration::CONF);
    #printinfo($Circos::Configuration::CONF{debug_group});
    my $match = 0; # $Circos::Configuration::CONF{debug};
    return $match if ! defined $Circos::Configuration::CONF{debug_group};
    $match ||= $Circos::Configuration::CONF{debug_group} =~ /$group/i;
    if($group =~ /(.+)s$/) {
	my $group_root = $1;
	$match ||= $Circos::Configuration::CONF{debug_group} =~ /$group_root/i;
    }
    $match ||= $Circos::Configuration::CONF{debug_group} =~ /_all/i;
    #printinfo("grouplist",$group,$Circos::Configuration::CONF{debug_group},$match);
    return $match;
}

# -------------------------------------------------------------------
sub printdumper {
    $Data::Dumper::Sortkeys = 1;
    $Data::Dumper::Indent   = 1;
    printinfo( Dumper(@_) );
}

# -------------------------------------------------------------------
sub printwarning {
    if($Circos::Configuration::CONF{warnings}) {
	printinfo( 'warning', @_ );
    }
}

# -------------------------------------------------------------------
sub printinfo {
    if(! @_) {
	printout();
    } else {
	printout( list_as_string(@_) );
    }
}

# -------------------------------------------------------------------
sub printout {
    print "@_\n" unless $Circos::Configuration::CONF{silent};
}

1;