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

View of /FigKernelScripts/svr_current_annotation.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Thu Jul 28 16:22:55 2011 UTC (8 years, 7 months ago) by fangfang
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, mgrast_release_3_1_2, mgrast_release_3_1_1, rast_rel_2011_0928, mgrast_dev_12152011, mgrast_dev_10262011
Changes since 1.1: +0 -2 lines
remove debugging lines

use strict;
use Data::Dumper;

#
# This is a SAS Component
#


=head1 svr_current_annotation

Get the functional role, annotator and timestamp of the current
annotation for a protein-encoding gene or RNA.

------

Example:

    svr_all_features 3702.1 peg | svr_current_annotation

would produce a 4-column table for genes occurring in genome 3702.1: [ PEG, function, annotator, timestamp ]

------

The standard input should be a tab-separated table (i.e., each line 
is a tab-separated set of fields).  Normally, the last field in each
line would contain the PEG for which functions are being requested.
If some other column contains the PEGs, use

    -c N

where N is the column (from 1) that contains the PEG in each case.

This is a pipe command. The input is taken from the standard input, and the
output is to the standard output.

=head2 Command-Line Options

=over 4

=item -c Column

This is used only if the column containing PEGs is not the last.

=back

=head2 Output Format

The standard output is a tab-delimited file. It consists of the input
file with 3 extra columns added (the function associated with the PEG,
the annotator who made the assignment, and the timestamp of the
annotation).

=cut

use SeedUtils;
use SAPserver;
my $sapObject = SAPserver->new();
use Getopt::Long;
use ScriptThing;

my $usage = "usage: svr_current_annotation [-c column]";

my $column;
my $i = "-";
my $rc  = GetOptions('c=i' => \$column, 'i=s' => \$i);
if (! $rc) { print STDERR $usage; exit }
open my $ih, "<$i";
while (my @tuples = ScriptThing::GetBatch($ih, undef, $column)) {
    my @ids = map { $_->[0] } @tuples;
    my ($annotations) = $sapObject->ids_to_annotations(-ids => \@ids);
    for my $tuple (@tuples) {
        my ($id, $line) = @$tuple;
        my ($function, $annotator, $timestamp) = @{$annotations->{$id}->[0]};
        $function =~ s/^\s*Set FIG function to\s*//;
        if (! defined $function) {
            print STDERR "$id not found.\n";
        } else {
            print join("\t", $line, $function, $annotator, $timestamp)."\n";
        }
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3