Skip to content

Commit

Permalink
v11.4 - fix Seg Fault for exome-seq without GC-correction
Browse files Browse the repository at this point in the history
  • Loading branch information
valeu committed Apr 24, 2018
1 parent 7c17db6 commit c4e299f
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
11 changes: 9 additions & 2 deletions src/ChrCopyNumber.cpp
Expand Up @@ -640,6 +640,11 @@ void ChrCopyNumber::calculateRatio(double *a, int degree) {
// }
//}

bool ChrCopyNumber::ifHasRatio() {
if (ratio_.size()>0) return 1;
return 0;
}

void ChrCopyNumber::recalculateRatio (float constant) {
for (int i = 0; i<length_; i++)
if (ratio_[i] != NA)
Expand Down Expand Up @@ -1684,9 +1689,11 @@ void ChrCopyNumber::addBAFinfo(SNPinGenome & snpingenome,int indexSNP) {
}
}
}

if (ratio_.size()==0) {
cerr << "Warning: Normalized read counts (ratio_) has not been initialized; check your parameters\n";
}
for (int i = 0; i<length_; i++) {
if (ratio_[i]==NA && BAF_[i]!=NA) //set BAF=NA in windows with ratio==NA to remove the noise from windows with low mappability
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
BAF_[i]=NA;

if (BAF_[i]==0) //remove windows with 100% AA counts
Expand Down
2 changes: 1 addition & 1 deletion src/ChrCopyNumber.h
Expand Up @@ -98,7 +98,7 @@ class ChrCopyNumber

bool isMedianCalculated();
bool isSmoothed();

bool ifHasRatio();


void fillCGprofile(std::string const& chrFolder);
Expand Down
5 changes: 5 additions & 0 deletions src/GenomeCopyNumber.cpp
Expand Up @@ -1099,6 +1099,11 @@ int GenomeCopyNumber::getNumberOfChromosomes() {
return chrCopyNumber_.size();
}

bool GenomeCopyNumber::ifHasRatio() {
if (chrCopyNumber_[0].ifHasRatio()) return 1;
return 0;
}

long double GenomeCopyNumber::calculateRSS(int ploidy)
{
string::size_type pos = 0;
Expand Down
1 change: 1 addition & 0 deletions src/GenomeCopyNumber.h
Expand Up @@ -110,6 +110,7 @@ class GenomeCopyNumber
bool getWESanalysis();
double getGenomeRefSize();
int getNumberOfChromosomes();
bool ifHasRatio();


void setPloidy(int ploidy);
Expand Down
29 changes: 17 additions & 12 deletions src/SNPinGenome.cpp
Expand Up @@ -213,18 +213,23 @@ void SNPinGenome::perform(std::string const& mateFile, const std::string& inputF
if (!pileup_read) {
assignValues(mateFile, inputFormat, minimalTotalLetterCountPerPosition,minimalQualityPerPosition);
}
cout << "..Adding BAF info to the " << what << " dataset" << std::endl;
genomeCopyNumber.addBAFinfo(*this);
cout << "..Recalculate breakpoints using BAF profiles" << std::endl;
genomeCopyNumber.calculateBAFBreakpoints(breakPointThreshold,breakPointType);
cout << "..Recalculate median values" << std::endl;
genomeCopyNumber.calculateCopyNumberMedians(minCNAlength, noisyData, CompleteGenomicsData);

cout << "..Reannotate copy numbers" << std::endl;
if (genomeCopyNumber.getWESanalysis() == false)
{genomeCopyNumber.calculateCopyNumberProbs_and_genomeLength(breakPointType);}
else
{genomeCopyNumber.calculateCopyNumberProbs_and_exomeLength(breakPointType);}

if (genomeCopyNumber.ifHasRatio()) {
cout << "..Adding BAF info to the " << what << " dataset" << std::endl;
genomeCopyNumber.addBAFinfo(*this);
cout << "..Recalculate breakpoints using BAF profiles" << std::endl;
genomeCopyNumber.calculateBAFBreakpoints(breakPointThreshold,breakPointType);
cout << "..Recalculate median values" << std::endl;
genomeCopyNumber.calculateCopyNumberMedians(minCNAlength, noisyData, CompleteGenomicsData);

cout << "..Reannotate copy numbers" << std::endl;
if (genomeCopyNumber.getWESanalysis() == false)
{genomeCopyNumber.calculateCopyNumberProbs_and_genomeLength(breakPointType);}
else
{genomeCopyNumber.calculateCopyNumberProbs_and_exomeLength(breakPointType);}

}

cout << "..Done" << std::endl;
}

Expand Down
Binary file modified src/freec
Binary file not shown.
6 changes: 3 additions & 3 deletions src/main.cpp
Expand Up @@ -707,8 +707,8 @@ int main(int argc, char *argv[])
snpingenome.setWESanalysis(WESanalysis);
SNPinGenome snpingenomeControl;
snpingenomeControl.setWESanalysis(WESanalysis);
if (makePileup== "false") {
snpingenome.setCopyNumberFromPileup(true); //use pileup for copy number asessment, not only for BAFs
if (makePileup== "false" && !isHasMiniPileUPcontrol && !isHasMiniPileUPsample) {
snpingenome.setCopyNumberFromPileup(true); //use pileup for copy number assessment, not only for BAFs
snpingenomeControl.setCopyNumberFromPileup(true);
}

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

sampleCopyNumber.printBAF(myName,snpingenome,sample_MateFile);

if (isControlIsPresent && makePileup == "false") {
if (isControlIsPresent && makePileup == "false" && !ifTargeted) { // will output Control data only for WGS data!
sampleCopyNumber.calculateSomaticCNVs(controlCopyNumber.getCNVs(),controlCopyNumber.getPloidy());
controlCopyNumber.printBAF(controlName,snpingenomeControl,control_MateFile);
controlCopyNumber.printRatio(myName+"_normal_ratio.txt",0,printNA);
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Expand Up @@ -3,7 +3,7 @@
#define VERSION_H

const double VERSION_OFFSET = 3;
const double FREEC_VERSION = 11.3;
const double FREEC_VERSION = 11.4;
const double CONTROL_FREEC_VERSION = FREEC_VERSION - VERSION_OFFSET;

#endif

0 comments on commit c4e299f

Please sign in to comment.