Skip to content

Commit

Permalink
Fixed extract transcripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjvincent committed Jun 5, 2018
1 parent 4d69e3c commit e054f18
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
History
-------

0.2.2 (06/04/2018)
~~~~~~~~~~~~~~~~~~

* Fixed extract transcripts

0.2.1 (05/30/2018)
~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion g2gtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '0.2.1'
__version__ = '0.2.2'
__author__ = 'Matthew Vincent and Kwangbom \"KB\" Choi, The Jackson Laboratory'
__email__ = 'matt.vincent@jax.org'
36 changes: 22 additions & 14 deletions g2gtools/gtf_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@
WHERE l.gtf_key = g._key
AND l.attribute_key = a._key
AND a.gtf_attribute = 'exon_number') AS exon_number
FROM gtf g
FROM gtf g,
gtf_types t
AND g.type_key = t._key
AND t.gtf_type in ('exon', 'transcript', 'gene')
"""

SQL_TRANSCRIPTS_SIMPLE_ORDER_BY = " ORDER BY g._key "
Expand Down Expand Up @@ -607,8 +610,6 @@ def get_transcripts_simple(db):
cursor.execute(sql)

transcripts = OrderedDict()
exons = OrderedDict()


counter = 0
for r in cursor:
Expand Down Expand Up @@ -639,13 +640,15 @@ def get_transcripts_simple(db):
elif r['transcript_id'] is not None and r['ensembl_id'] is not None \
and (r['gene_id'] != r['ensembl_id']):
# exon
#LOG.debug("ADDING exon")
exon = exons.get(r['ensembl_id'], Exon(r['ensembl_id'], r['seqid'], r['start'], r['end'], r['strand']))
LOG.debug("ADDING exon")
LOG.debug('{}:{}'.format(r['ensembl_id'], r['exon_number']))
exon = Exon(r['ensembl_id'], r['seqid'], r['start'], r['end'], r['strand'])
exon.gene_id = r['gene_id']
exon.transcript_ids[r['transcript_id']] = r['transcript_id']
exon.exon_number = r['exon_number']

exons[r['ensembl_id']] = exon

transcripts[r['transcript_id']].exons[r['ensembl_id']] = exon


## ** Addition
Expand Down Expand Up @@ -680,15 +683,20 @@ def get_transcripts_simple(db):


LOG.debug("Simplifying transcripts")
transcripts = {transcript.ensembl_id: transcript for i, transcript in transcripts.items()}
#transcripts = {transcript.ensembl_id: transcript for i, transcript in transcripts.items()}
#LOG.debug(transcripts)

for _id, exon in exons.items():
#LOG.debug('_id={}\texon={}'.format(_id, str(exon)))
for _tid in exon.transcript_ids:
#LOG.debug('_tid={}'.format(_id))
#LOG.debug(transcripts[_tid])
transcripts[_tid].exons[exon.ensembl_id] = exon
for i, transcript in transcripts.items():
LOG.debug("Transcript={0}".format(transcript))

for ensembl_id, exon in transcript.exons.items():
LOG.debug("Exon ID={0};{1}".format(ensembl_id, exon))

#for _id, exon in exons.items():
# LOG.debug('_id={}\texon={}'.format(_id, str(exon)))
# for _tid in exon.transcript_ids:
# #LOG.debug('_tid={}'.format(_id))
# LOG.debug(transcripts[_tid])
# transcripts[_tid].exons[exon.ensembl_id] = exon

cursor.close()
conn.close()
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.1
current_version = 0.2.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

setup(
name='g2gtools',
version='0.2.1',
version='0.2.2',
description="A suite of tools for the reconstruction of personal diploid genomes and better coordinate conversion",
long_description=readme + '\n\n' + history,
author='Matthew J. Vincent and Kwangbom "KB" Choi, The Jackson Laboratory',
Expand Down

0 comments on commit e054f18

Please sign in to comment.