rrazaghi / modbamtools

Set of tools to manipulate and visualize modified base bam files
Apache License 2.0
48 stars 4 forks source link

KeyError: 'gene_id' #38

Open partha434 opened 1 year ago

partha434 commented 1 year ago

modbamtools plot -r mtDNA:1-16626 --gtf /cluster/projects/nn9337k/as1_nanopolish/all_context/sequence.sorted.gtf.gz --out . --prefix unmethylated --samples unmethylated --track-titles Genes unmethylated.bam Traceback (most recent call last): File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/bin/modbamtools", line 8, in sys.exit(cli()) File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/click/core.py", line 760, in invoke return __callback(args, **kwargs) File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/modbamtools/cli.py", line 334, in plot fig = Plotter( File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/modbamtools/modbamviz.py", line 47, in init self.tracks, self.num_tracks = get_tracks_gl( File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/modbamtools/tracks_webgl.py", line 236, in get_tracks_gl genes = parse_gtf_exons(gtf, chrom, start, end) File "/cluster/projects/nn9337k/anaconda/envs/modbamtools/lib/python3.8/site-packages/modbamtools/gene_models.py", line 162, in parse_gtf_exons if record.gene_id not in recs.keys(): File "pysam/libctabixproxies.pyx", line 638, in pysam.libctabixproxies.GTFProxy.getattr KeyError: 'gene_id'

pwh124 commented 11 months ago

Hi Partha434,

I think this likely stems from the GTF you are using.

Unfortunately, we have not had a chance to update this. Since GTFs can come in different formats, modbamtools may fail if it encounters a GTF format different from what is expected. modbamtools seems to be hardcoded (currently) to parse a GENCODE-style GTF (as shown in the tutorial).

I would suggest using a GENCODE GTF to fix the issue in the short term. The long term fix will involve updating the code.

Paul