Take the 2-minute tour ×
Biology Stack Exchange is a question and answer site for biology researchers, academics, and students. It's 100% free, no registration required.

from Bio import SeqIO for seq_record in SeqIO.parse("ls_orchid.fasta", "fasta"): ... print(seq_record.id) File "", line 2 print(seq_record.id) ^ IndentationError: expected an indented block

First I import the sequence and then whenever i try to print using this " print(seq_record.id)" ^ 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 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.

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

1 Answer 1

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") :
        seqs.append(record)
        print(record.id)

Hope this helps!

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

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