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

View of /FigKernelScripts/process_new_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Mon Dec 5 18:56:38 2005 UTC (14 years, 7 months ago) by olson
Branch: MAIN
CVS Tags: caBIG-05Apr06-00, caBIG-13Feb06-00
Changes since 1.3: +17 -0 lines
Add license words.

#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
# 
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#

use FIG;

$usage = "usage: process_new_sims NR peg.synonyms SimsDir Prefix EnhancedSimsDir";

(  ($nr  = shift @ARGV) && (-s $nr) 
&& ($syn = shift @ARGV) && (-s $syn) 
&& ($from_dir = shift @ARGV) 
&& ($prefix = shift @ARGV) 
&& ($to_dir = shift @ARGV)
)  || die $usage;

#
# If fromdir  == "-", read a list of directories from stdin to process.
#

my @dir_list;
if ($from_dir eq '-')
{
    while (<>)
    {
	chomp;
	s/^\s*//;
	s/\s*$//;
	-d $_ or die "Sims directory $_ does not exist\n";
	push(@dir_list, $_);
    }
}
else
{
    push(@dir_list, $from_dir);
}

my @sim_files;
for my $dir (@dir_list)
{
    opendir(FROM,$dir) || die "could not open $dir";
    my @files = grep { $_ !~ /^\./ } readdir(FROM);
    @files = sort { $a =~ /\.(\d+)(\.gz)?$/; $x = $1; 
		     $b =~ /\.(\d+)(\.gz)?$/; $y = $1; ($x <=> $y) } 
                     @files;
    push(@sim_files, map { "$dir/$_" } @files);
    closedir(FROM);
}

@to_process = @sim_files;

printf "Processing %d files\n", int(@to_process);
(-d $to_dir) || mkdir($to_dir,0777) || die "could not make $to_dir";

open(OUT, "| reduce_sims $syn 300 | reformat_sims $nr | split_sims $to_dir $prefix")
    || die "could not open output pipeline";

foreach $file (@to_process)
{
    print STDERR "processing $file\n";
#   my $base = ($file =~ /^(\S+).gz$/) ? $1 : $file;
    
    if ($file =~ /^\S+\.gz$/)
    {
	open(IN, "zcat $file |") || die "Could not pipe-open $from_dir/$file";
    }
    else
    {
	open(IN, "<$file") || die "Could not read-open $from_dir/$file";
    }
    
    while (defined($entry = <IN>)) { print OUT $entry; }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3