~ubuntu-branches/ubuntu/utopic/circos/utopic

« back to all changes in this revision

Viewing changes to lib/Circos/Ideogram.pm

  • Committer: Package Import Robot
  • Author(s): Olivier Sallou
  • Date: 2013-05-20 09:01:27 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130520090127-s5nbumg8563x00ee
Tags: 0.64-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
use base 'Exporter';
37
37
our @EXPORT = qw(
38
 
 
 
38
is_on_ideogram
39
39
);
40
40
 
41
41
use Carp qw( carp confess croak );
388
388
  }
389
389
}
390
390
 
 
391
# Quickly check whether a point appears on a drawn portion of
 
392
# a chromosome. An ideogram must exist and have a cover that
 
393
# intersects with the data point coordinate. Not using Set::IntSpan
 
394
# here because it is too slow.
 
395
sub is_on_ideogram {
 
396
        my $datum       = shift;
 
397
        my $on_ideogram = 1;
 
398
        for my $point ( @{$datum->{data}}) {
 
399
                my $chr       = $point->{chr};
 
400
                my $ideograms = Circos::get_ideograms_by_name($chr);
 
401
                # If the chromosome is not being displayed, it has no ideogram.
 
402
                return if ! defined $ideograms;
 
403
                my ($start,$end) = ($point->{start},$point->{end});
 
404
                for my $ideogram (@$ideograms) {
 
405
                        for my $cover (@{$ideogram->{covers}}) {
 
406
                                my ($cstart,$cend) = ($cover->{set}->min,$cover->{set}->max);
 
407
                                if($cstart > $end || $cend < $start) {
 
408
                                        # not on ideogram
 
409
                                } else {
 
410
                                        return 1;
 
411
                                }
 
412
                        }
 
413
                }
 
414
        }
 
415
        # none of the points coordinates fell inside any ideogram cover
 
416
        return;
 
417
}
 
418
 
391
419
1;