Correct 'directory' section
[bioperl-live.git] / t / Align / Graphics.t
blobb77feb64ee06f9097a76025559ad044af305af3d
1 #!usr/bin/perl
2 use strict;
4 use Bio::Root::Test;
5 test_begin( -tests => 41,
6             -requires_modules => [qw(GD)]); 
8 #Check if module and all its methods can be loaded
9 use_ok('Bio::Align::Graphics');
10 require_ok('Bio::Align::Graphics');
11 can_ok('Bio::Align::Graphics', qw(new draw height width aln_length aln_format no_sequences));
12     
14 #Get an alignment file
15 my $file = Bio::Root::IO->catfile("t","data","pep-266.aln");
16 ok($file, 'input is defined');
17         
18 #Create an AlignI object using AlignIO
19 my $in=new Bio::AlignIO(-file=>$file, -format=>'clustalw');
20 ok(defined $in, 'AlignIO object is defined');
21 isa_ok($in, 'Bio::AlignIO');
23 #Read the alignment
24 my $aln=$in->next_aln();
25 ok(defined $aln, 'alignment is there and defined');
27 #Create some domains for highlighting
28 my @domain_start = ( 25, 50, 80 );
29 my @domain_end = ( 40 , 65 , 100 );
30 my @domain_color = ( 'red' , 'cyan' , 'green' );
31 ok(exists $domain_start[2], 'all starts are present');
32 ok(exists $domain_end[2],'all ends are present');
33 ok(exists $domain_color[2], 'all colors are present');
34 cmp_ok($domain_start[0], '<=', $domain_end[0],'first end is further than first start');   #Some  
35 cmp_ok($domain_start[1], '<=', $domain_end[1],'second end is further than second start');       #logical
36 cmp_ok($domain_start[2], '<=', $domain_end[2],'third end is further than third start');   #tests 
38 #Create Labels for the domains
39 my @dml = ("CARD", "Proline Rich", "Transmembrane");
40 my @dml_start = (25, 50, 80);
41 my @dml_end = (40, 65, 100);
42 my @dml_color = ("lightpink", "lightblue", "lightgreen");
43 ok(exists $dml[2], 'domain labels are present');
44 ok(exists $dml_start[2], 'domain starts are present');
45 ok(exists $dml_end[2], 'domain ends are present');
46 ok(exists $dml_color[2], 'domain colors are present');
48 #Some logical tests 
49 cmp_ok($dml_start[0], '<=', $dml_end[0],'label - first end is further than first start');         
50 cmp_ok($dml_start[1], '<=', $dml_end[1],'label - second end is further than second start');     
51 cmp_ok($dml_start[2], '<=', $dml_end[2],'label - third end is further than third start');          
52 cmp_ok($domain_start[0], '>=', $dml_start[0],'first label start is within domain range');        
53 cmp_ok($domain_start[1], '>=',$dml_start[1],'second label start is within domain range');        
54 cmp_ok($domain_start[2], '>=',$dml_start[2],'third label start is within domain range');        
55 cmp_ok($domain_end[0], '>=',$dml_end[0],'first label end is within domain range');        
56 cmp_ok($domain_end[1], '>=',$dml_end[1],'second label end is within domain range');        
57 cmp_ok($domain_end[2], '>=',$dml_end[2],'third label end is within domain range');        
59 #Create individual labels
60 my %labels = ( 145 => "Hep-c target");
61 ok(exists $labels{145}, 'individual labels work');
63 #my $output_file = test_output_file();
65 my $print_align = Bio::Align::Graphics->new( align => $aln,
66                                         pad_bottom => 5,
67                                         dm_start => \@domain_start,
68                                         dm_end => \@domain_end,
69                                         dm_color => \@domain_color,
70                                         dm_labels => \@dml,
71                                         dml_start => \@dml_start,
72                                         dml_end => \@dml_end,
73                                         dml_color => \@dml_color,
74                                         labels => \%labels,
75                                         out_format => "png",
76 #                                       output=>$output_file,
77                                         wrap=>80);
79 isa_ok($print_align, 'Bio::Align::Graphics');
80 ok( defined $print_align, 'new object is defined');
81 is($print_align->{pad_bottom}, 5, '  pad_bottom is right');
82 is($print_align->{pad_top}, 5, '  default pad_top is right');
83 is_deeply($print_align->{domain_start}, \@domain_start,'  start point loaded');
84 is_deeply($print_align->{domain_end}, \@domain_end,'  end point loaded');
85 is_deeply($print_align->{domain_color}, \@domain_color,'  color of domain loaded');
86 is_deeply($print_align->{dm_labels}, \@dml, '  domain labels loaded');
87 is_deeply($print_align->{dm_label_start}, \@dml_start, '  label starts loaded');
88 is_deeply($print_align->{dm_label_end}, \@dml_end, '  label ends loaded');
89 is_deeply($print_align->{dm_label_color}, \@dml_color, '  label colors loaded');
90 is_deeply($print_align->{labels}, \%labels, '  labels loaded');
91 is($print_align->{out_format}, 'png', '  output file is png');
92 isnt($print_align->{wrapping}, 0, '  wrapping length is not zero');
94 exit;