[Bioperl-l] Pattern search with gap

khoueiry khoueiry at ibdm.univ-mrs.fr
Wed Jun 22 06:07:48 EDT 2005


Skipped content of type multipart/alternative-------------- next part --------------
while($i<=length($seqstring) - $winSize){
	
	my $nucCount = 0;
	my $substring = substr($seqstring, $i, $winSize);
	
	#If the substring doesn't contain nuc or begins with a gap
	if($substring !~ /[AGCT]/ or $substring =~ /^-/){
		$i++;
		next;
	}
	
	#if the substring doesn't contain gap		
	if($substring !~ /-/){
		#print $substring."\n";
		if($substring eq $qseq){
			print "$qseq found on $i..".($i+length($qseq))."\n";
			last;
		}
		$i++;
	}
	
	if($substring =~ /-/){
		$nucCount++ while $substring =~ /[AGCT]/g;
		my $first = $i;
		my $j = 1;
		while($nucCount < length($qseq)){		
			$substring = substr($seqstring, $i, $winSize+$j);
			$j++;
			$nucCount = 0;
			$nucCount++ while $substring =~ /[AGCT]/g;
		}
		my $last = ($i + $winSize+$j) - 1;
		
		if($nucCount = length($qseq)){
			my $gapCount = $substring =~ s/-//g;
			if($substring eq $qseq){
				print "$qseq found on $i..";
				print "$last\t"."with $gapCount Gap(s)\n";
				last;
			}
		}
		
		$i++;
		
		print $substring."\t";
		print $first."..".$last."\t".$nucCount."\n";
		$nucCount = 0;
	}	
}	


More information about the Bioperl-l mailing list