This is a test version of Biostars. For the public version, visit https://www.biostars.org.
SAM line does not contain at least 11 tab-delimited fields

I am not understanding what this error means i tried this command too but its showing me same error

samtools view -bf 1 1A_sorted.bam > 1A_Sorted.bam

Error occured when reading beginning of SAM/BAM file. ('SAM line does not contain at least 11 tab-delimited fields.', 'line 1 of file 1A_Sorted.bam') [Exception type: ValueError, raised in _HTSeq.pyx:1276]

samtools view 1A_sorted.bam | head

HWI-D00574:89:C6ABRANXX:2:1101:7450:50398   133 gi|448814763|ref|NC_000962.3|   1   0   *   =   1   0   CAACAACGGTTGTAGCTCGACCCGGAACCAAGACCCGGAACTAACGAGAACCAGGCAGATACGTCGTTGACCGATGACCCCGGTTCAGGCTTCACCACAGT   B3A?AGB//=/CFDFG11=/E/E9///<CFB:FGGB///<B<1DDGB//91:1000>/0<::0<CB/E00@C9/:C#########################   YT:Z:UP
HWI-D00574:89:C6ABRANXX:2:1102:3006:26295   133 gi|448814763|ref|NC_000962.3|   1   0   *   =   1   0   GGAACCAAGACCCGGAACTAACGAGAACCAGGGAGATACGTCGTTGACCGATGACCCCGGTTCAGGCTTCACCACAGTGTGGAACGCGGTCGTCTCCGAAC   BBBBBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGEEGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGBGGGGGG   YT:Z:UP
HWI-D00574:89:C6ABRANXX:2:1102:12755:32164  163 gi|448814763|ref|NC_000962.3|   1   0   2M13I86M    =   1   -97 GGGAGATACGTCGTTGACCGATGACCCCGGTTCAGGCTTCACCACAGTGTGGAACGCGGTCGTCTCCGAACTTAACGGCGACCCTAAGGTTGACGACGGAC   CCCCCGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGCGGGGGGGGGGGBCCCGG   AS:i:-54    XN:i:0  XM:i:2  XO:i:1  XG:i:13 NM:i:15 MD:Z:0T0T86 YS:i:-32YT:Z:CP
HWI-D00574:89:C6ABRANXX:2:1102:1302:32973   163 gi|448814763|ref|NC_000962.3|   1   23  2M13I86M    =   19  119 GGGAGATACGTCGTTGACCGATGACCCCGGTTCAGGCTTCACCACAGTGTGGAACGCGGTCGTCTCCGAACTTAACGGCGACCCTAAGGTTGACGACGGAC   B@BBB>G>DGDGGGGGFGGD<EGGGGG9CGGGGGGGGGGGGGGGGGGGGGGGD>GGGGG>CGGGGGGEDG<FGECGGGGGG;CGGGEDGGGB=ED68CDC:   AS:i:-54    XN:i:0  XM:i:2  XO:i:1  XG:i:13 NM:i:15 MD:Z:0T0T86 YS:i:-3YT:Z:CP
HWI-D00574:89:C6ABRANXX:2:1102:6812:34459   133 gi|448814763|ref|NC_000962.3|   1   0   *   =   1   0   CAACGGTTGTAGCTCGACCCGGAACCAAGACCCGGAACTAACGAGAACCAGGGAGATACGTCGTTGACCGATGACCCCGGTTCAGGCTTCACCACAGTGTG   ABBBCGGGGGGGGGGGGGGGGGGGGFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGDGBGGGGGGGGGGGGGGGGGGGGGGGGGGGG   YT:Z:UP
HWI-D00574:89:C6ABRANXX:2:1102:16322:88949  133 gi|448814763|ref|NC_000962.3|   1   0   *   =   1   0   CAACAACGGTTGTAGCTCGACCCGGAACCAAGACCCGGAACTAACGAGAACCAGGGAGATACGTCGTTGACCGATGACCCCGGTTCAGGCTTCACCACAGT   BBCCCGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGC   YT:Z:UP
rna-seq htseq bam sam

This doesn't look like SAM/BAM format to me.

this is what i got after sorting and indexing the .bam file

At some point thing got corrupted, you might have to remake 1A_sorted.bam.

this error solved:

Error occured when reading beginning of SAM/BAM file. ('SAM line does not contain at least 11 tab-delimited fields.', 'line 1 of file 1A_Sorted.bam') [Exception type: ValueError, raised in _HTSeq.pyx:1276]

i tried installing

sudo apt-get install python python-setuptools python-pip python-matplotlib cython zlib1g-dev  
sudo pip install biopython
sudo pip install pysam

Then

htseq-count -f bam -t exon -i transcript_id   -o  1A_htseq.sam  1A_sorted.bam Mycobacterium_tuberculosis_h37rv.GCA_000195955.2.29.gtf > htseq_1_file

however still there is some problem because my htseq_1_file is of 0 byte. Nothing reported inside that file. It is full blank.

How have you created 1A_sorted.bam?

using command samtools sort 1A.bam 1A_sorted.bam

I'm also going to chime in and say this is a SAM format file that has been corrupted in a deeply confusing way. How was this file generated?

EDIT It looks like you've changed your example and now this looks like a SAM file. Glad you got this AHEM: ...sorted out :)

i used Bowtie2........

1 answer

actually my htseq file was showing 0 from above htseq-count command.. but then i changed my chromosome name in GTF file and kept it same which is reported in sam file so now i got correct count in htseq file

Log in to answer this question.