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

Diff of /FigKernelScripts/process_new_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Fri Mar 11 16:36:51 2005 UTC revision 1.3, Wed Nov 16 05:25:18 2005 UTC
# Line 9  Line 9 
9  && ($to_dir = shift @ARGV)  && ($to_dir = shift @ARGV)
10  )  || die $usage;  )  || die $usage;
11    
12  opendir(FROM,$from_dir) || die "could not open $from_dir";  #
13  @to_process = sort { $a =~ /\.(\d+)(\.gz)?$/; $x = $1;  # 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                       $b =~ /\.(\d+)(\.gz)?$/; $y = $1; ($x <=> $y) }                       $b =~ /\.(\d+)(\.gz)?$/; $y = $1; ($x <=> $y) }
40                       grep { $_ !~ /^\./ } readdir(FROM);                       @files;
41        push(@sim_files, map { "$dir/$_" } @files);
42  closedir(FROM);  closedir(FROM);
43    }
44    
45    @to_process = @sim_files;
46    
47    printf "Processing %d files\n", int(@to_process);
48  (-d $to_dir) || mkdir($to_dir,0777) || die "could not make $to_dir";  (-d $to_dir) || mkdir($to_dir,0777) || die "could not make $to_dir";
49    
50  open(OUT, "| reduce_sims $syn 300 | reformat_sims $nr | split_sims $to_dir $prefix")  open(OUT, "| reduce_sims $syn 300 | reformat_sims $nr | split_sims $to_dir $prefix")
# Line 27  Line 57 
57    
58      if ($file =~ /^\S+\.gz$/)      if ($file =~ /^\S+\.gz$/)
59      {      {
60          open(IN, "zcat $from_dir/$file |") || die "Could not pipe-open $from_dir/$file";          open(IN, "zcat $file |") || die "Could not pipe-open $from_dir/$file";
61      }      }
62      else      else
63      {      {
64          open(IN, "<$from_dir/$file") || die "Could not read-open $from_dir/$file";          open(IN, "<$file") || die "Could not read-open $from_dir/$file";
65      }      }
66    
67      while (defined($entry = <IN>)) { print OUT $entry; }      while (defined($entry = <IN>)) { print OUT $entry; }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3