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

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 t6.pl 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.


Comment on Re: Creating 2D array / Matrix
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-12-21 14:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls