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

Annotation of /FigKernelScripts/svr_upstream.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :     use strict;
3 :    
4 :     use Getopt::Long;
5 :     use SAPserver;
6 : parrello 1.5 use ScriptThing;
7 : parrello 1.1
8 :     #
9 :     # This is a SAS Component.
10 :     #
11 :    
12 :     =head1 svr_upstream
13 :    
14 : parrello 1.7 svr_upstream <gene_ids.tbl >upstream_dna.fasta
15 :    
16 : parrello 1.1 Retrieve upstream regions from the Sapling Server.
17 :    
18 :     This script takes as input a tab-delimited file with feature IDs at the end. For
19 :     each feature ID, the upstream DNA is computed and written to the output file in
20 :     FASTA format. Sections of DNA that occur inside a feature are shown in upper
21 :     case. DNA between known features is shown in lower case.
22 :    
23 : parrello 1.4 This is a pipe command. Input is from the standard input and output is to the
24 :     standard output.
25 :    
26 : parrello 1.1 =head2 Command-Line Options
27 :    
28 :     =over 4
29 :    
30 :     =item skipGene
31 :    
32 :     If specified, then only the upstream region is output. Otherwise, the upstream
33 :     region and the feature interior are output together.
34 :    
35 :     =item size
36 :    
37 :     Number of base pairs to show in the upstream region. The default is C<200>.
38 :    
39 :     =item url
40 :    
41 : parrello 1.3 The URL for the Sapling server, if it is to be different from the default.
42 : parrello 1.1
43 :     =back
44 :    
45 :     =cut
46 :    
47 :     # Parse the command-line options.
48 :     my $skipGene = '';
49 :     my $size = 200;
50 : parrello 1.2 my $url = '';
51 : parrello 1.3 my $opted = GetOptions('skipGene' => \$skipGene, 'size=i' => \$size, 'url=s' => \$url);
52 : parrello 1.1 if (! $opted) {
53 : parrello 1.3 print "usage: svr_upstream [--skipGene] [--size=200] [-url=http://...] <input >output\n";
54 : parrello 1.1 } else {
55 : parrello 1.6 # Fix STDIN.
56 :     ScriptThing::AdjustStdin();
57 : parrello 1.4 # Get the server object.
58 :     my $sapServer = SAPserver->new(url => $url);
59 : parrello 1.5 # The main loop processes chunks of input, 1000 lines at a time.
60 :     while (my @tuples = ScriptThing::GetBatch(\*STDIN)) {
61 :     # Compute the comment strings.
62 :     my %comments = ScriptThing::CommentHash(\@tuples);
63 : parrello 1.4 # Ask the server for results.
64 : parrello 1.5 my $document = $sapServer->upstream(-ids => [ map { $_->[0] } @tuples],
65 :     -size => $size,
66 : parrello 1.6 -fasta => 1,
67 : parrello 1.4 -comments => \%comments,
68 :     -skipGene => $skipGene);
69 : parrello 1.5 # Loop through the tuples, producing output.
70 :     for my $tuple (@tuples) {
71 :     # Get the feature ID.
72 :     my $fid = $tuple->[0];
73 : parrello 1.4 # Get this feature's FASTA.
74 :     my $fasta = $document->{$fid};
75 :     # Did we get something?
76 :     if (! $fasta) {
77 :     # No. Write an error notification.
78 :     print STDERR "Not found: $fid\n";
79 :     } else {
80 :     # Yes. output the FASTA.
81 :     print "$fasta";
82 : parrello 1.1 }
83 :     }
84 :     }
85 :     }
86 :    
87 :    
88 : parrello 1.4
89 : parrello 1.1

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3