Skip to content

Commit

Permalink
fixing coordinate bug in remove-short-exons mode #177
Browse files Browse the repository at this point in the history
  • Loading branch information
akahles committed Feb 6, 2023
1 parent b683178 commit 560d818
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion spladder/core/gen_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def gen_graphs(genes, bam_fnames, options=None):
print('Removing short exons ...', file=fd_log)
genes = remove_short_exons(genes, options)
for i in range(genes.shape[0]):
if np.any(genes[i].splicegraph.vertices[:, 1] - genes[i].splicegraph.vertices[:, 0] < options.remove_exons['min_exon_len_remove']):
if np.any(genes[i].splicegraph.vertices[1, :] - genes[i].splicegraph.vertices[0, :] < options.remove_exons['min_exon_len_remove']):
print('WARNING: could not remove all short exons', file=sys.stderr)
print('... done.\n', file=fd_log)

Expand Down
6 changes: 3 additions & 3 deletions spladder/editgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def remove_short_exons(genes, options):

### extend terminal exons to terminal_short_extend if they are shorter than terminal_short_len
if genes[i].splicegraph.vertices[1, 0] - genes[i].splicegraph.vertices[0, 0] < options.remove_exons['terminal_short_len']:
genes[i].splicegraph.vertices[0, 0] = genes[i].splicegraph.vertices[1, 0] - options.remove_exons['terminal_short_extend']
genes[i].splicegraph.vertices[0, 0] -= options.remove_exons['terminal_short_extend']
genes[i].start = min(genes[i].start, genes[i].splicegraph.vertices[0, 0])

if genes[i].splicegraph.vertices[1, -1] - genes[i].splicegraph.vertices[0, -1] < options.remove_exons['terminal_short_len']:
genes[i].splicegraph.vertices[1, -1] = genes[i].splicegraph.vertices[1, -1] + options.remove_exons['terminal_short_extend']
genes[i].splicegraph.vertices[1, -1] += options.remove_exons['terminal_short_extend']
genes[i].stop = max(genes[i].stop, genes[i].splicegraph.vertices[1, -1])

### check for very short exons and insert an edge that allows skipping them
Expand Down Expand Up @@ -67,7 +67,7 @@ def remove_short_exons(genes, options):
keep_idx = np.where(~np.in1d(np.array(np.arange(genes[i].splicegraph.vertices.shape[1])), exons_remove_idx))[0]
genes[i].splicegraph.subset(keep_idx)

keep_idx = np.where(~np.in1d(np.arange(len(genes[i])), rm_idx))[0]
keep_idx = np.where(~np.in1d(np.arange(len(genes)), rm_idx))[0]
genes = genes[keep_idx]

if options.verbose:
Expand Down

0 comments on commit 560d818

Please sign in to comment.