in reply to Re^3: Human genome array
in thread Human genome array

Fair enough. Here's my main code so far:
while (<FILE1>) { if ($_ =~ />/) #Header { if ($chr_num > 0) { my @str = split(undef,$temp_str); push (@genome,@str); } $chr_num++; print $chr_num . "\n"; $temp_str = ""; } else { my $temp = chomp($_); $temp_str = $temp_str . $temp; } }
I think that I have a problem of line endings or input formatting because I have warnings for unitialized values in: my @str = split(undef,$temp_str)

Replies are listed 'Best First'.
Re^5: Human genome array
by toolic (Bishop) on Jul 19, 2011 at 17:44 UTC
    To get rid of the Use of uninitialized value in regexp compilation warning message, I think you want to use:
    my @str = split //, $temp_str;
    This will split a string into individual characters.
Re^5: Human genome array
by AR (Friar) on Jul 19, 2011 at 19:34 UTC

    That's better, but it would be even better if posted code that was self contained. Also, as many will mention, always use strict; and use warnings; unless you have a specific reason you're not. I know you're using them, but you should show us you're using them.

    The main problem I'm seeing in your script is that you're pushing a list into an array. Your description implies you want a matrix. In order to do that, you'll have to push an array reference into your @genome array:

    push (@genome,\@str);

    Perl only stores scalars in arrays and hash values, so, in order to create a multi-level datastructure, you need fill the array with a reference to the array.

    A minor thing is that you'll probably miss your last chromosome because of how you're parsing the file. After you hit the end of the file, and there isn't a dangling header, you'll still have a lot of data in $temp_str that doesn't make it into @genome.

    Edit: also, as toolic says, you should change you split line to:

    my @str = split //, $temp_str;
Re^5: Human genome array
by Not_a_Number (Prior) on Jul 19, 2011 at 18:59 UTC

    Hi, uvnew!

    Perhaps you could elucidate why the answers to your previous post (from 8 months ago) Bioinformatic task failed to solve your problem?

    Meanwhile, I suggest that you consult the documentation for split.

    hth, dave