vector<paired_fasta_read> Read() { vector<paired_fasta_read> reads; string tmp_str; string name1, seq1, name2, seq2; while(!file_handler_.eof()) { getline(file_handler_, tmp_str); if(IsFastaName(tmp_str)) { if(name1 == "" && name2 == "" && seq1 == "" && seq2 == "") name1 = tmp_str; else if(name1 != "" && name2 != "" && seq1 != "" && seq2 != "") { reads.push_back(paired_fasta_read(fasta_read(name1, seq1), fasta_read(name2, seq2))); name1 = tmp_str; name2 = ""; seq1 = ""; seq2 = ""; } else name2 = tmp_str; } else { assert(name1 != ""); if(name2 == "") seq1 = seq1 + tmp_str; else seq2 = seq2 + tmp_str; } } if(name1 != "" && name2 != "" && seq1 != "" && seq2 != "") reads.push_back(paired_fasta_read(fasta_read(name1, seq1), fasta_read(name2, seq2))); return reads; }
void* pique_thread(void* arg) { pique_ctx_t* ctx = arg; seq_t* seq = seq_create(); twobit_t* tb = twobit_alloc(); rng_t* rng = rng_alloc(1234); bool r; while (true) { pthread_mutex_lock(ctx->f_mutex); if (ctx->fmt == INPUT_FMT_FASTA) r = fasta_read(ctx->f, seq); else if (ctx->fmt == INPUT_FMT_FASTQ) r = fastq_read(ctx->f, seq); pthread_mutex_unlock(ctx->f_mutex); if (!r) break; /* TODO: remove sequences with Ns? */ twobit_copy_str_n(tb, seq->seq.s, seq->seq.n); dbg_add_twobit_seq(ctx->G, rng, tb); } rng_free(rng); seq_free(seq); return NULL; }
vector<fasta_read> Read() { vector<fasta_read> reads; string tmp_str; string name, seq; while(!file_handler_.eof()) { getline(file_handler_, tmp_str); if(tmp_str != "") { if(IsFastaName(tmp_str)) { if(name != "" && seq != "") reads.push_back(fasta_read(name, seq)); name = tmp_str; seq = ""; } else seq = seq + tmp_str; } } if(name != "" && seq != "") reads.push_back(fasta_read(name, seq)); return reads; }