I am currently working on my own Metagenomic pipeline, utilizing Bowtie 2 to map. Bowtie 2 outputs a SAM file, which I convert to a .BAM and sort it using Samtools. When I try to utilize Samtools to index my .BAM file it gives me this error:
[E::hts_idx_push] NO_COOR reads not in a single block at the end 1652 -1.
Here is my code:
source /opt/asn/etc/asn-bash-profiles-special/modules.sh
module load samtools/1.3.1
cd ~/gz_files/soapdenovo
r=20
###SAM to BAM and sort
samtools faidx soapdenovo.fa
samtools view -b -T soapdenovo.fa -o sample${r}bowtiemapping.bam sample${r}bowtiemapping.sam
samtools sort -n -T ~/gz_files/soapdenovo/temp -o sample${r}bowtiemapping_sorte$
samtools index sample${r}bowtiemapping_sorted.bam
################LETS MAKE THE ABUNDANCE TABLES###########################$
samtools view -c -f 4 sample${r}bowtiemapping_sorted.bam > sample${r}alignment$
samtools idxstats sample${r}bowtiemapping_sorted.bam > sample${r}idxstats.txt
#git clone https://github.com/metajinomics/mapping_tools.git
#python mapping_tools/get_count_table.py *.idxstats.txt > contig_counts.tsv
##less contig_counts.tsv
Any help would be appreciated!
Notes on pipeline
samtools importwas replaced withsamtools viewfaidxcorrected- Instructions used are here on github
- Suggestion for future trouble shooting is given here by @winni2k
samtools faidx file.bam file.baimakes no sense.samtools faidxindexes fasta files, not bams or bais (bai are the indexes of bam files). – Poshi Sep 21 '18 at 20:07samtools indexfor indexing the bam, as you say. – Poshi Sep 21 '18 at 07:25samtools importhas been deprecated for 8 years. Usesamtools viewinstead. – Poshi Sep 21 '18 at 07:30samtools faidxmakes no sense: there are no fasta files to index! – Poshi Sep 21 '18 at 07:31samtools faidx sample${r}bowtiemapping_sorted.bam sample${r}bowtiemapping_sorted.bam.bai
– Sep 21 '18 at 15:22[E::hts_idx_push] NO_COOR reads not in a single block at the end 1652 -1 samtools index: "sample20bowtiemapping_sorted.bam" is corrupted or unsorted@Poshi – Sep 21 '18 at 17:56samtools index, but no samtools index is in the code. Can you update the question with the new information? Put the new code, tell us the line that fails and put also the error message. – Poshi Sep 21 '18 at 20:09