docfix, an array of genes can be returned
[bioperl-run.git] / t / Sim4.t
blobd90fb4f679c4d8e86dd32f476ecff73c6f303eca
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
5 use strict;
6 BEGIN {
7     eval { require Test; };
8     if( $@ ) {
9         use lib 't';
10     }
11     use Test;
12     use vars qw($NTESTS);
13     $NTESTS = 20;
14     plan tests => $NTESTS;
16 use Bio::Tools::Run::Alignment::Sim4;
17 use Bio::SimpleAlign;
18 use Bio::AlignIO;
19 use Bio::SeqIO;
20 use Bio::Root::IO;
22 END {
23     for ( $Test::ntest..$NTESTS ) {
24         skip("sim4 program not found. Skipping. (Be sure you have installed Sim4)",1);
25     }
28 ok(1);
29 my $verbose = -1;
31 my $cdna = Bio::Root::IO->catfile("t","data","sim4_cdna.fa");
32 my $genomic = Bio::Root::IO->catfile("t","data","sim4_genomic.fa");
33 my @params = (W=>15,K=>17,D=>10,N=>10,cdna_seq=>$cdna,genomic_seq=>$genomic);
34 my  $factory = Bio::Tools::Run::Alignment::Sim4->new(@params);
36 unless (defined $factory->executable) {
37     warn("Sim4 program not found. Skipping tests $Test::ntest to $NTESTS.\n");
38     exit 0;
41 ok $factory->isa('Bio::Tools::Run::Alignment::Sim4');
42 my $bequiet = 1;
43 $factory->quiet($bequiet);  # Suppress clustal messages to terminal
45 #test by having inputs in constructor
46 my @exon_set = $factory->align;
48 my @exons = $exon_set[0]->sub_SeqFeature;
49 ok $exons[0]->start, 26;
50 ok $exons[0]->end, 268;
51 ok $exons[0]->strand, 1;
54 my $sio = Bio::SeqIO->new(-file=>$cdna,-format=>"fasta");
55 my $sio2 = Bio::SeqIO->new(-file=>$genomic,-format=>"fasta");
57 #test with 2 seq objs
58 my @cdna_seq;
59 while(my $seq = $sio->next_seq){
60     push @cdna_seq,$seq;
62 my @genomic_seq;
63 while(my $seq = $sio2->next_seq){
64     push @genomic_seq,$seq;
67 @exon_set = $factory->align($cdna_seq[0],$genomic_seq[0]);
69 @exons = $exon_set[0]->sub_SeqFeature;
70 ok $exons[0]->start, 26;
71 ok $exons[0]->end, 268;
72 ok $exons[0]->strand, 1;
74 #test with cdna database as file
76 my $db =  Bio::Root::IO->catfile("t","data","sim4_database.fa");
77 @params = (W=>15,K=>17,D=>10,N=>10,cdna_seq=>$db,genomic_seq=>$genomic);
78 $factory = Bio::Tools::Run::Alignment::Sim4->new(@params);
80 @exon_set = $factory->align();
81 @exons = $exon_set[0]->sub_SeqFeature;
82 ok $exons[0]->start, 26;
83 ok $exons[0]->end, 268;
84 ok $exons[0]->strand, 1;
86 @exons = $exon_set[1]->sub_SeqFeature;
87 ok $exons[0]->start, 26;
88 ok $exons[0]->end, 268;
89 ok $exons[0]->strand, 1;
92 #test with cdna database as object
94 $sio = Bio::SeqIO->new(-file=>$db,-format=>"fasta");
95 @cdna_seq=();
96 while(my $seq = $sio->next_seq){
97     push @cdna_seq,$seq;
99     
100 $factory->align(\@cdna_seq,$genomic);
102 @exon_set = $factory->align();
103 @exons = $exon_set[0]->sub_SeqFeature;
104 ok $exons[0]->start, 26;
105 ok $exons[0]->end, 268;
106 ok $exons[0]->strand, 1;
108 @exons = $exon_set[1]->sub_SeqFeature;
109 ok $exons[0]->start, 26;
110 ok $exons[0]->end, 268;
111 ok $exons[0]->strand, 1;