-
Notifications
You must be signed in to change notification settings - Fork 43
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
handle KeyError: transcript_id not found #52
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except KeyError as e: | ||
print(line) | ||
exit(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except KeyError as e: | |
print(line) | |
exit(e) | |
except KeyError: | |
print("ERROR: 'transcript_id' attribute is missing in GTF file.") | |
exit(1) |
Maybe better if we do not print the GTF line, but rather provide a more clear error message, following this structure (analogous to the one employed for other error messages along the code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take advantage to suggest code to fix #48
d = dict(kv.strip().split(" ") for kv in tags.strip(";").split("; ")) | ||
transcript_id = d["transcript_id"] | ||
try: | ||
transcript_id = d["transcript_id"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transcript_id = d["transcript_id"] | |
transcript_id = re.findall('transcript_id ("[^"]+")', tags)[0] |
As it affects the same portion of code I take advantage to suggest this line too, which fixes #48
Hi @ygidtu, the modified proposals have been added, and will be part of the next release. Thank you! |
Still strong recommend using pysam to handle the IO of bam file