ClusterIO/unigene.pm

filter: Statementstmt 97.2% 71 / 73 Branchbran 90.2% 65 / 72 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 94.0% 143 / 152 CC 39 SCAR 35.1
CC
39
Cov
94%
next_cluster
38.4
_initialize
2.0
BEGIN
1.0
CRAP 33.3
↑ Summary ClusterIO/dbsnp.pm »
1 # BioPerl module for Bio::ClusterIO::unigene
2 #
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
4 #
5 # Cared for by Andrew Macgregor <andrew at cbbc.murdoch.edu.au>
6 #
7 # Copyright Andrew Macgregor, Jo-Ann Stanton, David Green
8 # Molecular Embryology Group, Anatomy & Structural Biology, University of Otago
9 # http://meg.otago.ac.nz
10 #
11 # You may distribute this module under the same terms as perl itself
12 #
13 # _history
14 # April 17, 2002 - Initial implementation by Andrew Macgregor
15  
16 # POD documentation - main docs before the code
17  
18 =head1 NAME
19  
20 Bio::ClusterIO::unigene - UniGene input stream
21  
22 =head1 SYNOPSIS
23  
24 Do not use this module directly. Use it via the Bio::ClusterIO class.
25  
26 =head1 DESCRIPTION
27  
28 This object reads from Unigene *.data files downloaded from
29 ftp://ftp.ncbi.nih.gov/repository/UniGene/. It does not download and
30 decompress the file, you have to do that yourself.
31  
32 =head1 FEEDBACK
33  
34 =head2 Mailing Lists
35  
36 User feedback is an integral part of the evolution of this and other
37 Bioperl modules. Send your comments and suggestions preferably to one
38 of the Bioperl mailing lists. Your participation is much appreciated.
39  
40 bioperl-l@bioperl.org - General discussion
41 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
42  
43 =head2 Support
44  
45 Please direct usage questions or support issues to the mailing list:
46  
47 I<bioperl-l@bioperl.org>
48  
49 rather than to the module maintainer directly. Many experienced and
50 reponsive experts will be able look at the problem and quickly
51 address it. Please include a thorough description of the problem
52 with code and data examples if at all possible.
53  
54 =head2 Reporting Bugs
55  
56 Report bugs to the Bioperl bug tracking system to help us keep track
57 the bugs and their resolution. Bug reports can be submitted via the
58 web:
59  
60 https://github.com/bioperl/bioperl-live/issues
61  
62 =head1 AUTHORS - Andrew Macgregor
63  
64 Email: andrew at cbbc.murdoch.edu.au
65  
66  
67 =head1 APPENDIX
68  
69 The rest of the documentation details each of the object
70 methods. Internal methods are usually preceded with a _
71  
72 =cut
73  
74 #'
75 # Let the code begin...
76  
77 package Bio::ClusterIO::unigene;
78 2 $Bio::ClusterIO::unigene::VERSION = '1.7.3';
79 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
80  
81 2 ▶use Bio::Cluster::UniGene;
Subroutine BEGIN: called CC=1 SCAR=0.0
82 2 ▶use Bio::Cluster::ClusterFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 2 ▶use base qw(Bio::ClusterIO);
Subroutine BEGIN: called CC=1 SCAR=0.0
85  
86 2 my %line_is = (
87 ID => q/ID\s+(\w{2,3}\.\d+)/,
88 TITLE => q/TITLE\s+(\S.*)/,
89 GENE => q/GENE\s+(\S.*)/,
90 CYTOBAND => q/CYTOBAND\s+(\S.*)/,
91 MGI => q/MGI\s+(\S.*)/,
92 LOCUSLINK => q/LOCUSLINK\s+(\S.*)/,
93 HOMOL => q/HOMOL\s+(\S.*)/,
94 EXPRESS => q/EXPRESS\s+(\S.*)/,
95 RESTR_EXPR => q/RESTR_EXPR\s+(\S.*)/,
96 GNM_TERMINUS => q/GNM_TERMINUS\s+(\S.*)/,
97 CHROMOSOME => q/CHROMOSOME\s+(\S.*)/,
98 STS => q/STS\s+(\S.*)/,
99 TXMAP => q/TXMAP\s+(\S.*)/,
100 PROTSIM => q/PROTSIM\s+(\S.*)/,
101 SCOUNT => q/SCOUNT\s+(\S.*)/,
102 SEQUENCE => q/SEQUENCE\s+(\S.*)/,
103 ACC => q/ACC=(\w+)(\.\d+)?/,
104 NID => q/NID=\s*(\S.*)/,
105 PID => q/PID=\s*(\S.*)/,
106 CLONE => q/CLONE=\s*(\S.*)/,
107 END => q/END=\s*(\S.*)/,
108 LID => q/LID=\s*(\S.*)/,
109 MGC => q/MGC=\s*(\S.*)/,
110 SEQTYPE => q/SEQTYPE=\s*(\S.*)/,
111 TRACE => q/TRACE=\s*(\S.*)/,
112 PERIPHERAL => q/PERIPHERAL=\s*(\S.*)/,
113 DELIMITER => q{^//},
114 );
115  
116 # we set the right factory here
117 1 ▶sub _initialize {
Subroutine _initialize: called CC=2 SCAR=7.0
118 1 my($self, @args) = @_;
119  
120 1 $self->SUPER::_initialize(@args);
121 1 ▶ if(! $self->cluster_factory()) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->cluster_factory) 1 0 1
122 1 $self->cluster_factory(Bio::Cluster::ClusterFactory->new(
123 -type => 'Bio::Cluster::UniGene'));
124 }
125 }
126  
127 =head2 next_cluster
128  
129 Title : next_cluster
130 Usage : $unigene = $stream->next_cluster()
131 Function: returns the next unigene in the stream
132 Returns : Bio::Cluster::UniGene object
133 Args : NONE
134  
135 =cut
136  
137 3 ▶sub next_cluster {
Subroutine next_cluster: called CC=38 SCAR=36.5
Pod documented
138 3 my( $self) = @_;
139 3 local $/ = "\n//";
140 3 ▶ return unless my $entry = $self->_readline;
Branch: 1 branch
BranchTrueFalseTotal
unless my $entry = $self->_readline 0 3 3
141  
142 # set up the variables we'll need
143 3 my (%unigene,@express,@locuslink,@chromosome,
144 @sts,@txmap,@protsim,@sequence);
145 3 my $UGobj;
146  
147 # set up the regexes
148  
149 # add whitespace parsing and precompile regexes
150 #foreach (values %line_is) {
151 # $_ =~ s/\s+/\\s+/g;
152 # print STDERR "Regex is $_\n";
153 # #$_ = qr/$_/x;
154 #}
155  
156 #$line_is{'TITLE'} = qq/TITLE\\s+(\\S.+)/;
157  
158 # run each line in an entry against the regexes
159 3 foreach my $line (split /\n/, $entry) {
160 #print STDERR "Wanting to match $line\n";
161 112 ▶ if ($line =~ /$line_is{ID}/gcx) {
Branch: 17 branches
BranchTrueFalseTotal
if ($line =~ /$line_is{'ID'}/cgx) { } 3 109 112
elsif ($line =~ /$line_is{'TITLE'}/cgx) { } 3 106 109
elsif ($line =~ /$line_is{'GENE'}/cgx) { } 1 105 106
elsif ($line =~ /$line_is{'CYTOBAND'}/cgx) { } 1 104 105
elsif ($line =~ /$line_is{'MGI'}/cgx) { } 0 104 104
elsif ($line =~ /$line_is{'LOCUSLINK'}/cgx) { } 1 103 104
elsif ($line =~ /$line_is{'HOMOL'}/cgx) { } 2 101 103
elsif ($line =~ /$line_is{'EXPRESS'}/cgx) { } 3 98 101
elsif ($line =~ /$line_is{'RESTR_EXPR'}/cgx) { } 1 97 98
elsif ($line =~ /$line_is{'GNM_TERMINUS'}/cgx) { } 1 96 97
elsif ($line =~ /$line_is{'CHROMOSOME'}/cgx) { } 2 94 96
elsif ($line =~ /$line_is{'TXMAP'}/cgx) { } 0 94 94
elsif ($line =~ /$line_is{'STS'}/cgx) { } 10 84 94
elsif ($line =~ /$line_is{'PROTSIM'}/cgx) { } 10 74 84
elsif ($line =~ /$line_is{'SCOUNT'}/cgx) { } 3 71 74
elsif ($line =~ /$line_is{'SEQUENCE'}/cgx) { } 66 5 71
elsif ($line =~ /$line_is{'DELIMITER'}/cgx) { } 3 2 5
162 3 $unigene{ID} = $1;
163 }
164 elsif ($line =~ /$line_is{TITLE}/gcx ) {
165 #print STDERR "MATCHED with [$1]\n";
166 3 $unigene{TITLE} = $1;
167 }
168 elsif ($line =~ /$line_is{GENE}/gcx) {
169 1 $unigene{GENE} = $1;
170 }
171 elsif ($line =~ /$line_is{CYTOBAND}/gcx) {
172 1 $unigene{CYTOBAND} = $1;
173 }
174 elsif ($line =~ /$line_is{MGI}/gcx) {
175 0 $unigene{MGI} = $1;
176 }
177 elsif ($line =~ /$line_is{LOCUSLINK}/gcx) {
178 1 @locuslink = split /;/, $1;
179 }
180 elsif ($line =~ /$line_is{HOMOL}/gcx) {
181 2 $unigene{HOMOL} = $1;
182 }
183 elsif ($line =~ /$line_is{EXPRESS}/gcx) {
184 3 my $express = $1;
185 # remove initial semicolon if present
186 3 $express =~ s/^;//;
187 3 @express = split /\s*;/, $express;
188 }
189 elsif ($line =~ /$line_is{RESTR_EXPR}/gcx) {
190 1 $unigene{RESTR_EXPR} = $1;
191 }
192 elsif ($line =~ /$line_is{GNM_TERMINUS}/gcx) {
193 1 $unigene{GNM_TERMINUS} = $1;
194 }
195 elsif ($line =~ /$line_is{CHROMOSOME}/gcx) {
196 2 push @chromosome, $1;
197 }
198 elsif ($line =~ /$line_is{TXMAP}/gcx) {
199 0 push @txmap, $1;
200 }
201 elsif ($line =~ /$line_is{STS}/gcx) {
202 10 push @sts, $1;
203 }
204 elsif ($line =~ /$line_is{PROTSIM}/gcx) {
205 10 push @protsim, $1;
206 }
207 elsif ($line =~ /$line_is{SCOUNT}/gcx) {
208 3 $unigene{SCOUNT} = $1;
209 }
210 elsif ($line =~ /$line_is{SEQUENCE}/gcx) {
211 # parse into each sequence line
212 66 my $seq = {};
213 # add unigene id to each seq
214 #$seq->{unigene_id} = $unigene{ID};
215 66 my @items = split(/;/, $1);
216 66 foreach (@items) {
217 403 ▶ if (/$line_is{ACC}/gcx) {
Branch: 10 branches
BranchTrueFalseTotal
if (/$line_is{'ACC'}/cgx) { } 66 337 403
elsif (/$line_is{'NID'}/cgx) { } 66 271 337
elsif (/$line_is{'PID'}/cgx) { } 6 265 271
elsif (/$line_is{'CLONE'}/cgx) { } 58 207 265
elsif (/$line_is{'END'}/cgx) { } 53 154 207
elsif (/$line_is{'LID'}/cgx) { } 60 94 154
elsif (/$line_is{'MGC'}/cgx) { } 5 89 94
elsif (/$line_is{'SEQTYPE'}/cgx) { } 66 23 89
elsif (/$line_is{'TRACE'}/cgx) { } 21 2 23
elsif (/$line_is{'PERIPHERAL'}/cgx) { } 2 0 2
218 66 $seq->{acc} = $1;
219 # remove leading dot if version pattern matched
220 66 ▶ $seq->{version} = substr($2,1) if defined $2;
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 66 0 66
221 }
222 elsif (/$line_is{NID}/gcx) {
223 66 $seq->{nid} = $1;
224 }
225 elsif (/$line_is{PID}/gcx) {
226 6 $seq->{pid} = $1;
227 }
228 elsif (/$line_is{CLONE}/gcx) {
229 58 $seq->{clone} = $1;
230 }
231 elsif (/$line_is{END}/gcx) {
232 53 $seq->{end} = $1;
233 }
234 elsif (/$line_is{LID}/gcx) {
235 60 $seq->{lid} = $1;
236 }
237 elsif (/$line_is{MGC}/gcx) {
238 5 $seq->{mgc} = $1;
239 }
240 elsif (/$line_is{SEQTYPE}/gcx) {
241 66 $seq->{seqtype} = $1;
242 }
243 elsif (/$line_is{TRACE}/gcx) {
244 21 $seq->{trace} = $1;
245 }
246 elsif (/$line_is{PERIPHERAL}/gcx) {
247 2 $seq->{peripheral} = $1;
248 }
249 }
250 66 push @sequence, $seq;
251 }
252 elsif ($line =~ /$line_is{DELIMITER}/gcx) {
253 # at the end of the record, add data to the object
254 $UGobj = $self->cluster_factory->create_object(
255 -display_id => $unigene{ID},
256 -description => $unigene{TITLE},
257 -size => $unigene{SCOUNT},
258 3 -members => \@sequence);
259 3 ▶ $UGobj->gene($unigene{GENE}) if defined ($unigene{GENE});
Branch: 1 branch
BranchTrueFalseTotal
if defined $unigene{"GENE"} 1 2 3
260 3 ▶ $UGobj->cytoband($unigene{CYTOBAND}) if defined($unigene{CYTOBAND});
Branch: 1 branch
BranchTrueFalseTotal
if defined $unigene{"CYTOBAND"} 1 2 3
261 3 ▶ $UGobj->mgi($unigene{MGI}) if defined ($unigene{MGI});
Branch: 1 branch
BranchTrueFalseTotal
if defined $unigene{"MGI"} 0 3 3
262 3 $UGobj->locuslink(\@locuslink);
263 3 ▶ $UGobj->homol($unigene{HOMOL}) if defined ($unigene{HOMOL});
Branch: 1 branch
BranchTrueFalseTotal
if defined $unigene{"HOMOL"} 2 1 3
264 3 $UGobj->express(\@express);
265 3 ▶ $UGobj->restr_expr($unigene{RESTR_EXPR}) if defined ($unigene{RESTR_EXPR});
Branch: 1 branch
BranchTrueFalseTotal
if defined $unigene{"RESTR_EXPR"} 1 2 3
266 3 ▶ $UGobj->gnm_terminus($unigene{GNM_TERMINUS}) if defined ($unigene{GNM_TERMINUS});
Branch: 1 branch
BranchTrueFalseTotal
if defined $unigene{"GNM_TERMINUS"} 1 2 3
267 3 $UGobj->chromosome(\@chromosome);
268 3 $UGobj->sts(\@sts);
269 3 $UGobj->txmap(\@txmap);
270 3 $UGobj->protsim(\@protsim);
271 }
272 }
273 3 return $UGobj;
274 }
275  
276 2 1;
↑ Summary ClusterIO/dbsnp.pm »