Body: <p><em>This question was also asked on <a href="https://github.com/malonge/RagTag/issues/152" rel="nofollow noreferrer">GitHub</a></em></p>
  <p>I'm trying to correct a long-read assembly with a short-read scaffold; I'm hoping to fill in the short gaps in the scaffold with the matching long-read sections. The RagTag &quot;patch&quot; function, if I understand correctly, is supposed to do exactly this. I use this command:</p>
  <pre><code>ragtag.py patch --fill-only liberibacter_central_ragtag.fasta liberibacter_central_assembly.fasta
  </code></pre>
  <p>But when I attempt to run it I get the following error:</p>
  <pre><code>Tue Feb  7 09:55:17 2023 --- VERSION: RagTag v2.1.0
  Tue Feb  7 09:55:17 2023 --- WARNING: This is a beta version of `ragtag patch`
  Tue Feb  7 09:55:17 2023 --- CMD: ragtag.py patch --fill-only liberibacter_central_assembly.fasta liberibacter_central_ragtag.fasta
  Tue Feb  7 09:55:17 2023 --- WARNING: Without '-u' invoked, some component/object AGP pairs might share the same ID. Some external programs/databases don't like this. To ensure valid AGP format, use '-u'.
  Tue Feb  7 09:55:17 2023 --- INFO: Running: ragtag_splitasm.py -o /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.agp /xdisk/baltrus/moshesteyn/liberibacter_central_assembly.fasta &gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.fasta 2&gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:17 2023 --- INFO: Finished running : ragtag_splitasm.py -o /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.agp /xdisk/baltrus/moshesteyn/liberibacter_central_assembly.fasta &gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.fasta 2&gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:17 2023 --- INFO: Running: ragtag_rename.py /xdisk/baltrus/moshesteyn/liberibacter_central_ragtag.fasta -p qseq -o /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.agp &gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.fasta 2&gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:17 2023 --- INFO: Finished running : ragtag_rename.py /xdisk/baltrus/moshesteyn/liberibacter_central_ragtag.fasta -p qseq -o /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.agp &gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.fasta 2&gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:17 2023 --- INFO: Writing: /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.comps.fasta
  Tue Feb  7 09:55:17 2023 --- INFO: Mapping the query genome to the target genome
  Tue Feb  7 09:55:17 2023 --- INFO: Running: nucmer --maxmatch -l 100 -c 500 -p /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.fasta /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.fasta 2&gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.delta.log
  Tue Feb  7 09:55:19 2023 --- INFO: Finished running : nucmer --maxmatch -l 100 -c 500 -p /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.fasta /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.fasta &gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.delta.log
  Tue Feb  7 09:55:19 2023 --- INFO: Running: ragtag_delta2paf.py /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.delta &gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.paf 2&gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:19 2023 --- INFO: Finished running : ragtag_delta2paf.py /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.delta &gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.paf 2&gt; /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:19 2023 --- INFO: Reading whole genome alignments
  Tue Feb  7 09:55:19 2023 --- INFO: Filtering and merging alignments
  Tue Feb  7 09:55:19 2023 --- INFO: Building a scaffold graph from the contig AGP file
  Tue Feb  7 09:55:19 2023 --- INFO: Building a scaffold graph from the target/query mappings
  Tue Feb  7 09:55:19 2023 --- INFO: Computing a matching solution to the scaffold graph
  Traceback (most recent call last):
  File &quot;/home/u30/moshesteyn/.conda/envs/py382/bin/ragtag_patch.py&quot;, line 518, in &lt;module&gt;
      main()
  File &quot;/home/u30/moshesteyn/.conda/envs/py382/bin/ragtag_patch.py&quot;, line 497, in main
      match_psg = aln_psg.max_weight_matching()
  File &quot;/home/u30/moshesteyn/.conda/envs/py382/lib/python3.8/site-packages/ragtag_utilities/ScaffoldGraph.py&quot;, line 824, in max_weight_matching
      for cc in nx.connected_components(G=cover_graph):
  File &quot;/home/u30/moshesteyn/.conda/envs/py382/lib/python3.8/site-packages/networkx/classes/backends.py&quot;, line 134, in wrapper
      graph = args[0]
  IndexError: tuple index out of range
  </code></pre>
  <p>Does anyone know what might be causing this error? No one else seems to have run into it on the github. I've run it with both files individually against a known reference, as well as reversing the order of the files and removing the &quot;fill-only&quot; option, and I have the same problem. I've looked at several of the output files, and they seem normal, at least in that they aren't empty or filled with zeroes.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-08T05:55:54.493Z
