lib/Bio/AutomatedAnnotation/GeneNameOccurances.pm

filter: Statementstmt 100% 47 / 47 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 98.2% 57 / 58 CC 5 SCAR 6.6
CC
5
Cov
98%
_build_gene_name_hashes
3.0
_build_all_gene_names
3.0
BEGIN
1.0
CRAP 1.9
« blib/lib/Bio/AutomatedAnnotation/Exceptions.pm ↑ Summary lib/Bio/AutomatedAnnotation/Exceptions.pm »
1 package Bio::AutomatedAnnotation::GeneNameOccurances;
2  
3 # ABSTRACT: Parse the gene names from multiple GFF files and provide a matrix of matches.
4  
5  
6 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Bio::Tools::GFF;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Bio::AutomatedAnnotation::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Bio::AutomatedAnnotation::GeneNamesFromGFF;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 has 'gff_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
12 3 has 'all_gene_names' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_all_gene_names' );
13 3 has 'sorted_all_gene_names' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build_sorted_all_gene_names' );
14  
15 3 has 'gene_name_hashes' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_gene_name_hashes' );
16 3 has 'number_of_files' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_number_of_files' );
17  
18 sub _build_sorted_all_gene_names
19 {
20 6 ▶ my ($self) = @_;
Subroutine _build_sorted_all_gene_names: called CC=1 SCAR=0.0
21 6 my %all_gene_names = %{$self->all_gene_names};
22
23 6 my @sorted_gene_names = sort { $b cmp $a } keys %all_gene_names;
24 6 return \@sorted_gene_names;
25 }
26  
27 sub _build_number_of_files
28 {
29 5 ▶ my ($self) = @_;
Subroutine _build_number_of_files: called CC=1 SCAR=0.0
30 5 return @{$self->gff_files};
31 }
32  
33 sub _build_all_gene_names {
34 7 ▶ my ($self) = @_;
Subroutine _build_all_gene_names: called CC=3 SCAR=11.0
35 7 my %all_gene_names;
36
37 7 for my $filename (keys %{$self->gene_name_hashes})
38 {
39 17 for my $gene_name (keys %{$self->gene_name_hashes->{$filename}})
40 {
41 70 $all_gene_names{$gene_name}++;
42 }
43 }
44 7 return \%all_gene_names;
45 }
46  
47 sub _build_gene_name_hashes {
48 11 ▶ my ($self) = @_;
Subroutine _build_gene_name_hashes: called CC=3 SCAR=11.0
49 11 my %gene_name_hashes;
50  
51 11 for my $gff_file ( @{ $self->gff_files } ) {
52 23 ▶ Bio::AutomatedAnnotation::Exceptions::FileNotFound->throw( error => 'Cant open file: ' . $gff_file )
Branch: 1 branch
BranchTrueFalseTotal
unless -e $gff_file 0 23 23
53 unless ( -e $gff_file );
54 23 my $gene_names_object = Bio::AutomatedAnnotation::GeneNamesFromGFF->new( gff_file => $gff_file );
55 23 $gene_name_hashes{$gff_file} = $gene_names_object->gene_names ;
56 }
57 11 return \%gene_name_hashes;
58 }
59  
60 3 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 3 __PACKAGE__->meta->make_immutable;
62  
63 3 1;
64  
65 __END__
66  
67 =pod
68  
69 =encoding UTF-8
70  
71 =head1 NAME
72  
73 Bio::AutomatedAnnotation::GeneNameOccurances - Parse the gene names from multiple GFF files and provide a matrix of matches.
74  
75 =head1 VERSION
76  
77 version 1.182685
78  
79 =head1 SYNOPSIS
80  
81 Parse the gene names from multiple GFF files and provide a matrix of matches.
82 use Bio::AutomatedAnnotation::GeneNameOccurances;
83  
84 my $obj = Bio::AutomatedAnnotation::GeneNameOccurances->new(
85 gff_files => ['abc.gff','efg.gff','hij.gff']
86 );
87 my %all_gene_names = %{$obj->all_gene_names};
88  
89 =head1 METHODS
90  
91 =head2 all_gene_names
92  
93 Returns a HashRef where the keys are all observed gene names and the values are the frequency of occurance.
94  
95 =head1 AUTHOR
96  
97 Andrew J. Page <ap13@sanger.ac.uk>
98  
99 =head1 COPYRIGHT AND LICENSE
100  
101 This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
102  
103 This is free software, licensed under:
104  
105 The GNU General Public License, Version 3, June 2007
106  
107 =cut
« blib/lib/Bio/AutomatedAnnotation/Exceptions.pm ↑ Summary lib/Bio/AutomatedAnnotation/Exceptions.pm »