In [1]: from djensembl.djpyensembl.models import CoordSystem
In [2]: CoordSystem.objects.all()
Out[2]: [
5 objects are returned from that call, corresponding to the 5 coord_systems. Just like in the tutorial, that naming system is not very informative. So, I modified the CoordSystem model just like they did by adding the __unicode__ method as such:
def __unicode__(self):
return str(self.coord_system_id) + ' -> ' + self.name
Now I get this:
In [1]: from djensembl.djpyensembl.models import CoordSystem
In [2]: CoordSystem.objects.all()
Out[2]: [
I doubt that's ultimately what I want but it works for now.
Some of the built-in generic behaviors don't work well with this db due to the particular use/misuse/nonuse of the 'id' column. In a Django-centric-developed app, you could issue statements like:
c = CoordSystem.objects.get(pk=1)
But, since the table doesn't have an id column which is the primary key, auto-incremented, this call fails, as does c = CoordSystem.objects.get(id=1), obviously.
What does work is c = CoordSystem.objects.get(coord_system_id=17). I presume this is one of the 'drawback' of using legacy db's where the table structure is not designed with Django's shortcuts in mind. No problemo.

1 comment:
I'm interested to see you are trying to wrap ensembl using python. FYI, I'm doing the same thing, but using SQLAlchemy, to be included as part of PyCogent (see http://sourceforge.net/projects/pycogent). Perhaps we could share some of our experiences in disentangling the Ensembl MySQL tables?
Gavin
Post a Comment