This is a test version of Biostars. For the public version, visit https://www.biostars.org.
A bash question

Hi, I have a set of human exome data sequenced with Agilent Sureselect XT HS2. I am following the Best practice document https://www.agilent.com/cs/library/software/public/AGeNTBestPractices.pdf

On p.3 the example for bwa, just want to check if this is correct before starting the long process for alignment. especially the " at the end and the - after samtools view -b

bwa mem ‐C ‐t 2 /hg38.fa trimmed_dir/sample_R1.cut.fastq.gz   trimmed_dir/sample_R2.cut.fastq.gz | samtools view ‐b ‐ >   aligned_dir/sample.bam"

Any advice would be appreciated! Thanks

bash

That extra " at the end is not needed.

- at the end of samtools view command is ok. That indicates that the input to samtools view is coming from the bwa and is being piped in.

your reference file is in the root folder. I am not sure if that is best practice.

1 answer

I would even sort the bam file on the fly as well, e.g.,

bwa mem -R '@RG\tID:READ_GROUP\tPL:PLATFORM\tLB:LIB\tSM:SAMPLE_NAME' ‐C ‐t 2 hg38.fa sample_R1.cut.fastq.gz sample_R2.cut.fastq.gz \
| samtools view -Sbh - | samtools sort -m 2G --threads 4 -o aligned.sorted.bwa.bam

You don't need the samtools view there - you can pipe it straight to samtools sort

Really? I didn't know that. Is there any flag I needed on the sort function? I thought you couldn't pipe plain text into samtools hence the -b flag in samtools view.

No flag is needed.

By default, samtools tries to select a format based on the -o filename extension; if output is to standard output or no format can be deduced, bam is selected.

Log in to answer this question.