#HG002_chr10:100886055-100886155_mapClipR.sam	chr7:20668129-20668130	SNA00132:51:HCJ2HDSXX:1:1116:19235:16611	97
#HG002_chr10:100886055-100886155_mapClipR.sam	chr7:20668185-20668186	SNA00132:51:HCJ2HDSXX:3:2667:9100:1626	2209

#>A00132:54:HFH2JDSXX:1:2512:9579:2644/2
#AACCAAGGTTTCCCCATTTCATACCACCCACCCAGTCCCATAAAGAAGCGGCAGCTTGGTGCAGCGGCTCATTCATTTGGTTCAAATGGATTTGAATAAACAAACCGGGGACAGGGAGGTCCCCACAAGTCCAAAGTCAAGGGCAAATAC
#>A00132:53:HFHJKDSXX:4:1318:27507:4507/2
#CCCATTTCATCCCTCCCACCCAGTCCCATAAAGAAGCGGCAGCTTCTGGCAGCTGCTCAGTCATTTGGTGCAATGGGATTTGAATAAACAAACCCGGGACAGTGAGGTCCCCAGAAGTCCATAGTCAAGGGCTAAGACCCCTAGAGGCTT

%RE;
%REG;
%REGF;
@name=`cat $ARGV[0] `;
chomp(@name);
foreach $i (@name)
{
#10:101340234-101340334	HISEQ1:20:H9V1RADXX:1:2211:5155:41672	1
	@dis=split(/\t/,$i);
	$RE{"$dis[1]"}=1;
	$REG{"$dis[1]"}=$dis[0];
	$REGF{"$dis[1]"}=$dis[2];
}
while(<STDIN>)
{
	chomp();
	$name=$_;
	$name=~s/\/\d//;
	$name=~s/^>//;
	$flag=$_;
	$flag=~s/.*\/(\d)/\1/;
	$seq=<STDIN>;
	if($RE{"$name"} ==1)
	{
		if($REGF{"$name"} != $flag)
		{
			print ">".$REG{"$name"}."\n$seq";
			$RE{"$name"}=0;
		}
	}
}
