1 #include "twoPassRunPass1.h"
2 #include "mapThreadsSpawn.h"
3 #include "ReadAlignChunk.h"
4 #include "Stats.h"
5 #include "GlobalVariables.h"
6 #include "outputSJ.h"
7 #include "sjdbInsertJunctions.h"
8 
twoPassRunPass1(Parameters & P,Genome & genomeMain,Transcriptome * transcriptomeMain,SjdbClass & sjdbLoci)9 void twoPassRunPass1(Parameters &P, Genome &genomeMain, Transcriptome *transcriptomeMain, SjdbClass &sjdbLoci) //2-pass: 1st pass
10 {
11     if (!P.twoPass.yes)
12         return;
13 
14     //re-define P and genomeMain for the pass1
15     Genome genomeMain1=genomeMain;
16 
17     Parameters P1=P;
18     //turn off unnecessary calculations
19     P1.outSAMtype[0]="None";
20     P1.outSAMbool=false;
21     P1.outBAMunsorted=false;
22     P1.outBAMcoord=false;
23 
24     P1.pCh.segmentMin=0;
25 
26     P1.quant.yes=false;
27     P1.quant.trSAM.yes=false;
28     P1.quant.trSAM.bamYes=false;
29     P1.quant.geneFull.yes=false;
30     P1.quant.geCount.yes=false;
31     P1.quant.gene.yes=false;
32 
33     P1.outSAMunmapped.within=false;
34 
35     P1.outFilterBySJoutStage=0;
36 
37     P1.outReadsUnmapped="None";
38 
39     P1.outFileNamePrefix=P.twoPass.dir;
40 
41     P1.readMapNumber=min(P.twoPass.pass1readsN, P.readMapNumber);
42 //         P1.inOut->logMain.open((P1.outFileNamePrefix + "Log.out").c_str());
43 
44     P1.wasp.outputMode="None"; //no WASP filtering on the 1st pass
45     P1.pSolo.type=P1.pSolo.SoloTypes::None; //no solo in the first pass
46 
47     g_statsAll.resetN();
48     time(&g_statsAll.timeStartMap);
49     P.inOut->logProgress << timeMonthDayTime(g_statsAll.timeStartMap) <<"\tStarted 1st pass mapping\n" <<flush;
50     *P.inOut->logStdOut << timeMonthDayTime(g_statsAll.timeStartMap) << " ..... started 1st pass mapping\n" <<flush;
51 
52     //run mapping for Pass1
53     ReadAlignChunk *RAchunk1[P.runThreadN];
54     for (int ii=0;ii<P1.runThreadN;ii++) {
55         RAchunk1[ii]=new ReadAlignChunk(P1, genomeMain, transcriptomeMain, ii);
56     };
57     mapThreadsSpawn(P1, RAchunk1);
58     outputSJ(RAchunk1,P1); //collapse and output junctions
59 //         for (int ii=0;ii<P1.runThreadN;ii++) {
60 //             delete [] RAchunk[ii];
61 //         };
62 
63     time_t rawtime; time (&rawtime);
64     P.inOut->logProgress << timeMonthDayTime(rawtime) <<"\tFinished 1st pass mapping\n";
65     *P.inOut->logStdOut << timeMonthDayTime(rawtime) << " ..... finished 1st pass mapping\n" <<flush;
66     ofstream logFinal1 ( (P.twoPass.dir + "/Log.final.out").c_str());
67     g_statsAll.reportFinal(logFinal1);
68 
69     P.twoPass.pass2=true;//starting the 2nd pass
70     P.twoPass.pass1sjFile=P.twoPass.dir+"/SJ.out.tab";
71 
72     sjdbInsertJunctions(P, genomeMain, genomeMain1, sjdbLoci);
73 
74     //reopen reads files
75     P.closeReadsFiles();
76     P.openReadsFiles();
77 };