Skip to content

Commit a48763e

Browse files
committed
v11.6 - forcing GC normalization for cases when minipileup is provided for both test and control files
1 parent f245983 commit a48763e

File tree

4 files changed

+110
-7
lines changed

4 files changed

+110
-7
lines changed

src/Help.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ void usage() {
2525
std::cout << "Usage:\n\n";
2626
//printf("ahokocc <arguments>\n\n");
2727
std::cout << "\tfreec -conf <config file>\n\n\tSee config.txt for example\n";
28+
std::cout << "\tor\n";
29+
std::cout << "\tfreec -conf <config file> -sample <mySample.bam> -control <myControl.bam>\n\n\tSee config.txt for example\n";
2830

2931
return;
3032
}

src/freec

1.6 MB
Binary file not shown.

src/main.cpp

Lines changed: 107 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,106 @@ static const char* get_conf_file(int argc, char *argv[])
5454
exit(0);
5555
}
5656

57-
if (argc > 3 || (strcmp(argv[1], "-conf") != 0 && strcmp(argv[1], "-config") != 0 && strcmp(argv[1], "--conf") != 0)) {
58-
usage();
57+
const char* conf_file;
58+
bool conf_file_set=0;
59+
60+
if (argc >= 3 && (strcmp(argv[1], "-conf") == 0 || strcmp(argv[1], "-config") == 0 || strcmp(argv[1], "--config") == 0 || strcmp(argv[1], "--conf") == 0)) {
61+
conf_file = argv[2];
62+
conf_file_set=1;
63+
} else {
64+
if (argc >= 5 && (strcmp(argv[3], "-conf") == 0 || strcmp(argv[3], "-config") == 0 || strcmp(argv[3], "--config") == 0 || strcmp(argv[3], "--conf") == 0)) {
65+
conf_file = argv[4];
66+
conf_file_set=1;
67+
} else {
68+
if (argc >= 7 && (strcmp(argv[5], "-conf") == 0 || strcmp(argv[5], "-config") == 0 || strcmp(argv[5], "--config") == 0 || strcmp(argv[5], "--conf") == 0)) {
69+
conf_file = argv[6];
70+
conf_file_set=1;
71+
}
72+
}
73+
}
74+
75+
if(!conf_file_set) {
76+
usage();
5977
exit(0);
6078
}
6179

62-
const char* conf_file = argv[2];
6380
ifstream ifile(conf_file);
6481

6582
if (!ifile) {
6683
std::cerr << "\n\tCould not find your config file.. Please, check the existance of "<< conf_file <<"\n\n";
84+
usage();
6785
exit(-1);
6886
}
6987

7088
return conf_file;
7189
}
7290

