From 1cbded37e7b6cbd9acdad9eebcb696d67cf315d9 Mon Sep 17 00:00:00 2001 From: Adetunji Date: Wed, 21 Apr 2021 18:57:36 -0500 Subject: [PATCH] keyerror with unmatched chromosomes --- bin/BAM2GFF_gtftogenes.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/BAM2GFF_gtftogenes.py b/bin/BAM2GFF_gtftogenes.py index 1fda578..4319fbc 100755 --- a/bin/BAM2GFF_gtftogenes.py +++ b/bin/BAM2GFF_gtftogenes.py @@ -129,8 +129,15 @@ def main(): newline[0], newline[1].strip('";'))) else: sys.exit("ERROR :\tFailed to process %s" %(gtf_name)) - PSEUDOGFF.write(results+"\n") - parse_genelocations(chrom_sizes, results, flank) + + #create annotation files + try: + if chrom_sizes[lines[0]]: + PSEUDOGFF.write(results+"\n") + parse_genelocations(chrom_sizes, results, flank) + except KeyError: + continue + #print("%s not found in genome fasta, skipped!" %(lines[0])) if __name__ == "__main__": main()