This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Check That Bwa Index -A Bwasw Succeeded

Hi,

Is there a quick and easy way to check that bwa index succeeded, like in the command below?

bwa index -a bwtsw Homo_sapiens.GRCh37.61.dna.toplevel.fa.gz

Cheers

bwa

2 answers

On a unix-like system checking for the return value of the process should work, if 0 it's fine, if != 0 an error happened. At least that's how it is supposed to work in a shell script:

#!/bin/sh
bwa index <whatever>
ret=$?
if [ $ret != 0 ] ; then
   echo "an error happened"
fi

Edit: to check if the file is ok or not? I think bwa aln should throw an error, shouldn't it?

So what could have gone wrong, then, the file transmission, use md5sum to check that? If unsure, I would always run bwa index myself, if I could. Otherwise, the user giving you the index should be asked to monitor the output and return code of bwa index.

Sorry, I meant once the file has been created with the command above, let's say by someone else, how would one go about checking if it was successfully indexed? Is there a command to check the files are fine after it's been run?

You could take random fragments of the original fasta file and use bwa to align them to the database; if it finds them all, then it's working. Then do the same with randomly generated fasta sequences, there should be almost no hits. That's the ol' positive-control/negative-control method of running an experiment! :-)

Log in to answer this question.