Mercurial > repos > mahtabm > ensemb_rep_gvl
comparison variant_effect_predictor/Bio/EnsEMBL/SimpleFeature.pm @ 0:2bc9b66ada89 draft default tip
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 06:29:17 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2bc9b66ada89 |
---|---|
1 =head1 LICENSE | |
2 | |
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and | |
4 Genome Research Limited. All rights reserved. | |
5 | |
6 This software is distributed under a modified Apache license. | |
7 For license details, please see | |
8 | |
9 http://www.ensembl.org/info/about/code_licence.html | |
10 | |
11 =head1 CONTACT | |
12 | |
13 Please email comments or questions to the public Ensembl | |
14 developers list at <dev@ensembl.org>. | |
15 | |
16 Questions may also be sent to the Ensembl help desk at | |
17 <helpdesk@ensembl.org>. | |
18 | |
19 =cut | |
20 | |
21 =head1 NAME | |
22 | |
23 Bio::EnsEMBL::SimpleFeature - A simple feature with a location and label | |
24 | |
25 =head1 SYNOPSIS | |
26 | |
27 use Bio::EnsEMBL::SimpleFeature; | |
28 | |
29 $feature = Bio::EnsEMBL::SimpleFeature->new( | |
30 -start => 100, | |
31 -end => 220, | |
32 -strand => -1, | |
33 -slice => $slice, | |
34 -analysis => $analysis, | |
35 -score => 58, | |
36 -display_label => 'EponineTSS', | |
37 -dbID => 1230, | |
38 -adaptor => $adaptor | |
39 ); | |
40 | |
41 =head1 DESCRIPTION | |
42 | |
43 This is a simple feature which extends the Feature class to add | |
44 display_label and score attributes. | |
45 | |
46 =head1 METHODS | |
47 | |
48 =cut | |
49 | |
50 use strict; | |
51 | |
52 package Bio::EnsEMBL::SimpleFeature; | |
53 | |
54 use vars qw(@ISA); | |
55 | |
56 use Bio::EnsEMBL::Feature; | |
57 use Bio::EnsEMBL::Utils::Argument qw(rearrange); | |
58 use Scalar::Util qw(weaken isweak); | |
59 | |
60 @ISA = qw(Bio::EnsEMBL::Feature); | |
61 | |
62 | |
63 =head2 new | |
64 | |
65 Arg [DISPLAY_LABEL]: The label assigned to this simple feature | |
66 Arg [...] : Named arguments passed to superclass | |
67 Example : $feature = Bio::EnsEMBL::SimpleFeature->new | |
68 (-start => 1, | |
69 -end => 100, | |
70 -strand => 1, | |
71 -slice => $slice, | |
72 -analysis => $analysis, | |
73 -adaptor => $adaptor, | |
74 -dbID => 10, | |
75 -display_label => 'EponineTSS', | |
76 -score => 100); | |
77 Description: Constructs a new Bio::EnsEMBL::Feature. Generally subclasses | |
78 of this method are instantiated, rather than this class itself. | |
79 Returntype : Bio::EnsEMBL::Feature | |
80 Exceptions : Thrown on invalid -SLICE, -ANALYSIS, -STRAND arguments | |
81 Caller : general, subclass constructors | |
82 Status : Stable | |
83 | |
84 =cut | |
85 | |
86 sub new { | |
87 my $caller = shift; | |
88 | |
89 #allow this to be called as class or object method | |
90 my $class = ref($caller) || $caller; | |
91 my $self = $class->SUPER::new(@_); | |
92 | |
93 my ($display_label, $score) = rearrange(['DISPLAY_LABEL','SCORE'],@_); | |
94 | |
95 $self->{'display_label'} = $display_label; | |
96 $self->{'score'} = $score; | |
97 | |
98 return $self; | |
99 } | |
100 | |
101 | |
102 =head2 new_fast | |
103 | |
104 Arg [1] : hashref to be blessed | |
105 Description: Construct a new Bio::EnsEMBL::Feature using the hashref. | |
106 Exceptions : none | |
107 Returntype : Bio::EnsEMBL::Feature | |
108 Caller : general, subclass constructors | |
109 Status : Stable | |
110 | |
111 =cut | |
112 | |
113 | |
114 sub new_fast { | |
115 my $class = shift; | |
116 my $hashref = shift; | |
117 my $self = bless $hashref, $class; | |
118 weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) ); | |
119 return $self; | |
120 } | |
121 | |
122 | |
123 =head2 display_label | |
124 | |
125 Arg [1] : (optional) string $value | |
126 Example : $label = $simple_feature->display_label(); | |
127 Description: Getter/Setter for the display label associated with this | |
128 feature. | |
129 Returntype : string | |
130 Exceptions : none | |
131 Caller : general | |
132 Status : Stable | |
133 | |
134 =cut | |
135 | |
136 sub display_label{ | |
137 my $self = shift; | |
138 | |
139 $self->{'display_label'} = shift if(@_); | |
140 | |
141 return $self->{'display_label'}; | |
142 } | |
143 | |
144 | |
145 =head2 display_id | |
146 | |
147 Arg [1] : none | |
148 Example : print $rf->display_id(); | |
149 Description: This method returns a string that is considered to be | |
150 the 'display' identifier. For simple features this is the | |
151 display_label if it is available otherwise it is an empty | |
152 string. | |
153 Returntype : string | |
154 Exceptions : none | |
155 Caller : web drawing code | |
156 Status : Stable | |
157 | |
158 =cut | |
159 | |
160 sub display_id { | |
161 my $self = shift; | |
162 return $self->{'display_label'} || ''; | |
163 } | |
164 | |
165 | |
166 | |
167 =head2 score | |
168 | |
169 Arg [1] : (optional) string $value | |
170 Example : $score = $simple_feature->score(); | |
171 Description: Getter/Setter for the score associated with this | |
172 feature. | |
173 Returntype : string | |
174 Exceptions : none | |
175 Caller : general | |
176 Status : Stable | |
177 | |
178 =cut | |
179 | |
180 sub score { | |
181 my $self = shift; | |
182 $self->{'score'} = shift if(@_); | |
183 return $self->{'score'}; | |
184 } | |
185 | |
186 | |
187 1; |