Skip to content

Commit

Permalink
temp version.. not working yet.. just saving
Browse files Browse the repository at this point in the history
  • Loading branch information
kalahasty committed Jan 22, 2016
1 parent 875ab11 commit 85257ce
Show file tree
Hide file tree
Showing 19 changed files with 7,076 additions and 203 deletions.
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@


extensions = [
Extension('taco.lib.cbedgraph',
sources=['taco/lib/cbedgraph.pyx'],
Extension('taco.lib.cBedGraph',
sources=['taco/lib/cBedGraph.pyx'],
include_dirs=[numpy_inc]),
Extension('taco.lib.cChangePoint',
sources=['taco/lib/cChangePoint.pyx'],
include_dirs=[numpy_inc])
]

Expand All @@ -31,7 +34,7 @@ def main():
description='transcriptome meta-assembly from rna-seq',
author='Matthew Iyer and Yashar Niknafs',
author_email='[email protected]',
requires=['numpy', 'networkx'],
requires=['numpy', 'networkx', 'h5py'],
license='GPL',
platforms='Linux',
url='https://github.com/yniknafs/taco',
Expand Down
39 changes: 29 additions & 10 deletions taco/lib/assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ def get_splice_graphs(locus):
# return transcript_graphs


def assemble(gtf_file, output_dir,
def assemble(gtf_file,
expr_h5_file,
chrom_sizes_file,
node_gtf_file,
output_dir,
guided_strand=False,
guided_ends=False,
guided_assembly=False):
Expand All @@ -76,6 +80,10 @@ def assemble(gtf_file, output_dir,
raw_bgfilehd = Locus.open_bedgraphs(file_prefix)
file_prefix = os.path.join(output_dir, 'loci.resolved')
resolved_bgfilehd = Locus.open_bedgraphs(file_prefix)
# setup expression hdf5
expr_h5f = Locus.open_expression_hdf5(expr_h5_file, chrom_sizes_file)
# setup node gtf file
node_fileh = open(node_gtf_file, 'w')

# parse gtf file
for interval, gtf_lines in GTF.parse_loci(open(gtf_file)):
Expand All @@ -86,9 +94,9 @@ def assemble(gtf_file, output_dir,
logging.debug('Locus %s:%d-%d: '
'%d transfrags (+: %d, -: %d, .: %d)' %
(chrom, start, end, len(t_dict),
len(locus.strand_transfrags[Strand.POS]),
len(locus.strand_transfrags[Strand.NEG]),
len(locus.strand_transfrags[Strand.NA])))
len(locus.get_transfrags(Strand.POS)),
len(locus.get_transfrags(Strand.NEG)),
len(locus.get_transfrags(Strand.NA))))
# write raw bedgraph files
locus.write_bedgraph(raw_bgfilehd)
# resolve unstranded transcripts
Expand All @@ -97,16 +105,27 @@ def assemble(gtf_file, output_dir,
logging.debug('Locus %s:%d-%d: %d '
'resolved (+: %d, -: %d, .: %d)' %
(chrom, start, end, num_resolved,
len(locus.strand_transfrags[Strand.POS]),
len(locus.strand_transfrags[Strand.NEG]),
len(locus.strand_transfrags[Strand.NA])))
len(locus.get_transfrags(Strand.POS)),
len(locus.get_transfrags(Strand.NEG)),
len(locus.get_transfrags(Strand.NA))))
# write bedgraph files after strand resolved
locus.write_bedgraph(resolved_bgfilehd)
locus.write_expression_hdf5(expr_h5f)

# create splice graphs
for sg in get_splice_graphs(locus):
print 'splice graph', sg.chrom, Strand.to_gtf(sg.strand), sg.start, sg.end
pass
for slocus in locus.L:
if slocus is None:
continue
G = slocus.create_splice_graph()
print len(G)

# for sg in get_splice_graphs(locus):
# pass
# for line in sg.get_change_point_data():
# print >>changept_fileh, line

# close expression
expr_h5f.close()

# close bedgraph files
Locus.close_bedgraphs(raw_bgfilehd)
Expand Down
5 changes: 2 additions & 3 deletions taco/lib/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import collections
import logging
import os
import numpy as np

__author__ = "Matthew Iyer and Yashar Niknafs"
__copyright__ = "Copyright 2015"
Expand All @@ -23,15 +22,15 @@
class TacoError(Exception):
pass

FLOAT_DTYPE = np.float64

Exon = collections.namedtuple('Exon', ['start', 'end'])


class Strand:
POS = 0
NEG = 1
NA = 2

STRANDS = [POS, NEG, NA]
NAMES = ['pos', 'neg', 'none']
FROM_GTF = {'+': POS, '-': NEG, '.': NA}
TO_GTF = {POS: '+', NEG: '-', NA: '.'}
Expand Down
2 changes: 1 addition & 1 deletion taco/lib/bedgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import collections
import numpy as np

from taco.lib.base import FLOAT_DTYPE
from taco.lib.dtypes import FLOAT_DTYPE

__author__ = "Matthew Iyer and Yashar Niknafs"
__copyright__ = "Copyright 2016"
Expand Down
Loading

0 comments on commit 85257ce

Please sign in to comment.