I've been trying to save a gene nlmsa to worldbase and retrieve it
from another script, but when I try to load the saved object, I get:
AttributeError: 'pygr.cnestedlist.NLMSA' object has no attribute
'itemClass'
Details:
I've defined a class (seperate file) to hold gene info, looks like:
class Gene:
"""docstring for Gene"""
def __init__(self, name, id, start, stop, strand):
self.name = name # gene name
self.id = id # chromosome id
if strand == -1:
self.start = -stop
self.stop = -start
else:
self.start = start
self.stop = stop
self.strand = strand
I create Gene objects and store them in a dictionary.
g = Gene(pac_id, chrom, start, end, strand)
genes[name] = g
Then, create annotationDB:
genes_db = seqdb.AnnotationDB(genes, sorghum, annotationType='Gene:')
and then build nlmsa.
genes_map = cnestedlist.NLMSA('genes', 'w', pairwiseMode=True)
for v in genes_db.values():
genes_map.addAnnotation(v)
genes_map.__doc__= "Genes Map"
genes_map.build()
And then I proceed to save it to worldbase:
worldbase.Bio.Annotation.sorghum.genes = genes_map
worldbase.commit()
genes_map.close()
This script runs without any errors. says "Index files saved.
Note: the NLMSA.seqDict was not saved to a file.... "
In a seperate script I try to load it.
#!/usr/bin/env python
from pygr import worldbase
genome = worldbase.Bio.Seq.Genome.sorghum()
genes = worldbase.Bio.Annotation.sorghum.genes() # this is where the
error occurs:
Traceback (most recent call last):
File "testGenes.py", line 7, in ?
genes = worldbase.Bio.Annotation.sorghum.genes()
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/pygr-0.8.0.alpha2-py2.4-macosx-10.3-fat.egg/
pygr/metabase.py", line 1201, in __call__
return self._mdb(self._path, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/pygr-0.8.0.alpha2-py2.4-macosx-10.3-fat.egg/
pygr/metabase.py", line 649, in __call__
obj = self.load(resID, objdata, docstr)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/pygr-0.8.0.alpha2-py2.4-macosx-10.3-fat.egg/
pygr/metabase.py", line 622, in load
self.bind_schema(resID, obj) # BIND SHADOW ATTRIBUTES IF ANY
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/pygr-0.8.0.alpha2-py2.4-macosx-10.3-fat.egg/
pygr/metabase.py", line 668, in bind_schema
self.bind_property(obj, attr, **rules)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/pygr-0.8.0.alpha2-py2.4-macosx-10.3-fat.egg/
pygr/metabase.py", line 676, in bind_property
targetClass = get_bound_subclass(obj,'itemClass') # CLASS USED FOR
CONSTRUCTING ITEMS
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/pygr-0.8.0.alpha2-py2.4-macosx-10.3-fat.egg/
pygr/classutil.py", line 340, in get_bound_subclass
targetClass = getattr(obj,classattr)
AttributeError: 'pygr.cnestedlist.NLMSA' object has no attribute
'itemClass'
I am not sure where itemClass is coming from. Is it having problems
reading the Gene class? Should I be providing nlmsa with that info
somewhere?
AnnotationDB has itemClass which defaults to AnnotationSeq, wondering
if AnnotationDB needs to know about my class. Or does my Gene class
need to extend AnnotationSeq?
thanks,
rochak
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pygr-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pygr-dev?hl=en
-~----------~----~----~----~------~----~------~--~---