int main(int argc, char* argv[]){ /* SWMatrix sw("ACACACTATTGG", "ATGACANNNNNNAGCACACATTGG"); assert(sw.score() == 18); SWMatrix sw2("ATGACANNNNNNAGCACACATTGG", "ACACACTATTGG"); assert(sw2.score() == 18); */ SWMatrix sw3("ACACACTA", "AGCACACA"); sw3.print_matrix(); sw3.gap_seqs(); cout << "Gapped Seqs:\n"; cout << sw3.get_gapped_seq1() << endl; cout << sw3.get_gapped_seq2() << endl; assert(sw3.score() == 10); Read read; read.seq("ATACGA"); assert(read.rev_comp() == "TCGTAT"); read.set_rev_comp(); assert(read.seq() == "TCGTAT"); cout << "All tests passed." << endl; }
void AddRead::Execute() { this->ReadActionParameters(); while (1) { Read *pRead = new Read(Position); Output *pOut = pManager->GetOutput(); pOut->PrintMessage("Enter String: "); Input *pIn = pManager->GetInput(); bool y = pRead->setData((pIn->GetString(pOut))); if (y) { pManager->AddStatement(pRead); pOut->ClearStatusBar(); break; } else { pOut->MsgBox("Invalid text !! Click ok to Re-enter data", "Error", true); } } }
// write read alignment results to disk using e.g. RocksDB void Writer::write() { std::stringstream ss; ss << "Writer " << id << " thread " << std::this_thread::get_id() << " started" << std::endl; std::cout << ss.str(); ss.str(""); auto t = std::chrono::high_resolution_clock::now(); int numPopped = 0; for (;;) { Read read = writeQueue.pop(); if (read.isEmpty) { if (writeQueue.getPushers() == 0) break; // no more records in the queue and no pushers => stop processing if (!read.isValid) continue; } ++numPopped; //std::string matchResultsStr = read.matchesToJson(); std::string readstr = read.toString(); if (!opts.dbg_put_kvdb && readstr.size() > 0) { kvdb.put(std::to_string(read.id), readstr); } } std::chrono::duration<double> elapsed = std::chrono::high_resolution_clock::now() - t; ss << std::setprecision(2) << std::fixed << id << " thread " << std::this_thread::get_id() << " done. Elapsed time: " << elapsed.count() << " s Reads written: " << numPopped << std::endl; std::cout << ss.str(); ss.str(""); } // Writer::write
/** * @param read Read to generate k-mers from. * @param bad_quality_threshold This class virtually cuts * nucleotides with quality lower the threshold from the ends of the * read. */ explicit ValidKMerGenerator(const Read &read, uint8_t bad_quality_threshold = 2) { Reset(read.getSequenceString().data(), read.getQualityString().data(), read.getSequenceString().size(), bad_quality_threshold); }
/** * The main member function for dispensing patterns. * * Returns true iff a pair was parsed succesfully. */ bool PatternSource::nextReadPair( Read& ra, Read& rb, TReadId& rdid, TReadId& endid, bool& success, bool& done, bool& paired, bool fixName) { // nextPatternImpl does the reading from the ultimate source; // it is implemented in concrete subclasses success = done = paired = false; nextReadPairImpl(ra, rb, rdid, endid, success, done, paired); if(success) { // Construct reversed versions of fw and rc seqs/quals ra.finalize(); if(!rb.empty()) { rb.finalize(); } // Fill in the random-seed field using a combination of // information from the user-specified seed and the read // sequence, qualities, and name ra.seed = genRandSeed(ra.patFw, ra.qual, ra.name, seed_); if(!rb.empty()) { rb.seed = genRandSeed(rb.patFw, rb.qual, rb.name, seed_); } } return success; }
void ColorSpaceLoader::load(int maxToLoad,ArrayOfReads*reads,MyAllocator*seqMyAllocator){ char bufferForLine[1024]; int loadedSequences=0; while(m_loaded<m_size&& loadedSequences<maxToLoad){ fgets(bufferForLine,4096,m_f); if(bufferForLine[0]=='#'){ continue;// skip csfasta comment } // read two lines if(bufferForLine[0]=='>'){ fgets(bufferForLine,4096,m_f); for(int j=0;j<(int)strlen(bufferForLine);j++){ if(bufferForLine[j]==DOUBLE_ENCODING_A_COLOR){ bufferForLine[j]='A'; }else if(bufferForLine[j]==DOUBLE_ENCODING_T_COLOR){ bufferForLine[j]='T'; }else if(bufferForLine[j]==DOUBLE_ENCODING_C_COLOR){ bufferForLine[j]='C'; }else if(bufferForLine[j]==DOUBLE_ENCODING_G_COLOR){ bufferForLine[j]='G'; } } Read t; // remove the leading T & first color t.constructor(bufferForLine+2,seqMyAllocator,true); reads->push_back(&t); loadedSequences++; m_loaded++; } } if(m_loaded==m_size){ fclose(m_f); } }
void FastqLoader::loadWithPeriod(int maxToLoad,ArrayOfReads*reads,MyAllocator*seqMyAllocator,int period){ char buffer[RAY_MAXIMUM_READ_LENGTH]; int rotatingVariable=0; int loadedSequences=0; while(loadedSequences<maxToLoad && NULL!=fgets(buffer,RAY_MAXIMUM_READ_LENGTH,m_f)){ if(rotatingVariable==1){ Read t; t.constructor(buffer,seqMyAllocator,true); reads->push_back(&t); } rotatingVariable++; // a period is reached for each read. if(rotatingVariable==period){ rotatingVariable=0; loadedSequences++; m_loaded++; } } if(m_loaded==m_size){ fclose(m_f); } }
Dist bi_partition(CommPtr comm, Read<I8> marks) { CHECK(comm->size() % 2 == 0); Write<I32> dest_ranks(marks.size()); Write<LO> dest_idxs(marks.size()); LO linsize = -1; auto halfsize = comm->size() / 2; I32 rank_start = 0; for (Int half = 0; half < 2; ++half) { marks = invert_marks(marks); auto marked = collect_marked(marks); auto total = comm->allreduce(GO(marked.size()), OMEGA_H_SUM); auto start = comm->exscan(GO(marked.size()), OMEGA_H_SUM); Read<GO> globals(marked.size(), start, 1); auto owners = globals_to_linear_owners(globals, total, halfsize); map_into(add_to_each(owners.ranks, rank_start), marked, dest_ranks, 1); map_into(owners.idxs, marked, dest_idxs, 1); if (rank_start <= comm->rank() && comm->rank() < (rank_start + halfsize)) { linsize = linear_partition_size(total, halfsize, comm->rank() - rank_start); } rank_start += halfsize; } auto dests = Remotes(Read<I32>(dest_ranks), Read<LO>(dest_idxs)); return Dist(comm, dests, linsize); }
/// Read another pattern from a FASTA input file bool TabbedPatternSource::read( Read& r, TReadId& rdid, TReadId& endid, bool& success, bool& done) { r.reset(); r.color = gColor; success = true; done = false; // fb_ is about to dish out the first character of the // name field if(parseName(r, NULL, '\t') == -1) { peekOverNewline(fb_); // skip rest of line r.reset(); success = false; done = true; return false; } assert_neq('\t', fb_.peek()); // fb_ is about to dish out the first character of the // sequence field int charsRead = 0; int mytrim5 = gTrim5; int dstLen = parseSeq(r, charsRead, mytrim5, '\t'); assert_neq('\t', fb_.peek()); if(dstLen < 0) { peekOverNewline(fb_); // skip rest of line r.reset(); success = false; done = true; return false; } // fb_ is about to dish out the first character of the // quality-string field char ct = 0; if(parseQuals(r, charsRead, dstLen, mytrim5, ct, '\n') < 0) { peekOverNewline(fb_); // skip rest of line r.reset(); success = false; done = true; return false; } r.trimmed3 = gTrim3; r.trimmed5 = mytrim5; assert_eq(ct, '\n'); assert_neq('\n', fb_.peek()); r.readOrigBuf.install(fb_.lastN(), fb_.lastNLen()); fb_.resetLastN(); rdid = endid = readCnt_; readCnt_++; return true; }
void TestIReadStreamFull() { ireadstream ifs("./test/data/s_6_1.fastq.gz"); ASSERT(ifs.is_open()); Read r; while (!ifs.eof()) { ifs >> r; } ifs.close(); ASSERT_EQUAL("TEST/1", r.getName()); ASSERT_EQUAL("CATACGGGTTTCCGCCAGTNTTTCCATGCCGCGATGGACGTAGAACAGACGGTAGTCGGCGTCGATAATGTTTTCGCCATCGACGCACAGACGGAAGTGG", r.getSequenceString()); //ASSERT_EQUAL("HHHGHHGIHIHHEHHHHHGHHHHHHHHGHEHHHHDHAHHHA?HFHEFHEHHHGHGGHGG@B2BEBEF=HHGEEA:C?CCD?B@EF/4=2<4188.?BA5=", r.getQuality()); }
/// Read another pair of patterns from a FASTA input file bool SRAPatternSource::readPair( Read& ra, Read& rb, TReadId& rdid, TReadId& endid, bool& success, bool& done, bool& paired) { assert(sra_run_ != NULL && sra_it_ != NULL); success = true; done = false; while(sra_data_->isEmpty()) { if(sra_data_->done && sra_data_->isEmpty()) { ra.reset(); rb.reset(); success = false; done = true; return false; } #if defined(_TTHREAD_WIN32_) Sleep(1); #elif defined(_TTHREAD_POSIX_) const static timespec ts = {0, 1000000}; // 1 millisecond nanosleep(&ts, NULL); #endif } pair<SRA_Read, SRA_Read>& pair = sra_data_->getPairForRead(); ra.name.install(pair.first.name.buf(), pair.first.name.length()); ra.patFw.install(pair.first.patFw.buf(), pair.first.patFw.length()); ra.qual.install(pair.first.qual.buf(), pair.first.qual.length()); ra.trimmed3 = gTrim3; ra.trimmed5 = gTrim5; if(pair.second.patFw.length() > 0) { rb.name.install(pair.first.name.buf(), pair.first.name.length()); rb.patFw.install(pair.second.patFw.buf(), pair.second.patFw.length()); rb.qual.install(pair.second.qual.buf(), pair.second.qual.length()); rb.trimmed3 = gTrim3; rb.trimmed5 = gTrim5; paired = true; } else { rb.reset(); } sra_data_->advanceReadPos(); rdid = endid = readCnt_; readCnt_++; return true; }
/** * The main member function for dispensing pairs of reads or * singleton reads. Returns true iff ra and rb contain a new * pair; returns false if ra contains a new unpaired read. */ bool PairedSoloPatternSource::nextReadPair( Read& ra, Read& rb, TReadId& rdid, TReadId& endid, bool& success, bool& done, bool& paired, bool fixName) { // printf("paired solo pattern source\n"); uint32_t cur = cur_; success = false; while(cur < src_->size()) { // Patterns from srca_[cur_] are unpaired do { (*src_)[cur]->nextReadPair( ra, rb, rdid, endid, success, done, paired, fixName); } while(!success && !done); if(!success) { assert(done); // If patFw is empty, that's our signal that the // input dried up lock(); if(cur + 1 > cur_) cur_++; cur = cur_; unlock(); continue; // on to next pair of PatternSources } assert(success); ra.seed = genRandSeed(ra.patFw, ra.qual, ra.name, seed_); if(!rb.empty()) { rb.seed = genRandSeed(rb.patFw, rb.qual, rb.name, seed_); if(fixName) { ra.fixMateName(1); rb.fixMateName(2); } } ra.rdid = rdid; ra.endid = endid; if(!rb.empty()) { rb.rdid = rdid; rb.endid = endid+1; } ra.mate = 1; rb.mate = 2; return true; // paired } assert_leq(cur, src_->size()); done = (cur == src_->size()); return false; }
int main(int argc, char **argv){ Read le = Read(); if (argc > 1){ le.setFile(string(argv[1])); InstanceVRP vrp = le.readVRP(); vrp.criaMatrizDistancias(); Solucao* sol = new Solucao(&vrp, 100); sol->start(8000, 20); }else cout << "Indique um arquivo de instancia.\n"; //vrp.imprimeMatrizDistancias(); return 0; }
void TestIReadStreamSingleRead() { ireadstream ifs("./test/data/s_6_1.fastq.gz"); ASSERT(ifs.is_open()); Read r; ifs >> r; ASSERT_EQUAL("EAS20_8_6_1_2_768/1", r.getName()); ASSERT_EQUAL("CAGCACAGAGGATATCGCTGTTACANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", r.getSequenceString()); //ASSERT_EQUAL("HGHIHHHGHECHHHHHHHGGHHHHH###########################################################################", r.getQuality()); ifs >> r; ASSERT_EQUAL("EAS20_8_6_1_2_1700/1", r.getName()); ASSERT_EQUAL("CTTGGTGCGGAACTGAAAAGTGGTANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", r.getSequenceString()); //ASSERT_EQUAL("GGGGCGGGGEGGGGGBGAGF:CCCC###########################################################################", r.getQuality()); }
bool QueryFile::next_read(Read &read) { Mutex::Locker locker(_mutex); while (read.read_short_read() > 0) { if (!open_next_file()) { if (_readCount == 0) cerr << "\n!!! WARNING: None of the given file(s) contain any usable read!\n\n"; return false; } } read._nr = _readCount++; if (read.length() > _maxReadLen) _maxReadLen = read.length(); return true; }
void Census::visit(const std::shared_ptr<Instruction> &instruction) { instructions_.push_back(instruction.get()); unique_ = false; switch (instruction->mnemonic()) { case Instruction::READ: { Read *read = instruction->as<Read>(); visit(read->reg()); visit(read->address()); spaces_.push_back(read->space()); break; } case Instruction::WRITE: { Write *write = instruction->as<Write>(); visit(write->value()); visit(write->address()); spaces_.push_back(write->space()); break; } case Instruction::MFENCE: { break; } case Instruction::LOCAL: { Local *local = instruction->as<Local>(); visit(local->reg()); visit(local->value()); break; } case Instruction::CONDITION: { Condition *condition = instruction->as<Condition>(); visit(condition->expression()); break; } case Instruction::ATOMIC: { Atomic *atomic = instruction->as<Atomic>(); for (const auto &instr : atomic->instructions()) { visit(instr); } break; } case Instruction::NOOP: /* FALLTHROUGH */ case Instruction::LOCK: /* FALLTHROUGH */ case Instruction::UNLOCK: break; default: { assert(!"NEVER REACHED"); } } }
CommPtr Comm::graph(Read<I32> dsts) const { #ifdef OMEGA_H_USE_MPI MPI_Comm impl2; int n = 1; int sources[1] = {rank()}; int degrees[1] = {dsts.size()}; HostRead<I32> destinations(dsts); int reorder = 0; CALL(MPI_Dist_graph_create(impl_, n, sources, degrees, destinations.data(), OMEGA_H_MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &impl2)); return CommPtr(new Comm(impl2)); #else return CommPtr(new Comm(true, dsts.size() == 1)); #endif }
// reads must ALWAYS be requested in increasing order of their ID bool ReadStream::getRead(uint64_t r_id, Read& read, bool strip_slash, uint64_t begin_id, uint64_t end_id, /* GBamWriter* um_out, //unmapped reads output char um_code, //if non-zero, write the found read to um_out with this code int64_t* unmapped_counter, //update this counter for unmapped/skipped reads *only* int64_t* multimapped_counter //update this counter for too multi-mapped reads */ GetReadProc* rProc, bool is_unmapped ) { if (!fstream.file) err_die("Error: calling ReadStream::getRead() with no file handle!"); if (r_id<last_id) err_die("Error: ReadStream::getRead() called with out-of-order id#!"); last_id=r_id; bool found=false; read.clear(); while (!found) { QReadData rdata; if (!next_read(rdata)) break; /* if (strip_slash) { string::size_type slash = rdata.read.name.rfind("/"); if (slash != string::npos) rdata.read.name.resize(slash); } uint64_t id = (uint64_t)atol(read.name.c_str()); */ if (rdata->id >= end_id) return false; if (rdata->id < begin_id) continue; //silently skip until begin_id found //does not trigger rProc->process() until begin_id if (rdata->id == r_id) { read=rdata->read; //it will be returned found=true; } else if (rdata->id > r_id) { //can't find it, went too far //only happens when reads [mates] were removed for some reason //read_pq.push(make_pair(id, read)); read_pq.push(rdata); break; } if (rProc) { //skipped read processing (unmapped reads) if (!rProc->process(rdata, found)) //, is_unmapped)) // rProc->process() should normally return TRUE return false; //abort search for r_id, return "not found" } } //while target read id not found return found; }
std::string extendContigsWithContigExtender(ReadSet & contigs, ReadSet::ReadSetVector &contigReadSet, ReadSet & changedContigs, ReadSet & finalContigs, SequenceLengthType minKmerSize, double minimumCoverage, SequenceLengthType maxKmerSize, SequenceLengthType maxExtend, SequenceLengthType kmerStep) { std::stringstream extendLog; //#pragma omp parallel for for (ReadSet::ReadSetSizeType i = 0; i < contigs.getSize(); i++) { const Read &oldRead = contigs.getRead(i); Read newRead; SequenceLengthType oldLen = oldRead.getLength(), newLen = 0; ReadSet::ReadSetSizeType poolSize = contigReadSet[i].getSize(); SequenceLengthType myKmerSize = minKmerSize; if (poolSize > minimumCoverage) { LOG_VERBOSE_OPTIONAL(2, true, "kmer-Extending " << oldRead.getName() << " with " << poolSize << " pool of reads"); ReadSet myContig; myContig.append(oldRead); ReadSet newContig; while (newLen <= oldLen && myKmerSize <= maxKmerSize) { newContig = ContigExtender<KS>::extendContigs(myContig, contigReadSet[i], maxExtend, myKmerSize, myKmerSize); newLen = newContig.getRead(0).getLength(); myKmerSize += kmerStep; } newRead = newContig.getRead(0); } else { newRead = oldRead; } long deltaLen = (long) newLen - (long) oldLen; if (deltaLen > 0) { extendLog << std::endl << "Kmer Extended " << oldRead.getName() << " " << deltaLen << " bases to " << newRead.getLength() << ": " << newRead.getName() << " with " << poolSize << " reads in the pool K " << (myKmerSize - kmerStep); //#pragma omp critical changedContigs.append(newRead); } else { extendLog << std::endl << "Did not extend " << oldRead.getName() << " with " << poolSize << " reads in the pool"; //#pragma omp critical finalContigs.append(oldRead); } } return extendLog.str(); }
void bam2Read(bam1_t *b, Read& rd, bool alt_name=false) { GBamRecord bamrec(b); rd.clear(); rd.seq=bamrec.seqData(&rd.qual); rd.name=bam1_qname(b); if (alt_name) rd.alt_name=bamrec.tag_str("ZN"); }
std::string extendContigsWithCap3(const ReadSet & contigs, ReadSet::ReadSetVector &contigReadSet, ReadSet & changedContigs, ReadSet & finalContigs, ReadSet::ReadSetSizeType minimumCoverage) { std::stringstream extendLog; int poolsWithoutMinimumCoverage = 0; // initialize per-thread Cap3 instances Cap3 cap3[omp_get_max_threads()]; #pragma omp parallel for for (long i = 0; i < (long) contigs.getSize(); i++) { const Read &oldRead = contigs.getRead(i); Read newRead = oldRead; SequenceLengthType oldLen = oldRead.getLength(), newLen = 0; ReadSet::ReadSetSizeType poolSize = contigReadSet[i].getSize(); double extTime = MPI_Wtime(); if (poolSize > minimumCoverage) { LOG_VERBOSE_OPTIONAL(2, true, "Extending " << oldRead.getName() << " with " << poolSize << " pool of reads"); newRead = cap3[omp_get_thread_num()].extendContig(oldRead, contigReadSet[i]); newLen = newRead.getLength(); } else { poolsWithoutMinimumCoverage++; } extTime = MPI_Wtime() - extTime; long deltaLen = (long)newLen - (long)oldLen; if (deltaLen > 0) { extendLog << std::endl << "Cap3 Extended " << oldRead.getName() << " " << deltaLen << " bases to " << newRead.getLength() << ": " << newRead.getName() << " with " << poolSize << " reads in the pool, in " << extTime << " sec"; //#pragma omp critical changedContigs.append(newRead); } else { extendLog << std::endl << "Did not extend " << oldRead.getName() << " with " << poolSize << " reads in the pool, in " << extTime << " sec"; //#pragma omp critical finalContigs.append(oldRead); } } LOG_VERBOSE_OPTIONAL(2, true, "Extended " << contigs.getSize() - poolsWithoutMinimumCoverage << " contigs out of " << contigs.getSize()); return extendLog.str(); }
void print_alignment_matrix(Read const &read, int chrstart, int readstart, int length, int offset_front, int offset_end, Chromosome const &chr, char ori, int K) { int i, j; printf(" k=%d |\t-\t", K); if (ori == '+') for (i = 0; i != length; i++) printf("%c\t", chr[chrstart + i]); else for (i = 0; i != length; i++) printf("%c\t", get_compl_base(chr[chrstart - i])); printf( "\n----------------------------------------------------------------------------------------------"); printf( "----------------------------------------------------------------------------------------------\n"); for (j = 0; j != length + 1; ++j) { if (j == 0) printf(" - |\t"); else { if ((readstart == 0 && (j <= offset_front || (j > length - offset_end && K != 1))) || (readstart != 0 && j > length - offset_end)) printf(" X |\t"); else printf(" %c |\t", read.data()[readstart + j - (readstart == 0) * offset_front - 1]); } if (j > K) for (i = 0; i != j - K; ++i) printf("\t"); for (i = 0; i != 2* K + 1; ++i) { if (i - j > K) break; if (i + j > length + K) break; if (i > length || j > length) break; if ((readstart != 0 && j > length - offset_end) || (readstart == 0 && j < offset_front)) break; //printf("{i%d,j%d}",i,j); //printf("%.1f(%c)\t", M[i][j], T[i][j]); if (i == 6 && j == 1) printf("---"); } printf( "\n----------------------------------------------------------------------------------------------"); printf( "----------------------------------------------------------------------------------------------\n"); } }
void OculusWorldDemoApp::GrabFrame() { pRead->getFrame().copyTo(*lastFrame); cv::flip(*lastFrame, *lastFrame, 1); if ( lastFrame->empty() ) { fprintf( stderr, "ERROR: frame is null...\n" ); } }
int AddBranches(int what=0) { Read A; TFile *f=TFile::Open(A.ReadParameterFromFile("data/config.ini","TREE"),"UPDATE"); TTree *t=(TTree*)f->Get(A.ReadParameterFromFile("data/config.ini","TREENAME")); int nPFCandJet0,nPFCand_QCJet0,nPFCand_QC_ptCutJet0; TBranch *b1=t->Branch("nPFCandJet0",&nPFCandJet0,"nPFCandJet0/I"); TBranch *b2=t->Branch("nPFCand_QCJet0",&nPFCand_QCJet0,"nPFCand_QCJet0/I"); TBranch *b3=t->Branch("nPFCand_QC_ptCutJet0",&nPFCand_QC_ptCutJet0,"nPFCand_QC_ptCutJet0/I"); int nChg,nCharged,nNeutral,nNeutral_ptCut; //SetBranchAddress if(what==0){ t->SetBranchAddress("nChg_QCJet0",&nChg); t->SetBranchAddress("nChargedJet0",&nCharged); t->SetBranchAddress("nNeutralJet0",&nNeutral); t->SetBranchAddress("nNeutral_ptCutJet0",&nNeutral_ptCut); } long long nEntries=t->GetEntries(); //Loop for(long long int i=0;i<nEntries;++i){ t->GetEntry(i); if(what==0){ nPFCandJet0=nCharged+nNeutral; nPFCand_QCJet0=nChg+nNeutral; nPFCand_QC_ptCutJet0=nChg+nNeutral_ptCut; b1->Fill(); b2->Fill(); b3->Fill(); } } //Write the Tree (With OverWrite Option) t->Write("",TObject::kOverwrite); //Close the file f->Close(); //Print a message on stdout printf("Done\n"); return 0; }
Object * Read::readList(std::istream& stream, bool firstTime) { Object * first; int rawChar = stream.peek(); char peekChar = static_cast<char>(rawChar); cout << peekChar; if (peekChar == EOF) throw UnterminatedList(); if (peekChar == ')') { stream.get(peekChar); return new Nil(); } if ((not firstTime) and (peekChar == '.')) { stream.get(peekChar); peekChar = stream.peek(); if (peekChar == EOF) throw LackingCdr(); Read * toRead = new Read(stream); first = toRead->read(); peekChar = stream.peek(); if (peekChar == EOF) throw UnterminatedCons(); if (not (peekChar == ')')) throw TooMuchInCdr() ; stream.get(peekChar); return first; } Read * toRead = new Read(stream); first = toRead->read(); Doublet * doublet = new Doublet(first, readList(stream, false)); return doublet; }
/** load sequences */ int FastaLoader::load(string file,ArrayOfReads*reads,MyAllocator*seqMyAllocator){ string id; ostringstream sequence; string buffer; ifstream f(file.c_str()); while(!f.eof()){ buffer=""; f>>buffer; if(buffer=="") continue; if(buffer[0]=='>'){ char bufferForLine[1024]; f.getline(bufferForLine,1024); if(id!=""){ string sequenceStr=sequence.str(); Read t; t.constructor(sequenceStr.c_str(),seqMyAllocator,true); reads->push_back(&t); } id=buffer; sequence.str(""); }else{ sequence<< buffer; } } string sequenceStr=sequence.str(); ostringstream quality; for(int i=0;i<(int)sequenceStr.length();i++){ quality<< "F"; } Read t; t.constructor(sequenceStr.c_str(),seqMyAllocator,true); reads->push_back(&t); f.close(); return EXIT_SUCCESS; }
void ColorSpaceLoader::load(int maxToLoad,ArrayOfReads*reads,MyAllocator*seqMyAllocator){ char bufferForLine[RAY_MAXIMUM_READ_LENGTH]; int loadedSequences=0; while(m_loaded<m_size&& loadedSequences<maxToLoad){ if(NULL==fgets(bufferForLine,RAY_MAXIMUM_READ_LENGTH,m_f)) continue; if(bufferForLine[0]=='#'){ continue;// skip csfasta comment } // read two lines if(bufferForLine[0]=='>'){ char*returnValue=fgets(bufferForLine,RAY_MAXIMUM_READ_LENGTH,m_f); assert(returnValue != NULL); for(int j=0;j<(int)strlen(bufferForLine);j++){ if(bufferForLine[j]==DOUBLE_ENCODING_A_COLOR){ bufferForLine[j]=SYMBOL_A; }else if(bufferForLine[j]==DOUBLE_ENCODING_T_COLOR){ bufferForLine[j]=SYMBOL_T; }else if(bufferForLine[j]==DOUBLE_ENCODING_C_COLOR){ bufferForLine[j]=SYMBOL_C; }else if(bufferForLine[j]==DOUBLE_ENCODING_G_COLOR){ bufferForLine[j]=SYMBOL_G; } } Read t; // remove the leading T & first color t.constructor(bufferForLine+2,seqMyAllocator,true); reads->push_back(&t); loadedSequences++; m_loaded++; } } if(m_loaded==m_size){ fclose(m_f); } }
void AlignerDriverRootSelector::select( const Read& q, const Read* qo, bool nofw, bool norc, EList<DescentConfig>& confs, EList<DescentRoot>& roots) { // Calculate interval length for both mates int interval = rootIval_.f<int>((double)q.length()); if(qo != NULL) { // Boost interval length by 20% for paired-end reads interval = (int)(interval * 1.2 + 0.5); } float pri = 0.0f; for(int fwi = 0; fwi < 2; fwi++) { bool fw = (fwi == 0); if((fw && nofw) || (!fw && norc)) { continue; } // Put down left-to-right roots w/r/t forward and reverse-complement reads { bool first = true; size_t i = 0; while(first || (i + landing_ <= q.length())) { confs.expand(); confs.back().cons.init(landing_, consExp_); roots.expand(); roots.back().init( i, // offset from 5' end true, // left-to-right? fw, // fw? q.length(), // query length pri); // root priority i += interval; first = false; } } // Put down right-to-left roots w/r/t forward and reverse-complement reads { bool first = true; size_t i = 0; while(first || (i + landing_ <= q.length())) { confs.expand(); confs.back().cons.init(landing_, consExp_); roots.expand(); roots.back().init( q.length() - i - 1, // offset from 5' end false, // left-to-right? fw, // fw? q.length(), // query length pri); // root priority i += interval; first = false; } } } }
bool VectorPatternSource::nextReadImpl( Read& r, TReadId& rdid, TReadId& endid, bool& success, bool& done) { // Let Strings begin at the beginning of the respective bufs r.reset(); lock(); if(cur_ >= v_.size()) { unlock(); // Clear all the Strings, as a signal to the caller that // we're out of reads r.reset(); success = false; done = true; assert(r.empty()); return false; } // Copy v_*, quals_* strings into the respective Strings r.color = gColor; r.patFw = v_[cur_]; r.qual = quals_[cur_]; r.trimmed3 = trimmed3_[cur_]; r.trimmed5 = trimmed5_[cur_]; ostringstream os; os << cur_; r.name = os.str(); cur_++; done = cur_ == v_.size(); rdid = endid = readCnt_; readCnt_++; unlock(); success = true; return true; }
CommPtr Comm::graph_adjacent(Read<I32> srcs, Read<I32> dsts) const { #ifdef OMEGA_H_USE_MPI MPI_Comm impl2; HostRead<I32> sources(srcs); HostRead<I32> destinations(dsts); int reorder = 0; CALL(MPI_Dist_graph_create_adjacent(impl_, sources.size(), sources.data(), OMEGA_H_MPI_UNWEIGHTED, destinations.size(), destinations.data(), OMEGA_H_MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &impl2)); return CommPtr(new Comm(impl2)); #else CHECK(srcs == dsts); return CommPtr(new Comm(true, dsts.size() == 1)); #endif }