svm-zhang/AGOUTI

agouti scaffold fails with error: local variable 'curIndex' referenced before assignment

Closed this issue · 4 comments

I have successfully run "agouti shred" and mapped the reads to the resulting shredded assembly. However, when I now run "agouti scaffold" it fails after a while with below error message. I would be grateful for any help you can provide. Thanks!

This is the error message:
Traceback (most recent call last):
File "/cluster/project/gdc/people/zollerst/tools/AGOUTI/agouti.py", line 288, in
main()
File "/cluster/project/gdc/people/zollerst/tools/AGOUTI/agouti.py", line 285, in main
args.func(args)
File "/cluster/project/gdc/people/zollerst/tools/AGOUTI/agouti.py", line 222, in run_scaffolder
prefix)
File "/cluster/project/gdc/people/zollerst/tools/AGOUTI/src/agouti_path.py", line 39, in agouti_path_main
report_consistency(agoutiPaths, dOriPaths, vertex2Name, outDir, prefix)
File "/cluster/project/gdc/people/zollerst/tools/AGOUTI/src/agouti_path.py", line 75, in report_consistency
curIndex = int(curIndex)
UnboundLocalError: local variable 'curIndex' referenced before assignment

This is the command I was running:
agouti.py scaffold -assembly red3.contigs.ctg.fasta -bam red3.contigs.ctg.bam -gff red3.contigs.ctg.gff -outdir ./red3.agouti.run1 -shredpath red3.contigs.shred.info.txt

