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

View of /FigKernelScripts/server_paper_example1.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (download) (as text) (annotate)
Wed Mar 31 17:59:21 2010 UTC (10 years ago) by parrello
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_2010_0526, 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.11: +9 -13 lines
Documentation fix for server paper.

use strict;
use SAPserver;
use Data::Dumper;

# Example 1: ACH Data for a Protein
#
# This script takes a protein ID on the command line and
# finds all identifiers in the Sapling database that correspond
# to the identified protein (that is, they have the same amino
# acid sequence). For each identifier found, the following six
# columns will be output.
#
#   1. The identifier found.
#   2. The scientific name of the associated genome (if any).
#   3. 1 if we believe the identifier corresponds to the
#      exact gene identified by the input identifier, else
#      0. If the input identifier does not specify a
#      particular gene, this column will always be 0.
#   4. The functional assignment associated with the protein
#      ID.
#   5. The source of the assignment.
#   6. 1 if the assignment is considered expert, else 0.
#
# The data in columns (1), (4), (5), and (6) are provided
# automatically by the Sapling Server method "equiv_sequence".
# The item in column (3) is extracted via a call to the Sapling
# Server method "genome_names". The tricky part is the value in
# column (3). To make this determination, we make an initial call
# to the "equiv_precise" method to get identifiers for precisely-
# equivalent genes and put them into a hash. The value of
# column (3) is then determined by whether or not an
# identifier is in the precise-equivalence hash.

my $sapObject = SAPserver->new();
my $id = $ARGV[0];
if (! $id) {
    die "No protein ID specified.";
} else {
    my %preciseHash;
    my $precise_assertions_list = $sapObject->equiv_precise_assertions(-ids => $id);
    $precise_assertions_list = $precise_assertions_list->{$id};
    if (@$precise_assertions_list > 0) {
	my $inputID = $id;
        for my $precise_assertion (@$precise_assertions_list) {
            my ($newID, $function, $source, $expert) = @$precise_assertion;
            $preciseHash{$newID} = 1;
        }
    }

    my $assertions = $sapObject->equiv_sequence_assertions(-ids => $id);
    $assertions = $assertions->{$id};
    if (@$assertions < 1) {
        print STDERR "No results found.\n";
    } else {
        for my $assertion (@$assertions) {
            my ($newID, $function, $source, $expert, $genomeName) = @$assertion;
            $genomeName = '' if ! defined $genomeName;
            my $column3 = ($preciseHash{$newID} ? 1 : 0);
            print join("\t", $newID, $genomeName, $column3, $function, $source,
                             $expert) . "\n";
        }
    }
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3