# AttributeError: 'FeatureDB' object has no attribute 'strand'

It appers when a gene has a negative strand then I need to reverse the sequence. Unfortunately, I got the following error:

print("1" + '"' + str(fastaIdx) + '"' + '"' + str(mrna_id) + "'" + db.strand())
AttributeError: 'FeatureDB' object has no attribute 'strand'


with the following code:

import gffutils
import pyfaidx
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC

def getPeptideSeq(fastaIDX, db, mrna_id):
print("Petide Sequence")
return Seq(getCdsSeq(fastaIDX, db, db[mrna_id]), IUPAC.unambiguous_dna).translate()

if __name__ == '__main__':
db = gffutils.FeatureDB('annotation.db', keep_order=True)
fastaIdx = pyfaidx.Fasta('assembly.fasta')
print("1" + '"' + str(fastaIdx) + '"' + '"' + str(mrna_id) + "'" + db.strand())

seq = getPeptideSeq(fastaIdx, db, mrna_id)


What did I miss?

• Presumably the field isn't called strand. Can you just print all the available fields in your db object? Also, what input are you giving? Can you provide a minimal, full example that we can try? Sep 22 '21 at 16:43
• gffutils databases don't typically have a single strand as they contain many features with different strands. It is typically the Feature objects within the database that have a strand attribute: pythonhosted.org/gffutils/autodocs/gffutils.Feature.html. Was it supposed to be db[mrna_id].strand or something like that. Sep 26 '21 at 23:20