trinity-plugins/bwa-0.5.7-patched_multi_map/bwtsw2_aux.c
static void process_seqs(bsw2seq_t *_seq, const bsw2opt_t *opt, const bntseq_t *bns, uint8_t *pac, bwt_t * const target[2])
{
	int i;

#ifdef HAVE_PTHREAD
	if (opt->n_threads <= 1) {
		bsw2_aln_core(0, _seq, opt, bns, pac, target);
	} else {
		pthread_t *tid;
		pthread_attr_t attr;
		thread_aux_t *data;
		int j;
		pthread_attr_init(&attr);
		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
		data = (thread_aux_t*)calloc(opt->n_threads, sizeof(thread_aux_t));
		tid = (pthread_t*)calloc(opt->n_threads, sizeof(pthread_t));
		for (j = 0; j < opt->n_threads; ++j) {
			thread_aux_t *p = data + j;
			p->tid = j; p->_seq = _seq; p->_opt = opt; p->bns = bns;
			p->pac = pac; p->target[0] = target[0]; p->target[1] = target[1];
			pthread_create(&tid[j], &attr, worker, p);
		}
		for (j = 0; j < opt->n_threads; ++j) pthread_join(tid[j], 0);
		free(data); free(tid);
	}
#else
	bsw2_aln_core(0, _seq, opt, bns, pac, target);
#endif

	// print and reset
	for (i = 0; i < _seq->n; ++i) {
		bsw2seq1_t *p = _seq->seq + i;
		if (p->sam) printf("%s", p->sam);
		free(p->name); free(p->seq); free(p->qual); free(p->sam);
		p->tid = -1; p->l = 0;
		p->name = p->seq = p->qual = p->sam = 0;
	}
	fflush(stdout);
	_seq->n = 0;
}
/* process sequences stored in _seq, generate SAM lines for these
 * sequences and reset _seq afterwards. */
process sequences stored in _seq, generate SAM lines for these
sequences and reset _seq afterwards.
process sequences stored in _seq generate SAM lines for these sequences and reset _seq afterwards .
static void process_seqs(bsw2seq_t *_seq, const bsw2opt_t *opt, const bntseq_t *bns, uint8_t *pac, bwt_t * const target[2])
{
	int i;
#ifdef HAVE_PTHREAD
	if (opt->n_threads <= 1) {
		bsw2_aln_core(0, _seq, opt, bns, pac, target);
	} else {
		pthread_t *tid;
		pthread_attr_t attr;
		thread_aux_t *data;
		int j;
		pthread_attr_init(&attr);
		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
		data = (thread_aux_t*)calloc(opt->n_threads, sizeof(thread_aux_t));
		tid = (pthread_t*)calloc(opt->n_threads, sizeof(pthread_t));
		for (j = 0; j < opt->n_threads; ++j) {
			thread_aux_t *p = data + j;
			p->tid = j; p->_seq = _seq; p->_opt = opt; p->bns = bns;
			p->pac = pac; p->target[0] = target[0]; p->target[1] = target[1];
			pthread_create(&tid[j], &attr, worker, p);
		}
		for (j = 0; j < opt->n_threads; ++j) pthread_join(tid[j], 0);
		free(data); free(tid);
	}
#else
	bsw2_aln_core(0, _seq, opt, bns, pac, target);
#endif
	for (i = 0; i < _seq->n; ++i) {
		bsw2seq1_t *p = _seq->seq + i;
		if (p->sam) printf("%s", p->sam);
		free(p->name); free(p->seq); free(p->qual); free(p->sam);
		p->tid = -1; p->l = 0;
		p->name = p->seq = p->qual = p->sam = 0;
	}
	fflush(stdout);
	_seq->n = 0;
}
static void process_seqs ( bsw2seq_t * _seq , const bsw2opt_t * opt , const bntseq_t * bns , uint8_t * pac , bwt_t * const target [ 2 ] ) { int i ; #ifdef HAVE_PTHREAD if ( opt -> n_threads <= 1 ) { bsw2_aln_core ( 0 , _seq , opt , bns , pac , target ) ; } else { pthread_t * tid ; pthread_attr_t attr ; thread_aux_t * data ; int j ; pthread_attr_init ( & attr ) ; pthread_attr_setdetachstate ( & attr , PTHREAD_CREATE_JOINABLE ) ; data = ( thread_aux_t * ) calloc ( opt -> n_threads , sizeof ( thread_aux_t ) ) ; tid = ( pthread_t * ) calloc ( opt -> n_threads , sizeof ( pthread_t ) ) ; for ( j = 0 ; j < opt -> n_threads ; ++ j ) { thread_aux_t * p = data + j ; p -> tid = j ; p -> _seq = _seq ; p -> _opt = opt ; p -> bns = bns ; p -> pac = pac ; p -> target [ 0 ] = target [ 0 ] ; p -> target [ 1 ] = target [ 1 ] ; pthread_create ( & tid [ j ] , & attr , worker , p ) ; } for ( j = 0 ; j < opt -> n_threads ; ++ j ) pthread_join ( tid [ j ] , 0 ) ; free ( data ) ; free ( tid ) ; } #else bsw2_aln_core ( 0 , _seq , opt , bns , pac , target ) ; #endif for ( i = 0 ; i < _seq -> n ; ++ i ) { bsw2seq1_t * p = _seq -> seq + i ; if ( p -> sam ) printf ( " " , p -> sam ) ; free ( p -> name ) ; free ( p -> seq ) ; free ( p -> qual ) ; free ( p -> sam ) ; p -> tid = -1 ; p -> l = 0 ; p -> name = p -> seq = p -> qual = p -> sam = 0 ; } fflush ( stdout ) ; _seq -> n = 0 ; }
process sequences stored in _seq, generate SAM lines for these
 sequences and reset _seq afterwards.
process sequences stored in _seq generate SAM lines for these sequences and reset _seq afterwards .
// print and reset