Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Creating 2D array / Matrix

by Cristoforo (Deacon)
on Mar 18, 2013 at 19:35 UTC ( #1024136=note: print w/replies, xml ) Need Help??

in reply to Creating 2D array / Matrix

This post finds overlapping .bed files, if that helps.

The link above will find overlapping ranges. If you just want to list both .bed files in sorted order, then the following will do it.

#!/usr/bin/perl use strict; use warnings; use 5.014; @ARGV = qw/ 148N.txt 162N.txt 174N.txt 175N.txt /; my @data = map {[split]} map {$_->[0]} sort {$a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] || $a->[3] +<=> $b->[3]} map {[ $_, /\d+/g]} <>; say "@$_" for @data;
Ouput from the 4 files (in sorted order):
C:\Old_Data\perlp>perl chr1 10 50 chr1 12 40 chr1 20 45 chr1 25 30 chr1 25 50 chr1 41 45 chr1 48 80 chr1 60 80 chr1 100 500 chr10 10 20

Update: changed the sort and made simpler and still correct. .bed file definition from here.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024136]
[Eily]: I still don't understand how the Turkish AA fit into the German+Czech joke though :P
[LanX]: new Firefox + cb sidebar do random auto expand on submit
[LanX]: probably need to start pm discussion
[LanX]: they have a constitutional referendum in turkey, kind of "do you want a dictator" and everybody opting no gets problems ...
[Corion]: LanX: Random Auto Expand?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2017-03-27 12:11 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (319 votes). Check out past polls.