1386b5f91d8d635cd76b984482e460dd05464237 hiram Tue May 17 17:06:35 2022 -0700 correctly sorting bed file output no redmine diff --git src/hg/utils/automation/aliasTextToBed.pl src/hg/utils/automation/aliasTextToBed.pl index f7fc41e..f7e7df7 100755 --- src/hg/utils/automation/aliasTextToBed.pl +++ src/hg/utils/automation/aliasTextToBed.pl @@ -87,31 +87,31 @@ printf AS " uint chromStart;\t\"always 0\"\n"; printf AS " uint chromEnd;\t\"chromosome size\"\n"; foreach my $title (@legendNames) { if (length($indexNames)) { $indexNames .= "," . $title; } else { $indexNames = $title; } printf AS " string %s;\t\"%s name\"\n", $title, $nameLabels{$title}; } printf AS " )\n"; close (AS); printf STDERR "# indexNames: '%s'\n", $indexNames; -open (BD, ">$opt_aliasBed") or die "can not write to $opt_aliasBed"; +open (BD, "|sort -k1,1 -k2,2n>$opt_aliasBed") or die "can not write to $opt_aliasBed"; while (my $line = <FH>) { chomp $line; my @a = split('\t', $line, -1); # the -1 keeps all empty fields too if (scalar(@a) != $expectFieldCount) { printf STDERR "ERROR: expected field count %d =! %d on line %d\n", $expectFieldCount, scalar(@a), $.; exit 255; } my $nameIndex = 0; printf BD "%s\t0\t%d", $a[$nameIndex], $chromSizes{$a[$nameIndex]}; foreach my $name (@a) { printf BD "\t%s", $a[$nameIndex++]; } printf BD "\n"; }