ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/genetable.pl
Revision: 1.1
Committed: Wed Dec 13 10:39:36 2006 UTC (9 years, 8 months ago) by gawi79
Branch: MAIN
CVS Tags: HEAD
Log Message:
A QuickMine script

Line File contents
1 #!/usr/bin/perl -w
2
3 ##############################################
4 ##############################################
5 # SCRIPT NAME: genetable.pl
6 # FUNCTION: Make a gene table from a set of *hits files
7 # AUTHOR: Cared for by Gareth Wilson (gawi@ceh.ac.uk)
8 ##############################################
9
10 use strict;
11
12 use Config::Simple;
13 my ($line, @fields, @lines, @tags, $tag, $file);
14
15 # get this from the command line
16
17 unless (@ARGV ==2) {
18 die "\n\nUsage:\n ./genetable.pl end configfile\nPlease try again.\n\n\n";}
19
20 my $end = shift;
21 my $config_file = shift;
22
23 my $cfg = new Config::Simple($config_file);
24 # get the record separator from the config file
25 my $record_separator = $cfg->param('PARAMS.record_separator');
26 # convert since use of \t in config file results in literal \t being printed
27
28 if ($record_separator =~ "tab") {$record_separator = "\t"}
29
30 print "RECORD SEP $record_separator\n";
31
32
33 open (OUT, ">gene_table.html") or die "can't open gene_table.html for writing";
34 open (TAGS, "abbr.list") or die "can't open abbr.list file";
35 print OUT "<PRE>\nGenome$record_separator"."SELF$record_separator";
36 while ($tag = <TAGS>) {
37 chomp($tag);
38 push (@tags, $tag);
39 print OUT "$tag$record_separator";
40 }
41
42 print "TAGS: @tags";
43
44
45
46 ### added here ability to append the values in the abbr_extra
47 ### file if it exists
48
49 my @tags_extra = ();
50 my $tag_extra = "";
51
52 if (-e "abbr_extra.list") {
53 open (TAGS, "abbr_extra.list") or die "can't open abbr_extra.list file";
54 while ($tag_extra = <TAGS>) {
55 chomp($tag_extra);
56 push (@tags_extra, $tag_extra);
57 print OUT "$tag_extra$record_separator";
58 }
59
60 print "Full TAGS: @tags_extra";
61
62 } # end if abbr_extra.list
63
64 print OUT "\n";
65
66
67
68 # pick up all the *hits file in order of tags list
69 foreach $tag (@tags) {
70 $file = "$tag"."$end";
71 print "TAG: $tag - Summarizing file $file\n";
72 open (IN, "$file") or die "can't open file: $file";
73
74 # pick up all lines in file
75 @lines = <IN>;
76 # get rid of summary lines
77 $line = shift @lines;
78 $line = shift @lines;
79 $line = shift @lines;
80 $line = shift @lines;
81
82 print OUT "\n$tag$record_separator";
83 foreach $line (@lines) {
84 print "$line\n";
85 if ($line =~ /^\s$/) {print "\n";last};
86 @fields = split(/$record_separator/,$line);
87 if ($fields[1]) {print OUT "$fields[2]$record_separator";}
88
89 }
90 } # next tag and file