adur has asked for the wisdom of the Perl Monks concerning the following question:
I want to find gene names in a bed file with multiple assigned ensembl ids, and regular gene names with multiple ensembl ids. For easier reading, x with multiple z, and y with multiple z. I want to push those values into the respective arrays. These are the variables:
my %bedgenenames; my @bedrepeats; my %realgenenames; my @haplotyperegionrepeats;
When I try this, I get the correct outputs for the first statement and incorrect outputs for the second.
chomp($entry); my @array = grep {$_} split /[\t ]/, $entry; unless(exists($bedgenenames{"$array[3]"})){ $bedgenenames{"$array[3]"}="$array[6]"; }elsif("$bedgenenames{$array[3]}" ne "array[6]"){ push @bedrepeats, "$array[3]"; print "$array[3] for $bedgenenames{$array[3]} and $array[6] bed\n" +; } unless(exists($realgenenames{"$array[8]"})){ $realgenenames{"$array[8]"}="$array[6]"; }elsif("$realgenenames{$array[8]}" ne "array[6]"){ push @haplotyperegionrepeats, "$array[8]"; print "$array[8] for $realgenenames{$array[8]} and $array[6] haplo +type\n"; }
This is the output for the first(correct, where the two ensembl ids are different) and second(incorrect, where the two ensembl ids are the same):
How can I solve this?WASH5P14829 for ENSG00000223972 and ENSG00000227232 bed WASH7P for ENSG00000227232 and ENSG00000227232 haplotype
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I solve this hash issue?
by talexb (Chancellor) on Jun 16, 2016 at 20:30 UTC | |
|
Re: How can I solve this hash issue?
by GotToBTru (Prior) on Jun 16, 2016 at 20:17 UTC | |
by choroba (Cardinal) on Jun 16, 2016 at 20:30 UTC | |
by adur (Initiate) on Jun 16, 2016 at 21:47 UTC | |
by adur (Initiate) on Jun 16, 2016 at 20:40 UTC |