[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Change colums and rows.



* F Zimmermann (fzimmerm@pugh.bip.bham.ac.uk) spake thusly:
> hello a have a little problem. I scanned a DNA sequence and the OCR
> software changed colums and rows. So instead of
> aaaaaaaaaa bbbbbbbbbb cccccccccc
> aaaaaaaaaa bbbbbbbbbb cccccccccc
> 
> I got this
> 
> aaaaaaaaaa aaaaaaaaaa
> bbbbbbbbbb bbbbbbbbbb
> cccccccccc cccccccccc
> 
> How can I change them back into the right order?

Off the top of my head:

#!/usr/bin/perl -w
my @row1;
my @row2;
my $line;
my @words;
my $i;
while( $line = <> )
{
    chomp $line;
    @words = split /\s+/, $line;
    push @row1, $words[0];
    push @row2, $words[1];
}
for( $i = 0; $i <= $#row1; $++ ) 
{
    print "$row1[$i] ";
}
print "\n";
for( $i = 0; $i <= $#row2; $++ ) 
{
    print "$row2[$i] ";
}
print "\n";

Use at own risk.
hth
Dima
-- 
E-mail dmaziuk at bmrb dot wisc dot edu (@work) or at crosswinds dot net (@home)
http://www.bmrb.wisc.edu/descript/gpgkey.dmaziuk.ascii -- GnuPG 1.0.4 public key
Well, lusers are technically human.                             -- Red Drag Diva



Reply to: