@@ -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\t Could 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\t Could 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\t Could 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+
73157static 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 " ;
0 commit comments