Skip to content

Commit

Permalink
Further code cleanup
Browse files Browse the repository at this point in the history
* convert some CR/LF line endings to LF
* be explicit about assignment operations within conditionals
* remove some unused variables
* add const to string literal argument types

Helps fix BoevaLab#11.
  • Loading branch information
sambrightman committed Dec 9, 2016
1 parent 4ca9c11 commit 3647b92
Show file tree
Hide file tree
Showing 18 changed files with 530 additions and 536 deletions.
568 changes: 282 additions & 286 deletions src/BAFpileup.cpp

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions src/BAFpileup.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once
#ifndef BAFPILEUP_H
#define BAFPILEUP_H

#include <string>
#ifndef BAFPILEUP_H
#define BAFPILEUP_H

#include <string>
#include <vector>
#include "GenomeCopyNumber.h"

class BAFpileup
{
public:

class BAFpileup
{
public:
BAFpileup();
void makepileup(GenomeCopyNumber & sampleCopyNumber, GenomeCopyNumber & controlCopyNumber,
std::string sample_MateFile,std::string control_MateFile,
Expand All @@ -35,7 +35,7 @@ class BAFpileup
std::vector < std::vector<int> > A_nb;
std::vector < std::vector<int> > B_nb;
std::vector < std::vector<std::string> > AB_nb;


private:

int length_;
Expand All @@ -50,7 +50,7 @@ class BAFpileup
std::vector <std::string> length_with_flanksTmp;
std::vector <std::string> strand;
std::vector <std::string> ref_name;
std::string pathToBedtools_;
};

#endif // BAFPILEUP_H
std::string pathToBedtools_;
};

#endif // BAFPILEUP_H
4 changes: 2 additions & 2 deletions src/GenomeCopyNumber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ int GenomeCopyNumber::getNumberOfChromosomes() {
return chrCopyNumber_.size();
}

long double GenomeCopyNumber::calculateRSS(int ploidy)
long double GenomeCopyNumber::calculateRSS(int ploidy)
{
string::size_type pos = 0;
vector<float> observedvalues;
Expand Down Expand Up @@ -1104,7 +1104,7 @@ long double GenomeCopyNumber::calculateRSS(int ploidy)
RSS = RSS + (long double)pow(diff,2);
}
}
return RSS;
return RSS;
}


Expand Down
2 changes: 1 addition & 1 deletion src/GenomeCopyNumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class GenomeCopyNumber
void setWESanalysis(bool WESgiven);
void setmakingPileup(bool makingPileup_given);
double Percentage_GenomeExplained(int &);
long double calculateRSS(int ploidy);
long double calculateRSS(int ploidy);


private:
Expand Down
12 changes: 6 additions & 6 deletions src/RSSerror.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "RSSerror.h"
#include "RSSerror.h"

using namespace std;

RSSerror::RSSerror()

RSSerror::RSSerror()
{
}
}

long double calculateRSS(GenomeCopyNumber & samplecopynumber, int ploidy)
long double calculateRSS(GenomeCopyNumber & samplecopynumber, int ploidy)
{
string::size_type pos = 0;
vector<float> observedvalues;
Expand Down Expand Up @@ -48,5 +48,5 @@ long double calculateRSS(GenomeCopyNumber & samplecopynumber, int ploidy)
RSS = RSS + (long double)pow(diff,2);
}
}
return RSS;
return RSS;
}
22 changes: 11 additions & 11 deletions src/RSSerror.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#ifndef RSSERROR_H
#define RSSERROR_H

#ifndef RSSERROR_H
#define RSSERROR_H

#include <iostream>
#include <stdlib.h>
#include <fstream>
Expand All @@ -13,13 +13,13 @@
#include "GenomeCopyNumber.h"
#include "ChrCopyNumber.h"


