[med-svn] [Git][med-team/gmap][upstream] New upstream version 2021-02-12+ds

Michael R. Crusoe gitlab at salsa.debian.org
Fri Feb 19 16:07:28 GMT 2021



Michael R. Crusoe pushed to branch upstream at Debian Med / gmap


Commits:
0ba0084d by Michael R. Crusoe at 2021-02-19T16:31:52+01:00
New upstream version 2021-02-12+ds
- - - - -


11 changed files:

- ChangeLog
- VERSION
- src/filestring.c
- src/genome128_hr.c
- src/gmap.c
- src/gsnap.c
- src/outbuffer.c
- src/output.c
- src/resulthr.c
- src/stage3hr.c
- src/stage3hr.h


Changes:

=====================================
ChangeLog
=====================================
@@ -1,3 +1,36 @@
+2021-02-14  twu
+
+    * index.html: Updated for latest version
+
+    * outbuffer.c: Added comment
+
+2021-02-13  twu
+
+    * outbuffer.c: Calling setvbuf before printing file headers
+
+    * gmap.c, gsnap.c: Added comments
+
+    * output.c: Fixed code for deciding on failed input for single-end reads
+
+    * VERSION, index.html: Updated version number
+
+    * output.c: Using the results of Stage3pair_print_end to determine whether a
+      sequence failed to print
+
+    * stage3hr.c, stage3hr.h: Stage3pair_print_end now returns whether it
+      printed an alignment
+
+    * gsnap.c: Formatting change
+
+    * genome128_hr.c: Removed extraneous semicolon at end of macro
+
+    * outbuffer.c: Checking for a NULL string from Filestring_T before pushing
+      onto the failedinput Filestring_T
+
+    * resulthr.c: Fixed a memory leak
+
+    * filestring.c: Removed faulty assertion
+
 2020-12-16  twu
 
     * outbuffer.c: Added option for using write instead of fwrite


=====================================
VERSION
=====================================
@@ -1 +1 @@
-2020-12-17
\ No newline at end of file
+2021-02-12
\ No newline at end of file


