0
|
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::FASTA::CopyDNA
|
|
24
|
|
25 =head1 DESCRIPTION
|
|
26
|
|
27 Performs a find in the DNA dumps directory, for the given species, in the
|
|
28 previous release FTP dump directory. Any files matching the normal gzipped
|
|
29 fasta extension will be copied over to this release's directory.
|
|
30
|
|
31 Previous release is defined as V<release-1>; override this class if your
|
|
32 definition of the previous release is different.
|
|
33
|
|
34 Allowed parameters are:
|
|
35
|
|
36 =over 8
|
|
37
|
|
38 =item release - Needed to build the target path
|
|
39
|
|
40 =item previous_release - Needed to build the source path
|
|
41
|
|
42 =item ftp_dir - Current location of the FTP directory for the previous
|
|
43 release. Should be the root i.e. the level I<release-XX> is in
|
|
44
|
|
45 =item species - Species to work with
|
|
46
|
|
47 =item base_path - The base of the dumps; reused files will be copied to here
|
|
48
|
|
49 =back
|
|
50
|
|
51 =cut
|
|
52
|
|
53 package Bio::EnsEMBL::Pipeline::FASTA::CopyDNA;
|
|
54
|
|
55 use strict;
|
|
56 use warnings;
|
|
57
|
|
58 use base qw/Bio::EnsEMBL::Pipeline::FASTA::Base/;
|
|
59
|
|
60 use File::Copy;
|
|
61 use File::Find;
|
|
62 use File::Spec;
|
|
63
|
|
64 sub fetch_input {
|
|
65 my ($self) = @_;
|
|
66 my @required = qw/release ftp_dir species/;
|
|
67 foreach my $key (@required) {
|
|
68 $self->throw("Need to define a $key parameter") unless $self->param($key);
|
|
69 }
|
|
70 return;
|
|
71 }
|
|
72
|
|
73 sub run {
|
|
74 my ($self) = @_;
|
|
75
|
|
76 my $new_path = $self->new_path();
|
|
77 #Remove all files from the new path
|
|
78 $self->unlink_all_files($new_path);
|
|
79
|
|
80 my $files = $self->get_dna_files();
|
|
81 foreach my $old_file (@{$files}) {
|
|
82 my $new_file = $self->new_filename($old_file);
|
|
83 $self->fine('copy %s %s', $old_file, $new_file);
|
|
84 copy($old_file, $new_file) or $self->throw("Cannot copy $old_file to $new_file: $!");
|
|
85 }
|
|
86
|
|
87 return;
|
|
88 }
|
|
89
|
|
90 sub new_filename {
|
|
91 my ($self, $old_filename) = @_;
|
|
92 my ($old_volume, $old_dir, $old_file) = File::Spec->splitpath($old_filename);
|
|
93 my $old_release = $self->param('previous_release');
|
|
94 my $release = $self->param('release');
|
|
95 my $new_file = $old_file;
|
|
96 $new_file =~ s/\.$old_release\./.$release./;
|
|
97 my $new_path = $self->new_path();
|
|
98 return File::Spec->catfile($new_path, $new_file);
|
|
99 }
|
|
100
|
|
101 sub new_path {
|
|
102 my ($self) = @_;
|
|
103 return $self->fasta_path('dna');
|
|
104 }
|
|
105
|
|
106 sub get_dna_files {
|
|
107 my ($self) = @_;
|
|
108 my $old_path = $self->old_path();
|
|
109 my $filter = sub {
|
|
110 my ($filename) = @_;
|
|
111 return ($filename =~ /\.fa\.gz$/ || $filename eq 'README') ? 1 : 0;
|
|
112 };
|
|
113 my $files = $self->find_files($old_path, $filter);
|
|
114 return $files;
|
|
115 }
|
|
116
|
|
117 1;
|