line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ace::Sequence::FeatureList; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use overload '""' => 'asString'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
0
|
|
|
0
|
0
|
|
local $^W = 0; # to prevent untrackable uninitialized variable warning |
7
|
0
|
|
|
|
|
|
my $package =shift; |
8
|
0
|
|
|
|
|
|
my @lines = split("\n",$_[0]); |
9
|
0
|
|
|
|
|
|
my (%parsed); |
10
|
0
|
|
|
|
|
|
foreach (@lines) { |
11
|
0
|
0
|
|
|
|
|
next if m!^//!; |
12
|
0
|
|
|
|
|
|
my ($minor,$major,$count) = split "\t"; |
13
|
0
|
0
|
|
|
|
|
next unless $count > 0; |
14
|
0
|
|
|
|
|
|
$parsed{$major}{$minor} += $count; |
15
|
0
|
|
|
|
|
|
$parsed{_TOTAL} += $count; |
16
|
|
|
|
|
|
|
} |
17
|
0
|
|
|
|
|
|
return bless \%parsed,$package; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# no arguments, scalar context -- count all features |
21
|
|
|
|
|
|
|
# no arguments, array context -- list of major types |
22
|
|
|
|
|
|
|
# 1 argument, scalar context -- count of major type |
23
|
|
|
|
|
|
|
# 1 argument, array context -- list of minor types |
24
|
|
|
|
|
|
|
# 2 arguments -- count of subtype |
25
|
|
|
|
|
|
|
sub types { |
26
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
27
|
0
|
|
|
|
|
|
my ($type,$subtype) = @_; |
28
|
0
|
|
|
|
|
|
my $count = 0; |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
unless ($type) { |
31
|
0
|
0
|
|
|
|
|
return wantarray ? grep !/^_/,keys %$self : $self->{_TOTAL}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
unless ($subtype) { |
35
|
0
|
0
|
|
|
|
|
return keys %{$self->{$type}} if wantarray; |
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
foreach (keys %{$self->{$type}}) { |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$count += $self->{$type}{$_}; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
return $count; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self->{$type}{$subtype}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# human-readable summary table |
46
|
|
|
|
|
|
|
sub asString { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my ($type,$subtype); |
49
|
0
|
|
|
|
|
|
for my $type ( sort $self->types() ) { |
50
|
0
|
|
|
|
|
|
for my $subtype (sort $self->types($type) ) { |
51
|
0
|
|
|
|
|
|
print join("\t",$type,$subtype,$self->{$type}{$subtype}),"\n"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Ace::Sequence::FeatureList - Lightweight Access to Features |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# get a megabase from the middle of chromosome I |
65
|
|
|
|
|
|
|
$seq = Ace::Sequence->new(-name => 'CHROMOSOME_I, |
66
|
|
|
|
|
|
|
-db => $db, |
67
|
|
|
|
|
|
|
-offset => 3_000_000, |
68
|
|
|
|
|
|
|
-length => 1_000_000); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# find out what's there |
71
|
|
|
|
|
|
|
$list = $seq->feature_list; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Scalar context: count all the features |
74
|
|
|
|
|
|
|
$feature_count = $list->types; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Array context: list all the feature types |
77
|
|
|
|
|
|
|
@feature_types = $list->types; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Scalar context, 1 argument. Count this type |
80
|
|
|
|
|
|
|
$gene_cnt = $list->types('Predicted_gene'); |
81
|
|
|
|
|
|
|
print "There are $gene_cnt genes here.\n"; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Array context, 1 argument. Get list of subtypes |
84
|
|
|
|
|
|
|
@subtypes = $list->types('Predicted_gene'); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Two arguments. Count type & subtype |
87
|
|
|
|
|
|
|
$genefinder_cnt = $list->types('Predicted_gene','genefinder'); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 DESCRIPTION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
I is a small class that provides |
92
|
|
|
|
|
|
|
statistical information about sequence features. From it you can |
93
|
|
|
|
|
|
|
obtain summary counts of the features and their types within a |
94
|
|
|
|
|
|
|
selected region. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 OBJECT CREATION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
You will not ordinarily create an I object |
99
|
|
|
|
|
|
|
directly. Instead, objects will be created by calling a |
100
|
|
|
|
|
|
|
I object's feature_list() method. If you wish to |
101
|
|
|
|
|
|
|
create an I object directly, please consult |
102
|
|
|
|
|
|
|
the source code for the I method. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
There are only two methods in I. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over 4 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item type() |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This method has five distinct behaviors, depending on its context and |
113
|
|
|
|
|
|
|
the number of parameters. Usage should be intuitive |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Context Arguments Behavior |
116
|
|
|
|
|
|
|
------- --------- -------- |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
scalar -none- total count of features in list |
119
|
|
|
|
|
|
|
array -none- list feature types (e.g. "exon") |
120
|
|
|
|
|
|
|
scalar type count features of this type |
121
|
|
|
|
|
|
|
array type list subtypes of this type |
122
|
|
|
|
|
|
|
-any- type,subtype count features of this type & subtype |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
For example, this code fragment will count the number of exons present |
125
|
|
|
|
|
|
|
on the list: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$exon_count = $list->type('exon'); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This code fragment will count the number of exons found by "genefinder": |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$predicted_exon_count = $list->type('exon','genefinder'); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This code fragment will print out all subtypes of "exon" and their |
134
|
|
|
|
|
|
|
counts: |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
for my $subtype ($list->type('exon')) { |
137
|
|
|
|
|
|
|
print $subtype,"\t",$list->type('exon',$subtype),"\n"; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item asString() |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
print $list->asString; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This dumps the list out in tab-delimited format. The order of columns |
145
|
|
|
|
|
|
|
is type, subtype, count. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 SEE ALSO |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L, L, L, |
152
|
|
|
|
|
|
|
L, L |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Lincoln Stein with extensive help from Jean |
157
|
|
|
|
|
|
|
Thierry-Mieg |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Copyright (c) 1999, Lincoln D. Stein |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
162
|
|
|
|
|
|
|
it under the same terms as Perl itself. See DISCLAIMER.txt for |
163
|
|
|
|
|
|
|
disclaimers of warranty. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|