I am still tring to successfully pass my data to a BioPerl module (as discussed here: Population of HoAoA based on file contents), but I now think that the problem that's making my program crash is the undef values in the data structure.

I've written some code to attempt to replace each undef with some fake data that flags a window as undef, but what I've written doesn't seem to be modifying the output. Perhaps someone can tell me how to fix this:

while (<$in_file>) { chomp; if (/^SAMPLE/) { my ( $placeholder, @coords ) = split /,/; foreach my $coord (@coords) { push @snp_bins, int( $coord / 100_000 ); } } else { my ( $id, @snps ) = split /,/; foreach my $snp (@snps) { # (@snps[0..$#snps-1] $snp =~ s/$snp/$snp,/ # put commas back in (preserve cs +v format) } foreach my $index ( 0 .. $#snp_bins ) { if ( $snps[$index] ) { push( @{ $data{$id}[ $snp_bins[$index] ] }, $snps[$index] +); # see note [1] } else { # replace 'undef' elements with f +lag data my @ones_array; foreach ( 1 .. 100) { push @ones_array, "1 1,"; } push( @{ $data{$id}[ $snp_bins[$index] ] }, @ones_arra +y ) } } } }

I am assuming that the problem lies with the line

if ( $snps[$index] )

Is this the case, and if so how can I fix it (I have examined my structure using Data::Printer, and all the 'undef's are still there)?

Input file sample (the file actually has hundreds of thousands of columns and hundreds of rows (obviously not shown)):

SAMPLE,16287215,16287226,16287365,16287649,16287784,16287851,16287912 HG00553,0 0,0 0,0 0,0 0,0 0,0 0,0 0 HG00554,0 0,0 0,0 0,0 0,0 0,0 0,0 0 HG00637,0 0,0 0,0 0,0 0,0 0,0 0,0 0 HG00638,0 0,0 0,0 0,0 0,0 0,1 1,0 0 HG00640,0 0,0 0,0 0,0 0,0 0,1 1,0 0

Sample of HoAoA contents (HG00553 is the first individual, then we have a series of 100kb windows, the first 162 of which are undef, then the 163rd window has 7 entries, etc. There are many more individuals later in the input file. You can see from my code above that I'm trying to replace each undef with 100 '1 1,' entries, which would flag these windows as undef but (hopefully) allow the program to successfully pass the data to the module):

{ HG00553 [ [0] undef, [1] undef, <<< SNIP>>> [159] undef, [160] undef, [161] undef, [162] [ [0] "0 0,", [1] "0 0,", [2] "0 0,", [3] "0 0,", [4] "0 0,", [5] "0 0,", [6] "0 0," ], [163] undef, [164] [ [0] "0 0," ], [165] undef, [166] undef, [167] undef, [168] undef, [169] undef, [170] [ [0] "0 0,", [1] "0 0,", [2] "0 0,", [3] "0 0,", [4] "0 0,", [5] "1 1,", [6] "0 0,", [7] "0 0,", [8] "1 1,", [9] "0 0,", [10] "0 0,", [11] "0 0,", [12] "0 0," ], [171] undef, [172] [ [0] "0 0,", [1] "0 0,", [2] "0 0,", [3] "0 0,", [4] "0 0,", [5] "0 0,", [6] "0 0,", [7] "0 0,", [8] "0 0,", [9] "0 0,", [10] "0 0,", [11] "0 0,", [12] "0 0," ], [173] undef, [174] [ [0] "0 0,", [1] "0 0,", [2] "0 0,", [3] "0 0,", [4] "0 0,", [5] "0 0,", [6] "0 0,", [7] "0 0,", [8] "0 0,", [9] "0 0,", [10] "0 0,", [11] "0 0,", [12] "0 0,", [13] "1 1,", [14] "0 0,", [15] "0 0,", [16] "0 0,", [17] "0 0,", [18] "0 0,", [19] "0 0,", [20] "0 0,", [21] "0 0,", [22] "0 0,", [23] "0 0,", [24] "0 0,", [25] "0 0,", [26] "0 0,", [27] "0 0,", [28] "0 0,", [29] "0 0,", [30] "0 0,", [31] "0 0,", [32] "0 0,", [33] "0 0,", [34] "0 0,", [35] "0 0,", [36] "0 0,", [37] "0 0,", [38] "0 0,", [39] "0 0,", [40] "0 0,", [41] "0 0,", [42] "0 0,", [43] "0 1,", [44] "0 1,", [45] "0 0,", [46] "0 0,", [47] "0 0,", [48] "0 0,", [49] "0 0,", [50] "0 0,", [51] "0 0,", [52] "0 0,", [53] "0 0,", [54] "0 0," ], [175] [ [0] "1 0,", <<< SNIP >>>

In reply to Trying to edit HoAoA entries by iangibson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.