Question: Failed to merge BAM files
0
gravatar for Ric
4 weeks ago by
Ric300
Australia
Ric300 wrote:

Hi, I have the following bash script:

#!/bin/bash
#usage: sh split_bam2sam-fasta_pbs.sh /path/to/reference.fasta /path/to/outputfolder/ /path/to/input/*.sorted.dedup.bam

output=$2
mkdir $output
merged=$(basename ${output})
echo $merged
#samlist=$(printf 'I="%s" ' "$@")
samlist=$(printf '%s ' $@)

echo ${samlist}

cat << EOF  |cat #qsub
#!/bin/bash -l

#PBS -N rna-seq-fix
#PBS -l walltime=20:00:00
#PBS -j oe
#PBS -l select=1:ncpus=8:mem=70G
#PBS -M m.lorenc@qut.edu.au
##PBS -m bea

cd \$PBS_O_WORKDIR

conda activate bowtie2
samtools merge ${output}/${merged}.sorted.dedup.bam ${samlist}
samtools index ${output}/${merged}.sorted.dedup.bam
conda deactivate

cd ${output}

conda activate gatk
ln -s $1 .
java -jar /work/waterhouse_team/apps/gatk-4.1.8.0/gatk-package-4.1.8.0-local.jar SplitNCigarReads -R $1 -I ${merged}.sorted.dedup.bam -O ${merged}.sorted.dedup.splitN.bam

EOF

I ran it in the following way:

bash ~/scripts/rna-mapping-fix_pbs.sh /scratch/waterhouse_team/QLD/sparse-orginal-77/bionano/juicer/juicebox2fasta/annotation/QLD0.81-pilon-3-andDebris.fasta-windowmasker.fasta root-merged root*/bams2/Qroot*.fastp.fq.gz.uniq.sorted.bam

Unfortunately, the merged command failed because QLD0.81-pilon-3-andDebris.fasta-windowmasker.fasta and root-merged

samtools merge: failed to read header from "/scratch/waterhouse_team/QLD/sparse-orginal-77/bionano/juicer/juicebox2fasta/annotation/QLD0.81-pilon-3-andDebris.fasta-windowmasker.fasta

How is it possible to modify the above the script to only use BAM files?

Thank you in advance,

bash samtools • 109 views
ADD COMMENTlink modified 4 weeks ago by Shalu Jhanwar400 • written 4 weeks ago by Ric300
2
gravatar for Shalu Jhanwar
4 weeks ago by
Shalu Jhanwar400
Switzerland
Shalu Jhanwar400 wrote:

You can create a samlist of SAM or BAM files only like below:

For SAM samlist=$(ls *.sam)

For BAM samlist=$(ls *.bam)

That samlist you can use in samtools merge command of your script.

ADD COMMENTlink modified 4 weeks ago • written 4 weeks ago by Shalu Jhanwar400
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 701 users visited in the last hour