line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Das::Request::Types; |
2
|
|
|
|
|
|
|
# $Id: Types.pm,v 1.6 2004/01/03 00:23:40 lstein Exp $ |
3
|
|
|
|
|
|
|
# this module issues and parses the types command, with arguments -dsn, -segment, -categories, -enumerate |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Bio::Das::Request::Types - The DAS "types" request |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my @types = $request->results; |
12
|
|
|
|
|
|
|
my $types = $request->results; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $das_command = $request->command; |
15
|
|
|
|
|
|
|
my $successful = $request->is_success; |
16
|
|
|
|
|
|
|
my $error_msg = $request->error; |
17
|
|
|
|
|
|
|
my ($username,$password) = $request->auth; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This is a subclass of L<Bio::Das::Request> specialized for the "types" |
22
|
|
|
|
|
|
|
command. All methods are the same as L<Bio::Das::Request> with the |
23
|
|
|
|
|
|
|
exception of results(), which has been modified to make it more useful. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item $types = $request->results |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
In a scalar context, results() returns a hashref in which the keys are |
30
|
|
|
|
|
|
|
segment strings (in the form "ref:start,end") and the values are |
31
|
|
|
|
|
|
|
arrayrefs of L<Bio::Das::Type> objects contained within those |
32
|
|
|
|
|
|
|
segments. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item @types = $request->results |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
In a list context, results() returns an array of L<Bio::Das::Type> |
37
|
|
|
|
|
|
|
objects. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=back |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 AUTHOR |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Lincoln Stein <lstein@cshl.org>. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Copyright (c) 2003 Cold Spring Harbor Laboratory |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
48
|
|
|
|
|
|
|
it under the same terms as Perl itself. See DISCLAIMER.txt for |
49
|
|
|
|
|
|
|
disclaimers of warranty. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SEE ALSO |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L<Bio::Das::Request::Features>, L<Bio::Das::Request>, |
54
|
|
|
|
|
|
|
L<Bio::Das::HTTP::Fetch>, L<Bio::Das::Segment>, L<Bio::Das::Type>, |
55
|
|
|
|
|
|
|
L<Bio::Das::Stylesheet>, L<Bio::Das::Source>, L<Bio::RangeI> |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
60
|
1
|
|
|
1
|
|
455
|
use Bio::Das::Type; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
61
|
1
|
|
|
1
|
|
6
|
use Bio::Das::Segment; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
18
|
|
62
|
1
|
|
|
1
|
|
5
|
use Bio::Das::Request; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
63
|
1
|
|
|
1
|
|
4
|
use Bio::Das::Util 'rearrange'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
1
|
|
6
|
use vars '@ISA'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
493
|
|
66
|
|
|
|
|
|
|
@ISA = 'Bio::Das::Request'; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub new { |
69
|
1
|
|
|
1
|
1
|
3
|
my $pack = shift; |
70
|
1
|
|
|
|
|
8
|
my ($dsn,$segments,$categories,$enumerate,$callback) = rearrange([['dsn','dsns'], |
71
|
|
|
|
|
|
|
['segment','segments'], |
72
|
|
|
|
|
|
|
['category','categories'], |
73
|
|
|
|
|
|
|
'enumerate', |
74
|
|
|
|
|
|
|
'callback', |
75
|
|
|
|
|
|
|
],@_); |
76
|
1
|
|
|
|
|
18
|
my $self = $pack->SUPER::new(-dsn => $dsn, |
77
|
|
|
|
|
|
|
-callback => $callback, |
78
|
|
|
|
|
|
|
-args => { segment => $segments, |
79
|
|
|
|
|
|
|
category => $categories, |
80
|
|
|
|
|
|
|
enumerate => $enumerate, |
81
|
|
|
|
|
|
|
} ); |
82
|
1
|
|
|
|
|
6
|
$self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
9
|
|
|
9
|
1
|
13
|
sub command { 'types' } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub t_DASTYPES { |
88
|
2
|
|
|
2
|
0
|
9
|
my $self = shift; |
89
|
2
|
|
|
|
|
3
|
my $attrs = shift; |
90
|
2
|
100
|
|
|
|
7
|
if ($attrs) { |
91
|
1
|
|
|
|
|
7
|
$self->clear_results; |
92
|
|
|
|
|
|
|
} |
93
|
2
|
|
|
|
|
15
|
delete $self->{tmp}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
2
|
|
|
2
|
0
|
8
|
sub t_GFF { |
97
|
|
|
|
|
|
|
# nothing to do here |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub t_SEGMENT { |
101
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
102
|
2
|
|
|
|
|
3
|
my $attrs = shift; |
103
|
2
|
100
|
|
|
|
9
|
if ($attrs) { # segment section is starting |
104
|
1
|
|
|
|
|
16
|
$self->{tmp}{current_segment} = Bio::Das::Segment->new($attrs->{id},$attrs->{start},$attrs->{stop},$attrs->{version}); |
105
|
1
|
|
|
|
|
5
|
$self->{tmp}{current_type} = undef; |
106
|
1
|
|
|
|
|
6
|
$self->{tmp}{types} = []; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
else { # reached the end of the segment, so push result |
110
|
1
|
|
|
|
|
11
|
$self->add_object($self->{tmp}{current_segment},$self->{tmp}{types}); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub t_TYPE { |
116
|
42
|
|
|
42
|
0
|
39
|
my $self = shift; |
117
|
42
|
|
|
|
|
42
|
my $attrs = shift; |
118
|
|
|
|
|
|
|
|
119
|
42
|
100
|
|
|
|
50
|
if ($attrs) { # start of tag |
120
|
21
|
|
|
|
|
75
|
my $type = $self->{tmp}{current_type} = Bio::Das::Type->new($attrs->{id},$attrs->{method},$attrs->{category}); |
121
|
21
|
50
|
|
|
|
124
|
$type->source($attrs->{source}) if exists $attrs->{source}; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
else { |
125
|
21
|
|
|
|
|
41
|
my $count = $self->char_data; |
126
|
21
|
50
|
|
|
|
90
|
my $type = $self->{tmp}{current_type} or return; |
127
|
21
|
50
|
|
|
|
63
|
$type->count($count) if defined $count; |
128
|
21
|
|
|
|
|
20
|
push (@{$self->{tmp}{types}},$type); |
|
21
|
|
|
|
|
96
|
|
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# override for "better" behavior |
133
|
|
|
|
|
|
|
sub results { |
134
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
135
|
1
|
50
|
|
|
|
10
|
my %r = $self->SUPER::results or return; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# in array context, return the list of types |
138
|
1
|
50
|
|
|
|
6
|
return map { @{$_} } values %r if wantarray; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# otherwise return ref to a hash |
141
|
0
|
|
|
|
|
|
return \%r; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |