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

View of /FigKernelScripts/ex_adjust_peg_on_off.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Sun Jul 28 13:11:53 2013 UTC (6 years, 3 months ago) by overbeek
Branch: MAIN
CVS Tags: rast_rel_2014_0729, rast_rel_2014_0912, HEAD
expression pipeline + ato,ic regulons

use Data::Dumper;
use File::Basename;
use Getopt::Long;
use SeedEnv;
use strict;

my $usage = "usage: ex_adjust_peg_on_off -d DataDir\n";

my($i,$j);
my $dataD;
my $rc  = GetOptions('d=s' => \$dataD);

if ((! $rc) || (! -d $dataD))
{ 
    print STDERR $usage; exit ;
}

my %to_peg = map { ($_ =~ /(fig\|\d+\.\d+\.peg\.\d+).*\t(\S[^\s]+\S)$/) ? ($2 => $1) : () }
             `cat $dataD/aliases`;

open(CALLS,"<$dataD/peg.on.off.calls") 
    || die "could not open $dataD/peg.on.off.calls";
my %pegs;
my %exp_peg_call;
my $line;
while (defined($line = <CALLS>))
{
    if (($line =~ /^(\S+)\t(\S+)\t(\S+)$/) && ($_ = $to_peg{$2}))
    {
	$exp_peg_call{$1}->{$_} = $3;
	$pegs{$2} = 1;
    }
}
close(CALLS);

my @exp = sort keys(%exp_peg_call);
my @pegs = keys(%pegs);

open(AR,"<$dataD/atomic.regulons")
    || die "could not open $dataD/atomic.regulons";
my %atomic_regulons;
my %peg_to_ar;
while (defined($_ = <AR>))
{
    if ($_ =~ /^(\S+)\t(\S+)/)
    {
	push(@{$atomic_regulons{$1}},$2);
	$peg_to_ar{$2} = $1;
    }
}
close(AR);

open(AR_CALLS,"<$dataD/atomic.regulon.on.off.calls")
    || die "could not open $dataD/atomic.regulon.on.off.calls";
my %exp_ar_call;
while (defined($_ = <AR_CALLS>))
{
    chop;
    my($exp,$ar,$call)  = split(/\t/,$_);
    $exp_ar_call{$exp}->{$ar} = $call;
}
close(AR_CALLS);

my %exp_peg_val;
foreach my $ar (keys(%atomic_regulons))
{
    my $pegs_in_ar = $atomic_regulons{$ar};
    foreach my $exp (keys(%exp_ar_call))
    {
	my $ar_call = $exp_ar_call{$ar};
	foreach my $peg (@$pegs_in_ar)
	{
	    if ($exp_peg_val{$exp}->{$peg} == 0)
	    {
		$exp_peg_val{$exp}->{$peg} = $ar_call;
	    }
	}
    }
}

if (-s "$dataD/peg.on.off.calls~") { unlink("$dataD/peg.on.off.calls~") }
if (-s "$dataD/peg.on.off.calls")
{
    rename("$dataD/peg.on.off.calls","$dataD/peg.on.off.calls~")
	|| die "could not rename $dataD/peg.on.off.calls";
}
open(PEG_CALLS,">$dataD/peg.on.off.calls")
    || die "could not open $dataD/peg.on.off.calls";
foreach my $exp (sort keys(%exp_peg_call))
{
    my $pegH = $exp_peg_call{$exp};
    foreach my $peg (sort { &SeedUtils::by_fig_id($a,$b) } keys(%$pegH))
    {
	print PEG_CALLS join("\t",($exp,$peg,$exp_peg_call{$exp}->{$peg})),"\n";
    }
}
close(PEG_CALLS);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3