| 1 | package Bio::ToolBox::Parser; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp qw(carp cluck croak confess); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Module::Load; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Bio::ToolBox::Data; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Bio::ToolBox::SeqFeature; # alternative to Bio::SeqFeature::Lite | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | our $VERSION = '2.02'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 36 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=39 SCAR=41.5
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 36 | my $class = shift; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # passed arguments | ||||||||||||||||||||||||||||
| 17 | 36 | my %args; | |||||||||||||||||||||||||||
| 18 | 36 | ▶ | if ( scalar(@_) == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 0 | $args{file} = shift; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | else { | ||||||||||||||||||||||||||||
| 22 | 36 | %args = @_; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # determine file, format, and parser subclass | ||||||||||||||||||||||||||||
| 26 | 36 | ▶ | my $file = $args{file} || $args{table} || undef; | ||||||||||||||||||||||||||
|
Condition40%2/5
$args{'file'} || $args{'table'} || undef
$args{"file"} or $args{"table"}
MC/DC0%0/2
$args{'file'} || $args{'table'} || undef
$args{"file"}
$args{"table"}
Truth table33%1/3
A or B
A= $args{"file"}B= $args{"table"}
| |||||||||||||||||||||||||||||
| 27 | 36 | ▶ | my $flavor = $args{flavor} || undef; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args{'flavor'} || undef
MC/DC100%1/1
$args{'flavor'} || undef
$args{'flavor'}
Truth table100%2/2
A
A= $args{'flavor'}
| |||||||||||||||||||||||||||||
| 28 | 36 | ▶ | my $filetype = $args{filetype} || $args{'format'} || undef; | ||||||||||||||||||||||||||
|
Condition80%4/5
$args{'filetype'} || $args{'format'} || undef
$args{"filetype"} or $args{"format"}
MC/DC50%1/2
$args{'filetype'} || $args{'format'} || undef
$args{"filetype"}
$args{"format"}
Truth table66%2/3
A or B
A= $args{"filetype"}B= $args{"format"}
| |||||||||||||||||||||||||||||
| 29 | 36 | ▶ | if ( not $flavor or not $filetype ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$flavor and $filetype
MC/DC50%1/2
$flavor and $filetype
$flavor
$filetype
Truth table66%2/3
A and B
A= $flavorB= $filetype
| |||||||||||||||||||||||||||||
| 30 | 23 | ▶ | if ( $class =~ m/Bio::ToolBox::Parser::(\w+)/x ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # we got the flavor directly from a flavored parser new function | ||||||||||||||||||||||||||||
| 33 | 23 | ▶ | $flavor ||= $1; | ||||||||||||||||||||||||||
|
Condition33%1/3
$flavor ||= $1
MC/DC0%0/2
$flavor ||= $1
$flavor
$1
Truth table33%1/3
A ||= B
A= $flavorB= $1
| |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | 23 | ▶ | if ($file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # get the flavor and file type directly by tasting the file | ||||||||||||||||||||||||||||
| 38 | # we use this in preference over what user may have provided | ||||||||||||||||||||||||||||
| 39 | 23 | ( $flavor, $filetype ) = Bio::ToolBox::Data->taste_file( $args{file} ); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 36 | ▶ | if ( $flavor and $flavor =~ m/^(?: gff | bed | ucsc )$/xi ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$flavor and $flavor =~ /^(?: gff | bed | ucsc )$/xi
MC/DC0%0/2
$flavor and $flavor =~ /^(?: gff | bed | ucsc )$/xi
$flavor
$flavor =~ /^(?: gff | bed | ucsc )$/xi
Truth table33%1/3
A and B
A= $flavorB= $flavor =~ /^(?: gff | bed | ucsc )$/xi
| |||||||||||||||||||||||||||||
| 43 | 36 | $class = 'Bio::ToolBox::Parser::' . $flavor; | |||||||||||||||||||||||||||
| 44 | 36 | load $class; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | else { | ||||||||||||||||||||||||||||
| 47 | # let the caller print errors as appropriate | ||||||||||||||||||||||||||||
| 48 | 0 | return; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # initialize self | ||||||||||||||||||||||||||||
| 52 | 36 | my $self = { | |||||||||||||||||||||||||||
| 53 | 'fh' => undef, | ||||||||||||||||||||||||||||
| 54 | 'file' => $file, | ||||||||||||||||||||||||||||
| 55 | 'filetype' => $filetype, | ||||||||||||||||||||||||||||
| 56 | 'do_gene' => 1, | ||||||||||||||||||||||||||||
| 57 | 'do_exon' => 0, | ||||||||||||||||||||||||||||
| 58 | 'do_cds' => 0, | ||||||||||||||||||||||||||||
| 59 | 'do_utr' => 0, | ||||||||||||||||||||||||||||
| 60 | 'do_codon' => 0, | ||||||||||||||||||||||||||||
| 61 | 'do_name' => 0, | ||||||||||||||||||||||||||||
| 62 | 'share' => 0, | ||||||||||||||||||||||||||||
| 63 | 'simplify' => 0, | ||||||||||||||||||||||||||||
| 64 | 'source' => undef, | ||||||||||||||||||||||||||||
| 65 | 'typelist' => q(), # string list of observed feature types | ||||||||||||||||||||||||||||
| 66 | 'seq_ids' => {}, # hash of seq_id to length | ||||||||||||||||||||||||||||
| 67 | 'loaded' => {}, # hash of primary_id to SeqFeature object | ||||||||||||||||||||||||||||
| 68 | 'top_features' => [], # list of top features | ||||||||||||||||||||||||||||
| 69 | 'eof' => 0, | ||||||||||||||||||||||||||||
| 70 | 'comments' => [], # array of comment lines | ||||||||||||||||||||||||||||
| 71 | 'convertor_sub' => undef, | ||||||||||||||||||||||||||||
| 72 | 'sfclass' => 'Bio::ToolBox::SeqFeature', | ||||||||||||||||||||||||||||
| 73 | }; | ||||||||||||||||||||||||||||
| 74 | 36 | bless $self, $class; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # parser specific object keys | ||||||||||||||||||||||||||||
| 77 | 36 | ▶ | if ( $flavor eq 'bed' ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 78 | 20 | $self->{bed} = undef; | |||||||||||||||||||||||||||
| 79 | 20 | $self->{line_count} = 0; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | elsif ( $flavor eq 'gff' ) { | ||||||||||||||||||||||||||||
| 82 | 11 | ▶ | if ( $filetype and $filetype eq 'gtf' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$filetype and $filetype eq "gtf"
MC/DC50%1/2
$filetype and $filetype eq "gtf"
$filetype
$filetype eq "gtf"
Truth table66%2/3
A and B
A= $filetypeB= $filetype eq "gtf"
| |||||||||||||||||||||||||||||
| 83 | 4 | $self->{gtf} = 1; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||
| 86 | 7 | $self->{gtf} = 0; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 11 | $self->{orphans} = []; | |||||||||||||||||||||||||||
| 89 | 11 | $self->{duplicate_ids} = {}; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | elsif ( $flavor eq 'ucsc' ) { | ||||||||||||||||||||||||||||
| 92 | 5 | $self->{share} = 1; # always true | |||||||||||||||||||||||||||
| 93 | 5 | $self->{source} = 'UCSC'; # presumptive default | |||||||||||||||||||||||||||
| 94 | 5 | $self->{gene2seqf} = {}; # hash of gene names to SeqFeature objects | |||||||||||||||||||||||||||
| 95 | 5 | $self->{id2count} = {}; # hash of seen IDs | |||||||||||||||||||||||||||
| 96 | 5 | $self->{counts} = {}; # hash of RNA types to count | |||||||||||||||||||||||||||
| 97 | 5 | $self->{refseqsum} = {}; # RefSeq Summary external data | |||||||||||||||||||||||||||
| 98 | 5 | $self->{refseqstat} = {}; # RefSeq Stats external data | |||||||||||||||||||||||||||
| 99 | 5 | $self->{kgxref} = {}; # knownGene RefSeq external data | |||||||||||||||||||||||||||
| 100 | 5 | $self->{ensembldata} = {}; # Ensembl external data | |||||||||||||||||||||||||||
| 101 | 5 | $self->{line_count} = 0; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # process remaining arguments | ||||||||||||||||||||||||||||
| 105 | 36 | ▶ | if ( exists $args{simplify} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 4 | $self->simplify( $args{simplify} ); | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 36 | ▶ | if ( exists $args{do_gene} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 5 | $self->do_gene( $args{do_gene} ); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | 36 | ▶ | if ( exists $args{do_exon} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 9 | $self->do_exon( $args{do_exon} ); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 36 | ▶ | if ( exists $args{do_cds} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 5 | $self->do_cds( $args{do_cds} ); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | 36 | ▶ | if ( exists $args{do_utr} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 1 | $self->do_utr( $args{do_utr} ); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 36 | ▶ | if ( exists $args{do_codon} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | $self->do_codon( $args{do_codon} ); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | 36 | ▶ | if ( exists $args{source} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | $self->source( $args{source} ); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | 36 | ▶ | if ( exists $args{class} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 18 | my $class = $args{class}; | |||||||||||||||||||||||||||
| 128 | 18 | eval { load $class; }; | |||||||||||||||||||||||||||
| 129 | 18 | ▶ | if ($EVAL_ERROR) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | croak $EVAL_ERROR; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | else { | ||||||||||||||||||||||||||||
| 133 | 18 | $self->{sfclass} = $class; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 36 | ▶ | if ( $flavor eq 'ucsc' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | # lots of accessory files for UCSC tables | ||||||||||||||||||||||||||||
| 139 | 5 | ▶ | if ( exists $args{refseqsum} ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 140 | 0 | $self->load_extra_data( $args{refseqsum}, 'refseqsum' ); | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | elsif ( exists $args{summary} ) { | ||||||||||||||||||||||||||||
| 143 | 0 | $self->load_extra_data( $args{summary}, 'refseqsum' ); | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | 5 | ▶ | if ( exists $args{refseqstat} ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 146 | 0 | $self->load_extra_data( $args{refseqstat}, 'refseqstat' ); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | elsif ( exists $args{status} ) { | ||||||||||||||||||||||||||||
| 149 | 0 | $self->load_extra_data( $args{status}, 'refseqstat' ); | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | 5 | ▶ | if ( exists $args{kgxref} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | $self->load_extra_data( $args{kgxref}, 'kgxref' ); | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | 5 | ▶ | if ( exists $args{ensembltogenename} ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 155 | 0 | $self->load_extra_data( $args{ensembltogenename}, 'ensembltogene' ); | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | elsif ( exists $args{ensname} ) { | ||||||||||||||||||||||||||||
| 158 | 0 | $self->load_extra_data( $args{ensname}, 'ensembltogene' ); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | 5 | ▶ | if ( exists $args{ensemblsource} ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 161 | 0 | $self->load_extra_data( $args{ensemblsource}, 'ensemblsource' ); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | elsif ( exists $args{enssrc} ) { | ||||||||||||||||||||||||||||
| 164 | 1 | $self->load_extra_data( $args{enssrc}, 'ensemblsource' ); | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | # open the file | ||||||||||||||||||||||||||||
| 169 | 36 | ▶ | if ($file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 36 | $self->open_file; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | # finished | ||||||||||||||||||||||||||||
| 174 | 36 | return $self; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 697 | ▶ | sub do_gene { | ||||||||||||||||||||||||||
|
Subroutine
do_gene: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 697 | my $self = shift; | |||||||||||||||||||||||||||
| 179 | 697 | ▶ | return 0 if ( ref($self) eq 'Bio::ToolBox::Parser::bed' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 685 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 10 | $self->{'do_gene'} = shift; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | 685 | return $self->{'do_gene'}; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 379 | ▶ | sub do_exon { | ||||||||||||||||||||||||||
|
Subroutine
do_exon: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 187 | 379 | my $self = shift; | |||||||||||||||||||||||||||
| 188 | 379 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 18 | $self->{'do_exon'} = shift; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | 379 | return $self->{'do_exon'}; | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 389 | ▶ | sub do_cds { | ||||||||||||||||||||||||||
|
Subroutine
do_cds: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | 389 | my $self = shift; | |||||||||||||||||||||||||||
| 196 | 389 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 6 | $self->{'do_cds'} = shift; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | 389 | return $self->{'do_cds'}; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 111 | ▶ | sub do_utr { | ||||||||||||||||||||||||||
|
Subroutine
do_utr: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 203 | 111 | my $self = shift; | |||||||||||||||||||||||||||
| 204 | 111 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 1 | $self->{'do_utr'} = shift; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | 111 | return $self->{'do_utr'}; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 150 | ▶ | sub do_codon { | ||||||||||||||||||||||||||
|
Subroutine
do_codon: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 211 | 150 | my $self = shift; | |||||||||||||||||||||||||||
| 212 | 150 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 0 | $self->{'do_codon'} = shift; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | 150 | return $self->{'do_codon'}; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 460 | ▶ | sub do_name { | ||||||||||||||||||||||||||
|
Subroutine
do_name: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 219 | 460 | my $self = shift; | |||||||||||||||||||||||||||
| 220 | 460 | ▶ | return 0 unless ( ref($self) eq 'Bio::ToolBox::Parser::ucsc' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | # does nothing with gff and bed | ||||||||||||||||||||||||||||
| 223 | 231 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 0 | $self->{'do_name'} = shift; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | 231 | return $self->{'do_name'}; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 623 | ▶ | sub share { | ||||||||||||||||||||||||||
|
Subroutine
share: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 230 | 623 | my $self = shift; | |||||||||||||||||||||||||||
| 231 | 623 | ▶ | return 0 unless ( ref($self) eq 'Bio::ToolBox::Parser::ucsc' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | # does nothing with gff and bed | ||||||||||||||||||||||||||||
| 234 | 394 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 0 | $self->{'share'} = shift; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | 394 | return $self->{'share'}; | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 666 | ▶ | sub simplify { | ||||||||||||||||||||||||||
|
Subroutine
simplify: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 241 | 666 | my $self = shift; | |||||||||||||||||||||||||||
| 242 | 666 | ▶ | return 0 unless ( ref($self) eq 'Bio::ToolBox::Parser::gff' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | # does nothing with ucsc and bed | ||||||||||||||||||||||||||||
| 245 | 656 | ▶ | if ( defined $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 7 | $self->{simplify} = shift; | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | 656 | return $self->{simplify}; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 209 | ▶ | sub source { | ||||||||||||||||||||||||||
|
Subroutine
source: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 252 | 209 | my $self = shift; | |||||||||||||||||||||||||||
| 253 | 209 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 5 | $self->{'source'} = shift; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 209 | return $self->{'source'}; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 85 | ▶ | sub filetype { | ||||||||||||||||||||||||||
|
Subroutine
filetype: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 260 | 85 | return shift->{filetype}; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub number_loaded { | ||||||||||||||||||||||||||
|
Subroutine
number_loaded: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 264 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 265 | 0 | return scalar keys %{ $self->{loaded} }; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 36 | ▶ | sub file { | ||||||||||||||||||||||||||
|
Subroutine
file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 269 | 36 | return shift->{file}; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 1152 | ▶ | sub fh { | ||||||||||||||||||||||||||
|
Subroutine
fh: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 273 | 1152 | return shift->{fh}; | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 0 | ▶ | sub comments { | ||||||||||||||||||||||||||
|
Subroutine
comments: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 277 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 278 | 0 | my @comments; | |||||||||||||||||||||||||||
| 279 | 0 | foreach ( @{ $self->{comments} } ) { | |||||||||||||||||||||||||||
| 280 | 0 | push @comments, $_; | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | 0 | ▶ | return wantarray ? @comments : \@comments; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 0 | ▶ | sub seq_ids { | ||||||||||||||||||||||||||
|
Subroutine
seq_ids: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 286 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 287 | 0 | my @s = keys %{ $self->{seq_ids} }; | |||||||||||||||||||||||||||
| 288 | 0 | ▶ | return wantarray ? @s : \@s; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub seq_id_lengths { | ||||||||||||||||||||||||||
|
Subroutine
seq_id_lengths: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 292 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 293 | 0 | return $self->{seq_ids}; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 131 | ▶ | sub next_top_feature { | ||||||||||||||||||||||||||
|
Subroutine
next_top_feature: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||
| 297 | 131 | my $self = shift; | |||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | # return next item | ||||||||||||||||||||||||||||
| 300 | 131 | ▶ | if ( exists $self->{top_feature_index} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 120 | my $i = $self->{top_feature_index}; | |||||||||||||||||||||||||||
| 302 | 120 | ▶ | if ( $i == $self->{last_top_feature_index} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | 8 | delete $self->{top_feature_index}; | |||||||||||||||||||||||||||
| 304 | 8 | delete $self->{last_top_feature_index}; | |||||||||||||||||||||||||||
| 305 | 8 | return undef; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | 112 | $self->{top_feature_index} += 1; | |||||||||||||||||||||||||||
| 308 | 112 | return $self->{top_features}->[$i]; | |||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | # otherwise, it's our first time | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | # check that we have an open filehandle | ||||||||||||||||||||||||||||
| 314 | 11 | ▶ | unless ( $self->fh ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 0 | croak 'FATAL: no annotation file loaded to parse!'; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | 11 | ▶ | unless ( $self->{'eof'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | $self->parse_file or croak 'FATAL: unable to parse file!'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | # set up index | ||||||||||||||||||||||||||||
| 322 | 11 | $self->{top_feature_index} = 1; | |||||||||||||||||||||||||||
| 323 | 11 | $self->{last_top_feature_index} = scalar( @{ $self->{top_features} } ); | |||||||||||||||||||||||||||
| 324 | 11 | return $self->{top_features}->[0]; | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 12 | ▶ | sub top_features { | ||||||||||||||||||||||||||
|
Subroutine
top_features: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 328 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 329 | 12 | ▶ | unless ( $self->{'eof'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | 6 | $self->parse_file; | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | 12 | my @features = @{ $self->{top_features} }; | |||||||||||||||||||||||||||
| 333 | 12 | ▶ | return wantarray ? @features : \@features; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 77 | ▶ | sub fetch { | ||||||||||||||||||||||||||
|
Subroutine
fetch: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||
| 337 | 77 | my ( $self, $id ) = @_; | |||||||||||||||||||||||||||
| 338 | 77 | ▶ | return unless $id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 77 | ▶ | unless ( $self->{'eof'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | 0 | $self->parse_file; | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | 77 | ▶ | return $self->{loaded}{$id} || undef; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'loaded'}{$id} || undef
MC/DC0%0/1
$self->{'loaded'}{$id} || undef
$self->{'loaded'}{$id}
Truth table50%1/2
A
A= $self->{'loaded'}{$id}
| |||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 2 | 1; | |||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | __END__ | ||||||||||||||||||||||||||||