JPRED-2 Initial commit of software for the Jpred website (some files excluded due...
[jpred.git] / websoft / bin / degap
1 #!/usr/bin/perl
2
3 #
4 # Removes insertions (represented by "-" or ".") from FASTA files
5 #
6
7 use strict;
8 use warnings;
9
10 if ($ARGV[0]) { open(FILE, "<$ARGV[0]") or die($!); }
11 else { open(FILE, "<-") or die($!); }
12
13 my $seq;
14
15 while (<FILE>) {
16         if (! /^>/) {
17                 s/-|\.|\n//g;
18                 $seq .= $_;
19                 }
20         else {          # If there's a sequence print it
21                 if ($seq) { $seq =~ s/(.{72})/$1\n/g; print "$seq\n"; }
22                 print $_;       # Then the title
23                 $seq = "";
24                 }
25         }
26 if ($seq) { $seq =~ s/(.{72})/$1\n/g; print "$seq\n"; }