Biology Stack Exchange is a question and answer site for biology researchers, academics, and students. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
>>> from Bio import SeqIO
>>> for seq_record in SeqIO.parse("ls_orchid.fasta", "fasta"):
... print(
  File "<stdin>", line 2
IndentationError: expected an indented block

First I import the sequence and then whenever i try to print using this " print(" ^ I get this error IndentationError: expected an indented block

how can I preent that need help..

share|improve this question

closed as off-topic by jonsca, Chris, Mad Scientist Feb 27 '14 at 6:54

  • This question does not appear to be about biology within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

This question appears to be off-topic because it is about a bioinformatics software development issue. – jonsca Feb 27 '14 at 5:33
basic python question. I suggest a quick search on – Memming Feb 27 '14 at 14:52
up vote 2 down vote accepted

Biopython is a module of python and the language is structured in the same way.

This particular example does not make it clear how and where to find the files and extract the data you want. First, you need to download the file and put it in a place where python will find it. Below I have an example where I was able to extract the record id. I first set up a fasta file for my code to go through and then it adds the data to a list (seq = []). The "with open" line joins my data files together. The line ends with a ":" to signal to the program that there is a block of something to do in the next line. Indentation is important in python and after a ":" the next line is indented 4 spaces.

from Bio import SeqIO

data_dir = 'data' #folder where my data files are
data_file = 'ampk.fasta' #name of file I want to get data from

seqs = []

with open(os.path.join(data_dir, data_file), "rU") as f:
    for record in SeqIO.parse(f, "fasta") :

Hope this helps!

share|improve this answer
okay I will try and let you know – krushna Feb 27 '14 at 6:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.