[Bio] / FigKernelScripts / process_new_sims.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/process_new_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (view) (download) (as text)

1 : efrank 1.1 use FIG;
2 :    
3 : overbeek 1.2 $usage = "usage: process_new_sims NR peg.synonyms SimsDir Prefix EnhancedSimsDir";
4 : efrank 1.1
5 : overbeek 1.2 ( ($nr = shift @ARGV) && (-s $nr)
6 :     && ($syn = shift @ARGV) && (-s $syn)
7 :     && ($from_dir = shift @ARGV)
8 :     && ($prefix = shift @ARGV)
9 :     && ($to_dir = shift @ARGV)
10 :     ) || die $usage;
11 : efrank 1.1
12 : olson 1.3 #
13 :     # If fromdir == "-", read a list of directories from stdin to process.
14 :     #
15 :    
16 :     my @dir_list;
17 :     if ($from_dir eq '-')
18 :     {
19 :     while (<>)
20 :     {
21 :     chomp;
22 :     s/^\s*//;
23 :     s/\s*$//;
24 :     -d $_ or die "Sims directory $_ does not exist\n";
25 :     push(@dir_list, $_);
26 :     }
27 :     }
28 :     else
29 :     {
30 :     push(@dir_list, $from_dir);
31 :     }
32 :    
33 :     my @sim_files;
34 :     for my $dir (@dir_list)
35 :     {
36 :     opendir(FROM,$dir) || die "could not open $dir";
37 :     my @files = grep { $_ !~ /^\./ } readdir(FROM);
38 :     @files = sort { $a =~ /\.(\d+)(\.gz)?$/; $x = $1;
39 : overbeek 1.2 $b =~ /\.(\d+)(\.gz)?$/; $y = $1; ($x <=> $y) }
40 : olson 1.3 @files;
41 :     push(@sim_files, map { "$dir/$_" } @files);
42 :     closedir(FROM);
43 :     }
44 :    
45 :     @to_process = @sim_files;
46 : efrank 1.1
47 : olson 1.3 printf "Processing %d files\n", int(@to_process);
48 : efrank 1.1 (-d $to_dir) || mkdir($to_dir,0777) || die "could not make $to_dir";
49 :    
50 : overbeek 1.2 open(OUT, "| reduce_sims $syn 300 | reformat_sims $nr | split_sims $to_dir $prefix")
51 :     || die "could not open output pipeline";
52 :    
53 : efrank 1.1 foreach $file (@to_process)
54 :     {
55 :     print STDERR "processing $file\n";
56 : overbeek 1.2 # my $base = ($file =~ /^(\S+).gz$/) ? $1 : $file;
57 :    
58 :     if ($file =~ /^\S+\.gz$/)
59 : efrank 1.1 {
60 : olson 1.3 open(IN, "zcat $file |") || die "Could not pipe-open $from_dir/$file";
61 : efrank 1.1 }
62 :     else
63 :     {
64 : olson 1.3 open(IN, "<$file") || die "Could not read-open $from_dir/$file";
65 : efrank 1.1 }
66 : overbeek 1.2
67 :     while (defined($entry = <IN>)) { print OUT $entry; }
68 : efrank 1.1 }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3