more, better tests for the new implementation for tree/bootstrap -- still some things...
[bioperl-run.git] / t / Vista.t
blob614b5cca8c11842dc5c75039f9980545dc4345dc
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
4 use strict;
5 BEGIN {
6     eval { require Test; };
7     if( $@ ) {
8         use lib 't';
9     }
10     use Test;
11     use vars qw($NTESTS);
12     $NTESTS = 5;
13     plan tests => $NTESTS;
16 use vars qw( $reason);
17 $reason = 'Unable to run Vista , java may not be installed';
19 END {
20    foreach ( $Test::ntest..$NTESTS ) {
21        skip($reason,1);
22    }
23    unlink "t/data/vista.pdf";
26 use Bio::Tools::Run::Vista;
27 use Bio::AlignIO;
29 #Java and java version check
30 my $v;
31 if (-d "java") {
32     print STDERR "You must have java to run vista\n";
33     $reason = "Skipping because no java present to run vista ";
34     exit(0);
36 my $output = `java -version 2>&1`;
37 open(PIPE,"java -version 2>&1 |");
39 while (<PIPE>) { 
40     if (/Java\sVersion\:\s(\d+\.\d+)/) {
41         $v = $1;
42         last;
43     }
44     elsif (/java version\s.(\d+\.\d+)/) {
45         $v = $1;
46         last;
47     }
48     elsif (/java version\s\"(\d\.\d)"/) {
49          $v = $1;
50         last;
51     }
53 if ($v < 1.2) {
54     print STDERR "You need at least version 1.2 of JDK to run vista\n";
55     $reason = "Skipping due to old java version";
56     exit(0);   
57 }   
58 open (PIPE ,'java Vista 2>&1 |');
59 while(<PIPE>){
60   if(/NoClassDefFoundError/){
61     print STDERR "Vista.jar is not your class path \n";
62     exit(0);
63   }
65 my $inputfilename= Bio::Root::IO->catfile("t","data","vista.cls");
66 my $gff_file = Bio::Root::IO->catfile("t","data","vista.gff");
67 my $aio = Bio::AlignIO->new(-file=>$inputfilename,-format=>'clustalw');
68 my $aln = $aio->next_aln;
70 my $out= Bio::Root::IO->catfile("t","data","vista.pdf");
71 my $vis = Bio::Tools::Run::Vista->new('outfile'=>$out,
72                                       'title' => "My Vista Plot",
73                                         'annotation'=>$gff_file,
74                                         'annotation_format'=>'GFF',
75                                         'min_perc_id'=>75,
76                                         'min_length'=>100,
77                                         'plotmin'   => 50,
78                                         'tickdist' => 2000,
79                                         'window'=>40,
80                                         'numwindows'=>4,
81                                         'start'=>50,
82                                         'end'=>1500,
83                                         'tickdist'=>100,
84                                         'bases'=>1000,
85                                         'color'=> {'EXON'=>'45 25 54','CNS'=>'0 0 100'},
86                                         'quiet'=>1);
87 ok $vis->isa('Bio::Tools::Run::Vista');
88 ok $vis->plotmin, 50,
89 ok $vis->annotation, $gff_file;
91 $vis->run($aln,1);
92 ok -e $out;
93 unlink $out;
94 $vis->run($aln,'mouse');
95 ok -e $out;