#!/usr/bin/perl -w

use warnings;
use strict;
use autodie;


        open IN1, "information_assembly_2.txt" or die;
        open IN2, "9pt_combined_snp.txt" or die;
        open OUT1, ">temp.txt" or die;
        open IN3, "temp.txt" or die;
        
        
        
        my (@node,@length,@R,@F,@delete_snp);
        my (%SNP_id,%length_F,%length_R,%node_F,%node_R,%filter_F,%filter_R);
        
        my $i=0;
        
       
        my (@ref_1,@ref_2);
        
        my $j=0;
        my (%count_missing_1,%count_missing_2);  
        my (@AN,@NS);
        
        
        
	        while (<IN1>){
        	chomp;
        	my @temp1=split /\t/,$_;
        	push @node,$temp1[0];
        	push @length, $temp1[1];
        	$temp1[2]=~s/[>]+//g;
        	push @F, $temp1[2];
        	$temp1[3]=~s/[>]+//g;
        	push @R, $temp1[3];
        	$node_F{$temp1[2]}=$temp1[0];
        	$node_R{$temp1[3]}=$temp1[0];
        	$length_F{$temp1[2]}=$temp1[1];
        	$length_R{$temp1[3]}=$temp1[1];
        	}
        	close IN1;    	
        	
        	
        	while (<IN2>){
        	chomp;
        	$i++;
        	my @temp2=split /\t/,$_;
        	
        	$SNP_id{$temp2[0]}=$temp2[1];
        	}
			close IN2;
        	
        	foreach (keys %length_F){
        			if ((exists $SNP_id{$_})&&($SNP_id{$_}>($length_F{$_}-80))){
        		my $key_F=$node_F{$_}; 
        		my $position_F=$_.":".$SNP_id{$_}.":".$length_F{$_};
        		$filter_F{$key_F}=$position_F;
        		#print OUT1 $position,"\n";
        	}
        	}
        	foreach (keys %length_R){
        			if ((exists $SNP_id{$_})&&($SNP_id{$_}>($length_R{$_}-80))){
        		my $key_R=$node_R{$_}; 
        		my $position_R=$_.":".$SNP_id{$_}.":".$length_R{$_};
        		$filter_R{$key_R}=$position_R;
        		#print OUT1 $position,"\n";
        	}
        	}
        	foreach (keys %filter_F){
        		if(exists $filter_R{$_}){
        			
        			print OUT1 $_."\t".$filter_F{$_}."\t".$filter_R{$_}."\n";
        		}
        	}