in reply to Hash making
You have quite a show-stopping issues.
Random application of my, part 1.
my $snp_chip_covered++;
makes no sense. my creates a variable. Why would you increment a variable you just created? You might as well just use
my $snp_chip_covered = 1;
since it's equivalent. Declare the variable outside the loop so that you have a continuously increasing variable instead of a new variable each loop pass that's always equal to 1.
Random application of my, part 2.
my $snp_covered{$mismatch}
makes no sense. $snp_covered{$mismatch} is not a variable. Remove the my. You simply want an assignment. You still need to declare the hash (%snp_covered), though, but you want to do it outside the loop. Again, you don't want a new hash for every pass of the loop.
Assign once
The hash assignment is outside of the loop, so how to you expect it to be executed multiple times?
Constant key.
You're always using $mismatch as the key, which is always 3. I think you meant to use $snp_chip_covered as the key.
Incorrect value.
You want to use 110000, 50000, ..., 1000 as the values, but you're currently using 1, 2, ..., 20. I don't know where the numbers you want are coming from. Maybe $current_line[something].
Fixed:
my $snp_chip_covered; my %snp_covered; while (<INPUT2>) { chomp; my @current_line = split /\t/; next if $current_line[5] != 1 || $current_line[14] < 3; $snp_covered{++$snp_chip_covered} = '?????'; }
That was just the necessities. There's one major improvement you can make, though.
Why are you using a hash if the keys are numerically ascending? That's an array!
Fixed:
my @snp_covered; while (<INPUT2>) { chomp; my @current_line = split /\t/; next if $current_line[5] != 1 || $current_line[14] < 3; push @snp_covered, '?????'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash making
by AnomalousMonk (Archbishop) on Sep 21, 2008 at 08:47 UTC | |
|
Re^2: Hash making
by sesemin (Beadle) on Sep 21, 2008 at 05:06 UTC | |
by ikegami (Patriarch) on Sep 21, 2008 at 05:07 UTC | |
|