MCPcopy Create free account
hub / github.com/OpenGene/fastp / interleavedReaderTask

Method interleavedReaderTask

src/peprocessor.cpp:890–1019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

888}
889
890void PairEndProcessor::interleavedReaderTask()
891{
892 if(mOptions->verbose)
893 loginfo("start to load data");
894 long lastReported = 0;
895 int slept = 0;
896 long readNum = 0;
897 bool splitSizeReEvaluated = false;
898 Read** dataLeft = new Read*[PACK_SIZE];
899 Read** dataRight = new Read*[PACK_SIZE];
900 memset(dataLeft, 0, sizeof(Read*)*PACK_SIZE);
901 memset(dataRight, 0, sizeof(Read*)*PACK_SIZE);
902 FastqReaderPair reader(mOptions->in1, mOptions->in2, true, mOptions->phred64,true);
903 int count=0;
904 bool needToBreak = false;
905 ReadPair* pair = new ReadPair();
906 while(true){
907 reader.read(pair);
908 // TODO: put needToBreak here is just a WAR for resolve some unidentified dead lock issue
909 if(pair->eof() || needToBreak){
910 // the last pack
911 ReadPack* packLeft = new ReadPack;
912 ReadPack* packRight = new ReadPack;
913 packLeft->data = dataLeft;
914 packRight->data = dataRight;
915 packLeft->count = count;
916 packRight->count = count;
917
918 mLeftInputLists[mLeftPackReadCounter % mOptions->thread]->produce(packLeft);
919 mLeftPackReadCounter++;
920
921 mRightInputLists[mRightPackReadCounter % mOptions->thread]->produce(packRight);
922 mRightPackReadCounter++;
923
924 mBackpressureCV.notify_all();
925 dataLeft = NULL;
926 dataRight = NULL;
927 break;
928 }
929 dataLeft[count] = pair->mLeft;
930 dataRight[count] = pair->mRight;
931 count++;
932 // configured to process only first N reads
933 if(mOptions->readsToProcess >0 && count + readNum >= mOptions->readsToProcess) {
934 needToBreak = true;
935 }
936 if(mOptions->verbose && count + readNum >= lastReported + 1000000) {
937 lastReported = count + readNum;
938 string msg = "loaded " + to_string((lastReported/1000000)) + "M read pairs";
939 loginfo(msg);
940 }
941 // a full pack
942 if(count == PACK_SIZE || needToBreak){
943 ReadPack* packLeft = new ReadPack;
944 ReadPack* packRight = new ReadPack;
945 packLeft->data = dataLeft;
946 packRight->data = dataRight;
947 packLeft->count = count;

Callers

nothing calls this directly

Calls 6

loginfoFunction · 0.85
produceMethod · 0.80
bufferLengthMethod · 0.80
setProducerFinishedMethod · 0.80
readMethod · 0.45
eofMethod · 0.45

Tested by

no test coverage detected