<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Raku script to find overlaps between two bed files !]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/44455/raku-script-to-find-overlaps-between-two-bed-files?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/44455/raku-script-to-find-overlaps-between-two-bed-files?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44455/raku-script-to-find-overlaps-between-two-bed-files</guid>
	<pubDate>Thu, 01 Feb 2024 02:02:46 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44455/raku-script-to-find-overlaps-between-two-bed-files</link>
	<title><![CDATA[Raku script to find overlaps between two bed files !]]></title>
	<description><![CDATA[<code>#!/usr/bin/env raku

# Check if the correct number of arguments are provided
if @*ARGS.elems != 2 {
    say &quot;Usage: ./compare_bed_files.raku file1.bed file2.bed&quot;;
    exit 1;
}

# Read the contents of the two BED files
my @bed1 = slurp(@*ARGS[0]).lines;
my @bed2 = slurp(@*ARGS[1]).lines;

# Iterate over each interval in the first BED file
for my $line1 (@bed1) {
    my @fields1 = $line1.split(&quot;\t&quot;);
    my $chr1 = @fields1[0];
    my $start1 = @fields1[1];
    my $end1 = @fields1[2];

    # Check for overlaps with intervals in the second BED file
    for my $line2 (@bed2) {
        my @fields2 = $line2.split(&quot;\t&quot;);
        my $chr2 = @fields2[0];
        my $start2 = @fields2[1];
        my $end2 = @fields2[2];

        # Check for chromosome match and overlap
        if $chr1 eq $chr2 &amp;&amp; $start1 &lt; $end2 &amp;&amp; $end1 &gt; $start2 {
            say &quot;Overlap found:&quot;;
            say &quot;File 1: $line1&quot;;
            say &quot;File 2: $line2&quot;;
            say &quot;&quot;;
        }
    }
}

say &quot;Comparison completed.&quot;;</code>]]></description>
	<dc:creator>LEGE</dc:creator>
</item>

</channel>
</rss>