ensembl-hive  2.8.1
AnophelesGambiae.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::AnophelesGambiae;
32 
33 # Package that implements incrementing and verification of Aedes aegypti
34 # stable IDs as used by the VectorBase project.
35 # Based on Aedes_Aegypti.pm
36 # Differs from Aedes in that Exon stable ids like Ennnnnn not AAEL.ennnnnn
37 # and gene/transcript/translation start AGAP not AAEL
38 # also need to exclude old Ensembl-style ids
39 
40 use strict;
41 use warnings;
42 
44 
46 
47  # This method will increment a stable ID. For Anopheles, it will
48  # pick out the numerical part of the stable ID (no matter what type of
49  # stable ID it is) and increment it by one. It will then replace the
50  # numerical part by the incremented value and return the new stable
51  # ID. The parsing of the stable ID is very naive.
52 
53  my ( $self, $stable_id ) = @_;
54 
55  if ( !$self->is_valid($stable_id) ) {
56  throw("Unknown or missing stable ID: $stable_id.");
57  }
58 
59  $stable_id =~ /^(\D*)(\d+)(\D*)/;
60 
61  my $number_as_string = "$2";
62  my $number = $2 + 1;
63  $stable_id = sprintf(
64  "%s" . sprintf( "%%0%dd", length($number_as_string) ) . "%s",
65  $1, $number, $3 );
66 
67  return $stable_id;
68 }
69 
70 sub is_valid {
71 
72  # A stable ID is a valid Anopheles stable ID if it begins with the
73  # character string "AGAP" or (for exons) just "E"
74  # explicitly make the exon one E+digits to exclude old-style ENSANG ids
75  # otherwise ENSANGnnn found as higher then AGAPnnn
76  # when initial_stable_id method checks archive tables
77 
78  my ( $self, $stable_id ) = @_;
79 
80  if ( !( defined($stable_id) && ( $stable_id =~ /^AGAP/ || $stable_id =~ /^E\d+$/ ) ) ) {
81  return 0;
82  }
83 
84  return 1;
85 }
86 
87 1;
Bio::EnsEMBL::IdMapping::StableIdGenerator::EnsemblGeneric
Definition: EnsemblGeneric.pm:69
increment_stable_id
public increment_stable_id()