RosettaCodeData/Task/Bioinformatics-base-count/Jq/bioinformatics-base-count-2.jq
2023-07-01 13:44:08 -04:00

15 lines
444 B
Text

def read_seq:
reduce inputs as $line (""; . + $line);
# Emit a bow of the letters in the input string
def counts:
. as $in | bow(range(0;length) | $in[.:.+1]);
def pp_counts:
"BASE COUNTS:",
(counts | to_entries | sort[] | " \(.key): \(.value | lpad(6;" "))"),
"Total: \(length|lpad(7;" "))" ;
def pp_sequence($cols):
range(0; length / $cols) as $i
| "\($i*$cols | lpad(5; " ")): " + .[ $i * $cols : ($i+1) * $cols] ;