This might help you get started.
#!/usr/bin/perl
use strict;
my $file_1 = <<END;
chr1 3204562 3661779
chr1 4334223 4350673
chr1 4481008 4486694
chr1 4764014 4775968
chr1 4797773 4836816
chr1 4847574 4887987
chr1 4847574 4887987
chr1 4848208 4887987
chr1 4900049 5009660
chr1 5073053 5152630
END
my @boundary_records;
open( my $file, '<', \$file_1 )
or die( "Error could not open $file_1" );
while( <$file> ) {
push( @boundary_records, [ split( /\s+/ ) ] );
}
close( $file );
my $count = 0;
while( <DATA> ) {
chomp;
my @test_records = split( /\s+/ );
for my $i (@boundary_records) {
if ( $test_records[1] eq $i->[0]
and $test_records[2] > $i->[1]
and $test_records[3] < $i->[2] ) {
$count++;
}
}
print "$_ = $count\n";
$count = 0;
}
__DATA__
Xkr4 chr1 3204562 3661779 - 3 457.217
Rp1 chr1 4334223 4350673 - 4 16.45
Sox17 chr1 4481008 4486694 - 5 5.686
Mrpl15 chr1 4764014 4775968 - 5 11.954
Lypla1 chr1 4797773 4836816 + 9 39.043
Tcea1 chr1 4847574 4887987 + 10 40.413
Tcea1 chr1 4848208 4887987 + 10 39.779
Rgs20 chr1 4900049 5009660 - 5 109.611
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|