JPRED-2 Initial commit of software for the Jpred website (some files excluded due...
[jpred.git] / websoft / bin / concise2fasta
1 #!/usr/bin/perl
2
3 # Converts concise file into fasta format
4 # also puts in the consensus.
5
6 use strict;
7 use warnings;
8
9 my ( @seqs, %seq, @pred, %pred );
10
11 my @var = (
12   "Lupas_21",  "Lupas_14", "Lupas_28", "JNETPSSM",  "MULTCOIL", "MULTCOIL_TRIMER", "MULTCOIL_DIMER", "JNETFREQ",
13   "JNETALIGN", "JNETHMM",  "JNETSOL5", "JNETSOL25", "JNETSOL0", "jnetpred",        "jpred",          "JNETCONF"
14 );
15
16 if   ( $ARGV[0] ) { open( IN, "<$ARGV[0]" ) or die($!); }
17 else              { open( IN, "<-" )        or die($!); }
18
19 while (<IN>) {
20   if (/^\n/) { next; }
21   my ( $id, $seq ) = split( ":", $_ );
22   if ( !$id || !$seq ) { next; }    # Check we have proper values
23   $seq =~ s/,//g;
24   chomp($seq);
25   if ( $id =~ /;/ ) {               # Then it's an alignment
26     @_ = split( ";", $id );
27     push @seqs, $_[1];
28     $seq{ $_[1] } = $seq;
29   }
30   foreach (@var) {
31     if ( $_ eq $id ) {
32       push @pred, $_;
33       $pred{$_} = $seq;
34     }
35   }
36 }
37 close(IN);
38
39 foreach (@seqs) {
40   $seq{$_} =~ s/(.{72})/$1\n/g;
41   print ">$_\n$seq{$_}\n";
42 }
43
44 foreach (@pred) {
45   $pred{$_} =~ s/[TCYWXZSI\?_]/-/g;
46   $pred{$_} =~ s/B/E/g;
47   $pred{$_} =~ s/G/H/g;
48
49   if (/SOL/) { $pred{$_} =~ s/E/B/g; }
50   $pred{$_} =~ s/(.{72})/$1\n/g;
51   print ">$_\n$pred{$_}\n";
52 }