eftsung / pygr

Automatically exported from code.google.com/p/pygr
0 stars 0 forks source link

sqlgraph.GraphView unpickle-able error #54

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Python 2.5.2 (r252:60911, Aug  8 2008, 09:22:44)
[GCC 4.3.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygr.Data
>>> from ensembl import adaptor
>>> from pygr import sqlgraph
>>> conn = pygr.Data.Bio.Server.Ensembl.Ensembldb()
>>> translationTB =
sqlgraph.SQLTable('homo_sapiens_core_47_36i.translation',
itemClass=sqlgraph.TupleO, serverInfo=conn)
>>> exonTB = sqlgraph.SQLTable('homo_sapiens_core_47_36i.exon',
itemClass=sqlgraph.TupleO, serverInfo=conn)
>>> cursor = translationTB.cursor
>>> sql_statement = 'SELECT t3.exon_id FROM
homo_sapiens_core_47_36i.translation AS tr,
homo_sapiens_core_47_36i.exon_transcript AS t1,
homo_sapiens_core_47_36i.exon_transcript AS t2,
homo_sapiens_core_47_36i.exon_transcript AS t3 WHERE tr.translation_id = %s
AND tr.transcript_id = t1.transcript_id AND t1.transcript_id =
t2.transcript_id AND t2.transcript_id = t3.transcript_id AND t1.exon_id =
tr.start_exon_id AND t2.exon_id = tr.end_exon_id AND t3.rank >= t1.rank AND
t3.rank <= t2.rank ORDER BY t3.rank'
>>> translationExons = sqlgraph.GraphView(translationTB, exonTB,
sql_statement, cursor)
>>> translation = translationTB[15121]
>>> exons = translationExons[translation]
>>> for e in exons:
...     print e.id
...
95160
95020
95035
95172
95110
95101
95088
95081
95069
95059
95050
>>> translationExons.__doc__ = 'Ensembl translation -> exons GraphView,
homo_sapiens_core_47_36i'
>>>
pygr.Data.Bio.Ensembl.GraphView.homo_sapiens_core_47_36i.translationExons =
translationExons
>>> pygr.Data.save()

qing@1[ensembl]$ python -i
Python 2.5.2 (r252:60911, Aug  8 2008, 09:22:44)
[GCC 4.3.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygr.Data
>>> from ensembl import adaptor
>>> from pygr import sqlgraph
>>> tExons =
pygr.Data.Bio.Ensembl.GraphView.homo_sapiens_core_47_36i.translationExons()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/qing/workspace2008/pygr/pygr/Data.py", line 1103, in __call__
    return getResource(self._path,layer=self._layer,*args,**kwargs)
  File "/home/qing/workspace2008/pygr/pygr/Data.py", line 725, in __call__
    obj = db.__getitem__(id,download) # TRY TO OBTAIN FROM THIS DATABASE
  File "/home/qing/workspace2008/pygr/pygr/Data.py", line 479, in __getitem__
    obj = self.finder.loads(s) # RUN THE UNPICKLER ON THE STRING
  File "/home/qing/workspace2008/pygr/pygr/Data.py", line 669, in loads
    obj=unpickler.load() # ACTUALLY UNPICKLE THE DATA
  File "/usr/lib/python2.5/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.5/pickle.py", line 1217, in load_build
    setstate(state)
  File "/home/qing/workspace2008/pygr/pygr/classutil.py", line 148, in
standard_setstate
    self.__init__(**state)
TypeError: __init__() got an unexpected keyword argument 'serverInfo'

Original issue reported on code.google.com by jqian....@gmail.com on 19 Dec 2008 at 8:14

GoogleCodeExporter commented 8 years ago
added kwargs pass-through to MapView, which uses the serverInfo argument.

Original comment by cjlee...@gmail.com on 7 Jan 2009 at 12:45

GoogleCodeExporter commented 8 years ago

Original comment by mare...@gmail.com on 21 Feb 2009 at 2:07

GoogleCodeExporter commented 8 years ago
Hi Jenny,
please verify the fix to this bug that you reported, and then change its status 
to
Closed.  We are now requiring that each fix be verified by someone other than 
the
developer who made the fix.

Thanks!

Chris

Original comment by cjlee...@gmail.com on 5 Mar 2009 at 12:24

GoogleCodeExporter commented 8 years ago
'unpicklingMode' Error.

Note:  In the attached script issue54.py, when constructing an GraphView 
object, I've
passed the 'serverInfo=conn' as a keyword argument to GraphView:  

translationExons = sqlgraph.GraphView(translationTB, exonTB, sql_statement, 
cursor,
serverInfo=conn)

Did I miss something else?

Thanks,
~ Jenny

-> 
qing@2[ensembl]$ python issue54.py
95160
95020
95035
95050
95059
95069
95081
95088
95101
95110
95172

->
qing@2[ensembl]$ python -i
Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygr.Data
>>> pygr.Data.dir('Bio.Ensembl')
['Bio.Ensembl.GraphView.homo_sapiens_core_47_36i.translationExons']
>>> myGraph = 
pygr.Data.Bio.Ensembl.GraphView.homo_sapiens_core_47_36i.translationExons()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pygr/Data.py", line 1126, in __call__
  File "pygr/Data.py", line 743, in __call__
  File "pygr/Data.py", line 495, in __getitem__
  File "pygr/Data.py", line 687, in loads
  File "/usr/lib/python2.5/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.5/pickle.py", line 1217, in load_build
    setstate(state)
  File "pygr/classutil.py", line 148, in standard_setstate
  File "/home/qing/workspace2009/pyensembl/pygr/sqlgraph.py", line 1808, in __init__
    MapView.__init__(self, sourceDB, targetDB, viewSQL, cursor, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'unpicklingMode'

Original comment by jqian....@gmail.com on 8 Mar 2009 at 12:56

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Jenny,
added another minor fix that should solve this.  Please test it from the latest 
code
in the public repository.  Unfortunately, we don't have a test for this issue 
in the
automated test suite.  We should add one!

-- Chris

Original comment by cjlee...@gmail.com on 12 Mar 2009 at 8:29

GoogleCodeExporter commented 8 years ago

Original comment by mare...@gmail.com on 13 Mar 2009 at 1:01

GoogleCodeExporter commented 8 years ago
Hi Chris,

After adding *OneToOneRelation* to two lines in Data.py as you suggested:

line1 
from metabase import ResourceServer, dumps, OneToManyRelation, \
     ManyToManyRelation, PygrDataNotPortableError, PygrDataNotFoundError, \
     PygrDataMismatchError, PygrDataEmptyError, PygrDataReadOnlyError, \
     PygrDataSchemaError, PygrDataNoModuleError, ResourceZone

line2
the __all__ list at the bottom of Data.py

I am able to save a GraphView object to pygr.Data successfully using the 
modified
issue54.py.

Saved GraphView can be accessed via pygr.Data and used as a mapper to retrieve 
target
objects, given a particular source object.

qing@1[ensembl]$ python -i
Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pygr import sqlgraph
>>> from ensembl import adaptor
>>> import pygr.Data
>>> pygr.Data.dir('Bio.Annotation.Ensembl')
['Bio.Annotation.Ensembl.homo_sapiens_core_47_36i.exonTB',
'Bio.Annotation.Ensembl.homo_sapiens_core_47_36i.translationTB']
>>> translationTB =
pygr.Data.getResource('Bio.Annotation.Ensembl.homo_sapiens_core_47_36i.translati
onTB')
>>> translation = translationTB[15121]
>>> pygr.Data.dir('Bio.Ensembl')
['Bio.Ensembl.GraphView.homo_sapiens_core_47_36i.translationExons']
>>> translationExons =
pygr.Data.getResource('Bio.Ensembl.GraphView.homo_sapiens_core_47_36i.translatio
nExons')
>>> exons = translationExons[translation]
>>> for e in exons:
...     print e.id
...
95160
95020
95035
95050
95059
95069
95081
95088
95101
95110
95172
>>>  

Cheers,
Jenny     

Original comment by jennyhap...@gmail.com on 22 Apr 2009 at 7:08

Attachments:

GoogleCodeExporter commented 8 years ago
OneToOneRelation has been added back to Data.py in the master branch, so please 
go
ahead and change the status of this issue to Closed.

Thanks!

Chris

Original comment by cjlee...@gmail.com on 22 Apr 2009 at 5:21

GoogleCodeExporter commented 8 years ago

Original comment by jqian....@gmail.com on 22 Apr 2009 at 5:52