File: PrimarySeq.t

package info (click to toggle)
bioperl 1.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,784 kB
  • ctags: 4,962
  • sloc: perl: 70,732; xml: 3,279; lisp: 107; makefile: 53
file content (93 lines) | stat: -rw-r--r-- 2,562 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*-Perl-*-
## Bioperl Test Harness Script for Modules
## $Id: PrimarySeq.t,v 1.14 2002/03/08 20:18:32 jason Exp $

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.t'

use strict;
BEGIN { 
    # to handle systems with no installed Test module
    # we include the t dir (where a copy of Test.pm is located)
    # as a fallback
    eval { require Test; };
    if( $@ ) {
	use lib 't';
    }
    use Test;
    plan tests => 23;
}
use Bio::PrimarySeq;
use Bio::Location::Simple;
use Bio::Location::Fuzzy;
use Bio::Location::Split;

ok(1);

my $seq = Bio::PrimarySeq->new('-seq'              =>'TTGGTGGCGTCAACT',
			       '-display_id'       => 'new-id',
			       '-alphabet'          => 'dna',
			       '-accession_number' => 'X677667',
			       '-desc'             =>'Sample Bio::Seq object');
ok defined $seq;
ok $seq->isa('Bio::PrimarySeqI');
ok $seq->accession_number(), 'X677667';
ok $seq->seq(), 'TTGGTGGCGTCAACT';
ok $seq->display_id(), 'new-id';
ok $seq->alphabet(), 'dna';
ok $seq->is_circular(), undef;
ok $seq->is_circular(1);

my $location = new Bio::Location::Simple('-start' => 2, '-end' => 5,
					 '-strand' => -1);
ok ($seq->subseq($location), 'ACCA');

my $splitlocation = new Bio::Location::Split();
$splitlocation->add_sub_Location( new Bio::Location::Simple('-start' => 1,
							    '-end'   => 4,
							    '-strand' => 1));

$splitlocation->add_sub_Location( new Bio::Location::Simple('-start' => 7,
							    '-end'   => 12,
							    '-strand' => -1));

ok( $seq->subseq($splitlocation), 'TTGGTGACGC');

my $fuzzy = new Bio::Location::Fuzzy(-start => '<3',
				     -end   => '8',
				     -strand => 1);

ok( $seq->subseq($fuzzy), 'GGTGGC');

my $trunc = $seq->trunc(1,4);
ok defined $trunc;
ok $trunc->seq(), 'TTGG', "Expecting TTGG. Got ".$trunc->seq();

$trunc = $seq->trunc($splitlocation);
ok( defined $trunc);
ok( $trunc->seq(), 'TTGGTGACGC');

$trunc = $seq->trunc($fuzzy);
ok( defined $trunc);
ok( $trunc->seq(), 'GGTGGC');

my $rev = $seq->revcom();
ok defined $rev; 

ok $rev->seq(), 'AGTTGACGCCACCAA', 'rev faile was ' . $rev->seq();

#
# Translate
#

my $aa = $seq->translate();
ok $aa->seq, 'LVAST', "Translation: ". $aa->seq;

$seq->seq('TTGGTGGCGTCAACTTAA');
$aa = $seq->translate(undef, undef, undef, undef, 1);

# tests for non-Methionin initiator codon (AGT) coding for M
ok $aa->seq, 'MVAST', "Translation: ". $aa->seq;

# test for character '?' in the sequence string
ok $seq->seq('TTGGTGGCG?CAACT'), 'TTGGTGGCG?CAACT';