This is the log of "agouti scaffold":
2018-12-15 11:39:12,042 - INFO - PARSE_ARGS PROGRESS - Assembly: /cluster/project/gdc/people/zollerst/agouti.test/red3.contigs.ctg.fasta
2018-12-15 11:39:12,042 - INFO - PARSE_ARGS PROGRESS - Gene Model: /cluster/project/gdc/people/zollerst/agouti.test/red3.contigs.ctg.gff
2018-12-15 11:39:12,042 - INFO - PARSE_ARGS PROGRESS - Original scaffold path: red3.contigs.shred.info.txt
2018-12-15 11:39:12,042 - INFO - PARSE_ARGS PROGRESS - Output directory: /cluster/project/gdc/people/zollerst/agouti.test/red3.agouti.run1
2018-12-15 11:39:12,042 - INFO - PARSE_ARGS PROGRESS - Output prefix: agouti
2018-12-15 11:39:12,043 - INFO - PARSE_ARGS PROGRESS - Minimum number of supports: 5
2018-12-15 11:39:12,043 - INFO - PARSE_ARGS PROGRESS - Length of gaps to fill between contigs: 1000
2018-12-15 11:39:12,044 - INFO - AGOUTI_SEQUENCE PROGRESS - [BEGIN] Reading the initial assembly
2018-12-15 11:39:15,559 - INFO - AGOUTI_SEQUENCE PROGRESS - 28416 sequences parsed
2018-12-15 11:39:15,560 - INFO - AGOUTI_SEQUENCE PROGRESS - The given assembly N50: 35014
2018-12-15 11:39:15,560 - INFO - AGOUTI_SEQUENCE PROGRESS - [DONE]
2018-12-15 11:39:15,571 - INFO - AGOUTI_GFF PROGRESS - [BEGIN] Getting gene models
2018-12-15 11:39:16,226 - INFO - AGOUTI_GFF PROGRESS - 11548 Gene Models parsed
2018-12-15 11:39:16,227 - INFO - AGOUTI_GFF PROGRESS - [DONE]
2018-12-15 11:39:16,246 - INFO - AGOUTI_SAM PROGRESS - ---------------------------------
2018-12-15 11:39:16,246 - INFO - AGOUTI_SAM PROGRESS - [BEGIN] Identifying joining pairs
2018-12-15 11:39:16,246 - INFO - AGOUTI_SAM PROGRESS - Found progress file from previous run
2018-12-15 11:39:16,246 - INFO - AGOUTI_SAM PROGRESS - Fail to pick up results from the previous run
2018-12-15 11:39:16,246 - INFO - AGOUTI_SAM PROGRESS - Re-processing the BAM file
2018-12-15 11:39:16,246 - INFO - AGOUTI_SAM PROGRESS - check SAMtools
2018-12-15 11:39:16,293 - INFO - AGOUTI_SAM PROGRESS - run SAMtools
2018-12-15 11:39:16,293 - INFO - AGOUTI_SAM PROGRESS - # processed | Current Reads ID | Elapsed Time
2018-12-15 11:40:09,237 - INFO - AGOUTI_SAM PROGRESS - 5000000 parsed | HWI-ST1122:237:D2AYDACXX:6:1301:11835:17871 | 0.88 m
2018-12-15 11:41:01,784 - INFO - AGOUTI_SAM PROGRESS - 10000000 parsed | HWI-ST1122:237:D2AYDACXX:6:2116:7639:77229 | 1.76 m
2018-12-15 11:41:54,246 - INFO - AGOUTI_SAM PROGRESS - 15000000 parsed | HWI-ST1122:237:D2AYDACXX:6:2316:12746:43339 | 2.63 m
2018-12-15 11:41:55,504 - INFO - AGOUTI_SAM PROGRESS - 15119151 reads pairs in the give BAM
2018-12-15 11:41:55,504 - INFO - AGOUTI_SAM PROGRESS - 156041 joining pairs parsed
2018-12-15 11:41:55,505 - INFO - AGOUTI_SAM PROGRESS - 30363 contig pairs given by these joining pairs
2018-12-15 11:41:55,505 - INFO - AGOUTI_SAM PROGRESS - Succeeded
2018-12-15 11:41:55,553 - INFO - AGOUTI_DENOISE PROGRESS - [BEGIN] Denoising joining pairs
2018-12-15 11:41:57,733 - INFO - AGOUTI_DENOISE PROGRESS - Succeeded
2018-12-15 11:41:57,735 - INFO - AGOUTI_DENOISE PROGRESS - Denoise took in 0.04 min CPU time
2018-12-15 11:41:57,735 - INFO - AGOUTI_DENOISE PROGRESS - 256 contig pairs filtered for spanning across >1 gene models
2018-12-15 11:41:57,735 - INFO - AGOUTI_DENOISE PROGRESS - 2690 contig pairs filtered for not being one of the four combinations
2018-12-15 11:41:57,735 - INFO - AGOUTI_DENOISE PROGRESS - 25972 contig pairs filtered for less support
2018-12-15 11:41:57,735 - INFO - AGOUTI_DENOISE PROGRESS - 1445 contig pairs for scaffolding
2018-12-15 11:41:57,741 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Building graph from joining reads pairs
2018-12-15 11:41:57,750 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Build graph took 0.0002 min CPU time
2018-12-15 11:41:57,750 - INFO - AGOUTI_SCAFFOLDING PROGRESS - 2622 vertices in the graph
2018-12-15 11:41:57,750 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Simplifying graph
2018-12-15 11:41:57,754 - INFO - AGOUTI_SCAFFOLDING PROGRESS - 92 Edges removed due to insufficient supports
2018-12-15 11:41:57,754 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Start graph walk
2018-12-15 11:41:57,773 - INFO - AGOUTI_SCAFFOLDING PROGRESS - number of visited nodes: 2622
2018-12-15 11:41:57,774 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Scaffolding took 0.0003 min CPU time
2018-12-15 11:41:57,792 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Graph Reconciliation
2018-12-15 11:41:57,800 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Reconciliation took 0.0000 min CPU time
2018-12-15 11:41:57,800 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Report scaffolding paths
2018-12-15 11:41:57,807 - INFO - AGOUTI_SCAFFOLDING PROGRESS - Visualize graph in DOT
2018-12-15 11:41:57,818 - INFO - AGOUTI_PATH PROGRESS - Analyzing scaffolding paths
2018-12-15 11:41:57,820 - INFO - AGOUTI_PATH PROGRESS - [BEGIN] Reading file with shred info
2018-12-15 11:41:57,925 - INFO - AGOUTI_PATH PROGRESS - Number of shredded contigs parsed: 28416
2018-12-15 11:41:57,925 - INFO - AGOUTI_PATH PROGRESS - [DONE]

As the error message says, it seems the "curIndex" is not set in agouti_path.py before it is used. This happens in the if-else constructs around the line 75. I have now changed the code, setting curIndex to 0 before and this seems to work, agouti now finishes and produces all expected results. However, I am not sure if I did it all correctly, so it would be great if you could have a look at it.
By the way, I got agouti version v0.3.3-dirty, downloaded on December 14.

@gdczoller, I am so sorry for not seeing your ticket coming in at all. Shouldn't GitHub send me an email? Weird...

Have you been able to solve the error? Let me look into this. Thanks for reporting!

Simo

@gdczoller, if you look at the agouti_path.py, this line curIndex = int(curIndex) is not there anymore. I think I updated that part long time ago. Could you please compare your local version with the one I see agouti_path.py?

Close it now. Feel free to reopen.