comparison variant_effect_predictor/Bio/EnsEMBL/Pipeline/FindDirs.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 =pod
2
3 =head1 LICENSE
4
5 Copyright (c) 1999-2012 The European Bioinformatics Institute and
6 Genome Research Limited. All rights reserved.
7
8 This software is distributed under a modified Apache license.
9 For license details, please see
10
11 http://www.ensembl.org/info/about/code_licence.html
12
13 =head1 CONTACT
14
15 Please email comments or questions to the public Ensembl
16 developers list at <dev@ensembl.org>.
17
18 Questions may also be sent to the Ensembl help desk at
19 <helpdesk@ensembl.org>.
20
21 =head1 NAME
22
23 Bio::EnsEMBL::Pipeline::FindDirs
24
25 =head1 DESCRIPTION
26
27 Finds all directories under the given path.
28
29 Allowed parameters are:
30
31 =over 8
32
33 =item path - The path to search
34
35 =back
36
37 =cut
38
39 package Bio::EnsEMBL::Pipeline::FindDirs;
40
41 use strict;
42 use warnings;
43
44 use base qw/Bio::EnsEMBL::Hive::RunnableDB::JobFactory/;
45
46 use File::Spec;
47
48 sub fetch_input {
49 my ($self) = @_;
50 $self->throw("No 'path' parameter specified") unless $self->param('path');
51 my $dirs = $self->dirs();
52 $self->param('inputlist', $dirs);
53 return;
54 }
55
56 sub dirs {
57 my ($self) = @_;
58
59 my @dirs;
60
61 my $dir = $self->param('path');
62 $self->info('Searching directory %s', $dir);
63
64 opendir(my $dh, $dir) or die "Cannot open directory $dir";
65 my @files = sort { $a cmp $b } readdir($dh);
66 closedir($dh) or die "Cannot close directory $dir";
67
68 foreach my $file (@files) {
69 next if $file =~ /^\./; #hidden file or up/current dir
70 my $path = File::Spec->catdir($dir, $file);
71 if(-d $path) {
72 $self->fine('Adding %s to the list of found dirs', $path);
73 push(@dirs, $path);
74 }
75 }
76
77 return \@dirs;
78 }
79
80 1;