Hi iangibson

The arrays @markers and @samples are empty that is why you are getting the error. If you run the following code where file1.csv is input file and testGENO as the output file the you won't get any error

#!/usr/bin/perl use strict; use warnings; use Bio::PopGen::IO; use Bio::PopGen::Statistics; use Data::Dumper; open my $input, "file1.csv" or die $!; open my $out_file, ">", "testGENO" or die "Can't open output file: $!\ +n"; my $io = new Bio::PopGen::IO( -format => 'csv', -file => "file1.csv" ); my @markers; my @samples; while ( my $ind = $io->next_individual ) { print $ind,"\n"; # my %hash = %$ind; print Dumper($ind); if ( $ind =~ /^SAMPLE/ ) { push @markers, $ind; } else { push @samples, [$ind]; } }

$ind is a reference variable to the hash and it is not a list of scalar variable therefore the if and else loop wont work and hence @markers and samples are empty set. I use Data Dumper to check the contents of the referenced hash variable $ind. And then when you use the methods in the module

my $segsites = Bio::PopGen::Statistics->segregating_sites_count( \@sam +ples );

you get an error and the reason is because @samples is empty and then you are referencing to an empty array. You first need to dereference the hash variable, extract the content you are interested in, then push it into the array and then use methods you are interested in.

I hope it is of some help to you.


In reply to Re^2: Errors when using module by snape
in thread Errors when using module 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.