JPRED-2 Initial commit of software for the Jpred website (some files excluded due...
[jpred.git] / websoft / bin / concise2jalview.pl
1 #! /usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use lib '/homes/www-jpred/new_site/jpred_new/lib';
7
8 use Concise;
9 use Concise::File;
10
11 use Getopt::Long;
12 use Pod::Usage;
13
14 my $file;
15 my $out;
16 my $help;
17 my $man;
18
19 GetOptions (
20    'file=s'    => \$file,
21    'out=s'     => \$out,
22    'help|?'    => \$help,
23    'man'       => \$man
24 ) or pod2usage(0);
25
26 pod2usage(-verbose => 1) if $help;
27 pod2usage(-verbose => 2) if $man;
28 pod2usage(-msg => 'Please give a concise file to read', -verbose => 0) if (!$file);
29
30 ## Hash of description lines for concise data types
31 my %desc = (
32    jnetpred    => 'Final secondary structure prediction by Jnet',
33    JNETHMM     => 'Jnet prediction using HMMer profiles',
34    JNETPSSM    => 'Jnet prediction using PSSM profiles',
35    JNETJURY    => 'Positions where Jnet predictions do not agree',
36    JNETSOL0    => 'Jnet solvent relative accessibility prediction at 0% cut-off',
37    JNETSOL5    => 'Jnet solvent relative accessibility prediction at 5% cut-off',
38    JNETSOL25   => 'Jnet solvent relative accessibility prediction at 25% cut-off',
39    JNETCONF    => 'Confidence of Jnet prediction 0 (low) -> 9 (high)',
40    Lupas_14     => 'Coiled-coil prediction windowed over 14 residues',
41    Lupas_21     => 'Coiled-coil prediction windowed over 21 residues',
42    Lupas_28     => 'Coiled-coil prediction windowed over 28 residues',
43 );
44
45 ## If an output file is given open it and select it as the default output
46 my $FH;
47 if ($out) {
48    open($FH, ">$out") or die "ERROR - unable to open '$out' for writing: $!\nDied";
49    select($FH);
50 }
51
52 ## Create a Concise::File object and fill it with the contents of the input file
53 my $concise = Concise::File->new(read_file => $file);
54
55 ## Write the Jalview Annotation file to the default output
56 print "JALVIEW_ANNOTATION\n";
57 print "# Created by concise2jalview using '$file' as input\n\n";
58 for my $data ($concise->get_entries) {
59    my $string = join("|", $data->seq);
60    if ($data->id =~ /prop|align/i) {       # skip sequence alignments and PROPH|C|E fields
61       next;
62    } elsif ($data->id =~ /jnetconf/i) {    # treat Jnet confidence as a bar graph as contains real numbers
63       print "BAR_GRAPH\t", $data->id,"\t",$desc{$data->id}, "\t$string\n";
64       next;
65    } elsif ($data->id =~ /jnet(pred|hmm|align|pssm)/i) {  # strip out '-' chars from prediction fields as unrequired by Jalview 
66       $string =~ s/-//g;
67    }
68    # By default don't treat fields as graphable data and add a description line
69    print "NO_GRAPH\t",$data->id,"\t",$desc{$data->id}, "\t$string\n";
70 }
71 exit;
72
73 =head1 NAME
74
75 concise2jalview -- covert Jnet concise files to Jalview annotation files
76
77 =head1 SYNOPSIS
78
79 concise2jalview --file <concise file> [--help] [--man] > <output file>
80
81 =head1 DESCRIPTION
82
83 This script takes a Jnet concise file as input and returns a Jalview annotation file as output. This allows Jalview to better view Jnet/Jpred prediction complete with descriptions of the various predictions.
84
85 All data types are included in the Jalview file except for 'JNETPROP*' and any sequence alignments.
86
87 =head1 OPTIONS
88
89 =over 4
90
91 =item B<--file> <concise file>
92
93 Give the path and name to the Jnet concise file.
94
95 =item B<--help>
96
97 Displays brief help.
98
99 =item B<--man>
100
101 Displays the full manpage.
102
103 =back
104
105 =head1 AUTHOR
106
107 Chris Cole <christian@cole.name>
108
109 =cut