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