File: Pictogram.t

package info (click to toggle)
bioperl 1.4-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 20,336 kB
  • ctags: 8,476
  • sloc: perl: 119,890; xml: 6,001; lisp: 121; makefile: 57
file content (73 lines) | stat: -rw-r--r-- 1,976 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*-Perl-*-
## Bioperl Test Harness Script for Modules


use strict;
use vars qw($NTESTS $SVG_AVAIL);

BEGIN {
    eval { require Test; };
    if( $@ ) {
        use lib 't';
    }
    use Test;
    $NTESTS = 3;
    plan tests => $NTESTS;
    eval {
	require Bio::Graphics::Pictogram;
    };
    $SVG_AVAIL = $@ ? 0 : 1;
}

END {
    for ( $Test::ntest..$NTESTS ) {
        skip("SVG module not found. Skipping. ",1);
    }
}

if(!$SVG_AVAIL){
  warn("SVG not installed, skipping tests");
  exit;
}

use Bio::SeqIO;
use Bio::Matrix::PSM::IO;

my $file =  Bio::Root::IO->catfile("t","data","pictogram.fa");
my $sio = Bio::SeqIO->new(-file=>$file,-format=>'fasta');
my @seq;
while(my $seq = $sio->next_seq){
  push @seq, $seq;
}
my $picto = Bio::Graphics::Pictogram->new(-width=>"800",
                                          -fontsize=>"80",
                                          -plot_bits=>1,
                                          -color=>{'A'=>'red',
                                                   'G'=>'blue',
                                                   'C'=>'green',
                                                   'T'=>'magenta'});
ok $picto->isa("Bio::Graphics::Pictogram");

my $svg = $picto->make_svg(\@seq);
ok $svg->xmlify;

my $psmIO =  new Bio::Matrix::PSM::IO(-format=>'meme', 
                                   -file=> Bio::Root::IO->catfile(qw(t data meme.dat)));
$picto = Bio::Graphics::Pictogram->new(-width=>"800",
                                          -normalize=>1,
                                          -fontsize=>"80",
                                          -plot_bits=>1,
                                          -color=>{'A'=>'red',
                                                   'G'=>'blue',
                                                   'C'=>'green',
                                                   'T'=>'magenta'});

my $psm = $psmIO->next_psm;
$svg = $picto->make_svg($psm);
ok $svg->xmlify;