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.libcalignedsegment.AlignedSegment' object has no attribute 'is_mapped' #13

Open
YuanQing-KIB opened this issue Oct 29, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@YuanQing-KIB
Copy link

Hello, When I used the GCI software to assemble my T2T genome, the following error occurred. What happened?

Used arguments:{'reference': '/export/home/zzl/YQ/Genome/Mel.genome.fa', 'hifi': ['/export/home/zzl/YQ/Genome/04-GCI/Mel.hifi.bam', '/export/home/zzl/YQ/Genome/04-GCI/Mel.hifi.paf'], 'nano': ['/export/home/zzl/YQ/Genome/04-GCI/Mel.ont.bam', '/export/home/zzl/YQ/Genome/04-GCI/Mel.ont.paf'], 'chrs': None, 'regions': None, 'threshold': 0, 'dist_percent': 0.005, 'threads': 20, 'directory': '/export/home/zzl/YQ/Genome/04-GCI/Mel.GCI.out', 'prefix': 'Mel', 'map_qual': 30, 'mq_cutoff': 50, 'iden_percent': 0.9, 'ovlp_percent': 0.9, 'clip_percent': 0.1, 'flank_len': 15, 'plot': True, 'depth_min': 0.1, 'depth_max': 4.0, 'window_size': 50000, 'image_type': 'pdf', 'force': False}
Finding gaps ...
Finding gaps done!!! Awesome! No gaps were found!

Filtering HiFi alignment files ...
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/export/software/miniconda3/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/export/software/miniconda3/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "GCI.py", line 152, in read_sam
if (segment.is_mapped == True) and (segment.is_secondary == False) and (segment.is_supplementary == False) and (segment.mapping_quality >= map_qual):
AttributeError: 'pysam.libcalignedsegment.AlignedSegment' object has no attribute 'is_mapped'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "GCI.py", line 1107, in
GCI(**args)
File "GCI.py", line 1008, in GCI
hifi_depths, targets_length = filter(hifi_paf, hifi_bam, prefix+'_hifi', map_qual, mq_cutoff, iden_percent, clip_percent, ovlp_percent, flank_len, directory, force, 'HiFi', chrs_list, threads)
File "GCI.py", line 262, in filter
for tmp_samfile_dict, tmp_high_qual_querys in pool.map(read_sam, tasks):
File "/export/software/miniconda3/lib/python3.7/multiprocessing/pool.py", line 268, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/export/software/miniconda3/lib/python3.7/multiprocessing/pool.py", line 657, in get
raise self._value
AttributeError: 'pysam.libcalignedsegment.AlignedSegment' object has no attribute 'is_mapped'

@yeeus yeeus added the help wanted Extra attention is needed label Oct 29, 2024
@yeeus
Copy link
Owner

yeeus commented Oct 29, 2024

I think it was the problem of your version of pysam as discussed in issue #9
Please check your pysam verison with pip show pysam and if it's not the lastest please update it.

@YuanQing-KIB
Copy link
Author

Thank you very much. I'll try

@chenys1998
Copy link

I also met this error.
As shown in logfile, error is occurred in GCI.py line 152.
if (segment.is_mapped == True) …

Maybe in some pysam version, "is_mapped" is not accessible.(The version I used is 0.17.0)
But in this version, "is_unmapped" is accessible.

So i changed GCI.py line 152 to:
if (segment.is_unmapped == False) …
And soft can run normally.

@yeeus
Copy link
Owner

yeeus commented Dec 1, 2024

@chenys1998 thank you every much for reporting this. I have fixed this in the lastest commit.

yeeus added a commit that referenced this issue Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants