Hi everyone I am working on a fasta file. I want to format it to a hash(SeqID as the key and Sequence as the value). I write a script, but somewhere is wrong. Could you please indicate for me? Thank you very much!
#!/bin/perl
use strict;
use warnings;
open IN, $ARGV[0];
while (<>){
$_ =~ s/[\r\n]/\t/g; ##replace all newlines with tabs
my @a;
my %h;
@a = split (/\t/, $_); ##change to array
my $i; ##change array to hash
for ($i=0, $i<=$#a/2, $i++){
my $id = shift @a;
my $seq = shift @a;
$h{$id} = $seq;
}
}
close IN;
Really helpful again! Thanks!