Commit e95fc1bf authored by Chaos's avatar Chaos
Browse files

update

parent 9247c906
Loading
Loading
Loading
Loading
+19 −46
Original line number Diff line number Diff line
@@ -6,31 +6,26 @@ $pigz_cmd ${work_dir}/*.fastq

fastq_suffix=fastq.gz

fastq_dir=${work_dir}/fastq
split_dir=${work_dir}/splits
tmp_dir=${work_dir}/HIC_tmp
out_dir=${work_dir}/result

if [ ! -d $fastq_dir ];then mkdir -p $fastq_dir;fi

if [ ! -d $split_dir ];then mkdir -p $split_dir;fi
if [ ! -d $out_dir ];then mkdir -p $out_dir;fi
if [ ! -d $tmp_dir ];then mkdir -p $tmp_dir;fi


ls ${work_dir}/*_read1.${fastq_suffix} | while read i
ls ${work_dir}/*_read1.${fastq_suffix} | while read read1_file
do
	sample=$(basename $i _read1.${fastq_suffix})
	j=${work_dir}/${sample}_read2.${fastq_suffix}
	sample=$(basename $read1_file _read1.${fastq_suffix})
	read2_file=${work_dir}/${sample}_read2.${fastq_suffix}

	if [ ! -e $j ];then
		echo "$j doesn't exist"
	if [ ! -e $read2_file ];then
		echo "$read2_file doesn't exist"
		stop
	fi

	mv $i ${fastq_dir}

	read1_file=${fastq_dir}/${sample}_read1.${fastq_suffix}
	read2_file=${fastq_dir}/${sample}_read2.${fastq_suffix}
	split_prefix=${split_dir}/${sample}
	out_prefix=${out_dir}/${sample}
	res_file=${split_prefix}_norm.txt.res.txt
@@ -58,23 +53,18 @@ do
		echo "$num2" > $linecount_file
	fi

	if [ ! -e ${split_prefix}.sam ];then
	if [ ! -e ${split_prefix}.bam ];then
		$bwa_cmd \
			mem \
				-SP5M \
				-t $thread_str \
				$bwa_index \
				$read1_file \
				$read2_file \
		> ${split_prefix}.sam
	fi

	if [ ! -e ${split_prefix}.bam ];then
				$read2_file | \
		$awk_cmd \
			-v stem=${split_prefix}_norm \
			-v site_file=$site_file \
			-f ${common_dir}/chimeric_sam.awk \
			${split_prefix}.sam | \
			-f ${common_dir}/chimeric_sam.awk | \
		$samtools_cmd \
			sort \
				-t cb \
@@ -110,23 +100,18 @@ do
				${split_dir}/${rep}*.bam
	fi

	if [ ! -e $rep_dedup_sam ];then
	if [ ! -e $rep_dedup_txt ];then
		$samtools_cmd \
			view \
				-@ $thread_str \
				-h $rep_bam | \
		$awk_cmd \
			-f ${common_dir}/dups_sam.awk \
		> $rep_dedup_sam
	fi

	if [ ! -e $rep_dedup_txt ];then
			-f ${common_dir}/dups_sam.awk | \
		$samtools_cmd \
			view \
				-@ $thread_str \
				-F 1024 \
				-O sam \
				$rep_dedup_sam | \
				-O sam | \
		$awk_cmd \
			-v mapq=1 \
			-f ${common_dir}/sam_to_pre.awk \
@@ -141,16 +126,14 @@ do
	fi

	if [ ! -e $rep_dedup_bam ];then
		$samtools_cmd
			view
				-b
				-@ $thread_str
				$rep_dedup_sam
		$samtools_cmd \
			view \
				-b \
				-@ $thread_str \
				$rep_dedup_sam \
		> $rep_dedup_bam
	fi

	rm $rep_dedup_sam

#	export IBM_JAVA_OPTIONS="-Xmx60g -Xgcthreads${thread_str}"
#	export _JAVA_OPTIONS="-Xmx60g -Xms60g"

@@ -232,17 +215,12 @@ do
					-@ $thread_str \
					-h $lib_bam | \
			$awk_cmd \
				-f ${common_dir}/dups_sam.awk \
			> $lib_dedup_sam
		fi
	
		if [ ! -e $lib_dedup_sam ];then
				-f ${common_dir}/dups_sam.awk | \
			$samtools_cmd \
				view \
					-@ $thread_str \
					-F 1024 \
					-O sam \
					$lib_dedup_sam | \
					-O sam | \
			$awk_cmd \
				-v mapq=1 \
				-f ${common_dir}/sam_to_pre.awk \
@@ -265,11 +243,6 @@ do
			> $lib_dedup_bam
		fi

		rm $lib_dedup_sam

		export IBM_JAVA_OPTIONS="-Xmx60g -Xgcthreads${thread_str}"
		export _JAVA_OPTIONS="-Xmx60g -Xms60g"

		if [ ! -e $lib_stat_m ];then
			dups=$(\
				$samtools_cmd \