Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'pysam.calignmentfile.AlignedSegment' object has no attribute 'reference_name' #128

Open
kerendanan1511 opened this issue Apr 21, 2024 · 1 comment

Comments

@kerendanan1511
Copy link

kerendanan1511 commented Apr 21, 2024

Hi,

I am tring to get sashimi plots for my test sample that was already aligned and sorted, after getting rmats-turbo output:

out_sa=/a/home/cc/lifesci/kerendanan1/rmats_turbo/test_N010/rmats/output_dir/sashimi_output
event=/a/home/cc/lifesci/kerendanan1/rmats_turbo/test_N010/rmats/output_dir/SE.MATS.JCEC.txt
test_bam=/a/home/cc/lifesci/kerendanan1/provide/high_quality/N010_NSSAligned.sortedByCoord.out.bam

rmats2sashimiplot --b1 $test_bam --exon_s 1 --intron_s 5 --event-type SE -e $event --l1 N010_sample_SE -o $out_sa

I get this error:

'/a/home/cc/lifesci/kerendanan1/provide/high_quality/N010_NSSAligned.sortedByCoord.out.bam' is indexed already: '/a/home/cc/lifesci/kerendanan1/provide/high_quality/N010_NSSAligned.sortedByCoord.out.bam.bai'
'pysam.calignmentfile.AlignedSegment' object has no attribute 'reference_name'
There is an exception in plot_with_eventsfile
Traceback (most recent call last):
File "/a/home/cc/lifesci/kerendanan1/.conda/envs/rmats_env/bin/rmats2sashimiplot", line 33, in
sys.exit(load_entry_point('rmats2sashimiplot==3.0.0', 'console_scripts', 'rmats2sashimiplot')())
File "/a/home/cc/lifesci/kerendanan1/.conda/envs/rmats_env/lib/python3.6/site-packages/rmats2sashimiplot-3.0.0-py3.6.egg/rmats2sashimiplot/rmats2sashimiplot.py", line 949, in main
plot_with_eventsfile(options)
File "/a/home/cc/lifesci/kerendanan1/.conda/envs/rmats_env/lib/python3.6/site-packages/rmats2sashimiplot-3.0.0-py3.6.egg/rmats2sashimiplot/rmats2sashimiplot.py", line 606, in plot_with_eventsfile
options.events_file = create_chr_aware_events_file(options)
File "/a/home/cc/lifesci/kerendanan1/.conda/envs/rmats_env/lib/python3.6/site-packages/rmats2sashimiplot-3.0.0-py3.6.egg/rmats2sashimiplot/rmats2sashimiplot.py", line 575, in create_chr_aware_events_file
ref_name = alignment.reference_name
AttributeError: 'pysam.calignmentfile.AlignedSegment' object has no attribute 'reference_name'

What should I do?

I have installed as in the README, I only want to get sashimi plots for some specific genes.
Any idea, beside that error, how could I get all the sashimi plots for all the events for specified gene symbols?

Thanks!

@EricKutschera
Copy link
Contributor

Here's the line for that error: https://github.com/Xinglab/rmats2sashimiplot/blob/v3.0.0/src/rmats2sashimiplot/rmats2sashimiplot.py#L575

It's reading the alignments from the bam file using pysam and it's checking the contig name (.reference_name). Based on this issue it looks like this error message can happen if using a pysam version older than 0.8.4: CGATOxford/UMI-tools#199

I was able to reproduce the error with 0.8.3 then I updated pysam to 0.9.1 (and removed .bai files created by the old version) and it worked correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants