removed use of deprecated CXGN::VHost class
[cview.git] / lib / CXGN / Cview / ChrMarkerImage.pm
blob8a7f7356f5c088ecf43f1cd670f12c78357daee3
1 =head1 NAME
3 CXGN::Cview::ChrMarkerImage - a class for drawing small chromosome image wit a specific marker hilited.
5 =head1 DESCRIPTION
7 Inherits from L<CXGN::Cview::MapImage>.
9 =head1 AUTHOR(S)
11 Lukas Mueller (lam87@cornell.edu)
12 Naama Menda (nm249@cornell.edu)
14 =head1 FUNCTIONS
17 =cut
19 use strict;
21 use CXGN::Cview;
22 use CXGN::Cview::Chromosome;
23 #use CXGN::Cview::Cview_data_adapter;
24 use CXGN::Cview::MapImage;
25 #use CXGN::VHost;
26 use File::Temp qw / tempfile /;
27 use File::Basename qw / basename /;
28 use File::Spec;
30 package CXGN::Cview::ChrMarkerImage;
32 use base "CXGN::Cview::MapImage";
34 =head2 new
36 Usage: my $chromosome= CXGN::Cview::ChrmarkerImage->new("map name", width,height,$dbh, $lg_name, $map, $marker_name);
37 Desc:
38 Ret:
39 Args: name of a map, width and height of the image in pixles, linkage group name, map object (my $map=CXGN::Map->new($dbh,$map_version_id);), $marker_name.
40 Side Effects:
41 Example:
43 =cut
45 sub new {
46 my $class=shift;
47 my $name = shift;
48 my $width = shift;
49 my $height = shift;
51 my $self= $class->SUPER::new($name, $width, $height);
53 my $dbh=shift;
54 my $lg_name= shift;
55 my $map = shift;
56 my $marker_name= shift;
57 my $basedir = shift;
58 my $tempdir = shift;
60 $self->set_dbh($dbh);
61 $self->set_lg_name($lg_name);
62 $self->set_map($map);
63 $self->set_marker_name($marker_name);
64 $self->{basedir} = $basedir;
65 $self->{tempdir} = $tempdir;
67 my $chromosome = $map->get_chromosome($lg_name);
69 $chromosome->set_horizontal_offset(50);
70 $chromosome->set_vertical_offset(25);
71 $chromosome->set_height(100);
72 $chromosome->set_caption($self->get_lg_name);
73 $chromosome->set_width(12);
74 my $map_version_id= $self->get_map()->get_id();
75 my $marker_name= $self->get_marker_name();
76 my $lg_name=$self->get_lg_name();
77 $chromosome->set_url("/cview/view_chromosome.pl?map_version_id=$map_version_id&amp;chr_nr=$lg_name&amp;hilite=$marker_name");
79 my @markers= $chromosome->get_markers();
81 foreach my $m(@markers) {
82 if ($m->get_name() eq $self->get_marker_name()) {
83 $m->hilite();
84 $m->set_label_spacer(20);
86 else { $m->hide_label(); }
87 $m->set_color(150, 80, 50);
90 $self->add_chromosome($chromosome);
92 return $self;
96 =head2 get_image_filename
98 Usage: my ($image_path, $image_url)=$chromosome->get_image_filename();
99 Desc: returns a tmp .png file of the chromosome image object
100 Ret: $image_path, $image_url
101 Args:
102 Side Effects:
103 Example:
105 =cut
107 sub get_image_filename {
108 my $self=shift;
110 my $dir = File::Spec->catfile($self->{basedir}, $self->{tempdir});
111 my $template = 'tempXXXX'; #not needed. The function tempfile seems to generate a default TEMPLATE 'XXXXXXXXXX$suffix'
112 my $suffix = '.png';
113 my ($fh, $image_path) = File::Temp::tempfile( DIR => $dir,
114 SUFFIX => $suffix
117 #my $filename = time().".$$.png";
119 my $filename = File::Basename::basename($image_path);
121 #print STDERR "IMAGE PATH: $image_path\n";
122 my $image_url = File::Spec->catfile($self->{tempdir}, $filename);
124 $self -> render_png_file($image_path);
125 return ($image_path, $image_url);
129 =head2 get_dbh
131 Usage:
132 Desc:
133 Ret:
134 Args:
135 Side Effects:
136 Example:
138 =cut
140 sub get_dbh {
141 my $self=shift;
142 return $self->{dbh};
146 =head2 set_dbh
148 Usage:
149 Desc:
150 Ret:
151 Args:
152 Side Effects:
153 Example:
155 =cut
157 sub set_dbh {
158 my $self=shift;
159 $self->{dbh}=shift;
164 =head2 get_lg_name
166 Usage:
167 Desc:
168 Ret:
169 Args:
170 Side Effects:
171 Example:
173 =cut
175 sub get_lg_name {
176 my $self=shift;
177 return $self->{lg_name};
181 =head2 set_lg_name
183 Usage:
184 Desc:
185 Ret:
186 Args:
187 Side Effects:
188 Example:
190 =cut
192 sub set_lg_name {
193 my $self=shift;
194 $self->{lg_name}=shift;
197 =head2 get_map
199 Usage:
200 Desc:
201 Ret:
202 Args:
203 Side Effects:
204 Example:
206 =cut
208 sub get_map {
209 my $self=shift;
210 return $self->{map};
214 =head2 set_map
216 Usage:
217 Desc:
218 Ret:
219 Args:
220 Side Effects:
221 Example:
223 =cut
225 sub set_map {
226 my $self=shift;
227 $self->{map}=shift;
231 =head2 get_marker_name
233 Usage:
234 Desc:
235 Ret:
236 Args:
237 Side Effects:
238 Example:
240 =cut
242 sub get_marker_name {
243 my $self=shift;
244 return $self->{marker_name};
248 =head2 set_marker_name
250 Usage:
251 Desc:
252 Ret:
253 Args:
254 Side Effects:
255 Example:
257 =cut
259 sub set_marker_name {
260 my $self=shift;
261 $self->{marker_name}=shift;