JPRED-2 Initial commit of software for the Jpred website (some files excluded due...
[jpred.git] / websoft / bin / concise2fasta
diff --git a/websoft/bin/concise2fasta b/websoft/bin/concise2fasta
new file mode 100755 (executable)
index 0000000..4f5b5a8
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+
+# Converts concise file into fasta format
+# also puts in the consensus.
+
+use strict;
+use warnings;
+
+my ( @seqs, %seq, @pred, %pred );
+
+my @var = (
+  "Lupas_21",  "Lupas_14", "Lupas_28", "JNETPSSM",  "MULTCOIL", "MULTCOIL_TRIMER", "MULTCOIL_DIMER", "JNETFREQ",
+  "JNETALIGN", "JNETHMM",  "JNETSOL5", "JNETSOL25", "JNETSOL0", "jnetpred",        "jpred",          "JNETCONF"
+);
+
+if   ( $ARGV[0] ) { open( IN, "<$ARGV[0]" ) or die($!); }
+else              { open( IN, "<-" )        or die($!); }
+
+while (<IN>) {
+  if (/^\n/) { next; }
+  my ( $id, $seq ) = split( ":", $_ );
+  if ( !$id || !$seq ) { next; }    # Check we have proper values
+  $seq =~ s/,//g;
+  chomp($seq);
+  if ( $id =~ /;/ ) {               # Then it's an alignment
+    @_ = split( ";", $id );
+    push @seqs, $_[1];
+    $seq{ $_[1] } = $seq;
+  }
+  foreach (@var) {
+    if ( $_ eq $id ) {
+      push @pred, $_;
+      $pred{$_} = $seq;
+    }
+  }
+}
+close(IN);
+
+foreach (@seqs) {
+  $seq{$_} =~ s/(.{72})/$1\n/g;
+  print ">$_\n$seq{$_}\n";
+}
+
+foreach (@pred) {
+  $pred{$_} =~ s/[TCYWXZSI\?_]/-/g;
+  $pred{$_} =~ s/B/E/g;
+  $pred{$_} =~ s/G/H/g;
+
+  if (/SOL/) { $pred{$_} =~ s/E/B/g; }
+  $pred{$_} =~ s/(.{72})/$1\n/g;
+  print ">$_\n$pred{$_}\n";
+}