1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 82);
12 use_ok('Bio::LocatableSeq');
13 use_ok('Bio::AlignIO');
16 my ($str, $aln, $seq, $loc);
18 ok $seq = Bio::LocatableSeq->new(
19 -seq => '--atg---gta--',
23 is $seq->alphabet, 'dna';
28 is $seq->column_from_residue_number(4), 9;
30 ok $loc = $seq->location_from_column(4);
31 isa_ok $loc,'Bio::Location::Simple';
32 is $loc->to_FTstring, 2;
34 ok $loc = $seq->location_from_column(6);
35 isa_ok $loc,'Bio::Location::Simple';
37 is $loc->location_type, 'IN-BETWEEN';
38 is $loc->to_FTstring, '3^4';
41 is $loc = $seq->location_from_column(2), undef;
44 $str = Bio::AlignIO->new(-file=> test_input_file('testaln.pfam'));
46 isa_ok $str,'Bio::AlignIO';
47 $aln = $str->next_aln();
48 ok $seq = $aln->get_seq_by_pos(1);
49 is ref($seq), 'Bio::LocatableSeq';
51 is $seq->get_nse, '1433_LYCES/9-246';
52 is $seq->id, '1433_LYCES';
54 # test revcom and trunc
56 $seq = Bio::LocatableSeq->new(
57 -seq => '--atg---gta--',
62 my $seq2 = $seq->trunc(1,9);
63 is $seq2->seq, '--atg---g';
66 is $seq2->strand, $seq->strand;
68 $seq2 = $seq->trunc(3,8);
69 is $seq2->seq, 'atg---';
73 is $seq->strand(-1), -1;
76 $seq2 = $seq->trunc(3,8);
77 is $seq2->seq, 'atg---';
84 $seq2 = $seq->revcom();
85 is $seq2->seq, '--tac---cat--';
86 is $seq2->start, $seq->start;
87 is $seq2->end, $seq->end;
88 is $seq2->strand, $seq->strand * -1;
90 # test column-mapping for -1 strand sequence
91 $seq = Bio::LocatableSeq->new(
92 -seq => '--atg---gtaa-',
96 is $seq->column_from_residue_number(5),5;
97 is $seq->column_from_residue_number(4),9;
98 ok $loc = $seq->location_from_column(4);
99 isa_ok $loc,'Bio::Location::Simple';
100 is $loc->to_FTstring, 6;
101 ok $loc = $seq->location_from_column(6);
102 isa_ok $loc,'Bio::Location::Simple';
104 is $loc->location_type, 'IN-BETWEEN';
105 is $loc->to_FTstring, '4^5';
108 # more tests for trunc() with strand -1
111 ok $seq = Bio::LocatableSeq->new(
112 -seq => '--atg---gta--',
116 is $seq->alphabet, 'dna';
121 is $seq->column_from_residue_number(4), 5;
124 ok $seq2 = $seq->trunc(1,9);
125 is $seq2->seq, '--atg---g';
128 is $seq2->strand, $seq->strand;
130 is $seq->location_from_column(3)->start, 6;
131 is $seq->location_from_column(11)->start, 1;
132 is $seq->location_from_column(9)->start, 3;
136 ok $seq2 = $seq->trunc(7,12);
137 is $seq2->seq, '--gta-';
142 ok $seq2 = $seq->trunc(2,6);
143 is $seq2->seq, '-atg-';
147 ok $seq2 = $seq->trunc(4,7);
148 is $seq2->seq, 'tg--';
152 ok $seq = Bio::LocatableSeq->new();
154 is $seq->start, undef;