I'm trying to use the code specified in this link to create a .bam file without the need for a .sam file.
Here is the code I'm using:
bwa mem -R "@RG\tID:$SAMPLE\tPL:illumina\tSM:$SAMPLE" \
$REF_PATH/hg38.fasta \
mapping/R1.fastq.gz \
mapping/R2.fastq.gz | \
samtools sort - | \
tee mapping/$SAMPLE\.bam | \
samtools index - mapping/$SAMPLE\.bam.bai \
2>> log
and I get the following error:
[M::bwa_idx_load_from_disk] read 0 ALT contigs
`[E::main_mem] fail to open file ` '.
The ref path and file locations work when creating and converting a .sam to a .bam file. Any ideas?
.sam
format, but already the mapping step. $\endgroup$tee
so that you can pipe tosamtools index
is such a spectacular anti-pattern. Though it's unfortunate thatsort
is one of the subcommands that does not yet support samtools's new--write-index
option.) $\endgroup$mapping [M::bwa_idx_load_from_disk] read 0 ALT contigs [M::process] read 1006360 sequences (150000291 bp)... ...
Then I would follow @Bastian Schiffthaler's answer to find what's the problem with your reads. $\endgroup$samtools sort
does support--write-index
since 1.10 after all. So this can be written more simply asbwa … | samtools sort --write-index -o mapping/$SAMPLE.bam -
(plus a little more if you want to use a BAI index rather than‑‑write-index
's default CSI). $\endgroup$