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

View of /FigKernelScripts/fc_figfams.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Thu Nov 11 17:44:33 2010 UTC (9 years, 3 months ago) by disz
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, 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, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.2: +1 -1 lines
FigFam 6 digit problem

########################################################################

# usage: fc_figfams [done] > couplings

my %done;
if (@ARGV > 0)
{
    foreach $_ (`cut -f1 $ARGV[0] | sort -u`)
    {
	if ($_ =~ /^(FIG\d+)/)
	{
	    $done{$1} = 1;
	}
    }
}

use FIG;
my $fig = new FIG;

use FigFams;
my $figfams = new FigFams($fig);

use FigFam;

$| = 1;
foreach $fam_id1 ($figfams->all_families)
{
    next if ($done{$fam_id1});
    undef %to;
    my $figfam = new FigFam($fig,$fam_id1);
    if (! $figfam)
    {
	print STDERR "could not make FIGfam $fam_id1\n";
    }
    else
    {
	my @pegs = $figfam->list_members;
	foreach $tuple (&batch($fig,@pegs))
	{
	    my($peg1,$peg2,$sc) = @$tuple;
	    foreach $fam_id2 ($figfams->families_containing_peg($peg2))
	    {
		if ((! ($x = $to{$fam_id2})) || ($x < $sc))
		{
		    $to{$fam_id2} = $sc;
		}
	    }
	}
    }
    foreach $fam_id2 (sort {$to{$b} <=> $to{$a}} keys(%to))
    {
	print join("\t",($fam_id1,$fam_id2,$to{$fam_id2})),"\n";
    }
}

sub batch {
    my($fig,@pegs) = @_;

    my $rdbH = $fig->db_handle;
    if (! $rdbH->table_exists('fc_pegs')) { return undef }

    my $cond = join(", ", map { "'$_'" } @pegs);
    my $relational_db_response = $rdbH->SQL("SELECT peg1,peg2,score FROM fc_pegs
                                             WHERE  peg1 in ($cond) ");
    return @$relational_db_response;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3