You don't seem to understand what you are doing. You index the reference genome with bwa. You align your fastq to the indexed genome with bwa. The .sai file is an intermediate file, it (or the two .sai files from a paired end experiment) are converted into a .sam file
Samtools doesn't do any of that.
Though piping that .sam file straight into samtools for compression into .bam format is a smart thing to do.
Also note that indexing the reference genome with bwa, and indexing a .bam file with samtools are two entirely different things. You might not even need the .bam file index.
Before you use samtools
you need to map your reads first. Then you get a sam/bam file based on your aligning tool. Only after that you use that bam/sam file to index it.
To index it, first you sort the bam/sam files.
samtools sort sample.bam sample_sorted
sample.bam here is your input file and sample_sorted here is the output file in the bam format too. Notice you don't mention the .bam extension in the output file name.
Then, you index it using the following command.
samtools index sample_sorted.bam
I fully agree with you Ashutosh, when I enrolled for a course in bioinformatics NGS was not in curriculum, it was introduced for 2 weeks and now got a big assignment really confusing and after 2 weeks i have my finals so totally lost between java, perl ,R and NGS. Thanks for your advise unfortunately I can't go deep in NGS now.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
that is not samtools, that's bwa. And your mapping quality will be off if you only map to one chromosome.
yes first i made a bwa index .how to go for samtools index,
before you go for samtools index, you need a bam file. is it single-end or paired-end ? use samse or sampe depending. Then samtools sort then samtools index