Entering edit mode
2.8 years ago
Phoebe Magdy
•
0
I'm trying to align PE fastq files using 'bwa mem' and in the command I want to add the read group information so that it appears in the output .sam file
Note: I'm using jupyter notebook here is my piece of code
R1 = os.path.join(rootdir, "001_S001_L001_R1_001.fastq")
R2 = os.path.join(rootdir, '001_S001_L001_R2_001.fastq')
SM = os.path.basename(R1).split('_')[0] ## Sample ID
LB = '_'.join(os.path.basename(R1).split('_')[0:2]) ## Library ID
PL="Illumina" ##platform (e.g. illumina, solid)
with open(R1) as f:
firstline = f.readline()
RGID = '_'.join(firstline.replace(':','_').split('_')[0:4])
PU= RGID + '_' + LB ## Platform unit
index_file = '/home/phoebemagdy/workdir/PhD/Trial_Code/Ecto_Data/BWA_alignment/BWA_Index/hg19.fa'
!bwa mem -t 2 -M -R "@RG\tID:{}\tSM:{}\tPL:{}\tLB:{}\tPU:{}".format (RGID, SM, PL, LB, PU) {index_file} {R1} {R2}> First_patient.sam
I always get the following error :
/bin/bash: -c: line 0: syntax error near unexpected token ('
/bin/bash: -c: line 0:
bwa mem -t 2 -M -R "@RG\tID:{}\tSM:{}\tPL:{}\tLB:{}\tPU:{}".format (RGID, SM, PL, LB, PU) {index_file} {R1} {R2}> First_patient.sam'
1
I'll be grateful for any suggestions to help fixing this error...!
`Do you have to use a jupyter notebook for this? It seems to complicate things unnecessarily.
You could try adding
echo
before the bwa mem call and see which command gets printed, and if you can spot something that looks off.