Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I actually found the answer to this. The code looks a bit complicated though.</p> <pre><code>#!/usr/bin/env perl use strict; use warnings; sub main { my $file; if (@ARGV != 1) { die "Usage: perl hashofhash_sort.pl &lt;filename&gt;\n"; } else { $file = $ARGV[0]; } open(IN, $file) or die "Error!! Cannot open the $file file: $!\n"; my @file = &lt;IN&gt;; chomp @file; my ($entrez_gene, $loci, $chr, $band, $pq, $band_num); my (%chromosome, %loci_entrez); foreach my $line (@file) { if ($line =~ /(\d+),(.+)/) { # Entrez genes $entrez_gene = $1; # Locus like 12p23.4 $loci = $2; if ($loci =~ /^(\d+)(.+)?/) { # chromosome number alone (only numericals) $chr = $1; if ($2) { # locus minus chromosome number. If 12p23.4, then $band is p23.4 $band = "$2"; if ($band =~ /^([pq])(.+)/) { # either p or q $pq = $1; # stores the numericals. for p23.4, stores 23.4 $band_num = $2; } if (exists $chromosome{$chr}) { if (exists $chromosome{$chr}{$pq}) { push (@{$chromosome{$chr}{$pq}}, $band_num); } else { $chromosome{$chr}{$pq} = [$band_num]; } } else { $chromosome{$chr}{$pq} = [$band_num]; } } } } } # End of foreach loop foreach my $key (sort {$a &lt;=&gt; $b} keys %chromosome) { my %seen = (); foreach my $key2 (sort {$a cmp $b } keys %{$chromosome{$key}}) { my @unique = grep { ! $seen{$_}++ } @{$chromosome{$key}{$key2}}; my @sorted = sort @unique; foreach my $element (@sorted) { my $sorted_locus = "$key$key2$element"; if (exists $loci_entrez{$sorted_locus}) { foreach my $element2 (@{$loci_entrez{$sorted_locus}}) { print "$element2,$sorted_locus\n"; } } } } } } # End of main main(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload