Skip to content

Commit 73b732b

Browse files
committed
Replacing P-> with P. Save before replacing *P) with P)
1 parent 96e0d92 commit 73b732b

File tree

82 files changed

+1516
-1521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1516
-1521
lines changed

source/BAMbinSortByCoordinate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "serviceFuns.cpp"
44
#include "BAMfunctions.h"
55

6-
void BAMbinSortByCoordinate(uint32 iBin, uint binN, uint binS, uint nThreads, string dirBAMsort, Parameters *P) {
6+
void BAMbinSortByCoordinate(uint32 iBin, uint binN, uint binS, uint nThreads, string dirBAMsort, Parameters &P) {
77

88
if (binS==0) return; //nothing to do for empty bins
99
//allocate arrays
@@ -30,7 +30,7 @@ void BAMbinSortByCoordinate(uint32 iBin, uint binN, uint binS, uint nThreads, st
3030
ostringstream errOut;
3131
errOut << "EXITING because of FATAL ERROR: number of bytes expected from the BAM bin does not agree with the actual size on disk: ";
3232
errOut << binS <<" "<< bamInBytes <<" "<< iBin <<"\n";
33-
exitWithError(errOut.str(),std::cerr, P->inOut->logMain, 1, *P);
33+
exitWithError(errOut.str(),std::cerr, P.inOut->logMain, 1, *P);
3434
};
3535

3636
//extract coordinates
@@ -48,8 +48,8 @@ void BAMbinSortByCoordinate(uint32 iBin, uint binN, uint binS, uint nThreads, st
4848
qsort((void*) startPos, binN, sizeof(uint)*3, funCompareArrays<uint,3>);
4949

5050
BGZF *bgzfBin;
51-
bgzfBin=bgzf_open((dirBAMsort+"/b"+to_string((uint) iBin)).c_str(),("w"+to_string((long long) P->outBAMcompression)).c_str());
52-
outBAMwriteHeader(bgzfBin,P->samHeaderSortedCoord,P->chrNameAll,P->chrLengthAll);
51+
bgzfBin=bgzf_open((dirBAMsort+"/b"+to_string((uint) iBin)).c_str(),("w"+to_string((long long) P.outBAMcompression)).c_str());
52+
outBAMwriteHeader(bgzfBin,P.samHeaderSortedCoord,P.chrNameAll,P.chrLengthAll);
5353
//send ordered aligns to bgzf one-by-one
5454
for (uint ia=0;ia<binN;ia++) {
5555
char* ib=bamIn+startPos[ia*3+2];

source/BAMbinSortByCoordinate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
#include "Parameters.h"
55
#include SAMTOOLS_BGZF_H
66

7-
void BAMbinSortByCoordinate(uint32 iBin, uint binN, uint binS, uint nThreads, string dirBAMsort, Parameters *P);
7+
void BAMbinSortByCoordinate(uint32 iBin, uint binN, uint binS, uint nThreads, string dirBAMsort, Parameters &P);
88

99
#endif

source/BAMbinSortUnmapped.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
#include "ErrorWarning.h"
33
#include "BAMfunctions.h"
44

5-
void BAMbinSortUnmapped(uint32 iBin, uint nThreads, string dirBAMsort, BGZF *bgzfBAM, Parameters *P) {
5+
void BAMbinSortUnmapped(uint32 iBin, uint nThreads, string dirBAMsort, BGZF *bgzfBAM, Parameters &P) {
66

77
BGZF *bgzfBin;
8-
bgzfBin=bgzf_open((dirBAMsort+"/b"+to_string((uint) iBin)).c_str(),("w"+to_string((long long) P->outBAMcompression)).c_str());
9-
outBAMwriteHeader(bgzfBin,P->samHeaderSortedCoord,P->chrNameAll,P->chrLengthAll);
8+
bgzfBin=bgzf_open((dirBAMsort+"/b"+to_string((uint) iBin)).c_str(),("w"+to_string((long long) P.outBAMcompression)).c_str());
9+
outBAMwriteHeader(bgzfBin,P.samHeaderSortedCoord,P.chrNameAll,P.chrLengthAll);
1010

1111

1212
vector<string> bamInFile;

source/BAMbinSortUnmapped.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
#include "Parameters.h"
55
#include SAMTOOLS_BGZF_H
66

7-
void BAMbinSortUnmapped(uint32 iBin, uint nThreads, string dirBAMsort, BGZF *bgzfBAM, Parameters *P);
7+
void BAMbinSortUnmapped(uint32 iBin, uint nThreads, string dirBAMsort, BGZF *bgzfBAM, Parameters &P);
88

99
#endif

source/BAMoutput.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
#include "serviceFuns.cpp"
66
#include "ThreadControl.h"
77

8-
BAMoutput::BAMoutput (int iChunk, string tmpDir, Parameters *Pin) {//allocate bam array
8+
BAMoutput::BAMoutput (int iChunk, string tmpDir, Parameters &Pin) {//allocate bam array
99

1010
P=Pin;
1111

12-
nBins=P->outBAMcoordNbins;
13-
binSize=P->chunkOutBAMsizeBytes/nBins;
12+
nBins=P.outBAMcoordNbins;
13+
binSize=P.chunkOutBAMsizeBytes/nBins;
1414
bamArraySize=binSize*nBins;
1515
bamArray = new char [bamArraySize];
1616

1717
bamDir=tmpDir+to_string((uint) iChunk);//local directory for this thread (iChunk)
1818

19-
mkdir(bamDir.c_str(),P->runDirPerm);
19+
mkdir(bamDir.c_str(),P.runDirPerm);
2020
binStart=new char* [nBins];
2121
binBytes=new uint64 [nBins];
2222
binStream=new ofstream* [nBins];
@@ -34,11 +34,11 @@ BAMoutput::BAMoutput (int iChunk, string tmpDir, Parameters *Pin) {//allocate ba
3434
nBins=1;//start with one bin to estimate genomic bin sizes
3535
};
3636

37-
BAMoutput::BAMoutput (BGZF *bgzfBAMin, Parameters *Pin) {//allocate BAM array with one bin, streamed directly into bgzf file
37+
BAMoutput::BAMoutput (BGZF *bgzfBAMin, Parameters &Pin) {//allocate BAM array with one bin, streamed directly into bgzf file
3838

3939
P=Pin;
4040

41-
bamArraySize=P->chunkOutBAMsizeBytes;
41+
bamArraySize=P.chunkOutBAMsizeBytes;
4242
bamArray = new char [bamArraySize];
4343
binBytes1=0;
4444
bgzfBAM=bgzfBAMin;
@@ -90,9 +90,9 @@ void BAMoutput::coordOneAlign (char *bamIn, uint bamSize, uint iRead) {
9090
bamIn32=(uint32*) bamIn;
9191
alignG=( ((uint) bamIn32[1]) << 32 ) | ( (uint)bamIn32[2] );
9292
if (bamIn32[1] == ((uint32) -1) ) {//unmapped
93-
iBin=P->outBAMcoordNbins-1;
93+
iBin=P.outBAMcoordNbins-1;
9494
} else if (nBins>1) {//bin starts have already been determined
95-
iBin=binarySearch1a <uint64> (alignG, P->outBAMsortingBinStart, (int32) (nBins-1));
95+
iBin=binarySearch1a <uint64> (alignG, P.outBAMsortingBinStart, (int32) (nBins-1));
9696
};
9797
};
9898

@@ -104,7 +104,7 @@ void BAMoutput::coordOneAlign (char *bamIn, uint bamSize, uint iRead) {
104104

105105
//write buffer is filled
106106
if (binBytes[iBin]+bamSize+sizeof(uint) > ( (iBin>0 || nBins>1) ? binSize : binSize1) ) {//write out this buffer
107-
if ( nBins>1 || iBin==(P->outBAMcoordNbins-1) ) {//normal writing, bins have already been determined
107+
if ( nBins>1 || iBin==(P.outBAMcoordNbins-1) ) {//normal writing, bins have already been determined
108108
binStream[iBin]->write(binStart[iBin],binBytes[iBin]);
109109
binBytes[iBin]=0;//rewind the buffer
110110
} else {//the first chunk of reads was written in one bin, need to determine bin sizes, and re-distribute reads into bins
@@ -125,11 +125,11 @@ void BAMoutput::coordOneAlign (char *bamIn, uint bamSize, uint iRead) {
125125
};
126126

127127
void BAMoutput::coordBins() {//define genomic starts for bins
128-
nBins=P->outBAMcoordNbins;//this is the true number of bins
128+
nBins=P.outBAMcoordNbins;//this is the true number of bins
129129

130130
//mutex here
131-
if (P->runThreadN>1) pthread_mutex_lock(&g_threadChunks.mutexBAMsortBins);
132-
if (P->outBAMsortingBinStart[0]!=0) {//it's set to 0 only after the bin sizes are determined
131+
if (P.runThreadN>1) pthread_mutex_lock(&g_threadChunks.mutexBAMsortBins);
132+
if (P.outBAMsortingBinStart[0]!=0) {//it's set to 0 only after the bin sizes are determined
133133
//extract coordinates and sort
134134
uint *startPos = new uint [binTotalN[0]];//array of aligns start positions
135135
for (uint ib=0,ia=0;ia<binTotalN[0];ia++) {
@@ -140,19 +140,19 @@ void BAMoutput::coordBins() {//define genomic starts for bins
140140
qsort((void*) startPos, binTotalN[0], sizeof(uint), funCompareUint1);
141141

142142
//determine genomic starts of the bins
143-
P->inOut->logMain << "BAM sorting: "<<binTotalN[0]<< " mapped reads\n";
144-
P->inOut->logMain << "BAM sorting bins genomic start loci:\n";
143+
P.inOut->logMain << "BAM sorting: "<<binTotalN[0]<< " mapped reads\n";
144+
P.inOut->logMain << "BAM sorting bins genomic start loci:\n";
145145

146-
P->outBAMsortingBinStart[0]=0;
146+
P.outBAMsortingBinStart[0]=0;
147147
for (uint32 ib=1; ib<(nBins-1); ib++) {
148-
P->outBAMsortingBinStart[ib]=startPos[binTotalN[0]/(nBins-1)*ib];
149-
P->inOut->logMain << ib <<"\t"<< (P->outBAMsortingBinStart[ib]>>32) << "\t" << ((P->outBAMsortingBinStart[ib]<<32)>>32) <<endl;
148+
P.outBAMsortingBinStart[ib]=startPos[binTotalN[0]/(nBins-1)*ib];
149+
P.inOut->logMain << ib <<"\t"<< (P.outBAMsortingBinStart[ib]>>32) << "\t" << ((P.outBAMsortingBinStart[ib]<<32)>>32) <<endl;
150150
//how to deal with equal boundaries???
151151
};
152152
delete [] startPos;
153153
};
154154
//mutex here
155-
if (P->runThreadN>1) pthread_mutex_unlock(&g_threadChunks.mutexBAMsortBins);
155+
if (P.runThreadN>1) pthread_mutex_unlock(&g_threadChunks.mutexBAMsortBins);
156156

157157
//re-allocate binStart
158158
uint binTotalNold=binTotalN[0];
@@ -186,7 +186,7 @@ void BAMoutput::coordFlush () {//flush all alignments
186186
};
187187

188188
void BAMoutput::coordUnmappedPrepareBySJout () {//flush all alignments
189-
uint iBin=P->outBAMcoordNbins-1;
189+
uint iBin=P.outBAMcoordNbins-1;
190190
binStream[iBin]->write(binStart[iBin],binBytes[iBin]);
191191
binStream[iBin]->flush();
192192
binBytes[iBin]=0;//rewind the buffer

source/BAMoutput.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
class BAMoutput {//
99
public:
1010
//sorted output
11-
BAMoutput (int iChunk, string tmpDir, Parameters *Pin);
11+
BAMoutput (int iChunk, string tmpDir, Parameters &Pin);
1212
void coordOneAlign (char *bamIn, uint bamSize, uint iRead);
1313
void coordBins ();
1414
void coordFlush ();
1515
//unsorted output
16-
BAMoutput (BGZF *bgzfBAMin, Parameters *Pin);
16+
BAMoutput (BGZF *bgzfBAMin, Parameters &Pin);
1717
void unsortedOneAlign (char *bamIn, uint bamSize, uint bamSize2);
1818
void unsortedFlush ();
1919
void coordUnmappedPrepareBySJout();
@@ -30,7 +30,7 @@ class BAMoutput {//
3030
uint64 *binBytes, binBytes1;//number of bytes currently written to each bin
3131
ofstream **binStream;//output streams for each bin
3232
BGZF *bgzfBAM;
33-
Parameters *P;
33+
Parameters &P;
3434
string bamDir;
3535
};
3636

source/Chain.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "streamFuns.h"
33
#include "serviceFuns.cpp"
44

5-
Chain::Chain(Parameters *Pin, string chainFileNameIn) : P(Pin), chainFileName(chainFileNameIn)
5+
Chain::Chain(Parameters &Pin, string chainFileNameIn) : P(Pin), chainFileName(chainFileNameIn)
66
{
77
chainLoad();
88
};
@@ -74,7 +74,7 @@ void Chain::liftOverGTF(string gtfFileName, string outFileName)
7474
continue;//empty or comment line
7575

7676
if (chrChains.count(chr1)==0)
77-
exitWithError("GTF contains chromosome " + chr1 + " not present in the chain file " + chainFileName,std::cerr, P->inOut->logMain, EXIT_CODE_INPUT_FILES, *P);
77+
exitWithError("GTF contains chromosome " + chr1 + " not present in the chain file " + chainFileName,std::cerr, P.inOut->logMain, EXIT_CODE_INPUT_FILES, P);
7878

7979
OneChain *ch1 = & chrChains[chr1];//the chain for the chr1
8080

@@ -115,12 +115,12 @@ void Chain::liftOverGTF(string gtfFileName, string outFileName)
115115
streamOut.close();
116116
};
117117

118-
// if (P->chrNameIndex.count(oldname))
118+
// if (P.chrNameIndex.count(oldname))
119119
// {
120120
// ostringstream errOut;
121121
// errOut << "EXITING because of fatal INPUT file error: chain file contains chromosome (scaffold) not present in the genome " << oldname <<"\n";
122122
// errOut << ERROR_OUT << "\n";
123-
// exitWithError(errOut.str(),std::cerr, P->inOut->logMain, EXIT_CODE_INPUT_FILES, *P);
123+
// exitWithError(errOut.str(),std::cerr, P.inOut->logMain, EXIT_CODE_INPUT_FILES, P);
124124
// };
125-
// uint ichr=P->chrNameIndex[oldname];//chr index in the genome list
126-
// bStart1[bN] += P->chrLength[ichr];//whole genome chain - shift by chr start
125+
// uint ichr=P.chrNameIndex[oldname];//chr index in the genome list
126+
// bStart1[bN] += P.chrLength[ichr];//whole genome chain - shift by chr start

source/Chain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class Chain {
1818
// // uint bN;//number of blocks
1919
// // vector <uint> bStart1, bStart2, bLen; //blocks starts in 1/2, lengths
2020

21-
Chain(Parameters *Pin, string chainFileNameIn);
21+
Chain(Parameters &Pin, string chainFileNameIn);
2222
void liftOverGTF(string gtfFileName, string outFileName);
2323
private:
24-
Parameters *P;
24+
Parameters &P;
2525
string chainFileName;
2626
void chainLoad();
2727
std::map <string,OneChain> chrChains;

0 commit comments

Comments
 (0)