Note that there are some explanatory texts on larger screens.

plurals
  1. POC - Trying to go back to previous line in the file
    primarykey
    data
    text
    <p>I have to read a text file which can begin with optional comments. In practice I have to skip any line at the beginning of the file that doesn't begin with '@' or '>'. In my test case the file looks like:</p> <pre><code># Sun Jul 12 22:04:52 2009 /share/apps/corona/bin/filter_fasta.pl --output=/data/results/solid0065/primary.20090712170542775 # Cwd: /state/partition1/home/pipeline # Title: solid0065_20090629_FC1_Tomate_Heinz_4_5_Kb_Tomate_Heinz_4_5_Kb_01 &gt;125_963_316_F3 T1230330231223011323010013 </code></pre> <p><br /></p> <p>So I have to skip the first 3 line (but in general I have to skip n lines). I have to repeat this with 2 or 4 files [which are inside FILE** inputFiles]. I've tried with this loop:</p> <pre><code>buffer = (char*) malloc (sizeof(char) * 5000); if (buffer == NULL) notEnoughMemory(); for (i = 0; i &lt; (cIn-1); i++){ fgetpos(inputFiles[i], &amp;position); fgets(buffer, 4999, inputFiles[i]); while ((buffer[0] != '@') &amp;&amp; (buffer[0] != '&gt;')){ fgetpos(inputFiles[i], &amp;position); fgets(buffer, 4999, inputFiles[i]); } fsetpos(inputFiles[i], &amp;position); } </code></pre> <p><br /></p> <p>Where cIn is number_of_input_files + 1. Trying to debug it the loop correctly stops after it reads the fourth line. But when I use setpos it doesn't go back to the beginning of the fourth line as I'd expect, but at the middle of the third. In fact if, exactly after the fsetpos(), I print buffer after these operations:</p> <pre><code>fgets(buffer, 4999, inputFiles[i]); fgets(buffer, 4999, inputFiles[i]); </code></pre> <p>I get:</p> <pre><code>FC1_Tomate_Heinz_4_5_Kb_Tomate_Heinz_4_5_Kb_01 &gt;125_963_316_F3 </code></pre> <p>Any idea? Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload