ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/fasta_html.pl
Revision: 1.1
Committed: Wed Dec 13 10:38:45 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: fasta_html.pl
6 # FUNCTION: Do lots of command line processing quickly!
7 ##############################################
8
9 use strict;
10
11
12
13 ############################################################
14 # initialize all variables local to this script #
15 ############################################################
16
17 # this is imported from the config file - can't be my! must be 'our'
18 our @cmd =() ; # user set commands to use with system calls
19
20 # all variables set in this script
21 my $file = ""; # each file from @input_files as it is processed
22 my $config_file = undef;# config file to read
23 my $cmd = undef;# each command as it's executed
24 undef (my @options); # split each $cmd into words to get $output_file
25 my $output_file = undef;# output file name made from ext added to $file.all
26 undef (my @output_files); # a list of $output_files
27 my $current_file = ""; # each file printed to QUICKMINE.html
28 my $current_ext = ""; # each file extension printed to QUICKMINE.html
29 my $list = ""; # each list of analysis files printed to QUICKMINE.html
30 undef (my @remembered_ext); # a list of all the extensions used to generate QUICKMINE.html
31 undef (my @analysis_files); # a list of all analysis files in the directory
32 my $ext = ""; # each extension before printed to QUICMINE.html
33 my $i = ""; # a counter
34 my $return = ""; # the value, if returned by failure to read config file (error)
35 my $count_file = ""; # read the ext out of the config file only on for the first file read
36 my $runinfo = ""; # what program was run and date
37 my $date = ""; # get date below
38
39
40
41
42
43
44 ##########################################################
45 # Start the main script not that all variables are set #
46 # You should need to modify anything below this #
47 ##########################################################
48 ##########################################################
49
50
51
52 ###########################################################
53 # Parse the command line and die if it doesn't look right #
54 ###########################################################
55
56 unless (@ARGV ==3) {
57 die "\n\nProper Command Line Usage: fasta_html.pl TAG glob path2output\nPlease try again.\n\n\n";}
58
59 my $tag = shift;
60 my $tag_file = $tag."_QM.html";
61 my $glob = shift;
62 my $path2output = shift;
63 my @input_files = ();
64
65 # To run the script on the QUICKMINE_sample.fasta file
66 chdir "$path2output";
67 my @tmp = <*$glob>;
68 for (@tmp)
69 {
70 if ($_ =~ /$tag/)
71 {
72 push (@input_files, $_);
73 }
74 }
75 @input_files = sort @input_files;
76
77 #################################################
78 # Get the Date #
79 #################################################
80
81 open(DATE, "date|");
82 $date = <DATE>;
83 close(DATE);
84
85 $runinfo = "QUICKMINE last run on $date";
86
87 #################################################
88 # LOOP over each file ... #
89 #################################################
90
91 # the commands file must be re-read for each file because it contains a $file
92 # variable that must be interpolated correctly each time - reading the
93 # config file only once results in no files being passed to the system
94 # commands
95
96 if (!@input_files) {
97 print "ERROR: couldn't find any input files - have you set \@input_files?\n";
98 die;
99 }
100
101 print "Will analyse the following files:\n";
102 for (@input_files) {
103 print "$_\n";
104 }
105
106
107
108 #################################################
109 # Print all the new files we made and exit ... #
110 #################################################
111
112 #-----------------------------------------------------------------------#
113 print "Now creating the $tag_file file...\n\n";
114
115 open (OUT, ">$tag_file") or die "can't open $tag_file: $!";
116
117 # print the start of the html page, start of the table and the header line
118 print OUT <<HTML_TABLE;
119
120 <html>
121 <head>
122 <title>Untitled Document</title>
123 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
124 <link rel="stylesheet" href="http://www.genomics.ceh.ac.uk/~dfield/QUICKMINE/quickmineoutput.css" type="text/css">
125 </head>
126
127 <body bgcolor="#FFFFFF" text="#000000">
128
129 <table width="80%" border="2" cellspacing="2" cellpadding="2" align="center">
130 <tr>
131 <td class="runinfo" colspan="3">QUICKMINE summary last updated on $date
132
133 </td>
134 </tr>
135 <tr>
136 <td class="header">File</td>
137 <td class="header">Description</td>
138 <td class="header">Analysis Files</td>
139 </tr>
140 HTML_TABLE
141
142
143 for $current_file (@input_files) {
144 my $linked_file = "<a href=\"$current_file\" class=\"A\" >$current_file</a>";
145 open (IN, "$current_file") or die "can't open $current_file: $!";
146 my ($header) = <IN>;
147 chomp($header);
148 close (IN);
149 @analysis_files = <$current_file*>;
150 foreach $current_ext (@analysis_files) {
151 $list .= "<a href=\"$current_ext\" class=\"A\">$current_ext</a> ";
152 }
153
154 # the links to the file and list of analysis files are made above
155 # added class = "A" to the href links
156
157
158 print OUT <<NEXT_ENTRY;
159 <tr>
160 <td>$linked_file</td>
161 <td class="analysisfilelinks">$header</td>
162 <td>$list</a></td>
163 </tr>
164 NEXT_ENTRY
165
166 $list = "";
167
168 }
169
170
171 # finish printing HTML page
172 print OUT <<END_TABLE_HTML;
173
174 </table>
175 </body>
176 </html>
177 END_TABLE_HTML
178
179
180 close (OUT);