#!/usr/bin/perl # fasta_to_tbl.pl use strict; use warnings; die "Please specify suitable file\n" if (@ARGV != 1); my ($fasta) = @ARGV; my $outfile = "$fasta.tbl"; open(my $in, "<", "$fasta") or die "error reading $fasta. $!"; open(my $out, ">", "$outfile") or die "error creating $outfile. $!"; my $identifier = ""; my $union = ""; while (<$in>) { chomp; next unless m/\w/; if ($_ =~ m/>/) { # Identifier! $_ =~ s/>//; ($identifier) = split /\:|\s|\||,|;/, $_; print "$identifier\n"; } else { # We have a line with sequence $union = $union . $_; } } print $out "$identifier\t$union\n"; close($in); close($out);