This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Parsing Genbank File: Get Locus Tag Vs Product

So that's all, just get this. Is there any already build perl/python module that could do this?

Thanks

bioperl biopython

Could you improve your question by giving an example input file (e.g. URL to an NCBI GenBank file) and the desired output (e.g. first few lines), since this is not clear. That would explain what you mean by product - which might be protein description, amino acid sequence, etc.

I don't think you got the most useful advice from SO. That module is an attempt to improve on something that works fine. Stick with the better supported, tried and tested original from BioPerl. Start with the Bio::SeqIO HOWTO and the Feature Annotation HOWTO.

Hi Neil, I'll dig a little more into BioPerl features, still very new for me. Thanks for your reply.

1 answer

Having read your question on StackOverflow (please don't double post like this), here's a minimal Biopython answer:

import sys
from Bio import SeqIO
filename = sys.argv[1] # Takes first command line argument input filename
for record in SeqIO.parse(filename, "genbank"):
    for feature in record.features:
        if feature.type == "CDS":
            locus_tag = feature.qualifiers.get("locus_tag", ["???"])[0]
            product = feature.qualifiers.get("product", ["???"])[0]
            print("%s\t%s" % (locus_tag, product))

With minor changes you can write this out to a file instead.

Log in to answer this question.