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

View of /FigKernelScripts/br_evaluate_properties.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Wed Sep 18 21:27:50 2013 UTC (6 years, 2 months ago) by overbeek
Branch: MAIN
CVS Tags: rast_rel_2014_0729, rast_rel_2014_0912, HEAD
trying to commit a working copy

use strict;
use Data::Dumper;
use Carp;
use Boolean;

use SeedEnv;
use Getopt::Long;

my $usage = "usage: evaluate_properites -r Rules -g ReactionsPerGenome\n";

my $rules;
my $reactions_in_genomes;
my $rc  = GetOptions('r=s' => \$rules, 
		     'g=s' => \$reactions_in_genomes);

if ((! $rc) || (! open(RULES,"<$rules")) || (! open(RG,"<$reactions_in_genomes"))) { print STDERR $usage; exit }

my %reactions_in_genomes;
while (defined($_ = <RG>))
{
    if ($_ =~ /^(\S+)\s+(\S+)\s*$/)
    {
	$reactions_in_genomes{$1}->{$2} = 1;
    }
}
close(RG);

$/ = "\n\n";
my($enzyme_names,$definitions,$properties) = <RULES>;
$/ = "\n";

my @properties = grep { $_ =~ /\S/ } split(/\n/,$properties);
foreach my $p (@properties)
{
    print STDERR "processing property $p\n";
    my($error,$compiled_rules) = &Boolean::compile_rules($enzyme_names,$definitions,$p);
    if ($error)
    {
	print "could not compile for p=$p\n";
	die "Fix the properties";
    }

    my $prop = $p;
    $prop =~ s/^(\S+).*$/$1/;
    foreach my $g (keys(%reactions_in_genomes))
    {
	my $rH = $reactions_in_genomes{$g};
	my $r_in_g = [keys(%$rH)];
	my($vc,$debug) = &Boolean::find_vc($compiled_rules,$r_in_g);
	if ($vc ne "-1")
	{
	    print join("\t",($prop,$g,1)),"\n";
	}
	else
	{
	    print join("\t",($prop,$g,0)),"\n";
	}
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3