This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Htseq-count error "start is larger than end"

Hello,

I am attempting to do htseq-count for an RNA-Seq differential expression data analysis and I have run into an error with the GFF file I am using. The exact error is as follows:

Error occured when processing GFF file (line 3497 of file /Users/*.gff):
  start is larger than end
  [Exception type: ValueError, raised in _HTSeq.pyx:64]

I looked specifically at line 3497 and the start position is larger than the stop position which makes sense why there is an error, but I am not sure how to fix it. Is there a way to just omit that line of the .gff file in terminal? Any advice would be greatly appreciated.

Thank you,
Evan

htseq-count gff
Can't you edit it and replace the coordinates?

Thats what I was hoping to do, but how would you go about doing that? I tried opening up the gff file in excel, but it messed with the overall format of the gff file

Open it in a text editor (think wordpad or notepad on Windows or Editor on a Mac). You should NEVER use Excel in bioinformatics.

Thank you for the tip, that made it possible to edit the file without error. Another problem that I have run into though is that there are way too many places in the gff file where the "start is larger than end" to edit them all by hand. I looked into the options for HTSeq-count, but it didn't seem like any of them would prevent the error.

1 answer

For future references I wrote a quick python script to fix the problem. This script simply separate each line by tab (\t) and reverse the odd if the start column is greater than the end column, and then print out the gff3.

file=open('file_name.fa','r')
    for line in file:
        line=line.rstrip('\n')
        if len(line.split('\t')) == 8: #make sure it's data line and not header
        scaffold,source,type,start,end,score,strand,phase,attributes=line.split('\t')
        if int(start)>int(end):
            print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (scaffold,source,type,end,start,score,strand,phase,attributes)
        else:
            print line

Hope this helps.

Log in to answer this question.