smithlabcode / ribotricer

A tool for accurately detecting actively translating ORFs from Ribo-seq data
http://doi.org/djv4
GNU General Public License v3.0
28 stars 8 forks source link

[BUG] speficying unstranded data ('no') leads to error #153

Open pinin4fjords opened 3 months ago

pinin4fjords commented 3 months ago

Description

Just experimenting with --stranded

What I Did

ribotricer detect-orfs \
    --bam SRX11780888_chr20.bam \
    --ribotricer_index homo_sapiens_chr20_candidate_orfs.tsv \
    --stranded no \
    --prefix test \
    --phase_score_cutoff 0.05

Error:

Mar 14 10:56:30 ..... started ribotricer detect-orfs
Mar 14 10:56:30 ... started parsing ribotricer index file
Mar 14 10:56:30 ... started reading bam file                                                                                                                                               
[W::hts_idx_load3] The index file is older than the data file: SRX11780888_chr20.bam.bai
  0%|                                                                                                                                                        | 0/566761 [00:00<?, ?reads/s][W::hts_idx_load3] The index file is older than the data file: SRX11780888_chr20.bam.bai
no
Traceback (most recent call last):                                                                                                                                                         
  File "/path/to/mambaforge/envs/ribotricer/bin/ribotricer", line 10, in <module>
    sys.exit(cli())
  File "/path/to/mambaforge/envs/ribotricer/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/path/to/mambaforge/envs/ribotricer/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/path/to/mambaforge/envs/ribotricer/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/path/to/mambaforge/envs/ribotricer/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/path/to/mambaforge/envs/ribotricer/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/path/to/mambaforge/envs/ribotricer/lib/python3.10/site-packages/ribotricer/cli.py", line 244, in detect_orfs_cmd
    detect_orfs(
  File "/path/to/mambaforge/envs/ribotricer/lib/python3.10/site-packages/ribotricer/detect_orfs.py", line 400, in detect_orfs
    alignments, read_length_counts = split_bam(bam, protocol, prefix, read_lengths)
  File "/path/to/mambaforge/envs/ribotricer/lib/python3.10/site-packages/ribotricer/bam.py", line 122, in split_bam
    alignments[length][strand][(chrom, pos + 1)] += 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Without looking too hard it seems that pos does not get defined for unstranded data here.

Input files:

test_files.zip

saketkc commented 3 months ago

Hi @pinin4fjords, we currently do not support unstranded data (and should probably make it explicit until we do). For now, my suggestion would be to use either of the strands and proceed with downstream tasks.

pinin4fjords commented 3 months ago

OK- but documentation states:

You can directly assign the strandedness using option --stranded, it can be 'yes', 'no', or 'reverse'. 

So you might want to get rid of the 'no' there.

saketkc commented 3 months ago

Indeed, that's right. Thanks for pointing it out.