Error
Closed this issue · 14 comments
Hello,
I am having this problem now:
'/home/mwiks/wub/scripts/bam_alignment_qc.py' -f '/home/mwiks/mergedbarcode02.fasta' -r bacode02qc.pdf -x '/home/mwiks/mergedbarcode02.bam'
Gathering read and error statistics from file: /home/mwiks/mergedbarcode02.bam
0%| | 0/193091 [00:00<?, ?it/s]Traceback (most recent call last):
File "/home/mwiks/wub/scripts/bam_alignment_qc.py", line 281, in
args.bam, references, region=args.c, context_sizes=context_sizes, min_aqual=args.q, verbose=verbose)
File "/home/mwiks/wub/wub/bam/stats.py", line 403, in error_and_read_stats
ref = refs[r.reference_name]
KeyError: 'tig00000019'
I have checked the bam file with samtools and it is ok.
Thank you.
Apparently the tig00000019 contig is missing from the file /home/mwiks/mergedbarcode02.fasta.
With this script, I must add -f reference fasta, I have got the alignment which, the polished sequence and the ref sequence I want to compare with. Should be -f the ref sequence I want to compare with?
Because it is what I have done:
mwiks@administrator-HP-Compaq-Elite-8300-SFF:~$ '/home/mwiks/wub/scripts/bam_alignment_qc.py' -f '/home/mwiks/Desktop/Mabscessusref.fna' '/home/mwiks/barcode01polishedabsref.bam'
Gathering read and error statistics from file: /home/mwiks/barcode01polishedabsref.bam
9%|███▊ | 4/46 [00:02<00:22, 1.86it/s]Traceback (most recent call last):
File "/home/mwiks/wub/scripts/bam_alignment_qc.py", line 281, in
args.bam, references, region=args.c, context_sizes=context_sizes, min_aqual=args.q, verbose=verbose)
File "/home/mwiks/wub/wub/bam/stats.py", line 404, in error_and_read_stats
_update_events(r, ref, events, indel_dists, context_sizes, base_stats)
File "/home/mwiks/wub/wub/bam/stats.py", line 332, in _update_events
if r.query_sequence[t[0]] == ref.seq[t[1]]:
TypeError: 'NoneType' object is not subscriptable
Hello. Now this is a different problem. Did you use minimap2 for alignment by any chance? It will output secondary alignments without sequences in them. You can get rid of this error by filtering out the secondary alignments using samtools.
Hello,
Yes I used minimap2 for alignment.
Do you mean with this, samtools view -b -F 4 file.bam > mapped.bam?
Thank you
You can use -F 2304 to keep the primary alignments only.
Ok, thank you!
Hello,
Sorry, but I after everything was ok last week, I am trying to run a new sequence and I am getting this error:
'/home/mwiks/wub/scripts/bam_alignment_qc.py' -f '/home/mwiks/Desktop/Mabscessussubolletii.fasta' '/home/mwiks/01boletiimapped.bam'
Traceback (most recent call last):
File "/home/mwiks/wub/scripts/bam_alignment_qc.py", line 14, in
from wub.util import misc
Hello! it seems your install is broken. You can try re-installing wub.
Hello!
I have installed again and it is running, but:
'/home/mwiks/wub/scripts/bam_accuracy.py' '/home/mwiks/01boletiimapped.bam'
Gathering read statistics from file: /home/mwiks/01boletiimapped.bam
100%|█████████████████████████████████████████████| 2/2 [00:00<00:00, 31.47it/s]
mwiks@administrator-HP-Compaq-Elite-8300-SFF:~/wub$ '/home/mwiks/wub/scripts/bam_alignment_qc.py' -f '/home/mwiks/Desktop/Mabscessussubolletii.fasta' '/home/mwiks/01boletiimapped.bam'
Gathering read and error statistics from file: /home/mwiks/01boletiimapped.bam
100%|█████████████████████████████████████████████| 2/2 [00:02<00:00, 1.34s/it]
Gathering pileup statistics from file: /home/mwiks/01boletiimapped.bam
9%|██▌ | 439323/5080450 [07:06<1:15:05, 1030.06it/s]
Generating per-reference plots.
0it [00:00, ?it/s]
Is that ok?
Yes, it looks okay. You might want to suppress the generation of per-reference plots using the -x flag.
Ok, Thank you!
Hello again,
I am trying today with more sequences and I get this error:
'/home/mwiks/wub/scripts/bam_alignment_qc.py' '/home/mwiks/baroce02_abscmapped.bam'
usage: bam_alignment_qc.py [-h] -f reference [-c region] [-n context_sizes]
[-x] [-t bam_tag] [-q aqual] [-i qual_ints]
[-r report_pdf] [-p results_pickle] [-Q]
bam
bam_alignment_qc.py: error: argument -f is required
mwiks@administrator-HP-Compaq-Elite-8300-SFF:~$ '/home/mwiks/wub/scripts/bam_alignment_qc.py' -f '/home/mwiks/polished02.fasta' '/home/mwiks/baroce02_abscmapped.bam'
Gathering read and error statistics from file: /home/mwiks/baroce02_abscmapped.bam
0it [00:00, ?it/s]Traceback (most recent call last):
File "/home/mwiks/wub/scripts/bam_alignment_qc.py", line 281, in
args.bam, references, region=args.c, context_sizes=context_sizes, min_aqual=args.q, verbose=verbose)
File "/home/mwiks/wub/wub/bam/stats.py", line 403, in error_and_read_stats
ref = refs[r.reference_name]
KeyError: 'NC_010397.1'
Exception KeyError: KeyError(<weakref at 0x7f3573dd7c00; to 'tqdm' at 0x7f355f382a90>,) in <bound method tqdm.del of 0it [00:00, ?it/s]> ignored
Thank you!
It seems that a reference entry in the BAM file is not included in the fasta file specified by -f. Make sure you have provided the fasta which you have used for mapping the reads.
I was providing -f my polished fasta instead the reference one!
Thank you