#!/bin/bash
echo "start run repeat elements module..."

binDir=$(cd `dirname $0`; pwd)
transDir=$1
species=$2
dataDir=$3/$species/repeat_elements
transBedFile=$transDir/exon.bed
outDir=$transDir/repeat_elements
rm -rf $outDir
mkdir -p $outDir

rmskFile=$dataDir/$species.rmsk.gz
rmskResultFile=$outDir/repeatmask_details.txt
strand=`head -n1 $transBedFile |cut -f6`
tabix $rmskFile -R $transBedFile | awk -v strand="$strand" '{if($6==strand)print $0}'> $rmskResultFile

#rm -f $outDir/tmp
tag=`cat $transDir/status |grep repeat_elements`
if [[ $tag == ""  ]];then
echo -e "repeat_elements\tfinished" >> $transDir/status
fi

echo "repeat elements module is done!"
