7 CXGN::Cview::PachyteneIdiogram - a class for drawing a schematic representation of chromosomes in the pachytene phase.
11 This object renders a pachytene idiogram, which are currently only defined for each of the 12 tomato chromosomes. It inherits from CXGN::Cview::chromosome. Inherits from L<CXGN::Cview::Chromosome>. The description of the tomato pachytene chromosomes is available in a flat file version, and there is a function in L<CXGN::Cview::Cview_data_adatper> to load it.
15 See also the documentation in L<CXGN::Cview>.
19 Lukas Mueller (lam87@cornell.edu)
28 use CXGN
::Cview
::Chromosome
;
29 use CXGN
::Cview
::Ruler
::PachyteneRuler
;
31 package CXGN
::Cview
::Chromosome
::PachyteneIdiogram
;
33 use base
qw( CXGN::Cview::Chromosome );
37 Constructor. Takes the same parameters as CXGN::Cview::Chromosome::new().
43 my $self = $class->SUPER::new
(@_);
44 $self->set_outline_color(0,0,0);
45 $self->set_color(255, 255, 255);
46 $self->set_hilite_color(50, 255, 50);
48 $self->set_vertical_offset_top_edge();
49 $self->{curved_height
} = 8;
51 $self->{feature_color
} = {
52 short_arm
=> "100 ,100,250",
53 long_arm
=> "100,100,250",
54 heterochromatin
=> "75,75,250",
55 telomere
=> "25,75,200",
56 satellite
=> "75,75,250",
58 $self->{feature_width
} = {
61 heterochromatin
=> 10,
66 @
{$self->{render_order
}} = (
74 my $r = CXGN
::Cview
::Ruler
::PachyteneRuler
->new();
79 =head2 function add_feature()
81 Add a feature to the pachytene idiogram. Allowed feature types are restricted to:
82 telomere, satellite, long_arm, short_arm etc. This is used to construct the
83 image representation of the idiogram.
85 Note: feature types are rendered in a specific order. See new().
92 my $start_coord = shift;
93 my $end_coord = shift;
95 #print STDERR "Cview::pchytene::add_feature: Adding feature $type, $start_coord, $end_coord\n";
97 if (!exists($self->{feature_color
}->{$type})) {
98 print STDERR
"Cview.pm [pachytene_idiogram]: Unknown feature type: $type\n";
100 if ($type eq "short_arm") {
101 $self->set_short_arm_length(abs($end_coord-$start_coord));
102 #print STDERR "short arm length: $self->{short_arm_length}\n";
104 if ($type eq "long_arm") {
105 $self->set_long_arm_length(abs($end_coord-$start_coord));
108 my %h = ( type
=> $type,
109 start_coord
=> $start_coord,
110 end_coord
=> $end_coord,
113 push @
{$self->{features
}}, \
%h;
117 # Note: _calculate_scaling_factor is overridden to account for the differences in the representation
118 # of a pachytene chromosome.
120 sub _calculate_scaling_factor
{
122 $self->{scaling_factor
} = ($self->get_height()/($self->get_short_arm_length()+$self->get_long_arm_length()));
123 #print STDERR "pachytene_idiogram: _calculate_scaling_factor::scaling factor: $self->{scaling_factor}\n";
126 =head2 function mapunits2pixels()
128 Override the chromosome mapunits2pixels to reflect the different unit and representation of this map.
132 sub mapunits2pixels
{
136 # note: give the pixels from the vertical_offset (centromere) to the percent marker positioin
137 my $shortarmratio = $self->get_short_arm_length()/($self->get_short_arm_length()+$self->get_long_arm_length());
138 my $longarmratio = 1-$shortarmratio;
140 $pixels = $self->get_height() * $shortarmratio * $percent / 100;
141 # the result is a negative number, always measured from the centromere
144 $pixels = $self->get_height()* $longarmratio * $percent / 100;
149 =head2 function get_short_arm_length()
153 Returns: the length of the short arm in arbitrary units.
159 sub get_short_arm_length
{
161 return $self->{short_arm_length
};
164 =head2 function set_short_arm_length()
174 sub set_short_arm_length
{
176 $self->{short_arm_length
}=shift;
179 =head2 function get_long_arm_length()
183 Returns: The short arm length in arbitrary units.
189 sub get_long_arm_length
{
191 return $self->{long_arm_length
};
194 =head2 function set_long_arm_length()
204 sub set_long_arm_length
{
206 $self->{long_arm_length
}=shift;
211 sub draw_chromosome
{
213 #print STDERR "Rendering the PACHYTENE business...\n";
215 $self->_calculate_scaling_factor();
217 # calculate ruler properties...
219 $self->get_ruler()->set_height($self->get_height());
220 $self->get_ruler()->set_short_arm_ruler_pixels($self->get_short_arm_length()*$self->get_scaling_factor());
221 $self->get_ruler()->set_long_arm_ruler_pixels($self->get_long_arm_length()*$self->get_scaling_factor());
223 #$image -> line(0, $self->get_vertical_offset(), 100, $self->get_vertical_offset(), $image->colorResolve(0, 0, 0));
226 # features have to be rendered in the correct order -- first the arms and then the rest.
227 foreach my $type (@
{$self->{render_order
}}) {
228 foreach my $f (@
{$self->{features
}}) {
229 if ($f->{type
} eq $type) {
230 #print STDERR "Rendering feature $f->{type}, $f->{start_coord}, $f->{end_coord} | Color: $self->{feature_color}->{$f->{type}}\n";
231 if (!exists($self->{feature_color
}->{$f->{type
}})) { print STDERR
"$f->{type} HAS NO ASSOCIATED FEATURE COLOR!\n";}
232 my ($red, $green, $blue) = split /\,/, $self->{feature_color
}->{$f->{type
}};
233 my $color = $image-> colorResolve
($red, $green,$blue);
235 my $x = $self->get_horizontal_offset() - $self->{feature_width
}->{$f->{type
}}/2;
236 my $y = $self->get_vertical_offset()+$f->{start_coord
}*$self->get_scaling_factor();
237 my $lx = $self->get_horizontal_offset()+ $self->{feature_width
}->{$f->{type
}}/2;
238 my $ly = $self->get_vertical_offset()+$f->{end_coord
}*$self->get_scaling_factor();
240 #print STDERR "Featurescreencoords: $f->{type}, $x, $y, $lx, $ly, $color\n";
241 # gd can't draw a filled rectangle with $y > $ly, so swap if that's the case.
242 if ($y > $ly) { my $z=$y; $y=$ly; $ly=$z; }
243 $image -> filledRectangle
(
253 $self->draw_centromere($image);
255 $self->draw_caption($image);
262 my @m = $self->get_markers();
264 #print STDERR "Drawing marker ".$self->get_name()."\n";
265 $m -> render
($image);
270 =head2 draw_centromere
281 sub draw_centromere
{
284 my $centromere_color = $image->colorResolve(80, 80, 150);
285 $image->filledArc($self->get_X(),$self->get_Y(),10,10,0,360, $centromere_color);
290 =head2 function set_vertical_offset_centromere()
292 This function sets the vertical offset to the centromere (default).
296 sub set_vertical_offset_centromere
{
298 $self->{vertical_offset_type
} = "centromere";
301 sub set_vertical_offset_top_edge
{
303 $self->{vertical_offset_type
} = "top_edge";
307 # sub get_vertical_offset {
309 # if ($self->{vertical_offset_type} eq "top_edge") {
310 # return $self->SUPER::get_vertical_offset()+100;
314 # The following method is overridden because the caption is rendered
315 # at a slightly different location (the vertical offset defines the
316 # centromere and not the top edge)
322 my $outline_color = $image -> colorResolve
(
323 $self->{outline_color
}[0],
324 $self->{outline_color
}[1],
325 $self->{outline_color
}[2]
327 my $bigfont = GD
::Font
->Large();
330 $self->get_horizontal_offset()- $bigfont->width() * length($self->get_caption())/2,
331 $self->get_vertical_offset()-$self->{scaling_factor
}*$self->{short_arm_length
}-$bigfont->height(),
332 $self->get_caption(), $outline_color );
334 #$image->string($bigfont, 50, 50, "HELLO", $outline_color);
340 print STDERR
"EXECUTING layout() in PachyteneIdiogram...\n";
341 # determine the offset type
342 if ($self->{vertical_offset_type
} eq "top_edge") {
343 my $new_offset = $self->get_vertical_offset()-$self->mapunits2pixels(-100);
344 #print STDERR "Setting the vertical offset to $new_offset..\n";
345 $self->set_vertical_offset($new_offset);
348 $self->_calculate_scaling_factor();
349 $self->distribute_labels();
354 sub get_enclosing_rect
{
356 if ($self->{vertical_offset_type
} eq "top_edge") {
357 $self->set_vertical_offset($self->get_vertical_offset()-$self->mapunits2pixels(-100));
359 return ($self->get_horizontal_offset()-int($self->get_width()/2),
360 $self->get_vertical_offset()+$self->mapunits2pixels(-100),
361 $self->get_horizontal_offset()+int($self->get_width()/2),
362 $self->get_vertical_offset()+$self->mapunits2pixels(100)