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

View of /FigKernelScripts/pg_get_reaction_keys.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, 8 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_reaction_keys -d Data\n";
my $dataD;
my $rc  = GetOptions('d=s' => \$dataD,);

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

#opendir(MODELS,"$dataD/Models") || die "could not open $dataD/Models";
#my @models = grep { $_ !~ /^\./ } readdir(MODELS);
#closedir(MODELS);

open(KEYS," > $dataD/reaction_keys.table") || die "could not open $dataD/reaction_keys.table";

foreach $_ (`cat $dataD/MODEL-ID`)
{
    if ($_ =~ /^(\S+)\t(\S+)/) {
        my($genome,$mid) = ($1,$2);
        open(MODEL,"<$dataD/Models/gapfilled.$mid.json") || die "could not open $dataD/Models/gapfilled.$mid.json";
        my $json = JSON::XS->new;
        my $model;
        {
            local $/;
            undef $/;
            my $txt = <MODEL>;
            $model = $json->decode($txt);
        }
        close(MODEL);
        my $gapfill  = $model->[0]->{unintegrated_gapfillings};
        print KEYS "$mid\t$gapfill->[@{$gapfill} - 1]->[1]\n"; 
    }
}
close(KEYS);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3