File Coverage

lib/Bio/Roary/LookupGeneFiles.pm
Criterion Covered Total %
statement 16 17 94.1
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 20 22 90.9


line stmt bran cond sub pod time code
1             package Bio::Roary::LookupGeneFiles;
2             $Bio::Roary::LookupGeneFiles::VERSION = '3.10.2';
3             # ABSTRACT: Take in an ordering of genes and a directory and return an ordered list of file locations
4              
5              
6 1     1   10 use Moose;
  1         3  
  1         10  
7              
8             has 'multifasta_directory' => ( is => 'ro', isa => 'Str', default => 'pan_genome_sequences' );
9             has 'ordered_genes' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
10              
11             has 'ordered_gene_files' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build_ordered_gene_files' );
12              
13              
14             sub _build_ordered_gene_files
15             {
16 2     2   5 my ($self) = @_;
17 2         5 my @gene_files;
18 2         83 for my $gene (@{$self->ordered_genes})
  2         67  
19             {
20 4         14 $gene =~ s!\W!_!gi;
21 4         11 my $filename = $gene.'.fa.aln';
22 4         109 my $gene_filepath = join('/',($self->multifasta_directory, $filename));
23            
24 4 50       70 if(! -e $gene_filepath)
25             {
26 0         0 print "Core gene file missing: ". $gene_filepath."\n";
27             }
28             else
29             {
30 4         14 push(@gene_files, $gene_filepath);
31             }
32             }
33 2         64 return \@gene_files;
34             }
35              
36 1     1   6931 no Moose;
  1         2  
  1         13  
37             __PACKAGE__->meta->make_immutable;
38              
39             1;
40              
41             __END__
42              
43             =pod
44              
45             =encoding UTF-8
46              
47             =head1 NAME
48              
49             Bio::Roary::LookupGeneFiles - Take in an ordering of genes and a directory and return an ordered list of file locations
50              
51             =head1 VERSION
52              
53             version 3.10.2
54              
55             =head1 SYNOPSIS
56              
57             Take in an ordering of genes and a directory and return an ordered list of file locations
58             use Bio::Roary::LookupGeneFiles;
59              
60             my $obj = Bio::Roary::LookupGeneFiles->new(
61             multifasta_directory => 'pan_genome_sequences',
62             ordered_genes => ['gene5','gene2','gene3'],
63              
64             );
65             $obj->ordered_gene_files();
66              
67             =head1 AUTHOR
68              
69             Andrew J. Page <ap13@sanger.ac.uk>
70              
71             =head1 COPYRIGHT AND LICENSE
72              
73             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
74              
75             This is free software, licensed under:
76              
77             The GNU General Public License, Version 3, June 2007
78              
79             =cut