eftsung / pygr

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

sqlgraph.GraphView ORDER-BY bug #53

Closed GoogleCodeExporter closed 8 years ago

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

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
>>> 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
...
95069
95088
95101
95020
95050
95035
95081
95110
95059
95160
95172

What is the expected output? 

mysql> 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 =
15121 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; 

+---------+
| exon_id |
+---------+
|   95160 |
|   95020 |
|   95035 |
|   95050 |
|   95059 |
|   95069 |
|   95081 |
|   95088 |
|   95101 |
|   95110 |
|   95172 |
+---------+

Please use labels and text to provide additional information.

Since 'ORDER BY' is such a common operation in a sql muti-table join
statement, it would be really cool if sqlgraph.GraphView could support it.

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

GoogleCodeExporter commented 8 years ago
had to change GraphViewEdgeDict from a dict (which won't retain the original 
order of
keys) subclass to DictMixin subclass.

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

GoogleCodeExporter commented 8 years ago

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

GoogleCodeExporter commented 8 years ago
Anybody else has problem running the sqltable_test.py?  When I tried to run it, 
I got
'cannot import name MapView' and 'cannot import name GraphView' errors.

qing@1[tests]$ python protest.py sqltable_test.py
Traceback (most recent call last):
  File "protest.py", line 126, in <module>
    run_all_tests(find_tests(*(sys.argv[1:])))
  File "protest.py", line 69, in find_tests
    exec 'import %s' % path
  File "<string>", line 1, in <module>
  File "/home/qing/workspace2008/pygr/tests/sqltable_test.py", line 3, in <module>
    from pygr.sqlgraph import SQLTable,getNameCursor,MapView,GraphView,DBServerInfo
ImportError: cannot import name MapView

I can import both modules using a python interactive session:
>>> from pygr.sqlgraph import SQLTable
>>> from pygr.sqlgraph import MapView
>>> from pygr.sqlgraph import GraphView
>>> from pygr.sqlgraph import getNameCursor

Original comment by jqian....@gmail.com on 22 Feb 2009 at 8:33

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:23

GoogleCodeExporter commented 8 years ago

Original comment by jqian....@gmail.com on 7 Mar 2009 at 11:49

GoogleCodeExporter commented 8 years ago

Original comment by mare...@gmail.com on 25 Jun 2009 at 1:28