text: user10768: And thanks in advance. I am debugging a text file which is the one the two inputs on the program RGmatch https://bitbucket.org/pfurio/rgmatch/src/master/.
  The code works. Is that some records give division by zero.
  I am doing it by hand.
  But is there a way by making a bash script, to see which records show the problem?
  I do not want to touch the python code.
  python rgmatch.py -g ../../hg38.ncbiRefSeq.gtf -b ../../test.bed -o myassoSort.txt
  
  I have tried with classical debugging, but my actual question is how to automatize that?
  Also there are no empty records. The bed file was created based on refseq.txt from the latest human assembly. And also the GTF file. On the refseq.txt I processed to obtain a bed file.
  I have checked if this works on a single record, it does, but not in some specific ones. The error I get is:
    File "rgmatch.py", line 1311, in <module>
      main()
    File "rgmatch.py", line 287, in main
      run(gtf, dhs, outputfile)
    File "rgmatch.py", line 1153, in run
      pctg_area      = (float(region_overlap)/intron_length)*100
  ZeroDivisionError: float division by zero
  
  The record I found so far is this one.
  chr19    14087850    14090751
  I did grep on both GTF files and Refseq Files and in both files there is information about the record. Because the program search for areas between region of interest, If I put inside just the record only in GTF file and bed Files no error occurs.
  grep "14090751" refseq.bed
  692  NM_138352.3 chr19   -   14087850    14090751    14088416    14090420    6   14087850,14088670,14088879,14089067,14089784,14090084,  14088575,14088782,14088976,14089362,14090084,14090751,  0   SAMD1   cmpl    cmpl    0,2,1,0,0,0,
  grep "14090751" hg38.ncbiRefSeq.gtf
  chr19   ncbiRefSeq.2021-02-10   exon    14090085    14090751    .   -   .   gene_id "SAMD1"; transcript_id "NM_138352.3"; exon_number "1"; exon_id "NM_138352.3.1"; gene_name "SAMD1";
  chr19   ncbiRefSeq.2021-02-10   5UTR    14090421    14090751    .   -   .   gene_id "SAMD1"; transcript_id "NM_138352.3"; exon_number "1"; exon_id "NM_138352.3.1"; gene_name "SAMD1";
  
  
  user298: If you want to just start incrementally adding lines from the bed file until you hit the one that reproduces the problem, you can do something like this:
  for i in $(seq 20 30 $(wc -l < ../../test.bed)); do
      head -n $i ../../test.bed > slice.bed
      if python rgmatch.py -g ../../hg38.ncbiRefSeq.gtf -b slice.bed -o slice.out
      then
          true
      else
          echo "Failed when running with the $i first lines."
          break
      fi
  done
      
  
  Explanation
  seq 20 30 $(wc -l < ../../test.bed) will iterate over all numbers between 20 and the number of lines in your bed file with increments of 30. Next, the head -n $i ../../test.bed > slice.bed will take the first $i lines of the bed file. This way, the loop will run the rgmatch command on the first 20 lines of the file, then the first 50, then the first 80 and so on as long as the command runs successfully. When the rgmatch command fails, it will report the value of $i to help you find the line that caused the problem.
  
original_text: 10768: <p>And thanks in advance. I am debugging a text file which is the one the two inputs on the program RGmatch <a href="https://bitbucket.org/pfurio/rgmatch/src/master/" rel="nofollow noreferrer">https://bitbucket.org/pfurio/rgmatch/src/master/</a>.</p>
  <p>The code works. Is that some records give division by zero.</p>
  <p>I am doing it by hand.</p>
  <p>But is there a way by making a bash script, to see which records show the problem?</p>
  <p>I do not want to touch the python code.</p>
  <pre><code>python rgmatch.py -g ../../hg38.ncbiRefSeq.gtf -b ../../test.bed -o myassoSort.txt
  </code></pre>
  <p>I have tried with classical debugging, but my actual question is how to automatize that?</p>
  <p>Also there are no empty records. The bed file was created based on refseq.txt from the latest human assembly. And also the GTF file. On the refseq.txt I processed to obtain a bed file.</p>
  <p>I have checked if this works on a single record, it does, but not in some specific ones. The error I get is:</p>
  <pre><code>  File &quot;rgmatch.py&quot;, line 1311, in &lt;module&gt;
      main()
    File &quot;rgmatch.py&quot;, line 287, in main
      run(gtf, dhs, outputfile)
    File &quot;rgmatch.py&quot;, line 1153, in run
      pctg_area      = (float(region_overlap)/intron_length)*100
  ZeroDivisionError: float division by zero
  </code></pre>
  <p>The record I found so far is this one.</p>
  <p><code>chr19    14087850    14090751</code></p>
  <p>I did grep on both GTF files and Refseq Files and in both files there is information about the record. Because the program search for areas between region of interest, If I put inside just the record only in GTF file and bed Files no error occurs.</p>
  <p><code>grep &quot;14090751&quot; refseq.bed</code></p>
  <p><code>692  NM_138352.3 chr19   -   14087850    14090751    14088416    14090420    6   14087850,14088670,14088879,14089067,14089784,14090084,  14088575,14088782,14088976,14089362,14090084,14090751,  0   SAMD1   cmpl    cmpl    0,2,1,0,0,0,</code></p>
  <p><code>grep &quot;14090751&quot; hg38.ncbiRefSeq.gtf</code></p>
  <pre><code>chr19   ncbiRefSeq.2021-02-10   exon    14090085    14090751    .   -   .   gene_id &quot;SAMD1&quot;; transcript_id &quot;NM_138352.3&quot;; exon_number &quot;1&quot;; exon_id &quot;NM_138352.3.1&quot;; gene_name &quot;SAMD1&quot;;
  chr19   ncbiRefSeq.2021-02-10   5UTR    14090421    14090751    .   -   .   gene_id &quot;SAMD1&quot;; transcript_id &quot;NM_138352.3&quot;; exon_number &quot;1&quot;; exon_id &quot;NM_138352.3.1&quot;; gene_name &quot;SAMD1&quot;;
  </code></pre>
   298: <p>If you want to just start incrementally adding lines from the bed file until you hit the one that reproduces the problem, you can do something like this:</p>
  <pre><code>for i in <span class="math-container">$(seq 20 30 $</span>(wc -l &lt; ../../test.bed)); do
      head -n <span class="math-container">$i ../../test.bed &gt; slice.bed
      if python rgmatch.py -g ../../hg38.ncbiRefSeq.gtf -b slice.bed -o slice.out
      then
          true
      else
          echo "Failed when running with the $</span>i first lines.&quot;
          break
      fi
  done
      
  </code></pre>
  <p><strong>Explanation</strong></p>
  <p><code>seq 20 30 $(wc -l &lt; ../../test.bed)</code> will iterate over all numbers between 20 and the number of lines in your bed file with increments of 30. Next, the <code>head -n $i ../../test.bed &gt; slice.bed</code> will take the first <code>$i</code> lines of the bed file. This way, the loop will run the <code>rgmatch</code> command on the first 20 lines of the file, then the first 50, then the first 80 and so on as long as the command runs successfully. When the <code>rgmatch</code> command fails, it will report the value of <code>$i</code> to help you find the line that caused the problem.</p>
  