Tags Frequency EFFFFDDDDDR 3 FFFFEFFEEDD 3 EFFDFEDEDDR 2 FFFFEFFEEDD 2 ............
I got different results from your dataset using the code below. I am assuming you want a new output file for every *.seq input file. You would just need to uncomment the 4 commented statements and change the foreach my $input_file ('o66.txt') line to foreach my $input_file (@input_files).
#!usr/bin/perl use strict; use warnings; my $sequence='ABCD'; my @headings= qw/ Tags Frequency /; my @input_files=<*.seq>; foreach my $input_file ('o66.txt') { open INPUT, "<", $input_file or die "Cannot open file \"$input_fil +e\". $!"; (my $outfile = $input_file) =~ s/.seq/.tag.txt/i; my %freq; while (my $line=<INPUT>) { if ($line=~m/$sequence(.{11})(.{11})$sequence/i){ $freq{$_}++ for $1, $2; } } close INPUT or die "Cannot close file \"$input_file\". $!"; #open OUTPUT, ">", $outfile or die "Cannot open file \"$outfile\". + $!"; #printf OUTPUT "%-12s%s\n", @headings; printf "%-12s%s\n", @headings; for my $tag (sort {$freq{$b} <=> $freq{$a}} keys %freq) { #printf OUTPUT "%-12s%5s\n", $tag, $freq{ $tag }; printf "%-12s%5s\n", $tag, $freq{ $tag}; } #close OUTPUT or die "Unable to close \"$outfile\". $!"; } __END__ o66.txt is below: @HWDFFFDDABCDEFFFFDDDDDRFFFFEFFEEDDABCDEDDDDDD @HWDFFFDDABCDEFFDFEDEDDRFFFFEFFEEDDABCDEDDDDDD @HWDFFFDDABCDEFFFFDDDDDRFFFFEFFEEDDABCDEDDDDDD @HWDFFFDDABCDEFFFFDDDDDRFFFFEFFEEDDABCDEDDDDDD @HWDFFFDDABCDEFFDFEDEDDRFFFFEFFEEDDABCDEDDDDDD output is: C:\Old_Data\perlp>perl t.pl Tags Frequency FFFFEFFEEDD 5 EFFFFDDDDDR 3 EFFDFEDEDDR 2

In reply to Re: Creating a column of frequency for the unique entries of another column by Cristoforo
in thread Creating a column of frequency for the unique entries of another column by bluray

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.