
frenchcookie
New User
Dec 15, 2012, 11:14 AM
Post #1 of 2
(2268 views)
|
Compare two sequences from one file
|
Can't Post
|
|
Hello, I have to compare two sequences form one file. I have to compare by the bases position. ( First base from seq A with first base from seq B, second base from seq A with second base from seq B etc. ) I have something like this, but it's not working properly. Could you give my any idea how to do it effectually?
my $end = $#a1 < $#a2 ? $#a1 : $#a2; my $result = 0; for (my $l=0; $l<=$end; $l++) { $result++ if $a1[$l] eq $a2[$l]; } my $A = (2 * $result) / ($#a1 + $#a2 + 2); my $B = $result / ($end+1); print "Similar = $result, A = $A, B = $B\n"; } my $file = 'seqs.txt'; open I, '<', $file or die "Can't open '$file' for reading: $!\n"; chop (%hash = map { split /\s*,\s*/,$_,2 } grep (!/^$/,<I>)); print "$_$hash{$_}\n" for keys %hash; open open (IN, $ARGV[0]) || die "File not found $ARGV[0]: $!\n"; chomp(my @in = <IN>); map { s/[^agtc]//ig; } @in; my $dna1 = read_file($ARGV[0]); my $dna2 = read_file($ARGV[1]); compare ($dna1, $dna2); compare($in[0], $in[1]); compare($in[1], $in[2]); compare($in[2], $in[3]); close (IN);
|