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

Annotation of /FigKernelScripts/svr_closest_genes.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :     use strict;
3 :    
4 :     use Getopt::Long;
5 :     use SAPserver;
6 :     use ScriptThing;
7 :    
8 :     #
9 :     # This is a SAS Component.
10 :     #
11 :    
12 :     =head1 svr_closest_genes
13 :    
14 :     svr_closest_genes [--protein] genome sequence
15 :    
16 :     Locate genes in a specified genome containing the specified protein or DNA sequence.
17 :    
18 :     The output will be a tab-delimited file. For each gene containing the specified
19 :     protein or DNA sequence, a line will be output containing the location of the
20 :     gene found, the location of the match, and the FIG ID of the gene.
21 :    
22 :     The specified sequence cannot contain ambiguity characters. In DNA sequences,
23 :     C<U> will be translated automatically to C<T>.
24 :    
25 :     =head2 Command-Line Options
26 :    
27 :     =over 4
28 :    
29 :     =item url
30 :    
31 :     The URL for the Sapling server, if it is to be different from the default.
32 :    
33 :     =item protein
34 :    
35 :     If specified, the sequence will be assumed to be a protein sequence; otherwise, it
36 :     will be assumed to be a DNA sequence unless it contains characters other than C<A>,
37 :     C<C>, C<G>, C<T>, or C<U>.
38 :    
39 :     =back
40 :    
41 :     =cut
42 :    
43 :     # Parse the command-line options.
44 :     my $url = '';
45 :     my $protein = 0;
46 :     my $opted = GetOptions('url=s' => \$url, 'protein' => \$protein);
47 :     # Get the positional parameters.
48 :     my ($genome, $sequence) = @ARGV;
49 :     if (! $opted || ! $genome || ! $sequence) {
50 :     print "usage: svr_closest_genes [--url=http://...] [--protein] genome sequence >output\n";
51 :     } else {
52 :     # Get the server object.
53 :     my $sapServer = SAPserver->new(url => $url);
54 :     # Find out if this is a protein.
55 :     if (! $protein && $sequence =~ /[^acgtuACGTU]/) {
56 :     $protein = 1;
57 :     }
58 :     # Ask the sapling server about the sequence.
59 :     my $document = $sapServer->find_closest_genes(-genome => $genome, -protein => $protein,
60 :     -seqs => { seq => $sequence });
61 :     # Get the list of hits.
62 :     my $hitList = $document->{seq};
63 :     # Only proceed if we found some.
64 :     if ($hitList) {
65 :     # Output the hits.
66 :     for my $hit (@$hitList) {
67 :     print join("\t", $hit->[1], $hit->[2], $hit->[0]) . "\n";
68 :     }
69 :     }
70 :     }
71 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3