This appears to do what you require:
#!/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. $!"; while ( <$in> ) { if ( /^>/ ) { # Identifier! # "\t" TAB character for "tabular format" s/[:\s|,;].*/\t/s; print $out $_; next; } s/\s//g; if ( !/\w/ || eof $in ) { # empty line or end of file print $out "$_\n\n"; } else { # Data print $out $_; } }
In reply to Re: Converting fasta (with multiple sequences) into tabular using perl
by jwkrahn
in thread Converting fasta (with multiple sequences) into tabular using perl
by rarenas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |