<?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: Perl script to find palindromic regions in DNA sequences]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/36915/perl-script-to-find-palindromic-regions-in-dna-sequences?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/36915/perl-script-to-find-palindromic-regions-in-dna-sequences?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/36915/perl-script-to-find-palindromic-regions-in-dna-sequences</guid>
	<pubDate>Tue, 12 Jun 2018 04:34:12 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/36915/perl-script-to-find-palindromic-regions-in-dna-sequences</link>
	<title><![CDATA[Perl script to find palindromic regions in DNA sequences]]></title>
	<description><![CDATA[<code>use strict;
use warnings;

my $pp = qr/(?: (\w) (?1) \g{-1} | \w? )/ix;
my $filename = $ARGV[0];
open(my $fh, &#039;&lt;:encoding(UTF-8)&#039;, $filename) or die &quot;Could not open file &#039;$filename&#039; $!&quot;;

local $/ = &#039;&#039;;

while (&lt;$fh&gt;) {
    chomp;
    my ($header, @lines) = split &quot;\n&quot;;
    my $data = join &#039;&#039;, @lines;

    print &quot;$header\n$data\n&quot;;

    while ($data =~ /(?=($pp))/g) {
	my $end=($-[0]+length($1));
	my $n=(length($1)/2);
	my $len=length($1);
	my $midPoint = ($n == int $n) ? $n : int($n + 1);
	$midPoint=$midPoint+$-[0];
        print &quot;$-[0]\t$midPoint\t$end\t$1\t$len\n&quot; if length($1) &gt; 100;
    }
}

__DATA__
&gt;TRE|Q47404|Q47404 (409 AA) Glycosyl transferase [Escherichia coli]
MIFDASLKKLRKLFVNPIGFFRDSWFFNSKNKAEELLSPLKIKSKNIFIVAHLGQLKKAE
LFIQKFSRRSNFLIVLATKKNTEMPRLILEQMNKKLFSSYKLLFIPTEPNTFSLKKVIWF
YNVYKYIVLNSKAKDAYFMSYAQHYAIFIWLFKKNNIRCSLIEEGTGTYKTEKKKPLVNI
NFYSWIINSIILFHYPDLKFENVYGTFPNLLKEKFDAKKIFEFKTIPLVKSSTRMDNLIH

&gt;seq1
TGAATTACTAGAAGTACTTAAAATGATGGTTGGAGGAAATATTCTTGATGATCAAATTGC
CGTTAAACTAGGATTTCTTATAAAGGAGGTTGGTAGTAAAATTCATGAAGATCATTAAGT

&gt;TRE|Q8VRL9|Q8VRL9 (492 AA) SiaD [Neisseria meningitidis]
MLQKIRKALFHPKKFFQDSQWFATPLFSSFAPKSNLFIISTFAQLNQAHSLTKMQKLKNN
LLVILYTTQNMKMPKLIQKSVDKELFSVTYMFELPRKPGIVSPKKFLYIQRGYKKLLKTI
QPAHLYVMSFAGHYSSLLSLAKKMNITTHLVEEGTATYAPLLESFTYKPTKFEQRFVGNN
LHQKGYFDKFDILHVAFPEYAKKIFNANEYHRFFAHSGGISTSQSIAKIQDKYRISQNDY</code>]]></description>
	<dc:creator>Abhimanyu Singh</dc:creator>
</item>

</channel>
</rss>