5 CXGN::Cview::IL - a class for drawing Isogenic Line (IL) diagrams
9 Inherits from L<CXGN::Cview::Chromosome>.
13 See also the documentation in L<CXGN::Cview>.
17 Lukas Mueller (lam87@cornell.edu)
27 use CXGN
::Cview
::Chromosome
;
29 package CXGN
::Cview
::IL
;
31 use base
qw( CXGN::Cview::Chromosome );
35 my $self = $class->SUPER::new
(@_);
37 $self->{fragments
} =();
42 # sections are the non-overlapping sections of the ILs that have labels of the form 1-A
44 my $section_name = shift;
52 $section{marker1
}=$marker1;
53 $section{offset1
}=$offset1;
54 $section{marker2
}=$marker2;
55 $section{offset2
}=$offset2;
56 $section{name
}=$section_name;
57 $section{label_position
} = 0;
58 push @
{$self->{sections
}}, \
%section;
64 # fragments are the overlapping sections defining the different IL lines and have lables of the form IL1-1.
66 my $fragment_name=shift;
73 $fragment{marker1
}=$marker1;
74 $fragment{offset1
}=$offset1;
75 $fragment{marker2
}=$marker2;
76 $fragment{offset2
}=$offset2;
77 $fragment{name
}=$fragment_name;
78 $fragment{label_position
} = 0;
79 push @
{$self->{fragments
}}, \
%fragment;
87 $self->_calculate_scaling_factor();
88 $self->_calculate_chromosome_length();
89 $self-> set_color
(100,100,100);
91 $self->{font
}= GD
::Font
->Small();
92 my $section_x = $self->get_horizontal_offset() - $self->get_width()/2;
94 my $color = $image -> colorResolve
($self->{color
}[0], $self->{color
}[1], $self->{color
}[2]);
95 my $light_color = $image -> colorResolve
(200, 200, 200);
99 my $previous_label_position = 0;
104 foreach my $s (@
{$self->{sections
}}) {
105 my $y_start = $self->get_vertical_offset()+$self->mapunits2pixels($$s{offset1
});
106 my $y_end = $self->get_vertical_offset()+$self->mapunits2pixels($$s{offset2
});
109 $image -> line
($section_x - 10, $y_start, $section_x + @
{$self->{fragments
}}*$spacing, $y_start, $light_color);
110 $image -> line
($section_x - 10, $y_end, $section_x + @
{$self->{fragments
}}*$spacing, $y_end, $light_color);
111 $image -> line
($section_x, $y_start, $section_x, $y_end, $color);
112 $image -> string
($self->{font
}, $section_x - $self->{font
}->width()* length($$s{name
})-2, ($y_end + $y_start)/2-$self->{font}->height()/2, $$s{name
}, $color);
118 if (!defined($self->{fragments
})) { warn "IL: no fragments to render.\n"; return; }
119 my $max_fragments = @
{$self->{fragments
}};
121 foreach my $f (@
{$self->{fragments
}}) {
122 my $y_start = $self->get_vertical_offset()+$self->mapunits2pixels($$f{offset1
});
123 my $y_end = $self->get_vertical_offset()+$self->mapunits2pixels($$f{offset2
});
125 my $label_position = ($y_end+$y_start)/2;
126 if ($label_position < ($previous_label_position+$self->{font
}->height())) { $label_position = $previous_label_position + $self->{font
}->height(); }
128 $image -> line
($section_x+$line*$spacing, $y_start, $section_x+$line*$spacing, $y_end,$color);
129 $image -> line
($section_x+$line*$spacing+1, $y_start, $section_x+$line*$spacing+1, $y_end, $color);
130 $image -> string
($self->{font
}, $section_x +$max_fragments*$spacing+3, $label_position-$self->{font
}->height()/2, $$f{name
}, $color);
131 $image -> line
($section_x+$line*$spacing, ($y_end+$y_start)/2, $section_x+$max_fragments*$spacing+3, $label_position, $color);
133 $previous_label_position = $label_position;