in reply to Splitting a multi-sequence fasta file into individual sequences in individual arrays

Why do you want an AOAs? Each sequence is a header + a single, wrapped sequence. Wouldn't a hash be more useful?

#! perl -slw use strict; use Data::Dump qw[ pp ]; my %seqs; { local $/ = ">"; my @seqs = <DATA>; chomp @seqs; s[\n][\t] for @seqs; tr[\n][]d for @seqs; shift @seqs; %seqs = map split( "\t" ), @seqs; } pp \%seqs; __DATA__ >sequence header 1. AAATATTATATATATTGCG ATTATTATATGCGCGGCGC >sequence header 2 AATTGGGCTCGCTGCTTTT AGGAGGAGGAGCCCTCTCC >sequence header 3 AATTGGCTGCTCGCTGCTC AATGTGTCGGCGCGCGTGC

Prints

[ 4:34:55.96] c:\test>junk40 { "sequence header 1." => "AAATATTATATATATTGCGATTATTATATGCGCGGCGC", "sequence header 2" => "AATTGGGCTCGCTGCTTTTAGGAGGAGGAGCCCTCTCC", "sequence header 3" => "AATTGGCTGCTCGCTGCTCAATGTGTCGGCGCGCGTGC", }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Splitting a multi-sequence fasta file into individual sequences in individual arrays
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Splitting a multi-sequence fasta file into individual sequences in individual arrays
by krish28 (Acolyte) on Feb 09, 2011 at 15:15 UTC
    Thanks for your reply, BrowserUk... I got the code working by using just the hash
    Have a good one
    Krishna.

      If you consult the FASTA format spec, all the lines in between headers will be the same length (except the last) and that count has no more significance than it is an arbitrary wrap point. All the lines between two header constitute as single sequence, not a set of sequences.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.