56aff44eacee07bc3679dd18fe70ad621f6142d5 hiram Mon Sep 1 23:45:50 2025 -0700 allow stdin as argument to asciiTree and updated perl issues for binaryTree diff --git src/hg/utils/phyloTrees/asciiTree.pl src/hg/utils/phyloTrees/asciiTree.pl index 94ae937e496..c1c63a35fa0 100755 --- src/hg/utils/phyloTrees/asciiTree.pl +++ src/hg/utils/phyloTrees/asciiTree.pl @@ -34,35 +34,41 @@ $answer =~ s/0+$//; } else { $answer = $string; } return $answer; } if ($argc != 1) { usage; } my $file = shift; my $nhString = ""; -open (FH, "<$file") or die "can not read $file"; -while (my $line = <FH>) { +my $fh; + +if ($file eq "stdin") { + open ($fh, "<" , "/dev/stdin") or die "can not read /dev/stdin"; +} else { + open ($fh, "<" , "$file") or die "can not read $file"; +} +while (my $line = <$fh>) { $nhString .= $line; } -close (FH); +close ($fh); $nhString =~ s/\s//g; my @species = split(',', $nhString); my $indent = 0; for (my $i = 0; $i < scalar(@species)-1; ++$i) { for (my $j = 0; $j < $indent; ++$j) { print " "; } my $thisLine = $species[$i]; my $j = 0; if (substr($thisLine,$j++,1) ne "(") { $indent -= 1; } else { while (substr($thisLine,$j++,1) eq "(") { ++$indent;