#include #include #include "IncludeDefine.h" #include "Parameters.h" #include "SequenceFuns.h" #include "Genome.h" #include "Chain.h" #include "ReadAlignChunk.h" #include "ReadAlign.h" #include "Stats.h" #include "genomeGenerate.h" #include "outputSJ.h" #include "ThreadControl.h" #include "GlobalVariables.h" #include "TimeFunctions.h" #include "ErrorWarning.h" #include "sysRemoveDir.h" #include "BAMfunctions.h" #include "bamSortByCoordinate.h" #include "Transcriptome.h" #include "signalFromBAM.h" #include "mapThreadsSpawn.h" #include "SjdbClass.h" #include "sjdbInsertJunctions.h" #include "Variation.h" #include "Solo.h" #include "samHeaders.h" #include "twoPassRunPass1.h" #include #include "parametersDefault.xxd" void usage(int usageType) { cout << "Usage: STAR [options]... --genomeDir /path/to/genome/index/ --readFilesIn R1.fq R2.fq\n"; cout <<"Spliced Transcripts Alignment to a Reference (c) Alexander Dobin, 2009-2020\n\n"; cout << "STAR version=" << STAR_VERSION << "\n"; cout << "STAR compilation time,server,dir=" << COMPILATION_TIME_PLACE << "\n"; cout << "For more details see:\n"; cout << "\n"; cout << "\n"; if (usageType==0) {//brief cout << "\nTo list all parameters, run STAR --help\n"; } else if (usageType==1) {//full cout.write(reinterpret_cast (parametersDefault), parametersDefault_len); }; exit(0); }; int main(int argInN, char* argIn[]) { // If no argument is given, or the first argument is either '-h' or '--help', run usage() if (argInN == 1) { usage(0); } else if (argInN == 2 && (strcmp("-h",argIn[1]) == 0 || strcmp ("--help",argIn[1]) == 0 )) { usage(1); }; time(&g_statsAll.timeStart); /////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////// Parameters Parameters P; //all parameters P.inputParameters(argInN, argIn); *(P.inOut->logStdOut) << "\t" << P.commandLine << '\n'; *(P.inOut->logStdOut) << "\tSTAR version: " << STAR_VERSION << " compiled: " << COMPILATION_TIME_PLACE << '\n'; *(P.inOut->logStdOut) << timeMonthDayTime(g_statsAll.timeStart) << " ..... started STAR run\n" <0) {//generate original genome, in addition to the transfomed generated above P.pGe.transform.type = 0; P.pGe.transform.typeString = "None"; P.pGe.transform.vcfFile = "-"; P.pGe.gDir += "/OriginalGenome/"; Genome genomeOrig(P, P.pGe); genomeOrig.genomeGenerate(); }; sysRemoveDir (P.outFileTmp); P.inOut->logMain << "DONE: Genome generation, EXITING\n" << flush; exit(0); } else if ( P.runMode == "liftOver" ) { for (uint ii=0; iilogMain << "DONE: lift-over of GTF file, EXITING\n" << flush; exit(0); }; } else { P.inOut->logMain << "EXITING because of INPUT ERROR: unknown value of input parameter runMode=" <1) { g_threadChunks.threadArray=new pthread_t[P.runThreadN]; pthread_mutex_init(&g_threadChunks.mutexInRead, NULL); pthread_mutex_init(&g_threadChunks.mutexOutSAM, NULL); pthread_mutex_init(&g_threadChunks.mutexOutBAM1, NULL); pthread_mutex_init(&g_threadChunks.mutexOutUnmappedFastx, NULL); pthread_mutex_init(&g_threadChunks.mutexOutFilterBySJout, NULL); pthread_mutex_init(&g_threadChunks.mutexStats, NULL); pthread_mutex_init(&g_threadChunks.mutexBAMsortBins, NULL); pthread_mutex_init(&g_threadChunks.mutexError, NULL); }; g_statsAll.progressReportHeader(P.inOut->logProgress); ///////////////////////////////////////////////////////////////////////////// //////////////////////////////////// 2-pass 1st pass twoPassRunPass1(P, genomeMain, transcriptomeMain, sjdbLoci); if ( P.quant.yes ) {//load transcriptome transcriptomeMain=new Transcriptome(P); }; //initialize Stats g_statsAll.resetN(); time(&g_statsAll.timeStartMap); *P.inOut->logStdOut << timeMonthDayTime(g_statsAll.timeStartMap) << " ..... started mapping\n" <logMain << "mlock value="<logMain << "Completed stage 1 mapping of outFilterBySJout mapping\n"<chunkOutBAMcoord->coordUnmappedPrepareBySJout(); }; }; mapThreadsSpawn(P, RAchunk); }; //close some BAM files if (P.inOut->outBAMfileUnsorted!=NULL) { bgzf_flush(P.inOut->outBAMfileUnsorted); bgzf_close(P.inOut->outBAMfileUnsorted); }; if (P.inOut->outQuantBAMfile!=NULL) { bgzf_flush(P.inOut->outQuantBAMfile); bgzf_close(P.inOut->outQuantBAMfile); }; if (P.outBAMcoord && P.limitBAMsortRAM==0) {//make it equal ot the genome size P.limitBAMsortRAM=genomeMain.nGenome+genomeMain.SA.lengthByte+genomeMain.SAi.lengthByte; }; time(&g_statsAll.timeFinishMap); *P.inOut->logStdOut << timeMonthDayTime(g_statsAll.timeFinishMap) << " ..... finished mapping\n" <chunkTr); soloMain.processAndOutput(); if ( P.quant.geCount.yes ) {//output gene quantifications for (int ichunk=1; ichunkchunkTr->quants->addQuants(*(RAchunk[ichunk]->chunkTr->quants)); }; RAchunk[0]->chunkTr->quantsOutput(); }; if (P.runThreadN>1 && P.outSAMorder=="PairedKeepInputOrder") {//concatenate Aligned.* files RAchunk[0]->chunkFilesCat(P.inOut->outSAM, P.outFileTmp + "/Aligned.out.sam.chunk", g_threadChunks.chunkOutN); }; bamSortByCoordinate(P, RAchunk, *genomeMain.genomeOut.g, soloMain); //wiggle output if (P.outWigFlags.yes) { *(P.inOut->logStdOut) << timeMonthDayTime() << " ..... started wiggle output\n" <logMain << timeMonthDayTime() << " ..... started wiggle output\n" <outChimJunction, P.pCh.outJunctionFormat, "#", STAR_VERSION + string(" ") + P.commandLine); g_statsAll.progressReport(P.inOut->logProgress); P.inOut->logProgress << "ALL DONE!\n"<logFinal.open((P.outFileNamePrefix + "Log.final.out").c_str()); g_statsAll.reportFinal(P.inOut->logFinal); *P.inOut->logStdOut << timeMonthDayTime(g_statsAll.timeFinish) << " ..... finished successfully\n" <logMain << "ALL DONE!\n" << flush; if (P.outTmpKeep=="None") { sysRemoveDir (P.outFileTmp); }; P.closeReadsFiles();//this will kill the readFilesCommand processes if necessary //genomeMain.~Genome(); //need explicit call because of the 'delete P.inOut' below, which will destroy P.inOut->logStdOut if (genomeMain.sharedMemory != NULL) {//need explicit call because this destructor will write to files which are deleted by 'delete P.inOut' below delete genomeMain.sharedMemory; genomeMain.sharedMemory = NULL; }; delete P.inOut; //to close files return 0; };