Hi
I have the code below working. I now need to set a threshold for how many mis-matches can be tolerated and also set a user-provided limit for how many characters are matched at a time (i.e. matches groups of characters rather than one character at a time).
The two strings are being read in from separate files and compared and a dot printed for each matching group.
. I'm a perl beginner and I've tried combinations of pattern matches but with little success. I would appreciate any help in what to change in the code in order to achieve this/
#!/usr/bin/perl
use strict;use warnings;
my $i;my $j;my $a;
open (FH1,'<', "./CAM3UCA.txt");
open (FH2,'<', "./TCH3A.txt");
my $seq1 = do { local $/; <FH1> };
my $seq2 = do { local $/; <FH2> };
my @s1=split('',$seq1);
my @s2=split('',$seq2);
my @matrix=();
for($i=0;$i<scalar(@s2);$i++)
{
for($j=0;$j<scalar(@s1);$j++)
{
if($s2[$i] eq $s1[$j])
{
$matrix[$i][$j]=".";
}
else
{
$matrix[$i][$j]=" ";
}
}
}
#Printing matrix of dot plot
open (FHOUT,">dotplot.txt") or die "cannot open outfile\n";
print FHOUT " ";
for($a=0;$a<scalar(@s1);$a++)
{
print FHOUT "$s1[$a]";
}
print FHOUT "\n";
#print FHOUT "\n\n";
for($i=0;$i<scalar(@s2);$i++)
{
print FHOUT "$s2[$i]";
for($j=0;$j<scalar(@s1);$j++)
{
print FHOUT "$matrix[$i][$j]";
}
print FHOUT "\n";
#print FHOUT "\n\n";
}
close FH1;
close FH2;
close FHOUT;<br>
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.