I am trying to read a long amino acid string into a Biopython Genbank record object so that a Genbank file can be written. Here is a truncated example
FEATURES Location/Qualifiers
CDS 687..3158
/gene="AXL2"
/translation="MTQLQISLLLTATISLLHLVVATPYEAYPIGKQYPPVARVNESF TFQISNDTYKSSVDKTAQITYNCFDLPSWLSFDSSSRTFSGEPSSDLLSDANTTLYFN VILEGTDSADSTSLNNTYQFVVTNRPSISLSSDFNLLALLKNYGYTNGKNALKLDPNE YGSQKTVDTEKLFDLEAPEKEKRTSRDVTMSSLDPWNSNISPSPVRKSVTPSPYNVTK HRNRHLQNIQDSQSGKNGITPTTMSTSSSDDFVPVKDGENFCWVHSMEPDRRPSKKRL VDFSNKSNVNVGQVKDIHGRIPEML"
My code reads a csv file with the data I want put into the Genbank file
feature = Feature()
feature.key = "CDS"
feature.location = "1..{}".format(len(row['DNA']))
feature.qualifiers = ["/translation=", "{}".format(row['Seq'])]
container.features.append(feature)
with open(row['FullCloneName'] + '.gb', 'w') as output_file:
output_file.write(str(container))
However, I get this error:
File "/usr/local/lib/python2.7/dist-packages/Bio/GenBank/Record.py", line 631, in __str__
if no_space_key in qualifier.key:
AttributeError: 'str' object has no attribute 'key'
Can someone explain how the Feature method from Genbank Record source takes information from the Qualifier method? My input string has no breaks. It is a long 120 character string. How does this method break up the long string to format it for the Genbank file? Do I need to break up the string with a split character ','?
class Feature(object):
604 """Hold information about a Feature in the Feature Table of GenBank record.
605
606 Attributes:
607 - key - The key name of the feature (ie. source)
608 - location - The string specifying the location of the feature.
609 - qualifiers - A listing Qualifier objects in the feature.
610
611 """
612
613 - def __init__(self):
614 """Initialize."""
615 self.key = ''
616 self.location = ''
617 self.qualifiers = []
618
619 - def __str__(self):
620 """Return feature as a GenBank format string."""
621 output = Record.INTERNAL_FEATURE_FORMAT % self.key
622 output += _wrapped_genbank(self.location, Record.GB_FEATURE_INDENT,
623 split_char=',')
624 for qualifier in self.qualifiers:
625 output += " " * Record.GB_FEATURE_INDENT
626
627 # determine whether we can wrap on spaces
628 space_wrap = 1
629 for no_space_key in \
630 Bio.GenBank._BaseGenBankConsumer.remove_space_keys:
631 if no_space_key in qualifier.key:
632 space_wrap = 0
633
634 output += _wrapped_genbank(qualifier.key + qualifier.value,
635 Record.GB_FEATURE_INDENT, space_wrap)
636 return output
637
638
639 -class Qualifier(object):
640 """Hold information about a qualifier in a GenBank feature.
641
642 Attributes:
643 - key - The key name of the qualifier (ie. /organism=)
644 - value - The value of the qualifier ("Dictyostelium discoideum").
645
646 """
647
648 - def __init__(self):
649 """Initialize."""
650 self.key = ''
651 self.value = ''
Might be time to call in the experts @ Peter