Parent Directory
|
Revision Log
Revision 1.1 - (view) (download) (as text)
1 : | parrello | 1.1 | =head1 Fix Up a Package Directory Containing Binning Files |
2 : | |||
3 : | package_fix.pl [options] targetDir | ||
4 : | |||
5 : | This script fixes up genome packages created from bins using files downloaded from a PATRIC binning run. The L<package_genome.pl> | ||
6 : | script should already have been run on the genomes. For each package directory I<XXXXXX.X>, there should be three files in the | ||
7 : | target directory. | ||
8 : | |||
9 : | =over 4 | ||
10 : | |||
11 : | =item 1 | ||
12 : | |||
13 : | I<XXXXXX.X>C<.scikit.eval.txt> becomes I<XXXXXX.X>C</EvalBySciKit/evaluate.out> | ||
14 : | |||
15 : | =item 2 | ||
16 : | |||
17 : | I<XXXXXX.X>C<.scikit.txt> becomes I<XXXXXX.X>C</EvalBySciKit/evaluate.log> | ||
18 : | |||
19 : | =item 3 | ||
20 : | |||
21 : | I<XXXXXX.X>C<.checkm.txt> becomes I<XXXXXX.X>C</EvalByCheckM/evaluate.log> | ||
22 : | |||
23 : | =back | ||
24 : | |||
25 : | |||
26 : | |||
27 : | =head2 Parameters | ||
28 : | |||
29 : | The sole positional parameter is the name of the target directory. | ||
30 : | |||
31 : | =cut | ||
32 : | |||
33 : | use strict; | ||
34 : | use P3DataAPI; | ||
35 : | use P3Utils; | ||
36 : | use File::Copy::Recursive; | ||
37 : | |||
38 : | # Get the command-line options. | ||
39 : | my $opt = P3Utils::script_opts('targetDir'); | ||
40 : | my ($targetDir) = @ARGV; | ||
41 : | if (! $targetDir) { | ||
42 : | die "No target directory specified."; | ||
43 : | } elsif (! -d $targetDir) { | ||
44 : | die "Target directory not found or invalid."; | ||
45 : | } | ||
46 : | # Read the files and directories in the target dir. | ||
47 : | opendir(my $dh, $targetDir) || die "Could not open $targetDir: $!"; | ||
48 : | my (@packages, %outFiles); | ||
49 : | while (my $member = readdir $dh) { | ||
50 : | if ($member =~ /^\d+\.\d+$/) { | ||
51 : | push @packages, $member; | ||
52 : | } elsif ($member =~ /\.txt$/) { | ||
53 : | $outFiles{$member} = 1; | ||
54 : | } | ||
55 : | } | ||
56 : | closedir $dh; | ||
57 : | print scalar(@packages) . " package directories found.\n"; | ||
58 : | # Loop through the packages. | ||
59 : | for my $pkg (@packages) { | ||
60 : | print "Checking package $pkg.\n"; | ||
61 : | if ($outFiles{"$pkg.scikit.eval.txt"} && $outFiles{"$pkg.scikit.txt"} && $outFiles{"$pkg.checkm.txt"}) { | ||
62 : | print "Eval files found for $pkg.\n"; | ||
63 : | # We have the files. Move them. | ||
64 : | File::Copy::Recursive::fmove("$targetDir/$pkg.scikit.eval.txt", "$targetDir/$pkg/EvalBySciKit/evaluate.out") || die "Could not move scikit.eval.txt: $!"; | ||
65 : | File::Copy::Recursive::fmove("$targetDir/$pkg.scikit.txt", "$targetDir/$pkg/EvalBySciKit/evaluate.log") || die "Could not move scikit.txt: $!"; | ||
66 : | File::Copy::Recursive::fmove("$targetDir/$pkg.checkm.txt", "$targetDir/$pkg/EvalByCheckm/evaluate.log") || die "Could not move checkm.txt: $!"; | ||
67 : | print "Files moved.\n"; | ||
68 : | } | ||
69 : | } |
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |