in reply to Re: how to split the elements in an array of arrays ?
in thread how to split the elements in an array of arrays ?

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re^3: how to split the elements in an array of arrays ?
by Fletch (Bishop) on Oct 31, 2006 at 19:05 UTC

    Huzzah, the crufty re-implementation of Bio::SeqIO continues unabashed by suggestions to the contrary and pointers to its documentation.

    Addendum: That perhaps sounds a bit cruel, but if you don't understand enough Perl to know how to split scalars into characters you really shouldn't be trying to re-invent wheels that other people have already solved. Use the off-the-shelf widgets for the parts you can, and get fancy once you know what you're doing. Something like Beginning Perl for Bioinformatics that's aimed at biology-types specifically should help you get going.

Re^3: how to split the elements in an array of arrays ?
by ptum (Priest) on Oct 31, 2006 at 18:54 UTC

    Perhaps I am not understanding you correctly, but this seems to be a very different question than the one you asked first. In the example you gave, what happens to the values in $entry, $title, $org or $acc? You seem to drop them on the floor ...

    To solve this kind of a problem, I would probably establish a hash of array references, something like this (untested):

    use strict; my %filecontents = ('entries' => [], 'titles' => [], 'organisms' => [], 'accessions' => [], 'unknown' => [] ); my $filehandle; unless (open($filehandle,"<file.txt")) { die "Cannot open file.txt: $!"; } while (<$filehandle>) { chomp; if (/^ENTRY/) { push @{$filecontents{'entries'}}, $_; } elsif (/^TITLE/) { push @{$filecontents{'titles'}}, $_; } # and so on ... }

    Update: Notice, by the way, that I check for success in opening the filehandle, always a good thing to do.

    Update 2: Arrghh! I was duped! I didn't realize you'd asked this question before. Why not pay attention to the answers you've already received, as Fletch points out below?