ensembl-hive  2.8.1
AedesAegypti.pm
Go to the documentation of this file.
1 =head1 LICENSE
2 
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5 
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
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
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.
17 
18 =cut
19 
20 
21 =head1 CONTACT
22 
23  Please email comments or questions to the public Ensembl
24  developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25 
26  Questions may also be sent to the Ensembl help desk at
27  <http://www.ensembl.org/Help/Contact>.
28 
29 =cut
30 
31 package Bio::EnsEMBL::IdMapping::StableIdGenerator::AedesAegypti;
32 
33 # Package that implements incrementing and verification of Aedes aegypti
34 # stable IDs as used by the VectorBase project.
35 
36 use strict;
37 use warnings;
38 
40 
42 
43  # This method will increment a stable ID. For Aedes aegypti, it will
44  # pick out the numerical part of the stable ID (no matter what type of
45  # stable ID it is) and increment it by one. It will then replace the
46  # numerical part by the incremented value and return the new stable
47  # ID. The parsing of the stable ID is very naive.
48 
49  my ( $self, $stable_id ) = @_;
50 
51  if ( !$self->is_valid($stable_id) ) {
52  throw("Unknown or missing stable ID: $stable_id.");
53  }
54 
55  $stable_id =~ /^(\D*)(\d+)(\D*)/;
56 
57  my $number_as_string = "$2";
58  my $number = $2 + 1;
59  $stable_id = sprintf(
60  "%s" . sprintf( "%%0%dd", length($number_as_string) ) . "%s",
61  $1, $number, $3 );
62 
63  return $stable_id;
64 }
65 
66 sub is_valid {
67 
68  # A stable ID is a valid Aedes aegypti stable ID if it begins with the
69  # character string "AAEL".
70 
71  my ( $self, $stable_id ) = @_;
72 
73  if ( !( defined($stable_id) && $stable_id =~ /^AAEL/ ) ) { return 0 }
74 
75  return 1;
76 }
77 
78 1;
Bio::EnsEMBL::IdMapping::StableIdGenerator::EnsemblGeneric
Definition: EnsemblGeneric.pm:69
increment_stable_id
public increment_stable_id()