Seqio.Parse Some Error
2
0
Entering edit mode
11.0 years ago

I am a beginner in bioinformatics world. I am following exercise on biopython but i am stuck here. I am not sure why print command is not working. Please let me know to correct this step.

> from Bio import SeqIO
> for seq_record in SeqIO.parse(" /Documents/biopython/hsa_piwil3.fasta", "fasta"):
... print seq_record.id
  File "<stdin>", line 2
    print seq_record.id
        ^
IndentationError: expected an indented block
>

thank you in advance

biopython • 3.6k views
ADD COMMENT
0
Entering edit mode

In addition to the indentation problem (which people have tried to explain below), you also have a space at the start of your filename, you want "/Documents/biopython/hsa_piwil3.fasta" not " /Documents/biopython/hsa_piwil3.fasta".

ADD REPLY
2
Entering edit mode
11.0 years ago

You'll want to read the python section on indentation, as it's very important in python. Something like the following will likely work:

from Bio import SeqIO
for seq_record in SeqIO.parse(" /Documents/biopython/hsa_piwil3.fasta", "fasta") :
    print seq_record.id
ADD COMMENT
0
Entering edit mode

I typed what you have suggested and it is giving me same answer : IndentationError : expected an indented block i read what you have suggested but I am not sure where I am making mistake. Thank you for replying

ADD REPLY
1
Entering edit mode

make sure you include the tab (or a couple of spaces) so type:

from Bio import SeqIO  
for seq_record in SeqIO.parse(" /Documents/biopython/hsa_piwil3.fasta", "fasta") :  
"tab" print seq_record.id
ADD REPLY
0
Entering edit mode
3.2 years ago
alexaminar • 0

Indentation means the space from margin to the begin of characters in a line. Python language is a very sensitive language for indentation, it has caused confusion for many beginners. Putting in an extra space or leaving one out where it is needed will surely generate an error message . Some common causes of this error include:

  • Forgetting to indent the statements within a compound statement.
  • Forgetting to indent the statements of a user-defined function.

The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error. It is probably caused by a mix of tabs and spaces .

ADD COMMENT

Login before adding your answer.

Traffic: 2188 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6