move ASN1 back to .travis.yml
[bioperl-live.git] / t / SeqEvolution.t
blob27e89f4ed353b68ac55d0fae28658819d3267cdd
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 39);
11         
12     use_ok('Bio::SeqEvolution::Factory');
13     use_ok('Bio::PrimarySeq');
17 # point mutations
20 ok my $evolve = Bio::SeqEvolution::Factory->new (-verbose => 1);
21 isa_ok $evolve, 'Bio::SeqEvolution::DNAPoint';
23 ok $evolve = Bio::SeqEvolution::DNAPoint->new (-verbose => 2);
24 isa_ok $evolve, 'Bio::SeqEvolution::DNAPoint';
26 ok $evolve = Bio::SeqEvolution::Factory->new (-verbose => 3,
27                                              -type => 'Bio::SeqEvolution::DNAPoint');
28 isa_ok $evolve, 'Bio::SeqEvolution::DNAPoint';
31 my $seq = Bio::PrimarySeq->new(-id=>'test',
32                               -seq=>'aaacccgggtta'
33                              );
35 ok $evolve = Bio::SeqEvolution::Factory->new (-verbose => 0,
36                                               -foo => 'bar',
37                                               -rate => 5,
38                                               -seq => $seq
39                                              );
41 is $evolve->seq->id, 'test';
42 is $evolve->rate, 5,               'get rate()';
43 is $evolve->rate(2), 2,            'get and set rate()';
46 is $evolve->identity(80), 80, 'identity()';
47 is $evolve->identity(undef), undef, 'identity()';
49 is $evolve->pam, undef, 'pam()';
50 is $evolve->pam(80), 80, 'pam()';
52 is $evolve->mutation_count, undef, 'mutation_count()';
53 is $evolve->mutation_count(5), 5, , 'mutation_count()';
57 is $evolve->seq_type, 'Bio::PrimarySeq', 'seq_type()';
58 is $evolve->seq_type('Bio::Seq'), 'Bio::Seq', 'seq_type()';
60 ok my $newseq = $evolve->next_seq, 'next_seq()';
62 foreach ( $evolve->each_mutation('string')) {
63     ok $_;
65 is $evolve->each_mutation, 5, 'each_mutation()';
67 ok $evolve = Bio::SeqEvolution::Factory->new (-verbose => 0,
68                                               -rate => 5,
69                                               -seq => $seq,
70                                               -identity => 50     ###
71                                              );
72 ok $newseq = $evolve->next_seq;
73 cmp_ok $evolve->get_alignment_identity, '<=', 50, "get_alignment_identity()";
75 ok $evolve = Bio::SeqEvolution::Factory->new (-verbose => 0,
76                                               -rate => 5,
77                                               -seq => $seq,
78                                               -pam => 50     ###
79                                              );
80 ok $newseq = $evolve->next_seq;
81 is $evolve->get_mutation_counter, 6, 'get_mutation_counter()';
82 $newseq = $evolve->next_seq;
83 is $evolve->get_sequence_counter, 2, 'get_sequence_counter()';
84 ok $evolve->reset_sequence_counter(), 'reset_sequence_counter()';
85 is $evolve->get_sequence_counter, 0, 'get_sequence_counter() == 0';
87 ok $evolve = Bio::SeqEvolution::Factory->new (-verbose => 0,
88                                               -rate => 5,
89                                               -seq => $seq,
90                                               -pam => 50
91                                              );
93 ok $newseq = $evolve->next_seq;
94 # ok $evolve->get_alignment_identity <= 50, "get_alignment_identity()";
95 isa_ok $evolve->get_alignmet, 'Bio::SimpleAlign';
99 #print "-----------------------------------------\n";
100 #print $evolve->{'_ori_locatableseq'}->seq, "\n";
101 #print $evolve->{'_mut_locatableseq'}->seq, "\n";
102 #print $evolve->{'_align'}->overall_percentage_identity, "\n";
103 #print $evolve->get_mutation_counter, "\n";
104 #print "-----------------------------------------\n";
109 # indels
112 #use Bio::SeqEvolution::DNAIndel;
113 #ok $evolve = Bio::SeqEvolution::DNAIndel->new (-verbose => 0,
114 #                                               -mutation_count => 3,
115 #                                               -rate => 1,
116 #                                               -seq => $seq
117 #                                             );
121 #ok $newseq = $evolve->next_seq;
122 #ok $evolve->get_mutation_counter, 3;
123 ##print Dumper $evolve;
125 #foreach ( $evolve->each_mutation) {
126 ##    print Dumper $_;
127 ##    print $_->sysname, "\n";
128 #    ok $_->sysname;
132 #ok $evolve = Bio::SeqEvolution::DNAIndel->new (-verbose => 0,
133 #                                               -duplication => 1,
134 ##                                               -identity =>50,
135 #                                               -mutation_count => 3,
136 #                                               -rate => 1,
137 #                                               -seq => $seq
138 #                                             );
139 ##$evolve->{'_mut_string'} = $evolve->{'_ori_string'};
141 ##ok $newseq = $evolve->mutate(12);
142 #ok $newseq = $evolve->next_seq;
143 ##print Dumper $evolve;
144 ##print $evolve->{'_ori_locatableseq'}->seq, "\n";
145 ##print $evolve->{'_mut_locatableseq'}->seq, "\n";
147 #print "-----------------------------------------\n";
148 #print $evolve->{'_ori_locatableseq'}->seq, "\n";
149 #print $evolve->{'_mut_locatableseq'}->seq, "\n";
150 #print $evolve->{'_align'}->overall_percentage_identity, "\n";
151 #print "-----------------------------------------\n";
155 ## mixer, simulation
159 #ok my $evolve2 = Bio::SeqEvolution::Factory->new (-verbose => 0,
160 #                                                  -rate => 2,
161 #                                                  -seq => $seq,
162 #                                                  -set_mutated_seq => $newseq,
163 ##                                                  -identity => 50
164 #                                                  -mutation_count => 1     ###
165 #                                             );
166 #ok $evolve2->seq_type('Bio::LocatableSeq');
168 #print "=-----------------------------------------\n";
169 #print $evolve2->{'_ori_locatableseq'}->seq, "\n";
170 #print $evolve2->{'_mut_locatableseq'}->seq, "\n";
171 #print $evolve2->{'_align'}->overall_percentage_identity, "\n";
172 #print "-----------------------------------------\n";
174 #ok $newseq = $evolve2->next_seq;
177 #print "-----------------------------------------\n";
178 #print $evolve2->{'_ori_locatableseq'}->seq, "\n";
179 #print $evolve2->{'_mut_locatableseq'}->seq, "\n";
180 #print $evolve2->{'_align'}->overall_percentage_identity, "\n";
181 #print "-----------------------------------------\n";