3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
37 Used when dumping Slices which represet a portion of the sequence region
38 they
map to e.g. the first section of human Y. The code will
return N
39 as sequence
if an attempt is made to retrieve sequence not covered by the
40 Slice given. This makes the code very memory efficient
if sequence dumping
41 is carried out
using C<subseq()> calls.
47 package Bio::EnsEMBL::PaddedSlice;
58 Arg [SLICE] : The
Slice to proxy
60 Description : Provides a
new instance of a padded slice
69 my ($class, @args) = @_;
70 my ($slice) = rearrange([qw/slice/], @args);
71 return $class->SUPER::new($slice);
76 Example : $slice->start();
77 Description : Always returns 1 since all padded slices start at 1
92 Example : $slice->end();
93 Description : Always returns the backing slice sequence region length
103 return $self->seq_region_length();
108 Example : $slice->length();
109 Description : Delegates to C<end()>
124 Example : my $seq = $slice->seq()
125 Description : Returns the entire sequence of the backing slice but padded
126 with N
's at the beginning and the end of the slice where
128 Returntype : Scalar string
137 my $parent_slice = $self->__proxy();
138 my $pad_start = 'N
' x ( $parent_slice->start() - 1 );
139 my $pad_end = 'N
' x ( $parent_slice->seq_region_length() - $parent_slice->end() );
140 my $seq = $parent_slice->seq();
141 return $pad_start . $seq . $pad_end;
146 Arg [1] : Int; start position of the subslice
147 Arg [2] : Int; end position of the subslice
148 Arg [3] : Int; strand of the subslice
149 Example : my $subseq = $slice->subseq(1, 1_000_000);
150 Description : Returns a portion of the sequence padded with N's
if required
151 Returntype : Scalar
string
159 my ( $self, $start, $end, $strand ) = @_;
161 if ( $end+1 < $start ) {
162 throw(
"End coord + 1 is less than start coord");
165 return '' if( $start == $end + 1);
167 $strand = 1 unless(defined $strand);
168 assert_strand($strand,
'strand');
170 my $parent_slice = $self->__proxy();
172 #Coords relative to the SeqRegion i.e. huge
173 my $parent_start = $parent_slice->start();
174 my $parent_end = $parent_slice->end();
176 #Return if we were upstream of overlap
177 if($start < $parent_start && $end < $parent_start) {
178 return 'N' x (( $end - $start )+1);
180 #Return if we were downstream of overlap
181 if($start > $parent_end && $end > $parent_end) {
182 return 'N' x (( $end - $start )+1);
187 my $subslice_start = ($start - $parent_start)+1;
188 my $subslice_end = ($end - $parent_start) + 1;
189 if($start < $parent_start) {
190 $prefix =
'N' x ($parent_start - $start);
193 if($end > $parent_end) {
194 $suffix =
'N' x ($end - $parent_end);
195 $subslice_end = (($parent_end - $parent_start)+1);
198 my $subseq = $parent_slice->subseq($subslice_start, $subslice_end, $strand);
200 return $prefix . $subseq . $suffix;
205 Arg [1] : Int; start position of the subslice
206 Arg [2] : Int; end position of the subslice
207 Arg [3] : Int; strand of the subslice
208 Example : my $subseq = $slice->subseq(1, 1_000_000);
209 Description : Returns a portion of the sequence padded with N
's if required
210 Returntype : Scalar string
224 Description : Delegates all non-overriden actions onto the backing slice
233 my ($self, $package_name, $method) = @_;
235 my ($local_self, @args) = @_;
236 return $local_self->__proxy()->$method(@args);