james.v has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I am trying to alter this script:
perl -lne '/>/ && do {print $c if defined $c; $c = 0; print} || $c++; END {print $c}' input_file > output_fileIn order to make the output counts for only unique lines that are between lines starting with '>'
Currently this script works well in generating overall counts of the lines that are between lines that begin with '>'
Example input_file:Example of output_file:>05143_African_trypanosomiasis TRINITY_DN26760_c1_g1 18169 42987 42987 >05145_Toxoplasmosis 43736 38319 38320 38320 TRINITY_DN24151_c3_g1 TRINITY_DN25493_c0_g1
Example of desired output:>05143_African_trypanosomiasis 4 >05145_Toxoplasmosis 6
>05143_African_trypanosomiasis 3 >05145_Toxoplasmosis 5
I'm also very new to perl so an explanation of the tweaked code would be much appreciated.
-James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting unique line counts between lines starting with '>'
by choroba (Cardinal) on Oct 19, 2017 at 21:34 UTC | |
by james.v (Initiate) on Oct 20, 2017 at 00:17 UTC | |
by NetWallah (Canon) on Oct 20, 2017 at 02:53 UTC | |
by Anonymous Monk on Oct 20, 2017 at 04:45 UTC | |
by james.v (Initiate) on Oct 19, 2017 at 21:51 UTC |