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

View of /FigKernelScripts/pg_get_gapfill_reactions.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Mar 21 20:20:48 2013 UTC (6 years, 7 months ago) by overbeek
Branch: MAIN
CVS Tags: rast_rel_2014_0729, rast_rel_2014_0912, HEAD
add gapfilling

use strict;
use Data::Dumper;
use Getopt::Long;
use SeedEnv;
use JSON::XS;

my $usage = "usage: get_gapfill_reactions -d Data\n";
my $dataD;
my $rc  = GetOptions('d=s' => \$dataD,);

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

#load up source id -> id, source id, cplx, role
my @rx_role = `all_entities_Reaction -f source_id  | get_relationship_IsStepOf -c 1 -to id | get_relationship_IsTriggeredBy -to id`;
my %rxroleH;
foreach my $r (@rx_role) {
        chomp $r;
            my ($id, $source, $cpx, $role) = split ("\t", $r);
                push (@{$rxroleH{$source}}, $r);
}


foreach my $mid  (`cat $dataD/reaction_keys.table`)
{
    chop ($mid);
    my ($model, $key) = split("\t", $mid);
    $model =~ /(^.*).fba/;
    my $genome = $1; 
    open(RX," > $dataD/GapfillReactions/$model.reaction_roles.table") || die "could not open $dataD/GapfillReactions/$model.reaction_roles.table";
    open(GAP_FILLS," > $dataD/GapfillReactions/$model.gapfill_reactions.table") || die "could not open $dataD/GapfillReactions/$model.gapfill_reactions.table";
    my $cmd = "kbfba-getgapfills $key NO_WORKSPACE -p";
     my $json = JSON::XS->new;
     my $reacts;
     {
         local $/;
         undef $/;
         my $txt = `$cmd`; 
         $reacts = $json->decode($txt);
     }
    foreach my $rx (@{$reacts->[0]->{solutions}->[0]->{reactionAdditions}}) {
            print GAP_FILLS $rx->[0], "\t", $rx->[4], "\n";
            print STDERR $genome, "\t", $rx->[0], "\t", $rx->[4], "\n";
            foreach my $r (@{$rxroleH{$rx->[0]}}) {
                    print RX $r, "\n";
                    print "$genome\t$r\n";
            }
    }
    close(GAP_FILLS);
    close(RX);
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3