please try to update it and add tags like <p>,<c> ...
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, ">", "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=<FIH>) { 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->new(-format => 'fasta', -file => $file); my $motif_count = 0; while ( my $seq = $in->next_seq) { $seqcount++; # count the number of sequences my $head = $seq->display_id(); my $str = $seq->seq; # get the sequence as a strin +g $str =~ s/\*//g; # remove all '*' from sequence my $i; for ($i=0; $i<=$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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |