-
Notifications
You must be signed in to change notification settings - Fork 1
/
DataType.pm
executable file
·265 lines (193 loc) · 5.85 KB
/
DataType.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#
# Object for storing sequence analysis details
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Shawn Hoon <shawnh@fugu-sg.org>
#
# Copyright Shawn Hoon
#
# You may distribute this module under the same terms as perl itself
#
# POD documentation - main docs before the code
=head1 NAME
Bio::Pipeline::DataType
=head1 SYNOPSIS
use Bio::Pipeline::DataType;
my $obj = new Bio::Pipeline::DataType
('-objecttype' => "Bio::SeqI",
'-name' => "-sequence",
'-reftype' => "ARRAY",
);
# or
# $range->isa('Bio::RangeI');
my $obj = new Bio::Pipeline::DataType();
my $dt = $obj->create_from_input($range);
=head1 DESCRIPTION
Object to represent a class of objects, used by Runnables for
matching inputs to get/sets
=head1 FEEDBACK
=head2 Mailing Lists
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
bioperl-pipeline@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
=head2 Support
Please direct usage questions or support issues to the mailing list:
L<bioperl-l@bioperl.org>
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
=head2 Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
bioperl-bugs@bio.perl.org
http://bugzilla.open-bio.org/
=head1 AUTHOR - FuguI Team
Email fugui@fugu-sg.org
=head1 APPENDIX
The rest of the documentation details each of the object methods. Internal metho
ds are usually preceded with a _
=cut
# Let the code begin...
package Bio::Pipeline::DataType;
use vars qw(@ISA);
use strict;
use Bio::Root::Root;
@ISA = qw(Bio::Root::Root);
=head1 Constructors
=head2 new
Title : new
Usage : my $obj = new Bio::Pipeline::DataType
('-objecttype'=> "Bio::SeqI",
'-name' => "-sequence",
'-reftype' => "ARRAY",
);
Function: this constructor should only be used in the IO_adaptor or IO objects.
generates a new Bio::Pipeline::DataHandler
Returns : L<Bio::Pipeline::DataType>
Args :
=cut
sub new {
my($class,@args) = @_;
my $self = $class->SUPER::new(@args);
my ($object_type,$name,$ref_type) =
$self->_rearrange([qw(OBJECT_TYPE
NAME
REFTYPE
)],@args);
$self->object_type($object_type);
$self->name($name);
$self->ref_type($ref_type);
return $self;
}
=head2 create_from_input
Title : create_from_input
Usage : $self->create_from_input($input)
Function: creates a datatype object from an input object
Returns : Bio::Pipeline::DataType
Args : an object
=cut
sub create_from_input {
my $dummy = shift;
my $input = shift;
my $datatype;
#can't figure out name..have to set it manually
if (ref($input) eq ""){ #a scalar
$datatype = Bio::Pipeline::DataType->new(
-object_type => "",
-reftype => "SCALAR",
-name => "",
);
}
elsif (ref($input) eq "ARRAY"){#an array of objects
my $first = $input->[0];
$datatype = Bio::Pipeline::DataType->new(
-object_type => ref($first),
-reftype => "ARRAY",
-name => "",
);
}
else {# a single object
$datatype = Bio::Pipeline::DataType->new(
-object_type => ref($input),
-reftype => "SCALAR",
-name => "",
);
}
return $datatype;
}
=head2 match
Title : match
Usage : $self->match($data_type)
Function: checks where two data types match.
Returns : 1/0
Args : Bio::Pipeline::DataType
=cut
sub match {
my ($self,$data_type) = @_;
$data_type->isa("Bio::Pipeline::DataType") ||
$self->throw("Need a Bio::Pipeline::DataType to check");
my $obj_type = $self->object_type;
my $name = $self->name;
my $ref_type = $self->ref_type;
my $q_obj_type = $data_type->object_type();
my $q_ref_type = $data_type->ref_type();
my $q_name = $data_type->name();
my $class = $data_type->object_type;
#if (($obj_type eq $q_obj_type) && ($name eq $q_name )
#&&($ref_type eq $q_ref_type)){
if (($obj_type eq $q_obj_type) &&($ref_type eq $q_ref_type))
{#don't require name to match for now
return 1;
}
else {
return 0;
}
}
=head2 object_type
Title : object_type
Usage : $self->object_type
Function: Get/set method for the object_type
Returns : string
Args : string
=cut
sub object_type {
my ($self,$arg) = @_;
if (defined($arg)) {
$self->{_object_type} = $arg;
}
return $self->{_object_type};
}
=head2 name
Title : name
Usage : $self->name
Function: Get/set method for the name string
Returns : string
Args : string
=cut
sub name {
my ($self,$arg) = @_;
if (defined($arg)) {
$self->{_name} = $arg;
}
return $self->{_name};
}
=head2 ref_type
Title : ref_type
Usage : $self->ref_type
Function: Get/set method for the ref_type
Returns : int
Args : int
=cut
sub ref_type{
my ($self,$arg) = @_;
if (defined($arg)) {
$self->{_ref_type} = $arg;
}
return $self->{_ref_type};
}
1;