Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Searching and Coutning using 2 files with multiple columns

by ccn (Vicar)
on Sep 16, 2009 at 14:54 UTC ( #795636=note: print w/ replies, xml ) Need Help??


in reply to Searching and Coutning using 2 files with multiple columns

Something like golf

#!/usr/bin/perl -lan BEGIN { die "Usage: $0 Boundary.out DB.out" unless @ARGV == 2; } if ( $isDB ) { print $_, "\t" . grep { $_->[0] > $F[2] && $_->[1] < $F[3] } @{$chr{$F[1]}} } else { push @{$chr{$F[0]}}, [ @F[1, 2] ]; $isDB = eof; }


Comment on Re: Searching and Coutning using 2 files with multiple columns
Download Code
Re^2: Searching and Coutning using 2 files with multiple columns
by shart3 (Novice) on Sep 16, 2009 at 17:54 UTC
    ccn,

    Thanks! This seems to work for the most part (even though I don't understand any of it).

    However, it is replacing the chr# with the count number. For example if the value is 2, I get

    Xkr4 2hr1 3204562 3661779 - 3 457.217

    or of the number is larger (say 12):

    Xkr4 12r1 3204562 3661779 - 3 457.217

    I would like it to be:

    Xkr4 chr1 3204562 3661779 - 3 457.217 2 or Xkr4 chr1 3204562 3661779 - 3 457.217 12

      Hmm... It works for me as desired on your sample data.

      What delimiters do you use between columns? What is your OS?

      Please try this one:

      #!/usr/bin/perl -lan BEGIN { die "Usage: $0 Boundary.out DB.out" unless @ARGV == 2; } if ( $isDB ) { print join "\t", @F, ~~grep { $_->[0] > $F[2] && $_->[1] < $F[3] } @{$chr{$F[1]}} } else { push @{$chr{$F[0]}}, [ @F[1, 2] ]; $isDB = eof; }

        Thanks. PROBLEM SOLVED!! Your original post worked! I had to remove a hard return in my text file that was screwing everything up

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://795636]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2015-07-05 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls