Sequence/Indexer.pm

filter: Statementstmt 96.1% 50 / 52 Branchbran 64.2% 9 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 100% 1 / 1 totaltotal 88.7% 71 / 80 CC 8 SCAR 8.9
CC
8
Cov
89%
_file_handle
4.2
_index_file
4.0
fetch_hash
2.0
CRAP 2.4
« EntrezGene/Indexer.pm ↑ Summary
1 package Bio::ASN1::Sequence::Indexer;
2 2 our $AUTHORITY = 'cpan:BIOPERLML';
3 2 $Bio::ASN1::Sequence::Indexer::VERSION = '1.72';
4 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Carp qw(carp croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Bio::ASN1::Sequence;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Bio::Index::AbstractSeq;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use parent qw(Bio::Index::AbstractSeq);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # ABSTRACT: Indexes NCBI Sequence files.
13 # AUTHOR: Dr. Mingyi Liu <mingyiliu@gmail.com>
14 # OWNER: 2005 Mingyi Liu
15 # OWNER: 2005 GPC Biotech AG
16 # OWNER: 2005 Altana Research Institute
17 # LICENSE: Perl_5
18  
19  
20  
21 # TODO: Should this be deprecated?
22  
23 sub _version
24 {
25 1 ▶ return $Bio::Index::AbstractSeq::VERSION;
Subroutine _version: called CC=1 SCAR=0.0
26 }
27  
28  
29 sub _type_stamp
30 {
31 0 ▶ return '__Sequence_ASN1__';
Subroutine _type_stamp: not called CC=1 SCAR=6.9
32 }
33  
34  
35 sub _index_file
36 {
37 1 ▶ my($self, $file, $idx) = @_;
Subroutine _index_file: called CC=4 SCAR=13.9
38 1 my $position;
39 1 ▶ open(IN, $file) || $self->throw("Can't open $file - $!");
Branch: 1 branch
BranchTrueFalseTotal
open IN, $file or $self->throw("Can't open $file - $!") 0 1 1
40 1 local $/ = "Seq-entry ::= set {";
41 1 ▶ while(<IN>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline IN)) 2 1 3
42 {
43 2 chomp;
44 2 ▶ while(/[,{}]\s+accession\s*"([^"]+)"\s+[,{}]/ig) # add both dna and protein
Branch: 1 branch
BranchTrueFalseTotal
if (/[,{}]\s+accession\s*"([^"]+)"\s+[,{}]/gi) 2 2 4
45 {
46 2 $self->add_record($1, $idx, $position);
47 }
48 2 $position = tell(IN) - 19; # $/'s length
49 }
50 1 close(IN);
51 1 return 1;
52 }
53  
54  
55 sub _file_format
56 {
57 0 ▶ return 'sequence';
Subroutine _file_format: not called CC=1 SCAR=6.9
58 }
59  
60  
61  
62 sub fetch_hash
63 {
64 1 ▶ my ($self, $seqid) = @_;
Subroutine fetch_hash: called CC=2 SCAR=7.0
Pod documented
65 1 ▶ if (my $seq = $self->db->{$seqid})
Branch: 1 branch
BranchTrueFalseTotal
if (my $seq = $self->db->{$seqid}) 1 0 1
66 {
67 1 my ($fileno, $position) = $self->unpack_record($seq);
68 1 my $parser = Bio::ASN1::Sequence->new('fh' => $self->_file_handle($fileno));
69 1 seek($parser->fh, $position, 0);
70 1 return $parser->next_seq;
71 }
72 }
73  
74  
75 sub _file_handle {
76 1 ▶ my( $self, $i ) = @_;
Subroutine _file_handle: called CC=4 SCAR=14.2
77  
78 1 ▶ unless ($self->{'_filehandle'}[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_filehandle"}[$i]) 1 0 1
79 1 ▶ my @rec = $self->unpack_record($self->db->{"__FILE_$i"})
Branch: 1 branch
BranchTrueFalseTotal
my(@rec) = $self->unpack_record($self->db->{"__FILE_$i"}) or $self->throw("Can't get filename for index : $i") 0 1 1
80 or $self->throw("Can't get filename for index : $i");
81 1 my $file = $rec[0];
82 1 local *FH;
83 1 ▶ open *FH, $file or $self->throw("Can't read file '$file' : $!");
Branch: 1 branch
BranchTrueFalseTotal
open *FH, $file or $self->throw("Can't read file '${file}' : $!") 0 1 1
84 1 $self->{'_filehandle'}[$i] = *FH; # Cache filehandle
85 }
86 1 return $self->{'_filehandle'}[$i];
87 }
88  
89 2 1;
90  
91 __END__
« EntrezGene/Indexer.pm ↑ Summary