JPRED-2 Initial commit of software for the Jpred website (some files excluded due...
[jpred.git] / websoft / bin / degap
diff --git a/websoft/bin/degap b/websoft/bin/degap
new file mode 100755 (executable)
index 0000000..1ca621d
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+#
+# Removes insertions (represented by "-" or ".") from FASTA files
+#
+
+use strict;
+use warnings;
+
+if ($ARGV[0]) { open(FILE, "<$ARGV[0]") or die($!); }
+else { open(FILE, "<-") or die($!); }
+
+my $seq;
+
+while (<FILE>) {
+       if (! /^>/) {
+               s/-|\.|\n//g;
+               $seq .= $_;
+               }
+       else {          # If there's a sequence print it
+               if ($seq) { $seq =~ s/(.{72})/$1\n/g; print "$seq\n"; }
+               print $_;       # Then the title
+               $seq = "";
+               }
+       }
+if ($seq) { $seq =~ s/(.{72})/$1\n/g; print "$seq\n"; }