This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Problems with extracting genes from a genbank file using biopython

I am trying go extract the gene positions from a genbank file using Biopython. This is the function i wrote so far:

def get_CDS(file):
record = SeqIO.read(file, "genbank")
cds = []
for feature in record.features:
    if feature.type == 'CDS':
        print feature.location
        start_i = feature.location.start
        end_i = feature.location.end
        cds.append((start_i, end_i))
return cds

However I noticed sometimes, there are entries like:

join{[4585844:4586295](-), [4584940:4585845](-)}

And then start and end positions will return: 4584940 and 4586295.

Does someone maybe know, how can I also get the positions of the genes accordingly, for the first part of the gene [4585844:4586295] and then [4584940:4585845]

gene genome biopython python

Could you please provide accession number of the genbank file you are trying to parse using this code?

For example, one of the pestis genomes causes this problem: NC_003143

1 answer

Hi There,

I have used a sample genbank file here, the following should work for you too.

This produces following output.

['335:4642', '335:1838', '4586:5165', '5104:5396', '5376:7970', '5515:8199', '5607:5856', '5770:8341', '6918:7488', '8342:8963']

Log in to answer this question.