[Bio] / Sprout / locations.pl Repository:
ViewVC logotype

Annotation of /Sprout/locations.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 Feature Location Computer
4 :    
5 :     This script adds feature locations to a data mining stream. The locations
6 :     are formatted as Sprout locations, consisting of the contig ID, the start
7 :     position, the direction, and the length. If a feature has multiple
8 :     locations, each one will produce a separate output line.
9 :    
10 :     The currently-supported command-line options are as follows.
11 :    
12 :     =over 4
13 :    
14 :     =item keyColumn
15 :    
16 :     Name or number of the column containing the feature ID.
17 :    
18 :     =item user
19 :    
20 :     Name suffix to be used for log files. If omitted, the PID is used.
21 :    
22 :     =item trace
23 :    
24 :     Numeric trace level. A higher trace level causes more messages to appear. The
25 :     default trace level is 2. Tracing will be directly to the standard output
26 :     as well as to a C<trace>I<User>C<.log> file in the FIG temporary directory,
27 :     where I<User> is the value of the B<user> option above.
28 :    
29 :     =item sql
30 :    
31 :     If specified, turns on tracing of SQL activity.
32 :    
33 :     =item background
34 :    
35 :     Save the standard and error output to files. The files will be created
36 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
37 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
38 :     B<user> option above.
39 :    
40 :     =item h
41 :    
42 :     Display this command's parameters and options.
43 :    
44 :     =back
45 :    
46 :     =cut
47 :    
48 :     use strict;
49 :     use Tracer;
50 :     use FIG;
51 :     use Sprout;
52 :     use SFXlate;
53 :     use ERDB;
54 :    
55 :     # Get the command-line options and parameters.
56 :     my ($options, @parameters) = StandardSetup([qw(Sprout ERDB SFXlate)],
57 :     {
58 :     keyColumn => ["Feature(id)", "column from which to take the feature ID"],
59 : parrello 1.2 trace => ["2-", "tracing level"],
60 : parrello 1.1 },
61 :     "",
62 :     @ARGV);
63 :     # Get the database.
64 :     my $sprout = SFXlate->new_sprout_only();
65 :     # Get the key column.
66 :     my $colName = $options->{keyColumn};
67 :     if (! $colName) {
68 :     Confess("No source column name specified.");
69 :     } else {
70 :     # Get the column headers.
71 :     my $colhdrs = <STDIN>;
72 :     # Verify that we have column headers.
73 :     if (! defined($colhdrs)) {
74 :     Confess("Nothing found in input.");
75 :     } else {
76 :     # Process the column headers.
77 :     my @metaData = ERDB::ParseColumns($colhdrs);
78 :     # Find the desired key column.
79 :     my $sourceCol = ERDB::FindColumn($colhdrs, $colName);
80 :     # Write out the new column headers.
81 :     print join("\t", @metaData, 'Feature(location)') . "\n";
82 :     # We will now loop through the input, appending feature locations to each
83 :     # input line.
84 :     while (my $line = <STDIN>) {
85 :     # Pull the feature ID from the line.
86 :     my @data = ERDB::ParseColumns($line);
87 :     my $keyValue = $data[$sourceCol];
88 :     # Get the feature's locations.
89 :     my @locations = $sprout->FeatureLocation($keyValue);
90 :     # Loop through the locations, producing output lines.
91 :     for my $loc (@locations) {
92 :     print join("\t", @data, $loc) . "\n";
93 :     }
94 :     }
95 :     }
96 :     }
97 :    
98 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3