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