unfortunately your post is unreadable

please try to update it and add tags like  <p>,<c> ...

see Markup in the Monastery

Cheers Rolf

UPDATE: since you're a beginner

-----------------

I wanna match array element patterns($pats[$i]) with the row sequence($str). Also find the overlapping region location in the sequence($str). Please help me. But my loop is not work properly.

Thanks.

INPUT FILES:

seq.txt >seq1 AAAAAA >seq2 TTTTT

pat.txt seq1 AAAAA TTTTT GGGGG

I want following output: Patterns sequence name start end length of seq. AAAAA seq1 1 5 6 AAAAA seq1 2 6 6 TTTTT seq2 1 5 5

not found GGGGG

I wrote following PERL script:

#!/usr/bin/perl-w + # perl program to find motif in text file eith its positions. + use strict; use Bio::SeqIO; open(my $outfile, "&gt;", "Motif_Result.txt"); my $file = 'seq.txt'; print {$outfile}"\t\t\t\t\t Positions\n"; print {$outfile}"\tPattern Name\tSequence Name\tStart\tEnd\tLength of +Sequence\n\n"; my $patternseq= 'pat.txt'; open(FIH, $patternseq); my $in; my %patsmap; my @residue; my @pats; my $seqcount = 0; while ($in=&lt;FIH&gt;) { chomp($in); my @pats=split " ",$in; my $residue=shift@pats; foreach my $nnn (@pats) # @pats = (AAAAA, TTTTT, GGGGG); { $patsmap{$nnn}=@residue; } print "Patterns\t"; print "@pats"; print "\n"; my $length = @pats; print "Total Patterns are: $length"; print "\n"; my $seqobj; my $in = Bio::SeqIO-&gt;new(-format =&gt; 'fasta', -file =&gt; $file); my $motif_count = 0; while ( my $seq = $in-&gt;next_seq) { $seqcount++; # count the number of sequences my $head = $seq-&gt;display_id(); my $str = $seq-&gt;seq; # get the sequence as a strin +g $str =~ s/\*//g; # remove all '*' from sequence my $i; for ($i=0; $i&lt;=$length; $i++) { while ( $str =~ m/(?=$pats<a href="?node=%24i">$i</a>)/ig +) { my @l = split('', $str); my $length=@l; print {$outfile}"\t"; print {$outfile}$pats<a href="?node=%24 +i">$i</a>; printf {$outfile}"\t\t$head\t\t%d", pos($str)+1; printf {$outfile}"\t%d", pos($str)+5; print {$outfile}"\t"; print {$outfile}$length; print {$outfi +le}"\n"; } } } print {$outfile}"\n\tTotal Sequences in file name $file\t:$seqcount\n" +; exit; }

---------------


In reply to Re: Pattern Matching using Array by LanX
in thread Pattern Matching using Array by ravimore

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.