Skip to content

Commit c4e299f

Browse files
committed
v11.4 - fix Seg Fault for exome-seq without GC-correction
1 parent 7c17db6 commit c4e299f

File tree

8 files changed

+37
-19
lines changed

8 files changed

+37
-19
lines changed

src/ChrCopyNumber.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,11 @@ void ChrCopyNumber::calculateRatio(double *a, int degree) {
640640
// }
641641
//}
642642

643+
bool ChrCopyNumber::ifHasRatio() {
644+
if (ratio_.size()>0) return 1;
645+
return 0;
646+
}
647+
643648
void ChrCopyNumber::recalculateRatio (float constant) {
644649
for (int i = 0; i<length_; i++)
645650
if (ratio_[i] != NA)
@@ -1684,9 +1689,11 @@ void ChrCopyNumber::addBAFinfo(SNPinGenome & snpingenome,int indexSNP) {
16841689
}
16851690
}
16861691
}
1687-
1692+
if (ratio_.size()==0) {
1693+
cerr << "Warning: Normalized read counts (ratio_) has not been initialized; check your parameters\n";
1694+
}
16881695
for (int i = 0; i<length_; i++) {
1689-
if (ratio_[i]==NA && BAF_[i]!=NA) //set BAF=NA in windows with ratio==NA to remove the noise from windows with low mappability
1696+
if (ratio_.size()>i && ratio_[i]==NA && BAF_[i]!=NA) //set BAF=NA in windows with ratio==NA to remove the noise from windows with low mappability
16901697
BAF_[i]=NA;
16911698

16921699
if (BAF_[i]==0) //remove windows with 100% AA counts

src/ChrCopyNumber.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ChrCopyNumber
9898

9999
bool isMedianCalculated();
100100
bool isSmoothed();
101-
101+
bool ifHasRatio();
102102

103103

104104
void fillCGprofile(std::string const& chrFolder);

src/GenomeCopyNumber.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,11 @@ int GenomeCopyNumber::getNumberOfChromosomes() {
10991099
return chrCopyNumber_.size();
11001100
}
11011101

1102+
bool GenomeCopyNumber::ifHasRatio() {
1103+
if (chrCopyNumber_[0].ifHasRatio()) return 1;
1104+
return 0;
1105+
}
1106+
11021107
long double GenomeCopyNumber::calculateRSS(int ploidy)
11031108
{
11041109
string::size_type pos = 0;

src/GenomeCopyNumber.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class GenomeCopyNumber
110110
bool getWESanalysis();
111111
double getGenomeRefSize();
112112
int getNumberOfChromosomes();
113+
bool ifHasRatio();
113114

114115

115116
void setPloidy(int ploidy);

src/SNPinGenome.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,23 @@ void SNPinGenome::perform(std::string const& mateFile, const std::string& inputF
213213
if (!pileup_read) {
214214
assignValues(mateFile, inputFormat, minimalTotalLetterCountPerPosition,minimalQualityPerPosition);
215215
}
216-
cout << "..Adding BAF info to the " << what << " dataset" << std::endl;
217-
genomeCopyNumber.addBAFinfo(*this);
218-
cout << "..Recalculate breakpoints using BAF profiles" << std::endl;
219-
genomeCopyNumber.calculateBAFBreakpoints(breakPointThreshold,breakPointType);
220-
cout << "..Recalculate median values" << std::endl;
221-
genomeCopyNumber.calculateCopyNumberMedians(minCNAlength, noisyData, CompleteGenomicsData);
222-
223-
cout << "..Reannotate copy numbers" << std::endl;
224-
if (genomeCopyNumber.getWESanalysis() == false)
225-
{genomeCopyNumber.calculateCopyNumberProbs_and_genomeLength(breakPointType);}
226-
else
227-
{genomeCopyNumber.calculateCopyNumberProbs_and_exomeLength(breakPointType);}
216+
217+
if (genomeCopyNumber.ifHasRatio()) {
218+
cout << "..Adding BAF info to the " << what << " dataset" << std::endl;
219+
genomeCopyNumber.addBAFinfo(*this);
220+
cout << "..Recalculate breakpoints using BAF profiles" << std::endl;
221+
genomeCopyNumber.calculateBAFBreakpoints(breakPointThreshold,breakPointType);
222+
cout << "..Recalculate median values" << std::endl;
223+
genomeCopyNumber.calculateCopyNumberMedians(minCNAlength, noisyData, CompleteGenomicsData);
224+
225+
cout << "..Reannotate copy numbers" << std::endl;
226+
if (genomeCopyNumber.getWESanalysis() == false)
227+
{genomeCopyNumber.calculateCopyNumberProbs_and_genomeLength(breakPointType);}
228+
else
229+
{genomeCopyNumber.calculateCopyNumberProbs_and_exomeLength(breakPointType);}
230+
231+
}
232+
228233
cout << "..Done" << std::endl;
229234
}
230235

src/freec

412 KB
Binary file not shown.

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ int main(int argc, char *argv[])
707707
snpingenome.setWESanalysis(WESanalysis);
708708
SNPinGenome snpingenomeControl;
709709
snpingenomeControl.setWESanalysis(WESanalysis);
710-
if (makePileup== "false") {
711-
snpingenome.setCopyNumberFromPileup(true); //use pileup for copy number asessment, not only for BAFs
710+
if (makePileup== "false" && !isHasMiniPileUPcontrol && !isHasMiniPileUPsample) {
711+
snpingenome.setCopyNumberFromPileup(true); //use pileup for copy number assessment, not only for BAFs
712712
snpingenomeControl.setCopyNumberFromPileup(true);
713713
}
714714

@@ -1070,7 +1070,7 @@ int main(int argc, char *argv[])
10701070

10711071
sampleCopyNumber.printBAF(myName,snpingenome,sample_MateFile);
10721072

1073-
if (isControlIsPresent && makePileup == "false") {
1073+
if (isControlIsPresent && makePileup == "false" && !ifTargeted) { // will output Control data only for WGS data!
10741074
sampleCopyNumber.calculateSomaticCNVs(controlCopyNumber.getCNVs(),controlCopyNumber.getPloidy());
10751075
controlCopyNumber.printBAF(controlName,snpingenomeControl,control_MateFile);
10761076
controlCopyNumber.printRatio(myName+"_normal_ratio.txt",0,printNA);

src/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define VERSION_H
44

55
const double VERSION_OFFSET = 3;
6-
const double FREEC_VERSION = 11.3;
6+
const double FREEC_VERSION = 11.4;
77
const double CONTROL_FREEC_VERSION = FREEC_VERSION - VERSION_OFFSET;
88

99
#endif

0 commit comments

Comments
 (0)