class RSSerror
{
public:
RSSerror();

class RSSerror
{
public:
RSSerror();
};

long double calculateRSS(GenomeCopyNumber & samplecopynumber, int ploidy);

#endif // RSSERROR_H
long double calculateRSS(GenomeCopyNumber & samplecopynumber, int ploidy);

#endif // RSSERROR_H
26 changes: 13 additions & 13 deletions src/SNPatChr.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#ifndef SNPATCHR_H
#define SNPATCHR_H
#ifndef SNPATCHR_H
#define SNPATCHR_H

#include <string>
#include <vector>
#include <vector>

#include "SNPposition.h"


class SNPatChr
{
public:

class SNPatChr
{
public:
SNPatChr(const std::string&);
SNPatChr();
void setChromosome(const std::string& chromosome);
Expand All @@ -25,11 +25,11 @@ class SNPatChr

void setStatusAt(int index,float value) ;
int getSize();
virtual ~SNPatChr();
protected:
virtual ~SNPatChr();
protected:
private:
std::vector <SNPposition> SNPpositionArray_;
std::string chromosome_;
};

#endif // SNPATCHR_H
std::string chromosome_;
};

#endif // SNPATCHR_H
10 changes: 5 additions & 5 deletions src/SNPinGenome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ long SNPinGenome::processPileUPLine(int & positionCount, char* line, string & ol
processChrName(chr);
int lindex = p_genomeCopyNumber->findIndex(chr);
if (lindex != NA) {
if (valueToReturn = strccnt(strs[4], '^')) {
if ((valueToReturn = strccnt(strs[4], '^'))) {
ChrCopyNumber& chrCopyNumber = p_genomeCopyNumber->getChrCopyNumberAt(lindex);
int step = p_genomeCopyNumber->getStep();
for (int i=0; i<valueToReturn; i++)
Expand All @@ -283,7 +283,7 @@ long SNPinGenome::processPileUPLine(int & positionCount, char* line, string & ol
processChrName(chr);
int lindex = p_genomeCopyNumber->findIndex(chr);
if (lindex != NA) {
if (valueToReturn = strccnt(strs[4], '^')) {
if ((valueToReturn = strccnt(strs[4], '^'))) {
ChrCopyNumber& chrCopyNumber = p_genomeCopyNumber->getChrCopyNumberAt(lindex);
int l = 0;
bool leftIsInTheWindow = false;
Expand Down Expand Up @@ -312,7 +312,7 @@ long SNPinGenome::processPileUPLine(int & positionCount, char* line, string & ol

if (currentPosition==sNPpositionToProceed) {
try {
float localBAF=addInfoFromAPileUp(atoi(strs[3]),minimalTotalLetterCountPerPosition,(*SNP_atChr_)[index].getNucleotideAt(positionCount),
addInfoFromAPileUp(atoi(strs[3]),minimalTotalLetterCountPerPosition,(*SNP_atChr_)[index].getNucleotideAt(positionCount),
index,positionCount,sNPpositionToProceed,strs[4], minimalQualityPerPosition,strs[5]);
// if (localBAF>=0) {
// heterozygousBAFs.push_back(localBAF);
Expand All @@ -333,8 +333,8 @@ long SNPinGenome::processPileUPLine(int & positionCount, char* line, string & ol
sNPpositionToProceed=NA;
}
if (currentPosition==sNPpositionToProceed) {
try {
float localBAF=addInfoFromAPileUp(atoi(strs[3]),minimalTotalLetterCountPerPosition,(*SNP_atChr_)[index].getNucleotideAt(positionCount),
try {
addInfoFromAPileUp(atoi(strs[3]),minimalTotalLetterCountPerPosition,(*SNP_atChr_)[index].getNucleotideAt(positionCount),
index,positionCount,sNPpositionToProceed,strs[4], minimalQualityPerPosition,strs[5]);
// if (localBAF>=0) {
// heterozygousBAFs.push_back(localBAF);
Expand Down
18 changes: 9 additions & 9 deletions src/SNPposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SNPposition::SNPposition(int position, char* alt) //for a VCF line
nucleotide_ = alt[0];
} else {
char* strs[4];
unsigned strs_cnt = split(alt, ',', strs);
split(alt, ',', strs);
nucleotide_ = strs[0][0];
}
freq_ = 0; // EV: must be initialized
Expand All @@ -45,7 +45,7 @@ SNPposition::SNPposition(int position, char* letters, const char* strand, const
if (strlen(letters) == 1) { //should not get here
nucleotide_ = letters[0];
} else {
unsigned strs_cnt = split(letters, '/', strs);
split(letters, '/', strs);
char c_ref;
if (reverse) {
c_ref = complement(ref[0]);
Expand All @@ -66,19 +66,19 @@ SNPposition::SNPposition(int position, char* letters, const char* strand, const
bin_=NA; //before initialization
}


SNPposition::~SNPposition()
{
//dtor
}

SNPposition::~SNPposition()
{
//dtor
}

int SNPposition::getPosition() {
return position_;
}

char SNPposition::getNucleotide() {
return nucleotide_;
}
}

void SNPposition::setFrequency(float freq) {
freq_ = freq;
Expand All @@ -87,7 +87,7 @@ void SNPposition::setFrequency(float freq) {
void SNPposition::setStatus(float status) {
status_ = status;
}


float SNPposition::getValue() {
return freq_ ;
}
Expand Down
24 changes: 12 additions & 12 deletions src/SNPposition.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef SNPPOSITION_H
#define SNPPOSITION_H

#ifndef SNPPOSITION_H
#define SNPPOSITION_H

#include <string>
#include <vector>

#include "myFunc.h"

class SNPposition
{
public:

class SNPposition
{
public:
SNPposition(int position, char* letters, const char* strand, const char* ref); //from TXT
SNPposition(int position, char* alt); //for VCF
virtual ~SNPposition();
Expand All @@ -19,14 +19,14 @@ class SNPposition
void setFrequency(float freq);
void setStatus(float status);
void setBin(int i);
int getBin();
protected:
int getBin();
protected:
private:
unsigned int position_;
char nucleotide_;
float freq_;
float status_; //0 - AA/BB, 0.5 - AB
int bin_; //bin in the copy number array
};

#endif // SNPPOSITION_H
};

#endif // SNPPOSITION_H
14 changes: 7 additions & 7 deletions src/SeekSubclones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ A copy of the GNU General Public License is available at
*************************************************************************/


#include "SeekSubclones.h"
#include "SeekSubclones.h"

using namespace std;

SeekSubclones::SeekSubclones(void)
SeekSubclones::SeekSubclones(void)
{
}

SeekSubclones::~SeekSubclones(void)
{
}



SeekSubclones::SeekSubclones(GenomeCopyNumber & samplecopynumber, int ploidy, std::string myName, float minimal_pop) {
ploidy_ = ploidy;
minimal_pop_ = minimal_pop/100;
getSegmentsInfo(samplecopynumber, myName);
}
minimal_pop_ = minimal_pop/100;
getSegmentsInfo(samplecopynumber, myName);
}


void SeekSubclones::getSegmentsInfo(GenomeCopyNumber & samplecopynumber, std::string myName)
Expand Down Expand Up @@ -191,7 +191,7 @@ bool SeekSubclones::PercentageTest(std::vector <float>& data, float& threshold)
subclone = true;
}
return subclone;
}
}


void SeekSubclones::EstimateSubclonalPopulation(vector <float> data, float threshold, int ploidy_)
Expand Down
24 changes: 12 additions & 12 deletions src/SeekSubclones.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#ifndef SEEKSUBCLONES_H
#define SEEKSUBCLONES_H
#ifndef SEEKSUBCLONES_H
#define SEEKSUBCLONES_H

#include<cstdlib>
#include<ctime>
Expand All @@ -13,23 +13,23 @@
#include <algorithm>
#include <map>
#include <fstream>

class SeekSubclones
{
public:

class SeekSubclones
{
public:
SeekSubclones(GenomeCopyNumber & samplecopynumber, int ploidy, std::string myName, float minimal_pop);
SeekSubclones();
~SeekSubclones(void);
void getSegmentsInfo(GenomeCopyNumber & samplecopynumber, std::string myName);
bool SignTest(std::vector <float>& data, float& threshold, int bonfer_correction);
void EstimateSubclonalPopulation(std::vector <float> data, float threshold, int ploidy_);
bool PercentageTest(std::vector <float>& data, float& threshold);
void EstimateSubclonalPopulation(std::vector <float> data, float threshold, int ploidy_);
bool PercentageTest(std::vector <float>& data, float& threshold);
protected:
int ploidy_;
float minimal_pop_;
std::vector <int> copynumber_;
std::vector <float> population_;
private:
std::vector <float> population_;
private:
};

#endif // SEEKSUBCLONES_H

#endif // SEEKSUBCLONES_H
Loading

0 comments on commit 3647b92

Please sign in to comment.