imtakinbioinformatic has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I'm trying to work on code that reads an input file that has lines that start with > then lines of characters (repeated many times). I want to put the line that starts with > into one array, and then put all of the lines following the >line into a separate array as one element (until the next > comes.) So I want to end up with one array that has all of those > lines as elements, and then another array that has all of the text behind each of those > lines as separate elements. My code is working for the > lines how I want, but I seem to just be filling the second array with the text that followed that first >. I feel like this is confusing, but any help would be greatly appreciated!
foreach $line(@DNA){ if ($line=~/^>(\S+)/){ $seqID=$1; push(@seqList, $seqID); push (@sequences,$dnaString); } else{ chomp $line; $dnaString=$dnaString .$line;} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating 2 arrays from a larger array
by tangent (Parson) on Mar 08, 2012 at 02:43 UTC | |
by imtakinbioinformatic (Initiate) on Mar 08, 2012 at 03:18 UTC | |
by tangent (Parson) on Mar 08, 2012 at 03:32 UTC | |
by imtakinbioinformatic (Initiate) on Mar 08, 2012 at 04:08 UTC | |
by NetWallah (Canon) on Mar 08, 2012 at 06:15 UTC | |
by tangent (Parson) on Mar 08, 2012 at 13:54 UTC | |
by imtakinbioinformatic (Initiate) on Mar 08, 2012 at 14:59 UTC | |
by imtakinbioinformatic (Initiate) on Mar 08, 2012 at 14:52 UTC | |
|
Re: Creating 2 arrays from a larger array
by Anonymous Monk on Mar 08, 2012 at 02:40 UTC |