3
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ In you code, which is the line that is causing trouble? I cannot see any samtools index for indexing the bam, as you say. $\endgroup$ – Poshi Sep 21 '18 at 7:25
  • 1
    $\begingroup$ More comments... samtools import has been deprecated for 8 years. Use samtools view instead. $\endgroup$ – Poshi Sep 21 '18 at 7:30
  • 1
    $\begingroup$ Finally, the second samtools faidx makes no sense: there are no fasta files to index! $\endgroup$ – Poshi Sep 21 '18 at 7:31
  • 1
    $\begingroup$ Which is the command that fails? Which one is giving that message? Again, I'm seeing several errors. faidx have too many parameters (what are you trying to achieve?), view will complain about not having a bam input, and sort have no input file given and the shell will complain about an orphan dollar sign. Four errors in for different lines. Better go step by step and check that one step works before going to the next. $\endgroup$ – Poshi Sep 24 '18 at 17:47
  • 1
    $\begingroup$ Try upgrading to the most recent version of samtools, this bug may have been squashed already. $\endgroup$ – Devon Ryan Nov 2 '18 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy