File: SubSeq.t

package info (click to toggle)
bioperl 1.7.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 35,888 kB
  • sloc: perl: 94,151; xml: 14,982; makefile: 20
file content (108 lines) | stat: -rw-r--r-- 2,561 bytes parent folder | download | duplicates (2)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
use strict;

BEGIN {
    use Bio::Root::Test;
    
    test_begin(-tests => 37);

    use_ok 'Bio::PrimarySeq';
    use_ok 'Bio::SeqFeature::SubSeq';
}

my ($subseq, $subseq_seq, $subsubseq, $subsubseq_seq, $template);


# Basic SubSeq object

$subseq = Bio::SeqFeature::SubSeq->new();
isa_ok $subseq, 'Bio::SeqFeature::SubSeq';
isa_ok $subseq, 'Bio::SeqFeature::Generic';
is $subseq->length, undef;


# SubSeq with explicit sequence (sequence string)

ok $subseq = Bio::SeqFeature::SubSeq->new(
    -seq => 'CCCCCAAAAAGGGGGTTTTT',
);
is $subseq->length, 20;
ok $subseq_seq = $subseq->seq;
isa_ok $subseq_seq, 'Bio::PrimarySeq';
is $subseq_seq->seq, 'CCCCCAAAAAGGGGGTTTTT';


# SubSeq with explicit sequence (sequence object)

ok $subseq = Bio::SeqFeature::SubSeq->new(
    -seq => Bio::PrimarySeq->new( -seq => 'CCCCCAAAAAGGGGGTTTTT' ),
);
is $subseq->length, 20;
ok $subseq_seq = $subseq->seq;
isa_ok $subseq_seq, 'Bio::PrimarySeq';
is $subseq_seq->seq, 'CCCCCAAAAAGGGGGTTTTT';


# SubSeq with explicit sequence and coordinates

ok $subseq = Bio::SeqFeature::SubSeq->new(
    -seq    => Bio::PrimarySeq->new( -seq => 'CCCCCAAAAAGGGGGTTTTT' ),
    -start  => 11,
    -end    => 40,
    -strand => -1
);
is $subseq->length, 30;
ok $subseq_seq = $subseq->seq;
isa_ok $subseq_seq, 'Bio::PrimarySeq';
is $subseq_seq->seq, 'CCCCCAAAAAGGGGGTTTTT';


# Subseq with implicit sequence

$template = Bio::Seq->new( -seq => 'ATCGATCGATCCCCCAAAAAGGGGGTTTTTAGCTAGCTAT');

ok $subseq = Bio::SeqFeature::SubSeq->new(
    -start  => 11,
    -end    => 30,
    -strand => -1
);
is $subseq->length, 20;

ok $template->add_SeqFeature($subseq);
ok $subseq_seq = $subseq->seq;
isa_ok $subseq_seq, 'Bio::PrimarySeq';
is $subseq_seq->seq, 'AAAAACCCCCTTTTTGGGGG';


# Subseq with implicit sequence

$template = Bio::Seq->new( -seq => 'ATCGATCGATCCCCCAAAAAGGGGGTTTTTAGCTAGCTAT');

ok $subseq = Bio::SeqFeature::SubSeq->new(
    -start    => 11,
    -end      => 30,
    -strand   => -1,
    -template => $template,
);
is $subseq->length, 20;
ok $subseq_seq = $subseq->seq;
isa_ok $subseq_seq, 'Bio::PrimarySeq';
is $subseq_seq->seq, 'AAAAACCCCCTTTTTGGGGG';


# Sub SubSeq

ok $subsubseq = Bio::SeqFeature::SubSeq->new(
    -start    => 11,
    -end      => 15,
    -strand   => 1,
    -template => $subseq,
);
is $subsubseq->length, 5;
ok $subsubseq_seq = $subsubseq->seq;
isa_ok $subsubseq_seq, 'Bio::PrimarySeq';
is $subsubseq_seq->seq, 'CCCCC';


# One-liner

is( Bio::SeqFeature::SubSeq->new(-start=>11,-end=>30,-strand=>1,-template=>$template)->seq->seq, 'CCCCCAAAAAGGGGGTTTTT' );