Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move alignment files from temporary to final location only after the BWA checks have finished #30

Open
vinjana opened this issue Nov 15, 2018 · 1 comment

Comments

@vinjana
Copy link
Member

vinjana commented Nov 15, 2018

We had two cases where alignment jobs failed, but the alignment files where already moved to the final location, so that a rerun required finding and deleting those cases of wrongly 'completed' alignment files.

Not sure why this happened. One likely explanation is that the files are not moved to their final destination at the very end of the script, but rather before a couple of final BWA checks. So if one of those fails, the job fails, but the alignment files are not marked as temporary. This is unwanted, as the BWA checks are used to indicate alignments which need to be replaced/taken care of.

Things to do in summary:

  • Alignment files should be moved to the final path at the very end of the alignment workflow
  • are the BWA checks carried out at the end of the alignment workflow still necessary?
  • If yes, change the code for the BWA checks so that they work on the temporary alignment file paths (since we will now move the alignments only after the checks)
@vinjana
Copy link
Member Author

vinjana commented Nov 15, 2018

By @schmattes42:
It seems that the temporary bam file is only moved to its final destination at the end of the bwa error checks (see line 10 of the following code fragment). Out of some reason the bwa error checking script ends with a non-zero exit code

lang=bash
if [[ ${bamFileExists} == true ]]; then
	wait $procIDOutPipe || throw 13 "Error from sambamba view pipe"
else	# make sure to rename BAM file when it has been produced correctly
	[[ -p $i1 ]] && rm $i1 $i2 $o1 $o2 2> /dev/null
	rm -rf ${WORKDIR} 2> /dev/null # Remove temporary files sorting
	rm $FNPIPE1
	rm $FNPIPE2
	errorString="There was a non-zero exit code in the bwa mem - sort pipeline; exiting..."
	source ${TOOL_BWA_ERROR_CHECKING_SCRIPT}
	mv ${tempSortedBamFile} ${FILENAME_SORTED_BAM} || throw 36 "Could not move file"
	# index is only created by samtools or biobambam when producing the BAM, it may be older than the BAM, so update time stamp
	if [[ -f ${tempBamIndexFile} ]]; then
	 	mv ${tempBamIndexFile} ${INDEX_FILE} && touch ${INDEX_FILE} || throw 37 "Could not move file"
	fi
	# clean up adapter trimming pipes if they exist
	[[ -p $i1 ]] && rm $i1 $i2 $o1 $o2 2> /dev/null
	
fi

Still we have to find out what exactly is the reason for crashing the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant