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

View of /FigKernelScripts/at.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Wed Mar 23 21:41:37 2011 UTC (8 years, 11 months ago) by fangfang
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_03252011, mgrast_release_3_0_4, mgrast_release_3_0_3, 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_10262011, HEAD
Changes since 1.2: +25 -0 lines
update

# -*- perl -*-
########################################################################
# Copyright (c) 2003-2008 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
# 
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
########################################################################

use Carp;
use Data::Dumper;
use Time::HiRes qw(gettimeofday);
use Time::Local;
use AlignsAndTreesServer;
use AliTreeSims;

use gjoseqlib;
use gjonewicklib;

# usage: at [-echo] [-time] [-url seed-url] [-orgdir RAST-genome-dir] [command]

$echo       = 0;
$time_cmds  = 0;

my($t1,$t2);
if (@ARGV > 0)  { $req = join( " ", @ARGV ); }
while ( (defined($req) && $req) || ((@ARGV == 0) && ($req = &get_req)) )
{
    if ($time_cmds)
    {
	$t1 = gettimeofday;
    }

    if ($req =~ /^\s*h\s*$/ || $req =~ /^\s*help\s*$/)
    {
     &help;
    }
    elsif ($req =~ /^\s*all_alignIDs\s*$/)
    {
	my @alignIDs = &AlignsAndTreesServer::all_alignIDs();
        print join('', map { $_, "\n" } @alignIDs);
    }
    elsif ($req =~ /^\s*md5IDs_in_align\s+(\d+)\s*$/)
    {
	my @md5IDs = &AlignsAndTreesServer::md5IDs_in_align($1);
        print join('', map { $_, "\n" } @md5IDs);
    }
    elsif ($req =~ /^\s*aligns_with_md5ID\s+(\S+)\s*$/)
    {
	my @alignIDs = &AlignsAndTreesServer::aligns_with_md5ID($1);
        print join('', map { $_, "\n" } @alignIDs);
    }
    elsif ($req =~ /^\s*md5_alignment_by_ID\s+(\d+)\s*$/)
    {
	my($seqs,$meta) = &AlignsAndTreesServer::md5_alignment_by_ID($1);
        gjoseqlib::print_alignment_as_fasta($seqs);
	# print &Dumper($seqs,$meta);
    } 
    elsif ($req =~ /^\s*pegIDs_in_align\s+(\d+)\s*$/)
    {
	my @pegIDs = &AlignsAndTreesServer::pegIDs_in_align($1);
        print join('', map { $_, "\n" } @pegIDs);
    }
    elsif ($req =~ /^\s*aligns_with_pegID\s+(\S+)\s*$/)
    {
	my @alignIDs = &AlignsAndTreesServer::aligns_with_pegID($1);
        print join('', map { $_, "\n" } @alignIDs);
    }
    elsif ($req =~ /^\s*peg_alignment_by_ID\s+(\d+)\s*$/)
    {
	my($seqs,$meta) = &AlignsAndTreesServer::peg_alignment_by_ID($1);
        gjoseqlib::print_alignment_as_fasta($seqs);
	# print &Dumper($seqs,$meta);
    } 
    elsif ($req =~ /^\s*all_treeIDs\s$/)
    {
	my $treeIDs = &AlignsAndTreesServer::all_treeIDs();
        print join('', map { $_, "\n" } @treeIDs);
    }
    elsif ($req =~ /^\s*md5IDs_in_tree\s+(\d+)\s*$/)
    {
	my @md5IDs = &AlignsAndTreesServer::md5IDs_in_tree($1);
        print join('', map { $_, "\n" } @md5IDs);
    }
    elsif ($req =~ /^\s*trees_with_md5ID\s+(\S+)\s*$/)
    {
	my @treeIDs = &AlignsAndTreesServer::trees_with_md5ID($1);
        print join('', map { $_, "\n" } @treeIDs);
    }
    elsif ($req =~ /^\s*md5_tree_by_ID\s+(\d+)\s*$/)
    {
	my $tree = &AlignsAndTreesServer::md5_tree_by_ID($1);
        gjonewicklib::writeNewickTree($tree);
    } 
    elsif ($req =~ /^\s*pegIDs_in_tree\s+(\d+)\s*$/)
    {
	my @pegIDs = &AlignsAndTreesServer::pegIDs_in_tree($1);
        print join('', map { $_, "\n" } @pegIDs);
    }
    elsif ($req =~ /^\s*trees_with_pegID\s+(\S+)\s*$/)
    {
	my @treeIDs = &AlignsAndTreesServer::trees_with_pegID($1);
        print join('', map { $_, "\n" } @treeIDs);
    }
    elsif ($req =~ /^\s*peg_tree_by_ID\s+(\d+)\s*$/)
    {
	my $tree = &AlignsAndTreesServer::peg_tree_by_ID($1);
        gjonewicklib::writeNewickTree($tree);
    } 
    elsif ($req =~ /^\s*md5_tree_sims_of_align\s+(\S+)\s+(\S+)\s*$/)
    {
        my $sims = AliTreeSims::md5_tree_sims_of_align($1, $2);
        print Dumper($sims);
    } 
    elsif ($req =~ /^\s*md5_tree_sims\s+(\S+)\s*$/)
    {
        my $sims = AliTreeSims::md5_tree_sims($1);
        print Dumper($sims);
    } 
    elsif ($req =~ /^\s*peg_tree_sims\s+(\S+)\s*$/)
    {
        my $sims = AliTreeSims::peg_tree_sims($1);
        print Dumper($sims);
    } 
    elsif ($req =~ /^\s*merged_sims\s+(\S+)\s*$/)
    {
        my $sims = AliTreeSims::merged_sims($1);
        print Dumper($sims);
    } 
    else
    {
	print "invalid command\n";
    }
    print STDERR "\n";
    $req = "";

    if ($time_cmds)
    {
	$t2 = gettimeofday;
	print $t2-$t1," seconds to execute command\n\n";
    }
}
sub padded {
    my($x,$n) = @_;

    if (length($x) < $n)
    {
	return $x . (" " x ($n - length($x)));
    }
    return $x;
}

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;
    aligns_with_md5ID         md5ID
    aligns_with_pegID         PEG
    all_alignIDs          
    all_treeIDs          
    md5IDs_in_align           alignID
    md5IDs_in_tree            treeID
    md5_alignment_by_ID       alignID
    md5_tree_by_ID            treeID
    md5_tree_sims_of_align    treeID md5ID
    md5_tree_sims             md5ID
    merged_sims               pegID
    pegIDs_in_align           alignID
    pegIDs_in_tree            treeID
    peg_alignment_by_ID       alignID
    peg_tree_by_ID            treeID
    peg_tree_sims             pegID
    trees_with_md5ID          md5ID
    trees_with_pegID          PEG

END
}






MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3