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

Diff of /FigKernelScripts/svr_upstream.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4, Tue Oct 20 20:22:08 2009 UTC revision 1.7, Wed Feb 17 15:03:27 2010 UTC
# Line 3  Line 3 
3    
4  use Getopt::Long;  use Getopt::Long;
5  use SAPserver;  use SAPserver;
6    use ScriptThing;
7    
8  #  #
9  #       This is a SAS Component.  #       This is a SAS Component.
# Line 10  Line 11 
11    
12  =head1 svr_upstream  =head1 svr_upstream
13    
14        svr_upstream <gene_ids.tbl >upstream_dna.fasta
15    
16  Retrieve upstream regions from the Sapling Server.  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  This script takes as input a tab-delimited file with feature IDs at the end. For
# Line 49  Line 52 
52  if (! $opted) {  if (! $opted) {
53      print "usage: svr_upstream [--skipGene] [--size=200] [-url=http://...] <input >output\n";      print "usage: svr_upstream [--skipGene] [--size=200] [-url=http://...] <input >output\n";
54  } else {  } else {
55        # Fix STDIN.
56        ScriptThing::AdjustStdin();
57      # Get the server object.      # Get the server object.
58      my $sapServer = SAPserver->new(url => $url);      my $sapServer = SAPserver->new(url => $url);
59      # The main loop processes chunks of input, 100 lines at a time.      # The main loop processes chunks of input, 1000 lines at a time.
60      while (! eof STDIN) {      while (my @tuples = ScriptThing::GetBatch(\*STDIN)) {
61          # We will build our list of IDs in here.          # Compute the comment strings.
62          my @ids;          my %comments = ScriptThing::CommentHash(\@tuples);
         # This hash will map each ID to its extra fields.  
         my %comments;  
         # This will count the lines read in this batch.  
         my $reads = 0;  
         # Loop through the input. We stop at 100 lines.  
         while ($reads <= 100 && ! eof STDIN) {  
             # Read the line and trim it.  
             my $line = <STDIN>;  
             chomp $line;  
             # Count the read.  
             $reads++;  
             # Get the feature ID and save it.  
             my @fields = split /\t/, $line;  
             if (scalar @fields) {  
                 my $fid = pop @fields;  
                 push @ids, $fid;  
                 $comments{$fid} = join(" ", @fields);  
             }  
         }  
63          # Ask the server for results.          # Ask the server for results.
64          my $document = $sapServer->upstream(-ids => \@ids, -size => $size,          my $document = $sapServer->upstream(-ids => [ map { $_->[0] } @tuples],
65                                                -size => $size,
66                                                -fasta => 1,
67                                              -comments => \%comments,                                              -comments => \%comments,
68                                              -skipGene => $skipGene);                                              -skipGene => $skipGene);
69          # Loop through the IDs, producing output.          # Loop through the tuples, producing output.
70          for my $fid (@ids) {          for my $tuple (@tuples) {
71                # Get the feature ID.
72                my $fid = $tuple->[0];
73              # Get this feature's FASTA.              # Get this feature's FASTA.
74              my $fasta = $document->{$fid};              my $fasta = $document->{$fid};
75              # Did we get something?              # Did we get something?

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3