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

View of /FigKernelScripts/ff.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (download) (as text) (annotate)
Thu Nov 11 17:43:54 2010 UTC (9 years, 4 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.6: +1 -1 lines
FigFam 6 digit problem

use DB_File;


my $dir;
($dir = shift @ARGV)
    || die "usage: ff Dir";

use FF;
use FFs;
my $figfams = new FFs($dir);

my($fam_id);
while ($req = &get_req)
{
    if ($req =~ /^\s*set\s+(FIG\d+)\s*$/)
    {
	$fam_id = $1;

	$figfam = new FF($fam_id,$dir);

	$figfam
	    || warn "could not handle $fam_id in $dir\n";
    }
    elsif ($req =~ /^\s*family_function(\s+(\S+))?\s*/)
    {
	if ($2)
	{
	    my $fam_id = $2;
	    $figfam = new FF($fam_id,$dir);
	}

	if (defined($figfam)) 
	{
	    print $figfam->family_function(1),"\n";
	}
	else
	{
	    print STDERR "you need to set the family first or give a family id\n";
	}
    }
    elsif ($req =~ /^\s*representatives(\s+(\S+))?\s*/)
    {
	if ($2)
	{
	    my $fam_id = $2;
	    $figfam = new FF($fam_id,$dir);
	}

	if (defined($figfam)) 
	{
	    my @reps = $figfam->representatives;
	    foreach my $seq (@reps)
	    {
		print "$seq\n\n";
	    }
	    print "\n";
	}
	else
	{
	    print STDERR "you need to set the family first or give a family id\n";
	}
    }
    elsif ($req =~ /^\s*list_members\s+(\S+)\s*/)
    {
	my $fam_id = $1;
	$figfam = new FF($fam_id,$dir);
	foreach my $id ($figfam->list_members)
	{
	    print join("\t",($id,$figfams->function_of($id))),"\n";
	}
    }
    elsif ($req =~ /^\s*place_in_family\s+(\S+)\s*/)
    {
	$seq = $1;
	($famO,$sims) = $figfams->place_in_family($seq);
	if ($famO)
	{
	    print "\nplaced into ",$famO->family_id,": ",$famO->family_function,"\n\n";
	}
	else
	{
	    print "\ncould not place into a family\n";
	}
    }
    elsif ($req =~ /^\s*should_be_member\s+(\S+)(\s+(\S+))?\s*/)
    {
	$seq = $1;
	if ($3)
	{
	    my $fam_id = $3;
	    $figfam = new FF($fam_id,$dir);
	}

	if (defined($figfam)) 
	{
	    my ($ans,undef) = $figfam->should_be_member($seq,0); 
	    print "Returned decision: ",$ans ? "yes" : "no","\n\n";
	}
	else
	{
	    print STDERR "you need to set the family first or give a family id\n";
	}
    }
    elsif ($req =~ /^\s*families_in_genome\s+(\d+\.\d+)\s*$/)
    {
	my $genome = $1;
	my @fams = $figfams->families_in_genome($genome);
	foreach $_ (@fams)
	{
	    print "$_\n";
	}
	print "\n";
    }
    elsif ($req =~ /^\s*families_with_function\s+(\S.*\S)\s*$/)
    {
	my $function = $1;
	my @fams = $figfams->families_with_function($function);
	foreach $_ (@fams)
	{
	    print "$_\n";
	}
	print "\n";
    }
    elsif ($req =~ /^\s*families_containing_peg\s+(\S+)\s*$/)
    {
	$peg = $1;
	my @families = $figfams->families_containing_peg($peg);
	foreach $fam_id (@families)
	{
	    $famO = new FF($fam_id,$dir);
	    $fam_func = $famO->family_function('full');
	    print "$fam_id\t$fam_func\n";
	}
	print "\n";
    }
    elsif ($req =~ /^\s*family_containing_peg\s+(\S+)\s*$/)
    {
	$peg = $1;
	my @families = $figfams->families_containing_peg($peg);
	foreach $fam_id (@families)
	{
	    $famO = new FF($fam_id,$dir);
	    $fam_func = $famO->family_function('full');
	    print "$fam_id\t$fam_func\n";
	}
	print "\n";
    }
    elsif ($req =~ /^\s*families_implementing_role\s+(\S.*\S)\s*$/)
    {
	my $role = $1;
	my @fams = $figfams->families_implementing_role($role);
	print join(",",@fams),"\n";
    }
    elsif ($req =~ /^\s*function_of\s+(\S+)\s*$/)
    {
	my $peg = $1;
	print $figfams->function_of($peg),"\n\n";
    }
    elsif ($req =~ /^\s*org_of\s+(\S+)\s*$/)
    {
	my $peg = $1;
	print $figfams->org_of($peg),"\n\n";
    }
    elsif ($req =~ /^\s*PDB_connections\s+(\S+)(\s+raw)?\s*$/)
    {
	my $fam = $1;
	my $raw = $2 ? 1 : 0;
	print &Dumper($figfams->PDB_connections($fam,$raw));
    }
    elsif ($req =~ /^\s*seq_of\s+(\S+)\s*$/)
    {
	my $peg = $1;
	print $figfams->seq_of($peg),"\n\n";
    }
    elsif ($req =~ /^\s*aliases_of\s+(\S+)\s*$/)
    {
	my $peg = $1;
	print $figfams->aliases_of($peg),"\n\n";
    }
    elsif ($req =~ /^\s*h\s*$/ || $req =~ /^\s*help\s*$/)
    {
     &help;
    }
    else
    {
	print "invalid command\n";
    }
    print "\n";
}

sub get_req {
    my($x);

    print "?? ";
    $x = <STDIN>;
    while (defined($x) && ($x =~ /^h$/i) )
    { 
	&help;
	print "?? ";
	$x = <STDIN>;
    }
    
    if ((! defined($x)) || ($x =~ /^\s*[qQxX]/))
    {
	return "";
    }
    else
    {
        if ($echo)
	{
	    print ">> $x\n";
	}
	return $x;
    }
}


sub help {
    print <<END;
    
    h                               
    aliases_of                       PEG
    family_containing_peg            PEG
    families_implementing_role       Role
    families_in_genome               GENOME
    families_with_function           Function
    family_function                  FamID
    function_of                      PEG
    list_members                     FamID
    org_of                           PEG
    PDB_connections                  FamID [raw]
    place_in_family                  Seq
    representatives                  FamID
    seq_of                           PEG
    set                              FamID
    should_be_member                 Seq [FamID]

END
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3