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

More informative error message for filter_gtf_for_genes_in_genome.py (Python only task!) #1082

Closed
MatthiasZepper opened this issue Oct 5, 2023 · 2 comments · Fixed by #1107
Labels
Milestone

Comments

@MatthiasZepper
Copy link
Member

Description of feature

The rnaseq pipeline filters records of the transcript annotation GTF, which refer to scaffolds lacking a sequence record in the FASTA file.

If there is e.g. a name mismatch between the two files and no overlaps are found, the custom script ./bin/filter_gtf_for_genes_in_genome.py fails ungracefully:

/../../../.nextflow/assets/nf-core/rnaseq/bin/filter_gtf_for_genes_in_genome.py
 - 2023-02-28 15:56:04,858 INFO: Extracted 0 / 0 lines from
Pisum_sativum_v1a_genes.gtf matching sequences in Pisum_sativum_v1a.fa
  Traceback (most recent call last):
    File "/home/../../.nextflow/assets/nf-core/rnaseq/bin/filter_gtf_for_genes_in_genome.py", line 79, in <module>
      extract_genes_in_genome(args.fasta, args.gtf, args.output)
    File "/../../../.nextflow/assets/nf-core/rnaseq/bin/filter_gtf_for_genes_in_genome.py", line 60, in extract_genes_in_genome
      [logger.info](http://logger.info/)("All sequence IDs from GTF: " + ", ".join(sorted(x for x in seq_name_gtf)))
  UnboundLocalError: local variable 'seq_name_gtf' referenced before assignment

The reason is that the script never corroborates that seq_name_gtf was assigned by this step:

      for line in g.readlines():
          n_total_lines += 1
          seq_name_gtf = line.split("\t")[0]

There are further scenarios causing this step to fail, e.g. if g.readlines() doesn't yield a single line or if the GTF file is not tab-separated.

Thus, I suggest that the script filter_gtf_for_genes_in_genome.py should be improved to account for those cases and produce meaningful and actionable error messages. I think, this would be a good issue for the next Hackathon?

For more details, see the respective conversation on the #rnaseq Slack channel.

@pinin4fjords
Copy link
Member

pinin4fjords commented Nov 10, 2023

This was related to what I was doing in #1107, so I sorted it there.

@MatthiasZepper I assume it was ok to handle this even though I'm not a first-timer, since it didn't get sorted in the hackathon.

@MatthiasZepper
Copy link
Member Author

MatthiasZepper commented Nov 10, 2023

@pinin4fjords: Absolutely! I am very grateful that you are working hard on the pipeline!

Because there had been a call to create issues for people to work on during the Hackathon, I went through my backlog of "I should do this somewhen" things for this pipeline and picked those that seemed doable for others without too much explanation.

I added the "First-timers only" label to highlight the easier ones for the Hackathon, but of course this is not imperative!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
2 participants