This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to run HTSeq in batch operation

Hi everyone, I am new in RNA-seq and Python. Recently, I meet a problem. When I use HTSeq to count my SAM file, I have to do it one by one. So I check in the website and someone say it can be done in batch operation. There is following commands:

for i in *.sam
do
echo $i
./local/bin/htseq-count  $i ./hg19.gtf > $i.count
done

But I cannot use it in my python. Does anyone may help me?? Thanks a lot!!!

python htseq rna-seq

But I cannot use it in my python.

What does that mean?
If you get an error message, it's very helpful to share that message too.

I have also added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

sorry, i am new in this fiels, here is the code that guy post:

for i in *.sam:
do
echo $i
.local/bin/ht-seq-count  $i ./hg19.gtf > $i.count

But when I follow him, it stop in line 1:

the system tells me "invalid syntax"

That's shell scripting code, not python.

oh, so it cannot use in the Python?

I again added code formatting to your post. See my previous comment on how you can do this yourself next time.

There are a couple of things wrong with that you command.

  • There shouldn't be a : after sam
  • You didn't add done (while you did include that in the previous command)
  • It's also not sure that you htseq-count (which you spelt differently the second time) is in that location. Try which htseq-count
  • Same for your hg19.gtf. Is the path specified correctly?

You have to be quite exact when executing commands.

thank you. But when I wirte the first code

for i in *.sam

the python tells me that "invalid syntax"

That's because, as Devon said, it's not Python code. You execute it just in your terminal (assuming you are using Linux/Mac).

1 answer

You execute it just in your terminal (assuming you are using Linux/Mac).

Log in to answer this question.