On Tue, Sep 9, 2008 at 1:15 PM, Christopher Lee <[EMAIL PROTECTED]> wrote:
>
>
> On Sep 9, 2008, at 1:09 PM, Jenny Qing Qian wrote:
>
> > So, for the pygr 0.8 release, will the SQLTable and SQLGraph support
> > the order of iteration? So that I can implement the one-to-many
> > relationship between translation and exon properly, as discussed
> > during the sprint session at Caltech.
>
> Yes, let's do it! Probably the best place to start is for you to give
> me examples of the kinds of code or SQL expressions you are currently
> having to use to get the results you want, then we can figure out how
> to make the standard SQLTable and SQLGraph components support that.
class Translation(StableObj, BaseModel):
def get_all_exons(self):
transcript_id = self.transcript_id
start_exon_id = self.start_exon_id
end_exon_id = self.end_exon_id
...
exonAdaptor = coreDBAdaptor.get_adaptor('exon')
exons = exonAdaptor.fetch_all_by_translation(transcript_id,
start_exon_id, end_exon_id)
return exons
class ExonAdaptor(FeatureAdaptor):
def fetch_all_by_translation(self, transcript_id, start_exon_id,
end_exon_id):
cursor = self.cursor
# get the start_rank for the given transcript_id and the given
start_exon_id from the exon_transcript table
n = cursor.execute('select rank from %s.exon_transcript where
transcript_id = %%s and exon_id = %%s' %(self.db), (transcript_id,
start_exon_id))
t = cursor.fetchall()
if n != 1:
raise KeyError('Warning: duplicated!')
start_rank = t[0][0]
# get the end_rank for the given transcript_id and the given
end_exon_id from the exon_transcript table
n = cursor.execute('select rank from %s.exon_transcript where
transcript_id = %%s and exon_id = %%s' %(self.db), (transcript_id,
end_exon_id))
t = cursor.fetchall()
if n != 1:
raise KeyError('Warning: duplicated!')
end_rank = t[0][0]
# fetch all the exons for the given transcript_id between the
start_rank and end_rank inclusive from the exon_transcript table
n = cursor.execute('select exon_id from %s.exon_transcript where
transcript_id = %%s and rank >= %%s and rank <= %%s' %(self.db),
(transcript_id, start_rank, end_rank))
t = cursor.fetchall()
exons = []
if n == 0:
return exons
for row in t:
e = self[row[0]]
exons.append(e)
return exons
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---