Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Converting fasta (with multiple sequences) into tabular using perl

by jwkrahn (Abbot)
on Dec 12, 2017 at 20:23 UTC ( [id://1205369]=note: print w/replies, xml ) Need Help??


in reply to Converting fasta (with multiple sequences) into tabular using perl

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 $_; } }
  • Comment on Re: Converting fasta (with multiple sequences) into tabular using perl
  • Download Code

Replies are listed 'Best First'.
Re^2: Converting fasta (with multiple sequences) into tabular using perl
by rarenas (Acolyte) on Dec 14, 2017 at 10:45 UTC

    Thank you! This is helpful!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1205369]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found