91+
92+
93+
static const char* getSampleNameFromCommandLine(int argc, char *argv[])
94+
{
95+
const char* sample_file;
96+
bool sample_file_set=0;
97+
98+
if (argc >= 3 && (strcmp(argv[1], "-s") == 0 || strcmp(argv[1], "-sample") == 0 || strcmp(argv[1], "--s") == 0 || strcmp(argv[1], "--sample") == 0)) {
99+
sample_file = argv[2];
100+
sample_file_set=1;
101+
} else {
102+
if (argc >= 5 && (strcmp(argv[3], "-s") == 0 || strcmp(argv[3], "-sample") == 0 || strcmp(argv[3], "--s") == 0 || strcmp(argv[3], "--sample") == 0)) {
103+
sample_file = argv[4];
104+
sample_file_set=1;
105+
} else {
106+
if (argc >= 7 && (strcmp(argv[5], "-s") == 0 || strcmp(argv[5], "-sample") == 0 || strcmp(argv[5], "--s") == 0 || strcmp(argv[5], "--sample") == 0)) {
107+
sample_file = argv[6];
108+
sample_file_set=1;
109+
}
110+
}
111+
}
112+
if(!sample_file_set) {
113+
cerr << "Error: You should provide a path to your sample either in the config file or in command line" << "\n";
114+
usage();
115+
exit(0);
116+
}
117+
ifstream ifile(sample_file);
118+
if (!ifile) {
119+
std::cerr << "\n\tCould not find your sample file.. Please, check the existance of "<< sample_file <<"\n\n";
120+
usage();
121+
exit(-1);
122+
}
123+
return sample_file;
124+
}
125+
126+
static const char* getControlNameFromCommandLine(int argc, char *argv[])
127+
{
128+
const char* sample_file;
129+
bool sample_file_set=0;
130+
131+
if (argc >= 3 && (strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "-control") == 0 || strcmp(argv[1], "--c") == 0 || strcmp(argv[1], "--control") == 0)) {
132+
sample_file = argv[2];
133+
sample_file_set=1;
134+
} else {
135+
if (argc >= 5 && (strcmp(argv[3], "-c") == 0 || strcmp(argv[3], "-control") == 0 || strcmp(argv[3], "--c") == 0 || strcmp(argv[3], "--control") == 0)) {
136+
sample_file = argv[4];
137+
sample_file_set=1;
138+
} else {
139+
if (argc >= 7 && (strcmp(argv[5], "-c") == 0 || strcmp(argv[5], "-control") == 0 || strcmp(argv[5], "--c") == 0 || strcmp(argv[5], "--control") == 0)) {
140+
sample_file = argv[6];
141+
sample_file_set=1;
142+
}
143+
}
144+
}
145+
if(!sample_file_set) {
146+
return ("");
147+
}
148+
ifstream ifile(sample_file);
149+
if (!ifile) {
150+
std::cerr << "\n\tCould not find your control file.. Please, check the existance of "<< sample_file <<"\n\n";
151+
usage();
152+
exit(-1);
153+
}
154+
return sample_file;
155+
}
156+
73157
static void thread_init(unsigned int max_threads, unsigned int thread_verbose)
74158
{
75159
if (max_threads > 1) {
@@ -197,7 +281,7 @@ int main(int argc, char *argv[])
197281
} else if (!has_coefficientOfVariation && has_window) {
198282
cout << "..Window = "<< window << " was set\n";
199283
} else if (!ifTargeted) {
200-
cerr << "Error: 'coefficientOfVariation' or 'window' must be provided\n";
284+
cerr << "Warning: 'coefficientOfVariation' or 'window' must be provided\n";
201285
cout << "..FREEC will use the coefficientOfVariation=0.05 to evaluate window size\n";
202286
coefficientOfVariation=0.05;
203287
has_coefficientOfVariation=true;
@@ -280,6 +364,14 @@ int main(int argc, char *argv[])
280364

281365
if (has_sample_MateFile) {
282366
sample_MateFile = std::string(cf.Value("sample","mateFile")) ;
367+
} else {
368+
// will try to get MateFile from the command line:
369+
sample_MateFile = getSampleNameFromCommandLine(argc, argv);
370+
if (sample_MateFile.compare("")!=0) { //i.e. there is information in the command line about the sample
371+
has_sample_MateFile=1;
372+
}
373+
}
374+
if (has_sample_MateFile) {
283375
cout << "..Sample file:\t" << sample_MateFile << "\n";
284376
if (sample_inputFormat.compare("")==0) {
285377
cerr << "Error: You need to set the inputFormat to be avaible to read "<< sample_MateFile << "\n";
@@ -300,6 +392,7 @@ int main(int argc, char *argv[])
300392
}
301393
}
302394
}
395+
303396
if (has_sample_mateCopyNumberFile){
304397
sample_MateCopyNumberFile = std::string(cf.Value("sample","mateCopyNumberFile"));
305398
cout << "..Sample file with precalculated copy numbers:\t" << sample_MateCopyNumberFile << "\n";
@@ -325,6 +418,14 @@ int main(int argc, char *argv[])
325418

326419
if (has_control_MateFile) {
327420
control_MateFile = std::string(cf.Value("control","mateFile")) ;
421+
} else {
422+
// will try to get control_MateFile from the command line:
423+
control_MateFile = getControlNameFromCommandLine(argc, argv);
424+
if (control_MateFile.compare("")!=0) { //i.e. there is information in the command line about the sample
425+
has_sample_MateFile=1;
426+
}
427+
}
428+
if (has_control_MateFile) {
328429
cout << "..Control file:\t" << control_MateFile << "\n";
329430
if (control_inputFormat.compare("")==0) {
330431
cerr << "Error: You need to set the inputFormat to be avaible to read "<< control_MateFile << "\n";
@@ -444,7 +545,7 @@ int main(int argc, char *argv[])
444545
cout <<"..FREEC will not normalize data at all; will perform segmentation of read counts in log2(x+1) space.\n";
445546
logLogNorm=true;
446547
forceGC=0;
447-
} else if (!isControlIsPresent || has_BAF || forceGC) {
548+
} else if (!isControlIsPresent || has_BAF || forceGC || isHasMiniPileUPcontrol&&isHasMiniPileUPsample) {
448549
if (!has_dirWithFastaSeq && !has_GCprofile) {
449550
cerr << "Error: with the current options, either 'chrFiles' or 'GCcontentProfile' must be set\n";
450551
exit(0);
@@ -490,7 +591,7 @@ int main(int argc, char *argv[])
490591
std::cout << "Warning: minimal recommended polynomial degree for \"ReadCount ~ GC-content\" is 3\nComment or remove the corresponding line in the config file to try both degree==3 and degree==4\n";
491592
}
492593
} else {
493-
if (intercept==1 && !(!has_BAF&&isControlIsPresent)) {
594+
if (intercept==1 && !(!has_BAF&&isControlIsPresent) || intercept==1 && isHasMiniPileUPcontrol&&isHasMiniPileUPsample) {
494595
std::cout << "..Polynomial degree for \"ReadCount ~ GC-content\" normalization is 3 or 4: will try both\n";
495596
} else if (!(ifTargeted && forceGC==1)&&normalization) {
496597
degree=1;

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.5;
6+
const double FREEC_VERSION = 11.6;
77
const double CONTROL_FREEC_VERSION = FREEC_VERSION - VERSION_OFFSET;
88

99
#endif

0 commit comments

Comments
 (0)