JPRED-2 Initial commit of software for the Jpred website (some files excluded due...
[jpred.git] / websoft / bin / create_readme
1 #!/usr/bin/perl
2
3 # Script to create README file, run in the directory with the results in it.
4 # Outputs to STDOUT by default, change with --out option or redirect.
5 # If you're using an alignment give the --format msf option
6
7 use strict;
8 use warnings;
9 use Getopt::Long;
10
11 my ($out, $format);
12 GetOptions(
13    "o|out=s" => \$out,
14 );
15
16 $out = '-' unless $out;
17
18 ## create look-up table of descriptions for files created by Jpred
19 my %file = (
20    'LOG'               => "The log file of the prediction\n",
21    'README'            => "This file\n",
22    '.align'            => "PSIBLAST alignment with gaps and redundancy removed in FASTA format\n",
23    '.align.msf'        => "Your alignment in MSF format\n",
24    '.als'              => "Alscript command file. Used to generate PS/PDF output",
25    '.blast.gz'         => "PSIBLAST output (compressed)\n",
26    '.coils.csv'        => "The output from coils in CSV format\n",
27    '.coilseq.lupas_14' => "The output from coils using a window length of 14\n",
28    '.coilseq.lupas_21' => "The output from coils using a window length of 21\n",
29    '.coilseq.lupas_28' => "The output from coils using a window length of 28\n",
30    '.concise'          => "The prediction in pseudo-CSV format, including the coiled-coil prediction, solvent accessiblity and the sequence alignment\n",
31    '.concise.blc'      => "A BLC file of the prediction and alignment\n",
32    '.concise.pdf'      => "A PDF file of the prediction and alignment\n",
33    '.concise.ps'       => "A PostScript file of the prediction and alignment\n",
34    '.fasta'            => "Input query sequence in FASTA format\n",
35    '.hmm'              => "The HHMer2 profile of the alignment\n",
36    '.html'             => "A HTML file of the prediction and alignment\n",
37    '.input'            => "Your raw input\n",
38    '.jalview'          => "A Jalview annotation file to be read in with the .align file to view the predictions in Jalview\n",
39    '.jnet'             => "The output from Jnet\n",
40    '.profile'          => "PSIBLAST profile\n",
41    '.pssm'             => "PSIBLAST PSSM in a format for Jnet\n",
42    '.seq'              => "Your sequence\n",
43    '.simple.html'      => "The brief HTML output of the query sequence and prediction only\n",
44    '.tar.gz'           => "An archive of all the files in the directory\n",
45 );
46
47 ## open the current directory
48 opendir DIR, $ENV{'PWD'} or die "$ENV{PWD}: $!\n";
49
50 ## find the longest filename in order to correctly format the file
51 my $len = 0;
52 foreach (readdir DIR) { $len = length if length > $len; }
53 rewinddir DIR;
54 $len = "%-".($len + 5)."s%s";  # filename format for printing is max. length + 5 chars
55
56 ## Open output and write formatted filenames with their descriptions
57 open FILE, ">$out" or die "$out: $!\n";
58 printf FILE $len, "Filename", "Description\n";
59 printf FILE $len, "--------", "-----------\n";
60
61 foreach my $file (sort readdir DIR) {
62    # determine the extension for each file
63    my ($extn) = ($file =~ /[^.]*(.*)$/);
64    
65    # remove unwanted files - Alignment in CSV format (can be found in the .concise file)
66    # and the SGE job files
67    unlink $file if ($extn eq '.align.csv');
68    unlink $file if ($extn =~ /\.[eo]\d{6}$/);
69
70    # output the formatted filename along with its description if it has a known extension
71    printf FILE $len, $file, $file{$extn} if $file{$extn};
72 }
73 close(FILE);
74 exit;
75