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

View of /FigKernelScripts/FFB2_get_prots.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Mon Jul 12 19:30:27 2010 UTC (9 years, 4 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.2: +53 -4 lines
Bunch of figfam generation optimizations.

use strict;
use Cache::Memcached::Fast;

my $usage = "usage: FFB2_get_prots ProtsByGenomeD setI [memcache-host memcache-port]";
my($prots_by_genomeD,$setI);

(
 ($prots_by_genomeD = shift @ARGV) &&
 ($setI             = shift @ARGV)
)
    || die $usage;
my $mchost = shift;
my $mcport = shift;
my $mc;

if ($mchost && $mcport)
{
    $mc = new Cache::Memcached::Fast({ servers => ["$mchost:$mcport"] } );
}

mkdir($prots_by_genomeD,0777)
    || die "could not make $prots_by_genomeD";
open(SETI,">$setI") || die "could not open $setI";

use FIG;
my $fig = new FIG;

my %active_genomes = map { $_ => 1 } $fig->genomes('complete');
open(SETS,"<$FIG_Config::global/genome.sets") || die "could not open genome.sets";
my($x,%seen,%genomes);

while (defined($x = <SETS>))
{
    if (($x =~ /^(\d+)\t(\d+\.\d+)\t(\S.*\S)/) && $active_genomes{$2})
    {
	$genomes{$2} = $1;
        if (! $seen{$1})
        {   
	    $seen{$1} = 1;
	    print SETI "$1\t$3\n";
        }
    }
}
close(SETS);
close(SETI);

foreach my $genome (sort { $a <=> $b } keys(%genomes))
{
    my $gs = $fig->genus_species($genome);
    my $set = $genomes{$genome};
    open(SET,">>$prots_by_genomeD/$set") || die "aborted";
    foreach my $peg ($fig->all_features($genome,'peg'))
    { 
        my $prot = &get_translation($fig, $peg);
        if ($prot)
        {
            my $func = &function_of($fig, $peg);
            print SET ">$peg $func [$gs]\n$prot\n";
        }
    }
    close(SET);
    print STDERR "processed $genome\n";
    if (! -s "$prots_by_genomeD/$set") { die "genome=$genome set=$set"   }
}
sub get_translation
{
    my($fig, $peg) = @_;

    my $tr;
    if ($mc)
    {
	$tr = $mc->get("s:$peg");
    }
    if (!$tr)
    {
	$tr = $fig->get_translation($peg);
	if ($tr && $mc)
	{
	    $mc->set("s:$peg", $tr);
	}
    }
    return $tr;
}

sub function_of
{
    my($fig, $peg) = @_;

    my $tr;
    if ($mc)
    {
	$tr = $mc->get("f:$peg");
    }
    if (!$tr)
    {
	$tr = $fig->function_of($peg);
	if ($tr && $mc)
	{
	    $mc->set("f:$peg", $tr);
	}
    }
    return $tr;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3