#!/usr/bin/perl -w 
my $format=$ARGV[0];
while(<STDIN>){
	$line=$_;
	chomp $line;
	if ($line =~/Sequence:\s(.*)\s+from/){
		$seq=$1;
	}
	if ($line =~/Pattern:\s(.*)/){
		$pattern=$1;
	}
	if ($line =~/\s+(\d+)\s+(\d+)\s+([\d\.])\s+([acgtACGT]+)/){
		$start=$1;
		$end=$2;
		$mismatch=$3;
		$site=$4;
		if($start>$end){
			$temp=$end;
			$end=$start;
			$start=$temp;
			$strand="-";
		}
		else{
			$strand="+";
		}
		if($format eq "BED"){
		    print $seq."\t".$start."\t".$end."\t.\t.\t".$strand."\n";
		}
		elsif($format eq "GFF"){
		    print $seq."\tfuzznuc\tmisc_feature\t".$start."\t".$end."\t".$mismatch."\t".$strand."\t.\tid \"".$pattern."\"; site \"".$site."\";\n";	
		}
	}
}

