Hello, I have a problem with samtools newest version and BWA tool from Sourceforge. I have sam files, but it looks like samtools are not recognizing header, and also not doing indexing. Is that a problem with bwa alignment, or samtools? scripts and samtools error message example are attached.
-- Best regards Baiba Alkšere
#!/bin/bash -x module load bio/samtools/1.10 export INPATH=/dir export INPATH1=/dir export INPATH2=/dir export INPATH3=/dir export INPATH4=/dir export INPATH5=/dir export INPATH6=/dir export INPATH7=/dir export reference=/_refseq.fasta samtools faidx $reference for file in $INPATH/*.sam ; do bname=$(basename $file ".sam") echo $bname file=$INPATH/*.sam echo file: $file bamfile=$INPATH1/$bname".bam" namesort=$INPATH2/$bname"_sorted.bam" fixmate=$INPATH3/$bname"_sorted_fixmate.bam" positionsort=$INPATH4/$bname"_sorted_fixmate_position.bam" markdup=$INPATH5/$bname"_sorted_fixmate_position_markdup.bam" bai=$INPATH6/$bname".bai" stats=$INPATH7/$bname".txt" echo $bamfile $namesort $fixmate $positionsort $markdup samtools view -bT $reference $file > $bamfile samtools sort -@ 12 -n $bamfile > $namesort samtools fixmate -m $namesort > $fixmate samtools sort -@ 12 $fixmate > $positionsort samtools markdup $positionsort > $markdup samtools index > $markdup samtools flagstat $markdup > $stats done
+ samtools sort -@ 12 -n file.bam samtools sort: failed to read header from "file.bam" + samtools fixmate -m file_sorted.bam Usage: samtools fixmate <in.nameSrt.bam> <out.nameSrt.bam> Options: -r Remove unmapped reads and secondary alignments -p Disable FR proper pair check -c Add template cigar ct tag -m Add mate score tag --no-PG do not add a PG line --input-fmt-option OPT[=VAL] Specify a single input file format option in the form of OPTION or OPTION=VALUE -O, --output-fmt FORMAT[,OPT[=VAL]]... Specify output format (SAM, BAM, CRAM) --output-fmt-option OPT[=VAL] Specify a single output file format option in the form of OPTION or OPTION=VALUE --reference FILE Reference sequence FASTA FILE [null] -@, --threads INT Number of additional threads to use [0] --verbosity INT Set level of verbosity As elsewhere in samtools, use '-' as the filename for stdin/stdout. The input file must be grouped by read name (e.g. sorted by name). Coordinated sorted input is not accepted. + samtools sort -@ 12 file_sorted_fixmate.bam samtools sort: failed to read header from "file_sorted_fixmate.bam" + samtools markdup file_sorted_fixmate_position.bam Usage: samtools markdup <input.bam> <output.bam> Option: -r Remove duplicate reads -l INT Max read length (default 300 bases) -S Mark supplementary alignments of duplicates as duplicates (slower). -s Report stats. -f NAME Write stats to named file. Implies -s. -T PREFIX Write temporary files to PREFIX.samtools.nnnn.nnnn.tmp. -d INT Optical distance (if set, marks with dt tag) -c Clear previous duplicate settings and tags. -m --mode TYPE Duplicate decision method for paired reads. TYPE = t measure positions based on template start/end (default). s measure positions based on sequence start. --include-fails Include quality check failed reads. --no-PG Do not add a PG line -t Mark primary duplicates with the name of the original in a 'do' tag. Mainly for information and debugging. --input-fmt-option OPT[=VAL] Specify a single input file format option in the form of OPTION or OPTION=VALUE -O, --output-fmt FORMAT[,OPT[=VAL]]... Specify output format (SAM, BAM, CRAM) --output-fmt-option OPT[=VAL] Specify a single output file format option in the form of OPTION or OPTION=VALUE --reference FILE Reference sequence FASTA FILE [null] -@, --threads INT Number of additional threads to use [0] --write-index Automatically index the output files [off] --verbosity INT Set level of verbosity The input file must be coordinate sorted and must have gone through fixmates with the mate scoring option on. + samtools index + samtools flagstat file_sorted_fixmate_position_markdup.bam Failed to read header for "file_sorted_fixmate_position_markdup.bam"
#!/bin/bash -x INPATH=dir OUTPATH=dir reference=refseq.fasta cd //tools/bwa-0.7.17 ./bwa index $reference for file1 in $INPATH/*.fastq.gz ; do bname=$(basename $file1 ) sample=$( cut -d'_' -f 1,2,3<<<"$bname") echo $bname $sample input1=$INPATH/$sample"_R1_001.paired.fastq.gz" output1=$OUTPATH/$sample"_R1_001.paired.sai" input2=$INPATH/$sample"_R2_001.paired.fastq.gz" output2=$OUTPATH/$sample"_R2_001.paired.sai" outfile=$OUTPATH/$sample".sam" echo $input1 $output1 $input2 $output2 ./bwa mem -t 8 $reference $input1 $input2 | gzip -3 > $outfile echo $outfile done
_______________________________________________ Samtools-help mailing list Samtools-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/samtools-help