Comments.Text: Were any errors/warnings logged in any of the `*.err` or `*.log` files (in the _ragtag_output_ folder)?
Comments.UserDisplayName: Steve
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-08T19:20:15.847Z
Comments.Text: The output mentions potential AGP issues if not using `-u`; have you tried running it with `-u` included?
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-08T19:25:41.743Z
Comments.Text: Can you post some assembly stats for your various assemblies? I could imagine that a filtering process under the hood removes some small artefactual contigs and exposes some sort of edge case, but it's not totally clear from what you've shown so far. For example, do you have any tiny short-read contigs that are all `GGGG` or something?
Comments.UserDisplayName: Maximilian Press
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-09T06:32:48.357Z
Comments.Text: @Steve no errors noted in the .log, and .err is empty.
Comments.UserDisplayName: schmiggle
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-09T06:42:57.593Z
Comments.Text: -u makes no difference, and the shortest contigs are non-repetitive between 190 and 600 bp. What kinds of stats are you looking for--spades log?
Comments.UserDisplayName: schmiggle
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-09T07:32:20.807Z
Comments.Text: Sorry to spam the comments. Attempting to run my own patch, I've mapped the contigs individually to the reference, but for two short ones Bowtie doesn't find matches at all. Might this be causing the problem?
Comments.UserDisplayName: schmiggle
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-07T22:44:13.557Z
Comments.Text: @schmiggle you will need to use `@` to tag us when you comment, or we won't see it. Yes, any sort of stats on the assembly would be helpful, spades/quast would be fine. I doubt that the issue is a failure to find a match as that is likely a common case. I'd suggest simply filtering out contigs <500bp because they are unlikely to be very informative.
Comments.UserDisplayName: Maximilian Press
Tags: <assembly><scaffold><ragtag>
Title: RagTag patch error--"Tuple index out of range"
ThreadText: # RagTag patch error--"Tuple index out of range"
  
  (Asked by: username_0 on 2023-02-07)
  
  *This question was also asked on [GitHub](https://github.com/malonge/RagTag/issues/152)*
  
  I'm trying to correct a long-read assembly with a short-read scaffold; I'm hoping to fill in the short gaps in the scaffold with the matching long-read sections. The RagTag "patch" function, if I understand correctly, is supposed to do exactly this. I use this command:
  
  ```
  ragtag.py patch --fill-only liberibacter_central_ragtag.fasta liberibacter_central_assembly.fasta
  
  ```
  
  But when I attempt to run it I get the following error:
  
  ```
  Tue Feb  7 09:55:17 2023 --- VERSION: RagTag v2.1.0
  Tue Feb  7 09:55:17 2023 --- WARNING: This is a beta version of `ragtag patch`
  Tue Feb  7 09:55:17 2023 --- CMD: ragtag.py patch --fill-only liberibacter_central_assembly.fasta liberibacter_central_ragtag.fasta
  Tue Feb  7 09:55:17 2023 --- WARNING: Without '-u' invoked, some component/object AGP pairs might share the same ID. Some external programs/databases don't like this. To ensure valid AGP format, use '-u'.
  Tue Feb  7 09:55:17 2023 --- INFO: Running: ragtag_splitasm.py -o /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.agp /xdisk/baltrus/moshesteyn/liberibacter_central_assembly.fasta > /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.fasta 2> /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:17 2023 --- INFO: Finished running : ragtag_splitasm.py -o /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.agp /xdisk/baltrus/moshesteyn/liberibacter_central_assembly.fasta > /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.fasta 2> /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:17 2023 --- INFO: Running: ragtag_rename.py /xdisk/baltrus/moshesteyn/liberibacter_central_ragtag.fasta -p qseq -o /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.agp > /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.fasta 2> /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:17 2023 --- INFO: Finished running : ragtag_rename.py /xdisk/baltrus/moshesteyn/liberibacter_central_ragtag.fasta -p qseq -o /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.agp > /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.fasta 2> /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:17 2023 --- INFO: Writing: /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.comps.fasta
  Tue Feb  7 09:55:17 2023 --- INFO: Mapping the query genome to the target genome
  Tue Feb  7 09:55:17 2023 --- INFO: Running: nucmer --maxmatch -l 100 -c 500 -p /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.fasta /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.fasta 2> /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.delta.log
  Tue Feb  7 09:55:19 2023 --- INFO: Finished running : nucmer --maxmatch -l 100 -c 500 -p /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.ctg.fasta /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.rename.fasta > /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.delta.log
  Tue Feb  7 09:55:19 2023 --- INFO: Running: ragtag_delta2paf.py /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.delta > /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.paf 2> /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:19 2023 --- INFO: Finished running : ragtag_delta2paf.py /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.delta > /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.asm.paf 2> /xdisk/baltrus/moshesteyn/ragtag_output/ragtag.patch.err
  Tue Feb  7 09:55:19 2023 --- INFO: Reading whole genome alignments
  Tue Feb  7 09:55:19 2023 --- INFO: Filtering and merging alignments
  Tue Feb  7 09:55:19 2023 --- INFO: Building a scaffold graph from the contig AGP file
  Tue Feb  7 09:55:19 2023 --- INFO: Building a scaffold graph from the target/query mappings
  Tue Feb  7 09:55:19 2023 --- INFO: Computing a matching solution to the scaffold graph
  Traceback (most recent call last):
  File "/home/u30/moshesteyn/.conda/envs/py382/bin/ragtag_patch.py", line 518, in <module>
      main()
  File "/home/u30/moshesteyn/.conda/envs/py382/bin/ragtag_patch.py", line 497, in main
      match_psg = aln_psg.max_weight_matching()
  File "/home/u30/moshesteyn/.conda/envs/py382/lib/python3.8/site-packages/ragtag_utilities/ScaffoldGraph.py", line 824, in max_weight_matching
      for cc in nx.connected_components(G=cover_graph):
  File "/home/u30/moshesteyn/.conda/envs/py382/lib/python3.8/site-packages/networkx/classes/backends.py", line 134, in wrapper
      graph = args[0]
  IndexError: tuple index out of range
  
  ```
  
  Does anyone know what might be causing this error? No one else seems to have run into it on the github. I've run it with both files individually against a known reference, as well as reversing the order of the files and removing the "fill-only" option, and I have the same problem. I've looked at several of the output files, and they seem normal, at least in that they aren't empty or filled with zeroes.
  
  **Tags:** assembly, scaffold, ragtag
  
  > **Comments:**
  > **username_1**: Were any errors/warnings logged in any of the `*.err` or `*.log` files (in the _ragtag_output_ folder)?  
  > **username_2**: The output mentions potential AGP issues if not using `-u`; have you tried running it with `-u` included?  
  > **username_3**: Can you post some assembly stats for your various assemblies? I could imagine that a filtering process under the hood removes some small artefactual contigs and exposes some sort of edge case, but it's not totally clear from what you've shown so far. For example, do you have any tiny short-read contigs that are all `GGGG` or something?  
  > **username_0**: @username_1 no errors noted in the .log, and .err is empty.  
  > **username_0**: -u makes no difference, and the shortest contigs are non-repetitive between 190 and 600 bp. What kinds of stats are you looking for--spades log?  
  > **username_0**: Sorry to spam the comments. Attempting to run my own patch, I've mapped the contigs individually to the reference, but for two short ones Bowtie doesn't find matches at all. Might this be causing the problem?  
  > **username_3**: @username_0 you will need to use `@` to tag us when you comment, or we won't see it. Yes, any sort of stats on the assembly would be helpful, spades/quast would be fine. I doubt that the issue is a failure to find a match as that is likely a common case. I'd suggest simply filtering out contigs <500bp because they are unlikely to be very informative.  
  
  ---
  
  ## 0 answers
  
  