Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert rows into columns

I have a file in rows as below and would like to convert into two column format.

>00000_x1688514
TGCTTGGACTACATATGGTTGAGGGTTGTA
>00001_x238968
TGCTTGGACTACATATTGTTGAGGGTTGTA
...

Desired output is

>00000_x1688514 TGCTTGGACTACATATGGTTGAGGGTTGTA
>00001_x238968 TGCTTGGACTACATATTGTTGAGGGTTGTA
...

I would appreciate any help. Thanks.

like image 412
Supertech Avatar asked Jul 09 '12 21:07

Supertech


1 Answers

I don't know if you are aware of the BioPerl modules for reading/writing and other genetic functions. Your problem can be written like this.

#!/usr/bin/perl
use strict;
use warnings;
use Bio::SeqIO;

my $file = 'o33.txt';
my $in  = Bio::SeqIO->new( -file   =>  $file,
                           -format => 'fasta');

while ( my $seq = $in->next_seq() ) {
    print $seq->id, "\t", $seq->seq, "\n";
}

__END__
00000_x1688514  TGCTTGGACTACATATGGTTGAGGGTTGTA
00001_x238968   TGCTTGGACTACATATTGTTGAGGGTTGTA
like image 150
Chris Charley Avatar answered Sep 27 '22 20:09

Chris Charley