line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::SIMBAD::Result; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# --------------------------------------------------------------------------- |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#+ |
6
|
|
|
|
|
|
|
# Name: |
7
|
|
|
|
|
|
|
# Astro::SIMBAD::Result |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Purposes: |
10
|
|
|
|
|
|
|
# Perl wrapper for the SIMBAD database |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Language: |
13
|
|
|
|
|
|
|
# Perl module |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Description: |
16
|
|
|
|
|
|
|
# This module wraps the SIMBAD online database. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Authors: |
19
|
|
|
|
|
|
|
# Alasdair Allan (aa@astro.ex.ac.uk) |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Revision: |
22
|
|
|
|
|
|
|
# $Id: Result.pm,v 1.3 2001/11/28 17:43:34 aa Exp $ |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Copyright: |
25
|
|
|
|
|
|
|
# Copyright (C) 2001 University of Exeter. All Rights Reserved. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#- |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# --------------------------------------------------------------------------- |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Astro::SIMBAD::Result - Results from an SIMBAD Query |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$result = new Astro::SIMBAD::Result( Objects => \@objects ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Stores the results returned from an SIMBAD search as a hash of |
42
|
|
|
|
|
|
|
Astro::SIMBAD::Result::Object objects with the objects being |
43
|
|
|
|
|
|
|
indexed by Object Name. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# L O A D M O D U L E S -------------------------------------------------- |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
2
|
|
10567
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
91
|
|
50
|
2
|
|
|
2
|
|
12
|
use vars qw/ $VERSION /; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
107
|
|
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
2
|
|
1600
|
use Astro::SIMBAD::Result::Object; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1177
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
'$Revision: 1.3 $ ' =~ /.*:\s(.*)\s\$/ && ($VERSION = $1); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# C O N S T R U C T O R ---------------------------------------------------- |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 REVISION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$Id: Result.pm,v 1.3 2001/11/28 17:43:34 aa Exp $ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 Constructor |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over 4 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item B |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Create a new instance from a hash of options |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$result = new Astro::SIMBAD::Result( Objects => \@objects ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
returns a reference to an SIMBAD Result object. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub new { |
79
|
1
|
|
|
1
|
1
|
10
|
my $proto = shift; |
80
|
1
|
|
33
|
|
|
7
|
my $class = ref($proto) || $proto; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# bless the query hash into the class |
83
|
1
|
|
|
|
|
6
|
my $block = bless { RESULTS => {}, |
84
|
|
|
|
|
|
|
SIZE => 0 }, $class; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# If we have arguments configure the object |
87
|
1
|
50
|
|
|
|
14
|
$block->configure( @_ ) if @_; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
3
|
return $block; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# A C C E S S O R -------------------------------------------------------- |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 Accessor Methods |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item B |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Return the number of objects in the Astro::SIMBAD::Result object. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$num = $result->sizeof(); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub sizeof { |
110
|
2
|
|
|
2
|
1
|
7
|
my $self = shift; |
111
|
2
|
|
|
|
|
9
|
return $self->{SIZE}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item B |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Push a new Astro::SIMBAD::Result::Object object onto the end of the |
117
|
|
|
|
|
|
|
Astro::SIMBAD::Result object |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$result->addobject( $object ); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
returns the number of objects now in the Result object. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub addobject { |
126
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# return unless we have arguments |
129
|
1
|
50
|
|
|
|
12
|
return undef unless @_; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# grab the object reference |
132
|
1
|
|
|
|
|
2
|
my $new_object = shift; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# increment the sizeof counter |
135
|
1
|
|
|
|
|
4
|
$self->{SIZE} = $self->{SIZE} + 1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# get the object name as a key for $self->{RESULTS} hash |
138
|
1
|
|
|
|
|
35
|
my $object_name = $new_object->name(); |
139
|
1
|
50
|
|
|
|
4
|
$object_name = "Object " . $self->{SIZE} unless defined $object_name; |
140
|
1
|
|
|
|
|
2
|
${$self->{RESULTS}}{$object_name} = $new_object; |
|
1
|
|
|
|
|
4
|
|
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
3
|
return $self->{SIZE}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item B |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Return an array of all the C objects |
149
|
|
|
|
|
|
|
stored in the results object. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
@objects = $result->objects; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub objects { |
156
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# build the return array from the Object hash |
159
|
0
|
|
|
|
|
0
|
my @array; |
160
|
0
|
|
|
|
|
0
|
for my $key ( keys %{$self->{RESULTS}} ) { |
|
0
|
|
|
|
|
0
|
|
161
|
0
|
|
|
|
|
0
|
push ( @array, ${$self->{RESULTS}}{$key} ); |
|
0
|
|
|
|
|
0
|
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# return it |
165
|
0
|
|
|
|
|
0
|
return @array; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item B |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Returns an list of C objects by name |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
@objects = $result->objectbyname("IP Peg"); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
the name given does not have to be a full object name, only a sub-string. |
175
|
|
|
|
|
|
|
However, if multiple matches are found an array of possible matches will be |
176
|
|
|
|
|
|
|
returned. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub objectbyname { |
181
|
2
|
|
|
2
|
1
|
193
|
my $self = shift; |
182
|
|
|
|
|
|
|
|
183
|
2
|
|
|
|
|
20
|
my $search_string = shift; |
184
|
|
|
|
|
|
|
# build the return array from the Object hash |
185
|
2
|
|
|
|
|
3
|
my @array; |
186
|
2
|
|
|
|
|
3
|
for my $key ( keys %{$self->{RESULTS}} ) { |
|
2
|
|
|
|
|
8
|
|
187
|
6
|
100
|
|
|
|
54
|
push ( @array, ${$self->{RESULTS}}{$key} ) if $key =~ $search_string; |
|
3
|
|
|
|
|
11
|
|
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# return it |
191
|
2
|
|
|
|
|
10
|
return @array; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item B |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Returns a list of all the stellar objects held in the Result object |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
@object_name = $result->listofobjects(); |
200
|
|
|
|
|
|
|
$number = $result->listofobjects(); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
if called in a scalar context it will return the number of objects in |
203
|
|
|
|
|
|
|
the Result object. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub listofobjects{ |
208
|
1
|
|
|
1
|
1
|
198
|
my $self = shift; |
209
|
|
|
|
|
|
|
|
210
|
1
|
|
|
|
|
2
|
my @list; |
211
|
1
|
|
|
|
|
3
|
for my $key ( sort keys %{$self->{RESULTS}} ) { |
|
1
|
|
|
|
|
7
|
|
212
|
3
|
|
|
|
|
7
|
push ( @list, $key); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
1
|
50
|
|
|
|
7
|
return wantarray ? @list : scalar(@list); |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# C O N F I G U R E ------------------------------------------------------- |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=back |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 General Methods |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=over 4 |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item B |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Configures the object, takes an options hash as argument |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
$result->configure( %options ); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Takes a hash as argument with the following keywords: |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub configure { |
238
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# return unless we have arguments |
241
|
1
|
50
|
|
|
|
3
|
return undef unless @_; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# grab the argument list |
244
|
1
|
|
|
|
|
4
|
my %args = @_; |
245
|
|
|
|
|
|
|
|
246
|
1
|
50
|
|
|
|
4
|
if (defined $args{Objects}) { |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# Go through each of the supplied stellar object and add it |
249
|
1
|
|
|
|
|
2
|
for my $i ( 0 ...$#{$args{Objects}} ) { |
|
1
|
|
|
|
|
4
|
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# increment the hash counter |
252
|
2
|
|
|
|
|
8
|
$self->{SIZE} = $self->{SIZE} + 1; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
# extract the object name and index by it |
255
|
2
|
|
|
|
|
3
|
my $object_name = ${$args{Objects}}[$i]->name(); |
|
2
|
|
|
|
|
7
|
|
256
|
2
|
50
|
|
|
|
6
|
$object_name = "Object " . $self->{SIZE} unless defined $object_name; |
257
|
2
|
|
|
|
|
2
|
${$self->{RESULTS}}{$object_name} = ${$args{Objects}}[$i]; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# T I M E A T T H E B A R -------------------------------------------- |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 COPYRIGHT |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Copyright (C) 2001 University of Exeter. All Rights Reserved. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
This program was written as part of the eSTAR project and is free software; |
274
|
|
|
|
|
|
|
you can redistribute it and/or modify it under the terms of the GNU Public |
275
|
|
|
|
|
|
|
License. |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=head1 AUTHORS |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Alasdair Allan Eaa@astro.ex.ac.ukE, |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=cut |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
# L A S T O R D E R S ------------------------------------------------------ |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
1; |