This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How can I handle UnknownSeq?

Hello!

I have wrote this code in Python:

from Bio import SeqIO 
fasta_file="OXA_finds.fasta" 
output=open(fasta_file,'w') 
gb_file="OXA_test.gb" 
wanted=["Beta-lactamase class D"] 
for record in SeqIO.parse(open(gb_file,"r"),"genbank"):
    print("Name %s, %i features" % (record.name,len(record.features)))
    print(repr(record.seq))
    for f in record.features:
        if f.type=="CDS" and "product" in f.qualifiers:
            product=f.qualifiers["product"][0]
            if product in wanted:
                output.write(">%s,%s from %s\n%s\n" % (f.qualifiers['product'][0],f.qualifiers['locus_tag'][0],record.name,f.extract(record.seq)))

output.close()

So this code gives me a lot 'N' in FASTA file, and I want a dna string here. How can I handle that?

Thanks in advance!

biopython gene

1 answer

The Ns are not a problem, you often find Ns in sequences. N corresponds to any nucleotide (not a gap). It means they didn't succeed to determine the base during the sequencing at this position.

If you prefer, adding a "if" statement, you can choose to avoid to work with sequences containing any N. I think is not a good idea because even with the presence of N, as they succeeded to determine that the sequence has "Beta-lactamase class D" as product, it means there is enough information in the sequence for determining the function (domains, orthology, etc ...).

Log in to answer this question.