Trying to create a .bam file without the need for a .sam file

Bioinformatics Asked on April 5, 2021

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 "@RGtID:$SAMPLEtPL:illuminatSM:$SAMPLE" 
    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?

2 Answers

This is an error from bwa saying that it can't find your input files:

Here's a checklist:

  1. Check that you have no whitespace after your newline breaks. I.e. is the very last character
  2. Check that you have no whitespace in any path names
  3. Quote your variables: $REF_PATH -> "$REF_PATH"
  4. Use set -x at the top of your bash script to debug.
  5. In general, read this

Correct answer by Bastian Schiffthaler on April 5, 2021

Why make this so complicated with the tee command?

I don't think you even can index an unsorted bam, so you have to wait until sorting is done before you index. Indexing is really short compared to mapping and sorting, you aren't saving much by trying to do both at once.

Answered by swbarnes2 on April 5, 2021

Add your own answers!

Related Questions

Block wise protein imputation

2  Asked on March 23, 2021 by whateversclever


RAD Seq Data Analysis without barcode

2  Asked on March 20, 2021 by biobash


FASTA and PDB: How to specify chain?

2  Asked on March 19, 2021 by lazer-guided-lazerbeam


How can I use my Myheritage DNA results file for further analysis?

1  Asked on March 19, 2021 by user3390486


Within and between sample count normalization

1  Asked on March 16, 2021 by maxno3


Too slow issue of BioMart

1  Asked on March 12, 2021 by user224050


Obtaining Whole Genetic Sequence

2  Asked on March 11, 2021


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir