extracting data from genbank file
1
0
Entering edit mode
2.2 years ago
danka • 0

Hi !

I'm new in Bioinformatics, and my question may be basic to you all, but I could not find a solution on the internet....

Genom of my bacteria was sequenced and annotated a few times and I need to make a table with old and new gene names so:

The thing I want to do is to extract from all gene features locus tag and old local tag, I wrote simple lines:

from Bio import SeqIO
record = SeqIO.read('My_genome.gb', 'genbank')
for feature in record.features:
    if feature.type == 'gene':
        print ('Locus tag:', feature.qualifiers['locus_tag'])
        print ('Old Locus tag:', feature.qualifiers['old_locus_tag'])

but the problem is that sometimes, there is a new gene in My_genome and it has no old locus tag... and it stops.

What would you advise me to do, so I can obtain all of them listed?

Thank you all in advance!

gene qualifiers genbank feature extraction • 855 views
ADD COMMENT
3
Entering edit mode
2.2 years ago

You can first check if the gene has the old_locus_tag qualifier. If it doesn't, you can assign it the default value (e.g., NA). This code should do the job:

from Bio import SeqIO

record = SeqIO.read('My_genome.gb', 'genbank')

for feature in record.features: 
    if feature.type == 'gene':
        locus = feature.qualifiers.get('locus_tag', 'NA')
        locus_old = feature.qualifiers.get('old_locus_tag', 'NA')
        print('Locus tag:', locus)
        print('Old Locus tag:', locus_old)
ADD COMMENT
0
Entering edit mode

Thank you very much ! It works:)

ADD REPLY

Login before adding your answer.

Traffic: 1592 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