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

View of /FigKernelScripts/svr_closest_genes.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Fri Jul 30 20:46:34 2010 UTC (9 years, 3 months 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_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
More server script stuff.

#!/usr/bin/perl -w
use strict;

use Getopt::Long;
use SAPserver;
use ScriptThing;

#
#	This is a SAS Component.
#

=head1 svr_closest_genes

    svr_closest_genes [--protein] genome sequence

Locate genes in a specified genome containing the specified protein or DNA sequence.

The output will be a tab-delimited file. For each gene containing the specified
protein or DNA sequence, a line will be output containing the location of the
gene found, the location of the match, and the FIG ID of the gene.

The specified sequence cannot contain ambiguity characters. In DNA sequences,
C<U> will be translated automatically to C<T>.

=head2 Command-Line Options

=over 4

=item url

The URL for the Sapling server, if it is to be different from the default.

=item protein

If specified, the sequence will be assumed to be a protein sequence; otherwise, it
will be assumed to be a DNA sequence unless it contains characters other than C<A>,
C<C>, C<G>, C<T>, or C<U>.

=back

=cut

# Parse the command-line options.
my $url = '';
my $protein = 0;
my $opted =  GetOptions('url=s' => \$url, 'protein' => \$protein);
# Get the positional parameters.
my ($genome, $sequence) = @ARGV;
if (! $opted || ! $genome || ! $sequence) {
    print "usage: svr_closest_genes [--url=http://...] [--protein] genome sequence >output\n";
} else {
    # Get the server object.
    my $sapServer = SAPserver->new(url => $url);
    # Find out if this is a protein.
    if (! $protein && $sequence =~ /[^acgtuACGTU]/) {
        $protein = 1;
    }
    # Ask the sapling server about the sequence.
    my $document = $sapServer->find_closest_genes(-genome => $genome, -protein => $protein,
                                                  -seqs => { seq => $sequence });
    # Get the list of hits.
    my $hitList = $document->{seq};
    # Only proceed if we found some.
    if ($hitList) {
        # Output the hits.
        for my $hit (@$hitList) {
            print join("\t", $hit->[1], $hit->[2], $hit->[0]) . "\n";
        }
    }
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3