~ubuntu-branches/ubuntu/oneiric/bioperl/oneiric

« back to all changes in this revision

Viewing changes to t/SeqUtils.t

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*-Perl-*-
2
2
## Bioperl Test Harness Script for Modules
3
 
##$Id: SeqUtils.t,v 1.8 2001/12/14 13:37:35 heikki Exp $
 
3
##$Id: SeqUtils.t,v 1.13 2003/08/12 20:16:48 jason Exp $
4
4
 
5
5
use strict;
6
6
 
7
 
BEGIN {     
 
7
BEGIN {
8
8
    # to handle systems with no installed Test module
9
9
    # we include the t dir (where a copy of Test.pm is located)
10
10
    # as a fallback
13
13
        use lib 't';
14
14
    }
15
15
    use Test;
16
 
    plan tests => 17;
 
16
    plan tests => 21;
17
17
}
18
18
 
19
19
use Bio::PrimarySeq;
20
20
use Bio::SeqUtils;
 
21
use Bio::LiveSeq::Mutation;
21
22
ok 1;
22
23
 
23
24
my ($seq, $util, $ascii, $ascii_aa, $ascii3);
27
28
$ascii_aa = 'ABCDEFGHIXKLMNXPQRSTUVWXYZ';
28
29
 
29
30
$ascii3 = 
30
 
    'AlaAsxCysAspGluPheGlyHisIleXaaLysLeuMetAsnXaaProGlnArgSerThrSelValTrpXaaTyrGlx';
 
31
    'AlaAsxCysAspGluPheGlyHisIleXaaLysLeuMetAsnXaaProGlnArgSerThrSecValTrpXaaTyrGlx';
31
32
 
32
33
$seq = Bio::PrimarySeq->new('-seq'=> $ascii,
33
 
                               '-alphabet'=>'protein', 
 
34
                            '-alphabet'=>'protein', 
34
35
                               '-id'=>'test');
35
36
 
36
37
# one letter amino acid code to three letter code
41
42
ok (Bio::SeqUtils->seq3($seq), $ascii3); 
42
43
ok (Bio::SeqUtils->seq3($seq, undef, ','), 
43
44
    'Ala,Asx,Cys,Asp,Glu,Phe,Gly,His,Ile,Xaa,Lys,'.
44
 
    'Leu,Met,Asn,Xaa,Pro,Gln,Arg,Ser,Thr,Sel,Val,Trp,Xaa,Tyr,Glx');
 
45
    'Leu,Met,Asn,Xaa,Pro,Gln,Arg,Ser,Thr,Sec,Val,Trp,Xaa,Tyr,Glx');
45
46
 
46
47
$seq->seq('asd-KJJK-');
47
48
ok (Bio::SeqUtils->seq3($seq, '-', ':'), 
65
66
ok scalar @a, 3;
66
67
#foreach $a (@a) {
67
68
#    print 'ID: ', $a->id, ' ', $a->seq, "\n";
68
 
#} 
 
69
#}
69
70
 
70
71
@a = $util->translate_6frames($seq);
71
72
ok scalar @a, 6;
72
73
#foreach $a (@a) {
73
74
#    print 'ID: ', $a->id, ' ', $a->seq, "\n";
74
 
#} 
 
75
#}
75
76
 
 
77
#
76
78
# test for valid AA return
 
79
#
 
80
 
77
81
my @valid_aa = sort Bio::SeqUtils->valid_aa;
78
 
ok(@valid_aa, 24);
79
 
ok ($valid_aa[1], 'B');
 
82
ok(@valid_aa, 25);
 
83
ok ($valid_aa[1], 'A');
 
84
 
80
85
@valid_aa = sort Bio::SeqUtils->valid_aa(1);
81
 
 
82
 
ok(@valid_aa, 24);
83
 
ok ($valid_aa[1], 'Ala');
 
86
ok(@valid_aa, 25);
 
87
ok ($valid_aa[1], 'Arg');
84
88
 
85
89
my %valid_aa = Bio::SeqUtils->valid_aa(2);
86
 
 
 
90
ok keys %valid_aa, 50;
87
91
ok($valid_aa{'C'}, 'Cys');
88
92
ok( $valid_aa{'Cys'}, 'C');
89
93
 
 
94
 
 
95
#
 
96
# Mutate
 
97
#
 
98
 
 
99
my $string1 = 'aggt';
 
100
$seq = Bio::PrimarySeq->new('-seq'=> 'aggt',
 
101
                            '-alphabet'=>'dna',
 
102
                            '-id'=>'test3');
 
103
 
 
104
# point
 
105
Bio::SeqUtils->mutate($seq,
 
106
                      Bio::LiveSeq::Mutation->new(-seq => 'c',
 
107
                                                  -pos => 3
 
108
                                                 )
 
109
                     );
 
110
ok $seq->seq, 'agct';
 
111
 
 
112
# insertion and deletion
 
113
my @mutations = (
 
114
                 Bio::LiveSeq::Mutation->new(-seq => 'tt',
 
115
                                             -pos => 2,
 
116
                                             -len => 0
 
117
                                            ),
 
118
                 Bio::LiveSeq::Mutation->new(-pos => 2,
 
119
                                             -len => 2
 
120
                                            )
 
121
);
 
122
 
 
123
Bio::SeqUtils->mutate($seq, @mutations);
 
124
ok $seq->seq, 'agct';
 
125
 
 
126
# insertion to the end of the sequence
 
127
Bio::SeqUtils->mutate($seq,
 
128
                      Bio::LiveSeq::Mutation->new(-seq => 'aa',
 
129
                                                  -pos => 5,
 
130
                                                  -len => 0
 
131
                                                 )
 
132
                     );
 
133
ok $seq->seq, 'agctaa';