=====================================
src/filestring.c
=====================================
@@ -1,4 +1,4 @@
-static char rcsid[] = "$Id: filestring.c 223773 2020-12-14 19:15:02Z twu $";
+static char rcsid[] = "$Id: filestring.c 223803 2021-02-13 17:17:15Z twu $";
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -63,7 +63,9 @@ Filestring_split_output (T this) {
 
 char *
 Filestring_string (T this) {
-  assert(this->string != NULL);	/* Because we assume that Filestring_stringify has been called */
+  /* Because we assume that Filestring_stringify has been called */
+  /* But could be NULL */
+  /* assert(this->string != NULL); */
   return this->string;
 }
 


=====================================
src/genome128_hr.c
=====================================
@@ -1,4 +1,4 @@
-static char rcsid[] = "$Id: genome128_hr.c 223551 2020-11-15 19:43:52Z twu $";
+static char rcsid[] = "$Id: genome128_hr.c 223806 2021-02-13 18:45:39Z twu $";
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -4186,7 +4186,7 @@ clear_lowbit_128 (__m128i _diff, int relpos) {
 #define clear_highbit_32(diff,relpos) (diff ^ (HIGH_BIT >> relpos))
 
 /* Slower: clear_lowbit(diff,relpos) diff -= (1 << relpos) */
-#define clear_lowbit_32(diff,relpos) (diff & (diff - 1));
+#define clear_lowbit_32(diff,relpos) (diff & (diff - 1))
 
 
 #if !defined(HAVE_SSE4_2)


=====================================
src/gmap.c
=====================================
@@ -1,4 +1,4 @@
-static char rcsid[] = "$Id: gmap.c 223772 2020-12-14 19:14:33Z twu $";
+static char rcsid[] = "$Id: gmap.c 223812 2021-02-14 00:01:36Z twu $";
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -4863,6 +4863,7 @@ worker_thread (void *data) {
   Stopwatch_T worker_stopwatch;
   Request_T request;
   Genome_T genome, genomealt;
+  /* Outbuffer_lines_T lines; -- For multithreaded, Output_thread_ordered and Output_thread_anyorder create lines */
   Filestring_T fp, fp_failedinput;
   Sequence_T queryseq;
   int worker_jobid = 0;
@@ -4951,6 +4952,8 @@ worker_thread (void *data) {
     if (fp_failedinput != NULL) {
       Filestring_stringify(fp_failedinput);
     }
+
+    /* For multithreaded, let Outbuffer_thread_ordered and Outbuffer_thread_anyordered call Outbuffer_lines_store */
     Outbuffer_put_filestrings(outbuffer,fp,fp_failedinput);
 
     if (worker_jobid % POOL_FREE_INTERVAL == 0) {


=====================================
src/gsnap.c
=====================================
@@ -1,4 +1,4 @@
-static char rcsid[] = "$Id: gsnap.c 223772 2020-12-14 19:14:33Z twu $";
+static char rcsid[] = "$Id: gsnap.c 223812 2021-02-14 00:01:36Z twu $";
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -1209,8 +1209,7 @@ single_thread () {
     }
 
     /* Previously called Outbuffer_print_filestrings */
-    if (Outbuffer_lines_store(lines,&fp,&fp_failedinput,&fp_failedinput_1,&fp_failedinput_2) >
-	output_buffer_size) {
+    if (Outbuffer_lines_store(lines,&fp,&fp_failedinput,&fp_failedinput_1,&fp_failedinput_2) > output_buffer_size) {
       Outbuffer_lines_print(lines);
     }
 
@@ -1300,6 +1299,7 @@ single_thread () {
 static void *
 worker_thread (void *data) {
   Request_T request;
+  /* Outbuffer_lines_T lines; -- For multithreaded, Output_thread_ordered and Output_thread_anyorder create lines */
   Filestring_T fp, fp_failedinput, fp_failedinput_1, fp_failedinput_2;
   Shortread_T queryseq1;
   Stopwatch_T worker_stopwatch;
@@ -1423,6 +1423,8 @@ worker_thread (void *data) {
     if (fp_failedinput_2 != NULL) {
       Filestring_stringify(fp_failedinput_2);
     }
+
+    /* For multithreaded, let Outbuffer_thread_ordered and Outbuffer_thread_anyordered call Outbuffer_lines_store */
     Outbuffer_put_filestrings(outbuffer,fp,fp_failedinput,fp_failedinput_1,fp_failedinput_2);
 
     if (worker_jobid % POOL_FREE_INTERVAL == 0) {
@@ -3658,12 +3660,6 @@ main (int argc, char *argv[]) {
   FREE(dbversion);
   chromosome_iit = chromosome_iit_setup(&genomelength,&nchromosomes,&circular_typeint,&any_circular_p,&circularp,
 					genomesubdir,genome_fileroot);
-  Outbuffer_setup(argc,argv,optind,chromosome_iit,any_circular_p,
-		  nthreads,orderedp,quiet_if_excessive_p,
-		  output_type,sam_headers_p,sam_read_group_id,sam_read_group_name,
-		  sam_read_group_library,sam_read_group_platform,
-		  paired_end_p,appendp,output_file,split_output_root,failedinput_root);
-
 
   if (transcriptome_dbroot != NULL) {
     if (user_transcriptomedir == NULL && user_genomedir != NULL) {
@@ -3692,6 +3688,13 @@ main (int argc, char *argv[]) {
     return 0;
   }
 
+
+  Outbuffer_setup(argc,argv,optind,chromosome_iit,any_circular_p,
+		  nthreads,orderedp,quiet_if_excessive_p,
+		  output_type,sam_headers_p,sam_read_group_id,sam_read_group_name,
+		  sam_read_group_library,sam_read_group_platform,
+		  paired_end_p,appendp,output_file,split_output_root,failedinput_root);
+
   outbuffer = Outbuffer_new(output_buffer_size,nread);
   Inbuffer_set_outbuffer(inbuffer,outbuffer);
 


=====================================
src/outbuffer.c
=====================================
@@ -1,4 +1,4 @@
-static char rcsid[] = "$Id: outbuffer.c 223787 2020-12-16 16:18:27Z twu $";
+static char rcsid[] = "$Id: outbuffer.c 223814 2021-02-14 17:59:44Z twu $";
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -39,7 +39,11 @@ static char rcsid[] = "$Id: outbuffer.c 223787 2020-12-16 16:18:27Z twu $";
    fewer system calls. */
 
 #define OUTPUTLEN 65536
-#define USE_WRITE 0		/* Use write instead of fwrite.  May not be portable. */
+
+/* Use write instead of fwrite.  May not be portable, and is als not
+   thread-safe, so it can cause a race condition where alignment
+   output is printed before headers.  Therefore, do not use */
+/* #define USE_WRITE 0 */
 
 /* sam-to-bam conversions always need the headers */
 #define SAM_HEADERS_ON_EMPTY_FILES 1
@@ -520,10 +524,10 @@ touch_all_single_outputs (FILE **outputs, char *split_output_root, bool appendp)
     if (outputs[split_output] == NULL) {
       outputs[split_output] = SAM_header_fopen(split_output,split_output_root,paired_end_p,appendp);
       buffer_outputs[split_output] = (char *) MALLOC_KEEP(OUTPUTLEN*sizeof(char));
-      setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
 #ifdef SAM_HEADERS_ON_EMPTY_FILES
       print_file_headers(outputs[split_output]);
 #endif
+      setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
     }
     split_output++;
   }
@@ -535,10 +539,10 @@ touch_all_single_outputs (FILE **outputs, char *split_output_root, bool appendp)
       if (outputs[split_output] == NULL) {
 	outputs[split_output] = SAM_header_fopen(split_output,split_output_root,paired_end_p,appendp);
 	buffer_outputs[split_output] = (char *) MALLOC_KEEP(OUTPUTLEN*sizeof(char));
-	setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
 #ifdef SAM_HEADERS_ON_EMPTY_FILES
         print_file_headers(outputs[split_output]);
 #endif
+	setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
       }
       split_output++;
     }
@@ -549,10 +553,10 @@ touch_all_single_outputs (FILE **outputs, char *split_output_root, bool appendp)
       if (outputs[split_output] == NULL) {
 	outputs[split_output] = SAM_header_fopen(split_output,split_output_root,paired_end_p,appendp);
 	buffer_outputs[split_output] = (char *) MALLOC_KEEP(OUTPUTLEN*sizeof(char));
-	setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
 #ifdef SAM_HEADERS_ON_EMPTY_FILES
         print_file_headers(outputs[split_output]);
 #endif
+	setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
       }
       split_output++;
     }
@@ -571,10 +575,10 @@ touch_all_paired_outputs (FILE **outputs, char *split_output_root, bool appendp)
   while (split_output <= N_SPLIT_OUTPUTS_STD) {
     if (outputs[split_output] == NULL) {
       outputs[split_output] = SAM_header_fopen(split_output,split_output_root,paired_end_p,appendp);
-      setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
 #ifdef SAM_HEADERS_ON_EMPTY_FILES
       print_file_headers(outputs[split_output]);
 #endif
+      setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
     }
     split_output++;
   }
@@ -585,10 +589,10 @@ touch_all_paired_outputs (FILE **outputs, char *split_output_root, bool appendp)
     while (split_output <= N_SPLIT_OUTPUTS_TOCIRC) {
       if (outputs[split_output] == NULL) {
 	outputs[split_output] = SAM_header_fopen(split_output,split_output_root,paired_end_p,appendp);
-	setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
 #ifdef SAM_HEADERS_ON_EMPTY_FILES
         print_file_headers(outputs[split_output]);
 #endif
+	setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
       }
       split_output++;
     }
@@ -598,10 +602,10 @@ touch_all_paired_outputs (FILE **outputs, char *split_output_root, bool appendp)
     while (split_output <= N_SPLIT_OUTPUTS) {
       if (outputs[split_output] == NULL) {
 	outputs[split_output] = SAM_header_fopen(split_output,split_output_root,paired_end_p,appendp);
-	setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
 #ifdef SAM_HEADERS_ON_EMPTY_FILES
         print_file_headers(outputs[split_output]);
 #endif
+	setvbuf(outputs[split_output],buffer_outputs[split_output],_IOFBF,OUTPUTLEN);
       }
       split_output++;
     }
@@ -815,8 +819,8 @@ Outbuffer_print_filestrings (Filestring_T fp, Filestring_T fp_failedinput, Files
       print_file_headers(stdout);
     } else {
       output = outputs[0] = SAM_header_fopen(/*split_output*/OUTPUT_FILE,output_file,paired_end_p,appendp);
-      setvbuf(outputs[0],buffer_outputs[0],_IOFBF,OUTPUTLEN);
       print_file_headers(output);
+      setvbuf(outputs[0],buffer_outputs[0],_IOFBF,OUTPUTLEN);
     }
   }
 
@@ -841,7 +845,7 @@ Outbuffer_print_filestrings (Filestring_T fp, Filestring_T fp_failedinput, Files
   return;
 }
 
-#else
+#elif 0
 void
 Outbuffer_print_filestrings (Filestring_T fp, Filestring_T fp_failedinput) {
   SAM_split_output_type split_output;
@@ -863,12 +867,12 @@ Outbuffer_print_filestrings (Filestring_T fp, Filestring_T fp_failedinput) {
   } else if ((output = outputs[0]) == NULL) {
     if (output_file == NULL) {
       output = outputs[0] = stdout;
-      setvbuf(outputs[0],buffer_outputs[0],_IOFBF,OUTPUTLEN);
       print_file_headers(stdout);
+      setvbuf(outputs[0],buffer_outputs[0],_IOFBF,OUTPUTLEN);
     } else {
       output = outputs[0] = SAM_header_fopen(/*split_output*/OUTPUT_FILE,output_file,paired_end_p,appendp);
-      setvbuf(outputs[0],buffer_outputs[0],_IOFBF,OUTPUTLEN);
       print_file_headers(output);
+      setvbuf(outputs[0],buffer_outputs[0],_IOFBF,OUTPUTLEN);
     }
   }
 
@@ -936,6 +940,7 @@ Outbuffer_lines_store (Outbuffer_lines_T this, Filestring_T *fp, Filestring_T *f
 #endif
 		       ) {
   SAM_split_output_type split_output;
+  char *string;
 
   if (split_output_root != NULL) {
     split_output = Filestring_split_output(*fp);
@@ -955,18 +960,24 @@ Outbuffer_lines_store (Outbuffer_lines_T this, Filestring_T *fp, Filestring_T *f
   this->nlines += 1;
   
   if (*fp_failedinput != NULL) {
-    this->lines_failedinput = List_push(this->lines_failedinput,(void *) Filestring_string(*fp_failedinput));
+    if ((string = Filestring_string(*fp_failedinput)) != NULL) {
+      this->lines_failedinput = List_push(this->lines_failedinput,(void *) string);
+    }
     Filestring_free(&(*fp_failedinput),/*free_string_p*/false);
   }
 
 #ifdef GSNAP
   if (*fp_failedinput_1 != NULL) {
-    this->lines_failedinput_1 = List_push(this->lines_failedinput_1,(void *) Filestring_string(*fp_failedinput_1));
+    if ((string = Filestring_string(*fp_failedinput_1)) != NULL) {
+      this->lines_failedinput_1 = List_push(this->lines_failedinput_1,(void *) string);
+    }
     Filestring_free(&(*fp_failedinput_1),/*free_string_p*/false);
   }
   if (*fp_failedinput_2 != NULL) {
-    this->lines_failedinput_2 = List_push(this->lines_failedinput_2,(void *) Filestring_string(*fp_failedinput_2));
-    Filestring_free(&(*fp_failedinput_1),/*free_string_p*/false);
+    if ((string = Filestring_string(*fp_failedinput_2)) != NULL) {
+      this->lines_failedinput_2 = List_push(this->lines_failedinput_2,(void *) string);
+    }
+    Filestring_free(&(*fp_failedinput_2),/*free_string_p*/false);
   }
 #endif
 


=====================================
src/output.c
=====================================
@@ -1,4 +1,4 @@
-static char rcsid[] = "$Id: output.c 223774 2020-12-14 19:16:04Z twu $";
+static char rcsid[] = "$Id: output.c 223811 2021-02-13 21:51:27Z twu $";
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -394,18 +394,13 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
   Shortread_T queryseq1, queryseq2;
   Stage3end_T *stage3array, stage3;
   int npaths_primary, npaths_altloc, pathnum, first_absmq, second_absmq;
+  bool print1p = false, print2p = false, single_end_p = false;
 
   fp = Filestring_new(Request_id(request));
-
   resulttype = Result_resulttype(result);
-  if (resulttype == SINGLEEND_NOMAPPING) {
-    if (failedinput_root == NULL) {
-      *fp_failedinput = (Filestring_T) NULL;
-    } else {
-      *fp_failedinput = Filestring_new(Request_id(request));
-    }
-    *fp_failedinput_1 = *fp_failedinput_2 = (Filestring_T) NULL;
 
+  if (resulttype == SINGLEEND_NOMAPPING) {
+    single_end_p = true;
     if (nofailsp == true) {
       /* No output */
       /* Filestring_set_split_output(fp,OUTPUT_NONE); -- Already initialized to be OUTPUT_NONE */
@@ -416,21 +411,10 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
       Filestring_set_split_output(fp,OUTPUT_NM);
       print_header_singleend(fp,request,/*translocationp*/false,/*npaths_primary*/0,/*npaths_altloc*/0);
       FPRINTF(fp,"\n");
-
-      if (failedinput_root != NULL) {
-	queryseq1 = Request_queryseq1(request);
-	Shortread_print_query_singleend(*fp_failedinput,queryseq1,/*headerseq*/queryseq1);
-      }
     }
 
   } else if (resulttype == SINGLEEND_UNIQ) {
-    if (failedinput_root == NULL) {
-      *fp_failedinput = (Filestring_T) NULL;
-    } else {
-      *fp_failedinput = Filestring_new(Request_id(request));
-    }
-    *fp_failedinput_1 = *fp_failedinput_2 = (Filestring_T) NULL;
-
+    single_end_p = true;
     if (failsonlyp == true) {
       /* Skip */
       /* Filestring_set_split_output(fp,OUTPUT_NONE); -- Already initialized to be OUTPUT_NONE */
@@ -441,6 +425,7 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
       stage3array = (Stage3end_T *) Result_array(&npaths_primary,&npaths_altloc,&first_absmq,&second_absmq,result);
       stage3 = stage3array[0];
 
+      print1p = true;
       print_header_singleend(fp,request,/*translocationp*/false,npaths_primary,npaths_altloc);
       Stage3end_print(fp,/*stage3pair*/NULL,stage3,
 		      chromosome_iit,queryseq1,/*headerseq*/queryseq1,/*acc_suffix*/"",
@@ -453,13 +438,7 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
     }
 
   } else if (resulttype == SINGLEEND_TRANSLOC) {
-    if (failedinput_root == NULL) {
-      *fp_failedinput = (Filestring_T) NULL;
-    } else {
-      *fp_failedinput = Filestring_new(Request_id(request));
-    }
-    *fp_failedinput_1 = *fp_failedinput_2 = (Filestring_T) NULL;
-
+    single_end_p = true;
     Filestring_set_split_output(fp,OUTPUT_UT);
 
     stage3array = (Stage3end_T *) Result_array(&npaths_primary,&npaths_altloc,&first_absmq,&second_absmq,result);
@@ -480,6 +459,7 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
     } else {
       queryseq1 = Request_queryseq1(request);
 
+      print1p = true;
       print_header_singleend(fp,request,/*translocationp*/true,npaths_primary,npaths_altloc);
       for (pathnum = 1; pathnum <= npaths_primary + npaths_altloc && pathnum <= maxpaths_report; pathnum++) {
 	stage3 = stage3array[pathnum-1];
@@ -495,13 +475,7 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
     }
 
   } else if (resulttype == SINGLEEND_MULT) {
-    if (failedinput_root == NULL) {
-      *fp_failedinput = (Filestring_T) NULL;
-    } else {
-      *fp_failedinput = Filestring_new(Request_id(request));
-    }
-    *fp_failedinput_1 = *fp_failedinput_2 = (Filestring_T) NULL;
-
+    single_end_p = true;
     stage3array = (Stage3end_T *) Result_array(&npaths_primary,&npaths_altloc,&first_absmq,&second_absmq,result);
 
     if (failsonlyp == true) {
@@ -523,6 +497,7 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
     } else {
       queryseq1 = Request_queryseq1(request);
 
+      print1p = true;
       Filestring_set_split_output(fp,OUTPUT_UM);
       print_header_singleend(fp,request,/*translocationp*/false,npaths_primary,npaths_altloc);
       for (pathnum = 1; pathnum <= npaths_primary + npaths_altloc && pathnum <= maxpaths_report; pathnum++) {
@@ -539,15 +514,6 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
     }
 
   } else if (resulttype == PAIREDEND_NOMAPPING) {
-    *fp_failedinput = (Filestring_T) NULL;
-    if (failedinput_root == NULL) {
-      *fp_failedinput_1 = (Filestring_T) NULL;
-      *fp_failedinput_2 = (Filestring_T) NULL;
-    } else {
-      *fp_failedinput_1 = Filestring_new(Request_id(request));
-      *fp_failedinput_2 = Filestring_new(Request_id(request));
-    }
-
     if (nofailsp == true) {
       /* No output */
       /* Filestring_set_split_output(fp,OUTPUT_NONE); -- Already initialized to be OUTPUT_NONE */
@@ -557,30 +523,17 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
       /* Stage3pair_print_end will call Filestring_set_split_output(), based on resulttype */
 
       /* First end */
-      Stage3pair_print_end(fp,*fp_failedinput_1,result,resulttype,'>',/*firstp*/true,chromosome_iit,
-			   /*queryseq*/queryseq1,/*headerseq1*/queryseq1,/*headerseq2*/queryseq2,
-			   maxpaths_report,quiet_if_excessive_p,invert_first_p,quality_shift);
+      print1p = Stage3pair_print_end(fp,result,resulttype,'>',/*firstp*/true,chromosome_iit,
+				     /*queryseq*/queryseq1,/*headerseq1*/queryseq1,/*headerseq2*/queryseq2,
+				     maxpaths_report,quiet_if_excessive_p,invert_first_p,quality_shift);
 
       /* Second end */
-      Stage3pair_print_end(fp,*fp_failedinput_2,result,resulttype,'<',/*firstp*/false,chromosome_iit,
-			   /*queryseq*/queryseq2,/*headerseq1*/queryseq1,/*headerseq2*/queryseq2,
-			   maxpaths_report,quiet_if_excessive_p,invert_second_p,quality_shift);
-
-      if (failedinput_root != NULL) {
-	Shortread_print_query_pairedend(*fp_failedinput_1,*fp_failedinput_2,queryseq1,queryseq2);
-      }
+      print2p = Stage3pair_print_end(fp,result,resulttype,'<',/*firstp*/false,chromosome_iit,
+				     /*queryseq*/queryseq2,/*headerseq1*/queryseq1,/*headerseq2*/queryseq2,
+				     maxpaths_report,quiet_if_excessive_p,invert_second_p,quality_shift);
     }
 
   } else {
-    *fp_failedinput = (Filestring_T) NULL;
-    if (failedinput_root == NULL) {
-      *fp_failedinput_1 = (Filestring_T) NULL;
-      *fp_failedinput_2 = (Filestring_T) NULL;
-    } else {
-      *fp_failedinput_1 = Filestring_new(Request_id(request));
-      *fp_failedinput_2 = Filestring_new(Request_id(request));
-    }
-
     if (failsonlyp == true) {
       /* Unwanted success: skip */
       /* Filestring_set_split_output(fp,OUTPUT_NONE); -- Already initialized to be OUTPUT_NONE */
@@ -591,14 +544,44 @@ filestring_fromresult_gsnap (Filestring_T *fp_failedinput, Filestring_T *fp_fail
       /* Stage3pair_print_end will call Filestring_set_split_output() based on resulttype */
 
       /* First end */
-      Stage3pair_print_end(fp,*fp_failedinput_1,result,resulttype,'>',/*firstp*/true,chromosome_iit,
-			   /*queryseq*/queryseq1,/*headerseq1*/queryseq1,/*headerseq2*/queryseq2,
-			   maxpaths_report,quiet_if_excessive_p,invert_first_p,quality_shift);
+      print1p = Stage3pair_print_end(fp,result,resulttype,'>',/*firstp*/true,chromosome_iit,
+				     /*queryseq*/queryseq1,/*headerseq1*/queryseq1,/*headerseq2*/queryseq2,
+				     maxpaths_report,quiet_if_excessive_p,invert_first_p,quality_shift);
 
       /* Second end */
-      Stage3pair_print_end(fp,*fp_failedinput_2,result,resulttype,'<',/*firstp*/false,chromosome_iit,
-			   /*queryseq*/queryseq2,/*headerseq1*/queryseq1,/*headerseq2*/queryseq2,
-			   maxpaths_report,quiet_if_excessive_p,invert_second_p,quality_shift);
+      print2p = Stage3pair_print_end(fp,result,resulttype,'<',/*firstp*/false,chromosome_iit,
+				     /*queryseq*/queryseq2,/*headerseq1*/queryseq1,/*headerseq2*/queryseq2,
+				     maxpaths_report,quiet_if_excessive_p,invert_second_p,quality_shift);
+    }
+  }
+
+  if (single_end_p == true) {
+    *fp_failedinput_1 = *fp_failedinput_2 = (Filestring_T) NULL;
+    if (failedinput_root == NULL) {
+      *fp_failedinput = (Filestring_T) NULL;
+    } else if (print1p == true) {
+      *fp_failedinput = (Filestring_T) NULL;
+    } else {
+      queryseq1 = Request_queryseq1(request);
+      Shortread_print_query_singleend(*fp_failedinput,queryseq1,/*headerseq1*/queryseq1);
+    }
+
+  } else {
+    *fp_failedinput = (Filestring_T) NULL;
+    if (failedinput_root == NULL) {
+      *fp_failedinput_1 = (Filestring_T) NULL;
+      *fp_failedinput_2 = (Filestring_T) NULL;
+
+    } else if (print1p == true || print2p == true) {
+      *fp_failedinput_1 = (Filestring_T) NULL;
+      *fp_failedinput_2 = (Filestring_T) NULL;
+
+    } else {
+      *fp_failedinput_1 = Filestring_new(Request_id(request));
+      *fp_failedinput_2 = Filestring_new(Request_id(request));
+      queryseq1 = Request_queryseq1(request);
+      queryseq2 = Request_queryseq2(request);
+      Shortread_print_query_pairedend(*fp_failedinput_1,*fp_failedinput_2,queryseq1,queryseq2);
     }
   }
 


=====================================
src/resulthr.c
=====================================
@@ -1,4 +1,4 @@
-static char rcsid[] = "$Id: resulthr.c 223349 2020-10-28 02:49:25Z twu $";
+static char rcsid[] = "$Id: resulthr.c 223804 2021-02-13 17:17:31Z twu $";
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -297,7 +297,14 @@ Result_free (T *old) {
   Stage3pair_T stage3pair;
 
   switch ((*old)->resulttype) {
-  case SINGLEEND_NOMAPPING: case PAIREDEND_NOMAPPING: break;
+  case SINGLEEND_NOMAPPING: case PAIREDEND_NOMAPPING:
+    /* It is possible to have results that are not printed because of various flags */
+    for (i = 0; i < (*old)->npaths_primary + (*old)->npaths_altloc; i++) {
+      stage3 = (*old)->array[i];
+      Stage3end_free(&stage3);
+    }
+    FREE_OUT((*old)->array);
+    break;
 
   case SINGLEEND_UNIQ: case SINGLEEND_TRANSLOC: case SINGLEEND_MULT:
     for (i = 0; i < (*old)->npaths_primary + (*old)->npaths_altloc; i++) {


=====================================
src/stage3hr.c
=====================================
@@ -1,4 +1,4 @@
-static char rcsid[] = "$Id: stage3hr.c 223538 2020-11-15 12:03:08Z twu $";
+static char rcsid[] = "$Id: stage3hr.c 223808 2021-02-13 18:47:25Z twu $";
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -5368,9 +5368,9 @@ Stage3end_new_splice (int *found_score_overall, int *found_score_within_trims,
   Substring_T substring1, substringN;
   Junction_T junction;
 
-  List_T transcripts;
-  char *remap_sequence;
-  int remap_seqlength;
+  /* List_T transcripts; */
+  /* char *remap_sequence; */
+  /* int remap_seqlength; */
   double donor_prob, acceptor_prob;
 #ifdef DEBUG0
   Substring_T substring;
@@ -5706,9 +5706,9 @@ Stage3end_new_distant (int *found_score_overall, int *found_score_within_trims,
   Substring_T donor, acceptor;
   Junction_T junction;
 
-  List_T transcripts;
-  char *remap_sequence;
-  int remap_seqlength;
+  /* List_T transcripts; */
+  /* char *remap_sequence; */
+  /* int remap_seqlength; */
 #ifdef DEBUG0
   Substring_T substring;
   List_T p;
@@ -10074,18 +10074,17 @@ print_barcode_and_quality (Filestring_T fp, Shortread_T queryseq, bool invertp,
 }
 
 
-void
-Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
-		      Result_T result, Resulttype_T resulttype,
+bool
+Stage3pair_print_end (Filestring_T fp, Result_T result, Resulttype_T resulttype,
 		      char initchar, bool firstp, Univ_IIT_T chromosome_iit,
 		      Shortread_T queryseq, Shortread_T headerseq1, Shortread_T headerseq2,
 		      int maxpaths, bool quiet_if_excessive_p,
 		      bool invertp, int quality_shift) {
+  bool printp = false, excessivep, translocationp;
   Stage3pair_T *stage3pairarray, stage3pair;
   T *stage3array, *stage3array_mate, this, hit5, hit3;
   int npaths_primary, npaths_altloc, npaths_mate_primary, npaths_mate_altloc, pathnum;
   int first_absmq, second_absmq;
-  bool excessivep, translocationp;
 
   if (resulttype == PAIREDEND_NOMAPPING) {
     if (output_type != M8_OUTPUT) {
@@ -10099,7 +10098,6 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
       Shortread_print_header(fp,headerseq1,headerseq2);
       FPRINTF(fp,"\n");
     }
-    /* If failedinput_root != NULL, then this case is handled by calling procedure */
 
   } else if (resulttype == CONCORDANT_UNIQ) {
     stage3pairarray = (Stage3pair_T *) Result_array(&npaths_primary,&npaths_altloc,&first_absmq,&second_absmq,result);
@@ -10128,6 +10126,7 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
 	Shortread_print_header(fp,headerseq1,headerseq2);
       }
     
+      printp = true;
       if (firstp == true) {
 	Stage3end_print(fp,stage3pair,hit5,
 			chromosome_iit,queryseq,headerseq1,/*acc_suffix*/"/1",
@@ -10171,10 +10170,6 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
 	FPRINTF(fp,"\n");
       }
 
-      if (failedinput_root != NULL) {
-	Shortread_print_query_singleend(fp_failedinput,queryseq,headerseq1);
-      }
-
     } else {
       if (output_type != M8_OUTPUT) {
 	print_query_header(fp,initchar,queryseq,invertp);
@@ -10187,6 +10182,7 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
 	Shortread_print_header(fp,headerseq1,headerseq2);
       }
 
+      printp = true;
       for (pathnum = 1; pathnum <= npaths_primary + npaths_altloc && pathnum <= maxpaths; pathnum++) {
 	stage3pair = stage3pairarray[pathnum-1];
 	hit5 = stage3pair->hit5;
@@ -10237,10 +10233,7 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
 
 	/* No further output */
 	FPRINTF(fp,"\n");
-	
-	if (failedinput_root != NULL) {
-	  Shortread_print_query_singleend(fp_failedinput,queryseq,headerseq1);
-	}
+	printp = false;
       }
 
     } else {
@@ -10255,6 +10248,7 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
 	Shortread_print_header(fp,headerseq1,headerseq2);
       }
 
+      printp = true;
       for (pathnum = 1; pathnum <= npaths_primary + npaths_altloc && pathnum <= maxpaths; pathnum++) {
 	stage3pair = stage3pairarray[pathnum-1];
 	hit5 = stage3pair->hit5;
@@ -10314,6 +10308,7 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
     hit5 = stage3pair->hit5;
     hit3 = stage3pair->hit3;
     
+    printp = true;
     if (firstp == true) {
       Stage3end_print(fp,stage3pair,hit5,
 		      chromosome_iit,queryseq,headerseq1,/*acc_suffix*/"/1",
@@ -10352,10 +10347,6 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
 
 	/* No further output */
 	FPRINTF(fp,"\n");
-
-	if (failedinput_root != NULL) {
-	  Shortread_print_query_singleend(fp_failedinput,queryseq,headerseq1);
-	}
       }
 
     } else {
@@ -10370,6 +10361,7 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
 	Shortread_print_header(fp,headerseq1,headerseq2);
       }
 
+      printp = true;
       for (pathnum = 1; pathnum <= npaths_primary + npaths_altloc && pathnum <= maxpaths; pathnum++) {
 	stage3pair = stage3pairarray[pathnum-1];
 	hit5 = stage3pair->hit5;
@@ -10476,11 +10468,9 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
 
     if (excessivep == true) {
       /* No output */
-      if (failedinput_root != NULL) {
-	Shortread_print_query_singleend(fp_failedinput,queryseq,headerseq1);
-      }
 					      
     } else {
+      printp = true;
       if (firstp == true) {
 	for (pathnum = 1; pathnum <= npaths_primary + npaths_altloc && pathnum <= maxpaths; pathnum++) {
 	  this = stage3array[pathnum-1];
@@ -10507,7 +10497,7 @@ Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
     }
   }
 
-  return;
+  return printp;
 }
 
 
@@ -11433,9 +11423,9 @@ Stage3pair_new (T hit5_orig, T hit3_orig, int genestrand, int sensedir, Pairtype
   int querylength5 = hit5_orig->querylength;
   int querylength3 = hit3_orig->querylength;
 
-  char *remap_sequence;
-  int remap_seqlength;
-  List_T transcripts;
+  /* char *remap_sequence; */
+  /* int remap_seqlength; */
+  /* List_T transcripts; */
 
 
   debug0(printf("\nStage3pair_new called with pairtype %s and chrnum %d, %d (effective %d, %d), expect_concordant_p %d\n",


=====================================
src/stage3hr.h
=====================================
@@ -1,4 +1,4 @@
-/* $Id: stage3hr.h 223538 2020-11-15 12:03:08Z twu $ */
+/* $Id: stage3hr.h 223808 2021-02-13 18:47:25Z twu $ */
 #ifndef STAGE3HR_INCLUDED
 #define STAGE3HR_INCLUDED
 
@@ -420,9 +420,8 @@ Stage3end_print_transcript_info (Filestring_T fp, Intlist_T trnums, Intlist_T tr
 extern void
 Stage3end_print_transcript_diff (Filestring_T fp, T hit, Intlist_T common_trnums, bool invertp);
 
-extern void
-Stage3pair_print_end (Filestring_T fp, Filestring_T fp_failedinput,
-		      Result_T result, Resulttype_T resulttype,
+extern bool
+Stage3pair_print_end (Filestring_T fp, Result_T result, Resulttype_T resulttype,
 		      char initchar, bool firstp, Univ_IIT_T chromosome_iit,
 		      Shortread_T queryseq, Shortread_T headerseq1, Shortread_T headerseq2,
 		      int maxpaths, bool quiet_if_excessive_p,



View it on GitLab: https://salsa.debian.org/med-team/gmap/-/commit/0ba0084d34b8453a7c19ded1b3b6bf3e3743d358

-- 
View it on GitLab: https://salsa.debian.org/med-team/gmap/-/commit/0ba0084d34b8453a7c19ded1b3b6bf3e3743d358
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20210219/07bd41de/attachment-0001.html>


More information about the debian-med-commit mailing list