#!/usr/bin/perl

my $seq_file = $ARGV[0];
my $pwmatch_file = $ARGV[0] . ".pwmatch";



my $transen = `ls /homes/biertank/praktikum/TRANSFAC/M*`;
$transen =~ s/.*pwm\n//g;
#print $transen;
my @transenhaufen = split(/\n/,$transen);

foreach $transe (@transenhaufen) {
		open(FILEIN, "<$transe") || die ("kann net offnen datei.");
		my $line = <FILEIN>;
		close(FILEIN);

		$line =~ s/[\s]//g;
		my $length = length($line);
		if($length>0) {
			my $score = ((0.6*$length));
			my $befehl = "/homes/biertank/praktikum/sicher/bin/pwmatch ".$score." ".$transe." ".$seq_file;		
			#print "\n---\n".$befehl."\n--\n\n";
			my $result = `$befehl`;
					
				
			if(!($result =~ /0 matches found/)) {
				
			print "\n\nScore: ".$score."\tMotif: ".$transe."\tlength: ".$length."\n\n";
			print $result;
			}
			
		}
}
 
