tabtofasta.pl

10/12/2014 14:17

Ce script perl convertit un fichier tabulé en fichier fasta à condition que la première colonne contienne les identifiants et la deuxième colonne la séquence.

 

#!/usr/bin/perl
#a script pretty much ripped off from the Bioperl web page SeqIO HOWTO suggestions:
#https://bioperl.open-bio.org/wiki/HOWTO:SeqIO
use strict;
use warnings;
use Bio::SeqIO;

my $format1 = "tab";
my $format2 = "Fasta";
my $file = shift || die "Usage: tabtofasta.pl <filename>\n";
open (FILEIN, "$file");

    my $in  = Bio::SeqIO->newFh(-format => $format1, -fh => \*FILEIN );
    my $out = Bio::SeqIO->newFh(-format => $format2 );
    print $out $_ while <$in>;

close FILEIN;