Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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]
[Lady_Aleena]: I'll just have to search for the files using the subs and open them up.
[Discipulus]: nice Perl dreams, folks.. shower->Dumas->bed
[erix]: pere ou fils?
[Lady_Aleena]: Discipulus, good night.
[Discipulus]: pere, le vicomte de bragelonne.. wonderfull
[erix]: I'll keep that in mind (haven't read), buona notte :)
[Discipulus]: oh erix but is the fourth of cycle;read them in order
[erix]: hm, perhaps I can just read it here
Discipulus zzz...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2017-05-23 19:57 GMT
Find Nodes?
    Voting Booth?