Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrej-fischer committed Apr 22, 2014
2 parents 4eb9eab + 68b2c14 commit 07119fb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# changelog for EMu and EMu-prepare

v1.5.2 / to come

* bug fix in EMu-prepare: `--bin` now accepts `1e5` notation
* changed EMu-prepare localized output to `pre.sample.opp.chr23.per-1Mb.txt` etc.

v1.5.1 / 15.04.2014

* moved to MAJOR.MINOR.PATCH release numbering
Expand Down
28 changes: 20 additions & 8 deletions src/EMu-prepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct cmdl_opts{
const char * pre;
const char * suff;
const char * chr_dir;
string bin_str;
int bin_size, max_chr, no_chr, cnv_def;
};

Expand Down Expand Up @@ -152,7 +153,7 @@ void get_opts( int argc, const char ** argv, cmdl_opts& opts){
}
else if ( opt_switch.compare("--bin") == 0){
opt_idx++;
opts.bin_size = atoi( argv[opt_idx]);
opts.bin_size = int(atof( argv[opt_idx]));
}
else if ( opt_switch.compare("--default") == 0){
opt_idx++;
Expand All @@ -172,14 +173,25 @@ void get_opts( int argc, const char ** argv, cmdl_opts& opts){
exit(1);
}
if (opts.cnv_file_name == NULL && opts.chr_dir == NULL){
cout<<"ERROR: for mutational opportunity, you have to set --cnv [cnf_file] and --chr [dir]\n";
cout<<"ERROR: for mutational opportunity, you have to set --cnv [cnv_file] and --chr [dir]\n";
exit(1);
}
if (opts.reg_file_name != NULL && opts.bin_size > 0 ){
cout<<"ERROR: you have to decide whether to get data per bin genome wide (with --bin [size]) ";
cout<<"OR whether to get data collapsed over specific regions (with --regions [reg_file])\n";
exit(1);
}
if (opts.bin_size>0){
char buff[128];
sprintf( buff, "per-%ib", opts.bin_size);
opts.bin_str.assign(buff);
int bs = opts.bin_size;
if (bs == 1000) opts.bin_str = "per-1kb";
if (bs == 10000) opts.bin_str = "per-10kb";
if (bs == 100000) opts.bin_str = "per-100kb";
if (bs == 1000000) opts.bin_str = "per-1Mb";
if (bs == 10000000) opts.bin_str = "per-10Mb";
}
}


Expand Down Expand Up @@ -258,13 +270,12 @@ void get_regions( vector<int> * region_start,
}



//*******************************************************************************************
// translate mutation information to the 96 tri-nucleotide channel format...
void get_mut( cmdl_opts& opts,
map<string,char>& mut_idx,
map<char,char>& base_idx
){
//
int no_chn = 96;
ifstream * chr_ifs = new ifstream [opts.max_chr];
int * start = new int [opts.max_chr];
Expand Down Expand Up @@ -432,10 +443,11 @@ void get_mut( cmdl_opts& opts,
for (it = mut_per_bin.begin(); it != mut_per_bin.end(); ++it){
for (int chr=0; chr<opts.no_chr; chr++){
string out_fn(opts.pre);
out_fn.append(".");
out_fn.append(it->first);
out_fn.append(".mut.");
char chrbuff [32];
sprintf( chrbuff, "chr%i.%i.dat", chr+1, opts.bin_size);
sprintf( chrbuff, "chr%i.%s.txt", chr+1, opts.bin_str.c_str());
out_fn.append(chrbuff);
FILE * out_fp = fopen(out_fn.c_str(),"w");
for (int bin=0; bin<(int) (it->second)[chr]->size1; bin++){
Expand All @@ -460,7 +472,7 @@ void get_mut( cmdl_opts& opts,
}



//*******************************************************************************************
// translate sequences to opportunity tracks, i.e. which mutational channels are open...
void get_opp( map<char,char>& base_idx,
cmdl_opts& opts
Expand Down Expand Up @@ -509,8 +521,8 @@ void get_opp( map<char,char>& base_idx,
cnv_mult.insert(pair<string,vector<int>*>(sample,mults));
if (opts.pre != NULL){
string ofn(opts.pre);
ofn.append(".");
ofn.append(sample);
ofn.append(".opp.");
sample_fn.insert(pair<string,string>(sample,ofn));
}
}
Expand Down Expand Up @@ -729,7 +741,7 @@ void get_opp( map<char,char>& base_idx,
for ( int s=0; s< no_samples; s++){
string fn = sample_fn[samples[s]];
char chrbuff [32];
sprintf( chrbuff, "chr%i.%i.dat", chr+1, opts.bin_size);
sprintf( chrbuff, ".opp.chr%i.%s.txt", chr+1, opts.bin_str.c_str());
fn.append(chrbuff);
FILE * track_fp = fopen( fn.c_str(), "w");
// BINS:
Expand Down
4 changes: 2 additions & 2 deletions src/EMu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int main(int argc, const char * argv[]){
}
}
}
else{
else{//flat opportunity...
gsl_matrix_set_all( Opp, 1.0);
}
// *** SCENARIO 1 ***
Expand Down Expand Up @@ -215,7 +215,7 @@ int main(int argc, const char * argv[]){
if ( opts.with_gwts == 1){
get_dims( opts.gwts_fn, &Npat, &Nsp);
if ( (Nsa % Npat) != 0 ){
printf("The number of samples (%i) is not a multiple of the number of patients (%i).\n",Nsa,Npat);
printf("The number of lines (%i) is not a multiple of the number of samples (%i).\n",Nsa,Npat);
exit(1);
}
else{
Expand Down

0 comments on commit 07119fb

Please sign in to comment.