in reply to Re^2: stupid/simple mistake
in thread stupid/simple mistake
#!/usr/bin/perl use warnings; use strict; open (FILE,"sequence.txt"); my $substring = 'GATC'; my$i=0; my$count; my $sequence; my$result; my $number=0; my $string; my $offset = 0; my @results; while ($sequence=<FILE>){ foreach($sequence =~ /$substring/g) { #print "malakas\n"; $count += () = /$substring/g; $number++; my $result = index($sequence, $substring, $offset); while ($result != -1) { push (@results, $result); print "Found $substring at $result\n"; $offset = $result + 1; $result = index($sequence, $substring, $offset); } #print "$count\n"; } #print "$result\n"; } foreach $result(@results){ my $sum } print "There are $count GATCs";
ok now I have the positions into an array, but I need to calculate the distances between them, which is the sum of result(1)-result(0) + result(2)-result(1) +.... etc etc. I don't really know how to write that in code. any ideas? Thanks in advance again !
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: stupid/simple mistake
by Caio (Acolyte) on Oct 18, 2011 at 16:05 UTC | |
|
Re^4: stupid/simple mistake
by JavaFan (Canon) on Oct 18, 2011 at 22:04 UTC |