/usr/share/perl5/Circos/Geometry.pm is in circos 0.64-1.
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 | package Circos::Geometry;
=pod
=head1 NAME
Circos::Geometry - utility routines for Geometry in 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>.
=cut
# -------------------------------------------------------------------
use strict;
use warnings;
use base 'Exporter';
our @EXPORT = qw(
getxypos
angle_quadrant
getu
);
use Carp qw( carp confess croak );
use FindBin;
use GD::Image;
use Params::Validate qw(:all);
use lib "$FindBin::RealBin";
use lib "$FindBin::RealBin/../lib";
use lib "$FindBin::RealBin/lib";
use Circos::Configuration; # qw(%CONF $DIMS fetch_conf);
use Circos::Constants;
use Circos::Debug;
use Circos::Error;
use Circos::Utils;
use Memoize;
for my $f ( qw ( angle_quadrant ) ) {
memoize($f);
}
################################################################
# given an angle, get the xy position for a certain radius
#
sub getxypos {
if(! defined $_[0] || ! defined $_[1]) {
fatal_error("geometry","bad_angle_or_radius",$_[0],$_[1]);
}
return (
$DIMS->{image}{radius} + $_[1] * cos( $_[0] * $DEG2RAD ),
$DIMS->{image}{radius} + $_[1] * sin( $_[0] * $DEG2RAD )
);
}
sub angle_quadrant {
my $angle = shift;
# added tests in 0.56-2
while($angle < -90) { $angle += 360; }
while($angle > 270) { $angle -= 360; }
if($angle < -90 || $angle > 270) {
fatal_error("geometry","angle_out_of_bounds",$angle);
} else {
if($angle <= 0) {
return 0;
} elsif ($angle <= 90) {
return 1;
} elsif ($angle <= 180) {
return 2;
} else {
return 3;
}
}
}
sub getu {
my ( $x1, $y1, $x2, $y2, $x3, $y3 ) = @_;
my $x21 = $x2 - $x1;
my $y21 = $y2 - $y1;
my $u = ( ( $x3 - $x1 ) * $x21 + ( $y3 - $y2 ) * $y21 ) / ( $y21**2 + $x21**2 );
my $x = $x1 + $u * $x21;
my $y = $y1 + $u * $y21;
return ( $x, $y, $u );
};
1;
|