Hi all,
I have information about a gene stored in a Python Class as shown below
class Gene():
"""
Gene:
Class which stores all the information about a gene from GenBank file
locus_tag, note, translation, protein_id, product are
all set to N/A by default and start, stop, codon_start,
transl_table and strand are 0
"""
def __init__(self,locus_tag = "N/A", gene = "N/A",
start = 0, stop = 0, note = "N/A", codon_start = 0,
transl_table = 0, product = "N/A", protein_id = "N/A",
translation = "N/A", strand = 0):
self.__locus_tag = locus_tag
self.__note = note
self.__start = start
self.__stop = stop
self.__codon_start = codon_start
self.__transl_table = transl_table
self.__product = product
self.__protein_id = protein_id
self.__translation = translation
self.__strand = strand
self.__gene = gene
All these are arranged in a circular linked list and I want to write this information into a genbank file, and have come up with the following
def record(self):
"""
Returns a record of a gene to be written to a genbank file
"""
z = self.get_strand()
sequence = Seq(self.get_translation(), IUPAC.protein)
rec = SeqRecord(sequence,
id = self.get_protein(),
name = self.get_gene(),
description = self.get_note())
loc = SeqFeature(FeatureLocation(
(self.get_start(),self.get_stop()),
type="CDS",strand=self.get_strand()))
rec.features = [loc]
print(rec.format("genbank"))
but every time I run this code I get this error:
TypeError: __init__() got an unexpected keyword argument 'type'
Please does anyone know how to do this or has a better way of doing this?
Thanks in advance
Thanks a lot, greatly appreciated
I got this error,
what I'm missing?
That's for CDS sequences, but what if I want the same complete file that is downloaded from the browser?
Thanks!
The entity denoted
self
in the code being debugged here was an instance of a class OP's created. I don't think it is 1:1 withSeqRecord
. If you're trying to write aSeqRecord
in GenBank format, I think you'd just pass yourSeqRecord
throughSeqIO.write(records, handle, "genbank")
. I'm not a regular user of BioPython, so I can't comment further on that.