]> git.donarmstrong.com Git - fastq-tools.git/blobdiff - src/parse.c
Added a program to adjust quality scores by a fixed offset.
[fastq-tools.git] / src / parse.c
index 9a7774d381a982972a67e4c806ebb46b7066a7d1..61e3efa3cab29160ce59e4823d9aaa726e335059 100644 (file)
@@ -67,7 +67,7 @@ typedef enum
 fastq_t* fastq_open(FILE* f)
 {
     fastq_t* fqf = malloc_or_die(sizeof(fastq_t));
-    or_die((int)(fqf->file = gzdopen(fileno(f), "rb")),
+    or_die((int)((fqf->file = gzdopen(fileno(f), "rb")) != NULL),
            "Can not open gzip file.");
     
     fqf->state = STATE_ID1;
@@ -113,7 +113,7 @@ void fastq_refill(fastq_t* f)
 
 void fastq_get_line(fastq_t* f, str_t* s)
 {
-    int i = 0;
+    size_t i = 0;
 
     if (f->state == STATE_EOF) goto fastq_get_line_done;
 
@@ -169,10 +169,12 @@ int fastq_next(fastq_t* f, seq_t* seq)
         }
 
         /* skip comments */
+        /*
         else if (*f->c == ';') {
             fastq_get_line(f, NULL);
             if (f->state == STATE_EOF) return 0;
         }
+        */
 
         /* read id1 */
         else if (f->state == STATE_ID1) {
@@ -239,6 +241,15 @@ int fastq_next(fastq_t* f, seq_t* seq)
 }
 
 
+void fastq_rewind(fastq_t* fqf)
+{
+    gzrewind(fqf->file);
+    fqf->state = STATE_ID1;
+    fqf->buf[0] = '\0';
+    fqf->c = fqf->buf;
+}
+
+
 void fastq_print(FILE* fout, seq_t* seq)
 {
     /* FASTQ */