A chromosome class for scaffold-based chromosomes.
[cview.git] / lib / CXGN / Cview / Chromosome / Scaffold.pm
blobae768b3cae2f12492b6358ec9f88532278229b67
2 use strict;
4 package CXGN::Cview::Chromosome::Scaffold;
6 use base "CXGN::Cview::Chromosome";
8 our $INTER_SCAFFOLD_DISTANCE = 100_000;
10 sub new {
11 my $class = shift;
12 my $file = shift;
13 my $chr_nr = shift;
14 my $marker_link = shift;
16 my $self = $class-> SUPER::new($chr_nr);
18 $self->{marker_link} = $marker_link;
20 open (my $F, "<$file") || die "Can't find file $file.";
22 my $current_offset = 0;
24 while (<$F>) {
25 chomp;
27 my ($scaffold, $length, $c, $cM) = split /\t/;
29 if ($c != $chr_nr) { next(); }
31 my $m = CXGN::Cview::Marker::RangeMarker->new($self);
33 $current_offset += $INTER_SCAFFOLD_DISTANCE;
35 $m->get_label()->set_name($scaffold);
36 $m->set_marker_name($scaffold);
37 $m->get_label()->set_url(&{$self->{marker_link}}($scaffold));
38 $m->set_offset($current_offset + ($length/2));
39 $m->set_north_range($length/2);
40 $m->set_south_range($length/2);
41 $self->add_marker($m);
42 $current_offset += $length;
44 close($F);
46 $self->sort_markers();
47 $self->set_length($current_offset);
48 #$chr->set_url($self->{url});
49 $self->distribute_labels();
50 $self->distribute_label_stacking();
51 $self->set_units("bp");
52 $self->get_ruler()->set_units("bp");
54 return $self;
57 return 1;