| 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 | =head1 NAME | ||
| 32 | |||
| 33 | Bio::EnsEMBL::IdMapping::Entry - object representing a ScoredMappingMatrix entry | ||
| 34 | |||
| 35 | =head1 SYNOPSIS | ||
| 36 | |||
| 37 | =head1 DESCRIPTION | ||
| 38 | |||
| 39 | This object represents a ScoredMappingMatrix entry. It is defined by a | ||
| 40 | pair of a source and target object's internal Id and a score for this | ||
| 41 | mapping. | ||
| 42 | |||
| 43 | =head1 METHODS | ||
| 44 | |||
| 45 | new | ||
| 46 | new_fast | ||
| 47 | source | ||
| 48 | target | ||
| 49 | score | ||
| 50 | to_string | ||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | package Bio::EnsEMBL::IdMapping::Entry; | ||
| 55 | $Bio::EnsEMBL::IdMapping::Entry::VERSION = '114.0.0_50'; # TRIAL | ||
| 56 | $Bio::EnsEMBL::IdMapping::Entry::VERSION = '114.0.050'; | ||
| 57 | use strict; | ||
| 58 | use warnings; | ||
| 59 | no warnings 'uninitialized'; | ||
| 60 | |||
| 61 | use Bio::EnsEMBL::Utils::Exception qw(throw warning); | ||
| 62 | |||
| 63 | |||
| 64 | =head2 new | ||
| 65 | |||
| 66 | Example : my $entry = Bio::EnsEMBL::IdMapping::Entry->new(); | ||
| 67 | Description : Constructor. This is a no-argument constructor, so you need to | ||
| 68 | populate the object manually. Rarely used since in most cases | ||
| 69 | new_fast() is preferred. | ||
| 70 | Return type : a Bio::EnsEMBL::IdMapping::Entry object | ||
| 71 | Exceptions : none | ||
| 72 | Caller : general | ||
| 73 | Status : At Risk | ||
| 74 | : under development | ||
| 75 | |||
| 76 | =cut | ||
| 77 | |||
| 78 | sub new { | ||
| 79 | my $caller = shift; | ||
| 80 | my $class = ref($caller) || $caller; | ||
| 81 | |||
| 82 | my $self = []; | ||
| 83 | bless ($self, $class); | ||
| 84 | |||
| 85 | return $self; | ||
| 86 | } | ||
| 87 | |||
| 88 | |||
| 89 | =head2 new_fast | ||
| 90 | |||
| 91 | Arg[1] : Arrayref $array_ref - the arrayref to bless into the Entry | ||
| 92 | object | ||
| 93 | Example : my $entry = Bio::EnsEMBL::IdMapping::Entry->new_fast([ | ||
| 94 | $source_gene->id, $target_gene->id, 0.9]); | ||
| 95 | Description : Fast constructor. | ||
| 96 | Return type : a Bio::EnsEMBL::IdMapping::Entry object | ||
| 97 | Exceptions : none | ||
| 98 | Caller : general | ||
| 99 | Status : At Risk | ||
| 100 | : under development | ||
| 101 | |||
| 102 | =cut | ||
| 103 | |||
| 104 | sub new_fast { | ||
| 105 | my $class = shift; | ||
| 106 | my $array_ref = shift; | ||
| 107 | return bless $array_ref, $class; | ||
| 108 | } | ||
| 109 | |||
| 110 | |||
| 111 | =head2 source | ||
| 112 | |||
| 113 | Arg[1] : (optional) Int - source object's internal Id | ||
| 114 | Description : Getter/setter for source object's internal Id. | ||
| 115 | Return type : Int | ||
| 116 | Exceptions : none | ||
| 117 | Caller : general | ||
| 118 | Status : At Risk | ||
| 119 | : under development | ||
| 120 | |||
| 121 | =cut | ||
| 122 | |||
| 123 | sub source { | ||
| 124 | my $self = shift; | ||
| 125 | $self->[0] = shift if (@_); | ||
| 126 | return $self->[0]; | ||
| 127 | } | ||
| 128 | |||
| 129 | |||
| 130 | =head2 target | ||
| 131 | |||
| 132 | Arg[1] : (optional) Int - target object's internal Id | ||
| 133 | Description : Getter/setter for target object's internal Id. | ||
| 134 | Return type : Int | ||
| 135 | Exceptions : none | ||
| 136 | Caller : general | ||
| 137 | Status : At Risk | ||
| 138 | : under development | ||
| 139 | |||
| 140 | =cut | ||
| 141 | |||
| 142 | sub target { | ||
| 143 | my $self = shift; | ||
| 144 | $self->[1] = shift if (@_); | ||
| 145 | return $self->[1]; | ||
| 146 | } | ||
| 147 | |||
| 148 | |||
| 149 | =head2 score | ||
| 150 | |||
| 151 | Arg[1] : (optional) Float - a score | ||
| 152 | Description : Getter/setter for score for the mapping between source and | ||
| 153 | target object. | ||
| 154 | Return type : Float | ||
| 155 | Exceptions : none | ||
| 156 | Caller : general | ||
| 157 | Status : At Risk | ||
| 158 | : under development | ||
| 159 | |||
| 160 | =cut | ||
| 161 | |||
| 162 | sub score { | ||
| 163 | my $self = shift; | ||
| 164 | $self->[2] = shift if (@_); | ||
| 165 | return $self->[2]; | ||
| 166 | } | ||
| 167 | |||
| 168 | |||
| 169 | =head2 to_string | ||
| 170 | |||
| 171 | Example : print LOG $entry->to_string, "\n"; | ||
| 172 | Description : Returns a string representation of the Entry object. Useful for | ||
| 173 | debugging and logging. | ||
| 174 | Return type : String | ||
| 175 | Exceptions : none | ||
| 176 | Caller : general | ||
| 177 | Status : At Risk | ||
| 178 | : under development | ||
| 179 | |||
| 180 | =cut | ||
| 181 | |||
| 182 | sub to_string { | ||
| 183 | my $self = shift; | ||
| 184 | return sprintf('%-10s%-10s%-5.6f', $self->source, $self->target, $self->score); | ||
| 185 | } | ||
| 186 | |||
| 187 | |||
| 188 | 1; | ||
| 189 |