Body: <p>It appers when a gene has a negative strand then I need to reverse the sequence. Unfortunately, I got the following error:</p>
  <pre><code>print(&quot;1&quot; + '&quot;' + str(fastaIdx) + '&quot;' + '&quot;' + str(mrna_id) + &quot;'&quot; + db.strand())
  AttributeError: 'FeatureDB' object has no attribute 'strand'
  </code></pre>
  <p>with the following code:</p>
  <pre><code>import gffutils
  import pyfaidx
  from Bio.Seq import Seq
  from Bio.Alphabet import IUPAC
  
  def getPeptideSeq(fastaIDX, db, mrna_id):
      print(&quot;Petide Sequence&quot;)
      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(&quot;1&quot; + '&quot;' + str(fastaIdx) + '&quot;' + '&quot;' + str(mrna_id) + &quot;'&quot; + db.strand())
  
          seq = getPeptideSeq(fastaIdx, db, mrna_id)
  </code></pre>
  <p>What did I miss?</p>
  <p>Thank you in advance,</p>
  <p>Best wishes,</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-22T16:43:41.793Z
Comments.Text: 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?
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-26T23:20:58.493Z
Comments.Text: 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: https://pythonhosted.org/gffutils/autodocs/gffutils.Feature.html. Was it supposed to be `db[mrna_id].strand` or something like that.
Comments.UserDisplayName: Maximilian Press
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-28T00:55:08.427Z
Comments.Text: Thank you, it worked.
Comments.UserDisplayName: user3523406
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-29T04:42:57.530Z
Comments.Text: If something worked, can you please write it up as an accepted answer? This keeps the StackExchange answer-fishing bots happy.
Comments.UserDisplayName: gringer
Tags: <python><gffutils>
Title: AttributeError: 'FeatureDB' object has no attribute 'strand'
ThreadText: # AttributeError: 'FeatureDB' object has no attribute 'strand'
  
  (Asked by: username_0 on 2021-09-21)
  
  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?
  
  Thank you in advance,
  
  Best wishes,
  
  **Tags:** python, gffutils
  
  > **Comments:**
  > **username_1**: 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?  
  > **username_2**: 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: https://pythonhosted.org/gffutils/autodocs/gffutils.Feature.html. Was it supposed to be `db[mrna_id].strand` or something like that.  
  > **username_0**: Thank you, it worked.  
  > **username_3**: If something worked, can you please write it up as an accepted answer? This keeps the StackExchange answer-fishing bots happy.  
  
  ---
  
  ## 0 answers
  
  