Commit 262e8216 authored by Raquel Bromberg's avatar Raquel Bromberg

Minor code changes (mostly code cleanup)

parent 25aca03f
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <omp.h> //#include <omp.h>
#include <getopt.h> #include <getopt.h>
#include "mctr.h" #include "mctr.h"
...@@ -58,9 +58,11 @@ int main(int argc, char* argv[]) ...@@ -58,9 +58,11 @@ int main(int argc, char* argv[])
// cout<<"p="<<full_path<<endl; // cout<<"p="<<full_path<<endl;
// cout<<"fs="<<fs<<endl; // cout<<"fs="<<fs<<endl;
cout<<"Calling run on real data"<<endl;
mctr m(full_path,"",fs,fo,partial_run); mctr m(full_path,"",fs,fo,partial_run);
cout<<"Calling run()"<<endl;
m.run_it0(); m.run_it0();
cout<<"Calling run on scrambled data"<<endl;
mctr mscr(full_path,"scr",fs,fo,partial_run);//scrambled mctr mscr(full_path,"scr",fs,fo,partial_run);//scrambled
mscr.run_it0(); mscr.run_it0();
......
...@@ -9,10 +9,18 @@ using namespace std; ...@@ -9,10 +9,18 @@ using namespace std;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
string full_path = ""; if(argc<2)
{
cout<<"Wrong use of filter.cpp: ./filt <path to run>"<<endl;
exit(1);
}
string full_path = argv[1];
int mismatch = 13; int mismatch = 13;
int filtering_steps = 10; int filtering_steps = 10;
char c; char c;
bool verbose=false;
bool very_similar_set=false; //e.g. input of all E.coli
cout<<"Values stored in argv:"<<endl; cout<<"Values stored in argv:"<<endl;
for(int i=0; i<argc; i++) for(int i=0; i<argc; i++)
...@@ -20,7 +28,7 @@ int main(int argc, char* argv[]) ...@@ -20,7 +28,7 @@ int main(int argc, char* argv[])
cout<<argv[i]<<endl; cout<<argv[i]<<endl;
} }
while((c = getopt(argc,argv,"m:p:f:")) != -1) while((c = getopt(argc,argv,"m:p:f:vs")) != -1)
{ {
switch(c) switch(c)
{ {
...@@ -33,14 +41,19 @@ int main(int argc, char* argv[]) ...@@ -33,14 +41,19 @@ int main(int argc, char* argv[])
case 'f': case 'f':
filtering_steps=atoi(optarg); filtering_steps=atoi(optarg);
break; break;
case 'v':
verbose=true;
break;
case 's':
very_similar_set=true;
break;
default: default:
abort(); abort();
} }
} }
filter f(full_path,mismatch,filtering_steps); filter f(full_path,mismatch,filtering_steps,verbose,very_similar_set);
f.write_out_filt_logs(); f.write_out_filt_logs();
f.print_final_hist();
f.mark_discrepancies(); f.mark_discrepancies();
return 0; return 0;
......
This diff is collapsed.
...@@ -10,6 +10,12 @@ using namespace std; ...@@ -10,6 +10,12 @@ using namespace std;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if(argc<2)
{
cout<<"Improper input. ./fmerg <full path to run, e.g. ../my_runs/300_bacteria/>"<<endl;
exit(1);
}
string full_path = ""; string full_path = "";
int filtering_steps = -1; int filtering_steps = -1;
int filt_choice=-1; int filt_choice=-1;
......
/**************************************************************************
fpwrite.cpp
INPUT:
OUTPUT:
*************************************************************************/
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <vector> #include <vector>
...@@ -18,12 +24,23 @@ struct h ...@@ -18,12 +24,23 @@ struct h
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
cout<<"Usage: ./fpw -p <path> -f <filtering_steps, default=10> -o <stringency level>"<<endl; if(argc<2)
{
cout<<"Wrong input."<<endl;
cout<<"./fpwrite <path to run, e.g. ../my_runs/medium_run/> "<<endl;
cout<<"verbose: -v"<<endl;
cout<<"help: -h"<<endl;
cout<<"filtering steps (default 10): -f"<<endl;
cout<<"filtering choice (default 0): -o"<<endl;
exit(1);
}
string full_path = ""; string full_path =argv[1];
int filtering_steps = -1; int filtering_steps = 10;
int filt_choice=-1; int filt_choice=0;
char c; char c;
bool verbose=false;
bool help=false;
cout<<"Values stored in argv:"<<endl; cout<<"Values stored in argv:"<<endl;
for(int i=0; i<argc; i++) for(int i=0; i<argc; i++)
...@@ -31,7 +48,7 @@ int main(int argc, char* argv[]) ...@@ -31,7 +48,7 @@ int main(int argc, char* argv[])
cout<<argv[i]<<endl; cout<<argv[i]<<endl;
} }
while((c = getopt(argc,argv,"o:p:f:")) != -1) while((c = getopt(argc,argv,"o:p:f:hv")) != -1)
{ {
switch(c) switch(c)
{ {
...@@ -44,22 +61,45 @@ int main(int argc, char* argv[]) ...@@ -44,22 +61,45 @@ int main(int argc, char* argv[])
case 'f': case 'f':
filtering_steps=atoi(optarg); filtering_steps=atoi(optarg);
break; break;
case 'v':
verbose=true;
break;
case 'h':
help=true;
break;
default: default:
abort(); abort();
} }
} }
//open the right filtering log, e.g. filtlog_15_8.txt if(help)
{
cout<<"./fpwrite <path to run, e.g. ../my_runs/medium_run/> "<<endl;
cout<<"verbose: -v"<<endl;
cout<<"help: -h"<<endl;
cout<<"filtering steps (default 10): -f"<<endl;
cout<<"filtering choice (default 0): -o"<<endl;
exit(1);
}
//open the right filtering log file, e.g. filtlog_15_8.txt
util u; util u;
string path,bfn; string path,bfn;
u.extract_paths(full_path,path,bfn); u.extract_paths(full_path,path,bfn);
string fss,fcs; string fss,fcs;
fss=u.int_to_string(filtering_steps); fss=u.int_to_string(filtering_steps);
fcs=u.int_to_string(filt_choice); fcs=u.int_to_string(filt_choice);
cout<<fss<<" "<<fcs<<endl; if(verbose)
{
cout<<"path="<<path<<endl;
cout<<"bfn="<<bfn<<endl;
cout<<"filtering_steps=fss="<<fss<<endl;
cout<<"filt_choice=fcs="<<fcs<<endl;
}
ifstream instream; ifstream instream;
string infile = path+"/"+bfn+"/filt_logs/filtlog_"+fss+"_"+fcs+".txt"; string filt_infile = path+"/"+bfn+"/FILT_LOGS/filtlog_"+fss+"_"+fcs+".txt";
u.open_ifile(instream,infile,"infile"); u.open_ifile(instream,filt_infile,"filt_infile");
//read all the acceptable pairs into a map //read all the acceptable pairs into a map
set<pair<int,int> > g2k; //genes to keep set<pair<int,int> > g2k; //genes to keep
...@@ -76,7 +116,10 @@ int main(int argc, char* argv[]) ...@@ -76,7 +116,10 @@ int main(int argc, char* argv[])
instream>>gnum>>gene_id; instream>>gnum>>gene_id;
} }
cout<<"g2k.size() = "<<g2k.size()<<endl; if(verbose)
{
cout<<"g2k.size() = "<<g2k.size()<<endl;
}
//Read in the info file. //Read in the info file.
ifstream infostream; ifstream infostream;
...@@ -121,12 +164,18 @@ int main(int argc, char* argv[]) ...@@ -121,12 +164,18 @@ int main(int argc, char* argv[])
infostream>>o; infostream>>o;
} }
cout<<"hv.size() = "<<hv.size()<<endl; if(verbose)
{
cout<<"hv.size() = "<<hv.size()<<endl;
}
cout<<"Deleting previous *FAA_csv* and *FAA_ncsv* directories, if they exist..."<<endl;
u.rm_mkdir(path+"/"+bfn+"/","FAA_csv_"+fss+"_"+fcs); u.rm_mkdir(path+"/"+bfn+"/","FAA_csv_"+fss+"_"+fcs);
u.rm_mkdir(path+"/"+bfn+"/","FAA_mob_"+fss+"_"+fcs); u.rm_mkdir(path+"/"+bfn+"/","FAA_ncsv_"+fss+"_"+fcs);
u.rm_mkdir(path+"/"+bfn+"/","FAA_ref_csv_"+fss+"_"+fcs); u.rm_mkdir(path+"/"+bfn+"/","FAA_ref_csv_"+fss+"_"+fcs);
u.rm_mkdir(path+"/"+bfn+"/","FAA_ref_mob_"+fss+"_"+fcs); u.rm_mkdir(path+"/"+bfn+"/","FAA_ref_ncsv_"+fss+"_"+fcs);
cout<<"Creating new *FAA_csv* and *FAA_ncsv* directories..."<<endl;
for(int i=0; i<hv.size(); i++) for(int i=0; i<hv.size(); i++)
{ {
...@@ -135,7 +184,7 @@ int main(int argc, char* argv[]) ...@@ -135,7 +184,7 @@ int main(int argc, char* argv[])
string outdirectory = path+"/"+bfn+"/FAA_csv_"+fss+"_"+fcs+"/"+hv.at(i).dir; string outdirectory = path+"/"+bfn+"/FAA_csv_"+fss+"_"+fcs+"/"+hv.at(i).dir;
int system_return = system ( ("rm -r "+outdirectory).c_str()); int system_return = system ( ("rm -r "+outdirectory).c_str());
system_return = system ( ("mkdir "+outdirectory).c_str()); system_return = system ( ("mkdir "+outdirectory).c_str());
string outdirectory2 = path+"/"+bfn+"/FAA_mob_"+fss+"_"+fcs+"/"+hv.at(i).dir; string outdirectory2 = path+"/"+bfn+"/FAA_ncsv_"+fss+"_"+fcs+"/"+hv.at(i).dir;
int system_return2 = system ( ("rm -r "+outdirectory2).c_str()); int system_return2 = system ( ("rm -r "+outdirectory2).c_str());
system_return2 = system ( ("mkdir "+outdirectory2).c_str()); system_return2 = system ( ("mkdir "+outdirectory2).c_str());
} }
...@@ -145,7 +194,7 @@ int main(int argc, char* argv[]) ...@@ -145,7 +194,7 @@ int main(int argc, char* argv[])
string outdirectory = path+"/"+bfn+"/FAA_ref_csv_"+fss+"_"+fcs+"/"+hv.at(i).dir; string outdirectory = path+"/"+bfn+"/FAA_ref_csv_"+fss+"_"+fcs+"/"+hv.at(i).dir;
int system_return = system ( ("rm -r "+outdirectory).c_str()); int system_return = system ( ("rm -r "+outdirectory).c_str());
system_return = system ( ("mkdir "+outdirectory).c_str()); system_return = system ( ("mkdir "+outdirectory).c_str());
string outdirectory2 = path+"/"+bfn+"/FAA_ref_mob_"+fss+"_"+fcs+"/"+hv.at(i).dir; string outdirectory2 = path+"/"+bfn+"/FAA_ref_ncsv_"+fss+"_"+fcs+"/"+hv.at(i).dir;
int system_return2 = system ( ("rm -r "+outdirectory2).c_str()); int system_return2 = system ( ("rm -r "+outdirectory2).c_str());
system_return2 = system ( ("mkdir "+outdirectory2).c_str()); system_return2 = system ( ("mkdir "+outdirectory2).c_str());
} }
...@@ -203,9 +252,13 @@ int main(int argc, char* argv[]) ...@@ -203,9 +252,13 @@ int main(int argc, char* argv[])
} }
instream.close(); instream.close();
} // Done going through files. } // Done going through files.
cout<<"p2k.size()="<<p2k.size()<<endl;
cout<<"First protein:"<<endl; if(verbose)
cout<<p2k.at(0).first<<endl<<p2k.at(0).second<<endl; {
cout<<"p2k.size()="<<p2k.size()<<endl;
cout<<"First protein:"<<endl;
cout<<p2k.at(0).first<<endl<<p2k.at(0).second<<endl;
}
//Open the 2 output files. (new .faa files) //Open the 2 output files. (new .faa files)
//conserved write out //conserved write out
...@@ -224,16 +277,16 @@ int main(int argc, char* argv[]) ...@@ -224,16 +277,16 @@ int main(int argc, char* argv[])
cstream<<p2k.at(j).first<<endl<<p2k.at(j).second<<endl; cstream<<p2k.at(j).first<<endl<<p2k.at(j).second<<endl;
} }
//mobile write out //non-conserved proteins write out
ofstream mstream; ofstream mstream;
string mobfile=path+"/"+bfn+"/FAA"; string ncsv_file=path+"/"+bfn+"/FAA";
if(i<rss) if(i<rss)
{ {
mobfile+="_ref"; ncsv_file+="_ref";
} }
mobfile+="_mob_"+fss+"_"+fcs+"/"+hv.at(i).dir+"/mob_proteins.faa"; ncsv_file+="_ncsv_"+fss+"_"+fcs+"/"+hv.at(i).dir+"/ncsv_proteins.faa";
cout<<"mobfile = "<<mobfile<<endl; cout<<"ncsv_file = "<<ncsv_file<<endl;
u.open_ofile(mstream,mobfile,"mobfile"); u.open_ofile(mstream,ncsv_file,"ncsv_file");
for(int j=0; j<pn2k.size(); j++) for(int j=0; j<pn2k.size(); j++)
{ {
......
This diff is collapsed.
...@@ -484,6 +484,8 @@ void plot_v2::calculate_slope(double a_avg, double a_uncertainty, double wi_par, ...@@ -484,6 +484,8 @@ void plot_v2::calculate_slope(double a_avg, double a_uncertainty, double wi_par,
{ {
cout<<"Too few points to calculate a slope: right_bound-left_bound = "<<right_bound-left_bound<<endl; cout<<"Too few points to calculate a slope: right_bound-left_bound = "<<right_bound-left_bound<<endl;
cout<<"id1 id2 = "<<id1<<" "<<id2<<endl; cout<<"id1 id2 = "<<id1<<" "<<id2<<endl;
cout<<"right_bound = "<<right_bound<<endl;
cout<<"left_bound = "<<left_bound<<endl;
slope_exists=false; slope_exists=false;
exit(1); exit(1);
} }
......
...@@ -10,7 +10,7 @@ int main(int argc, char* argv[]) ...@@ -10,7 +10,7 @@ int main(int argc, char* argv[])
{ {
if(argc<2) if(argc<2)
{ {
cout<<"Improper use of tmerg.cpp: ./tmerg <full path to main run directory>"; cout<<"Improper use of tmerg.cpp: ./tmerg <full path to main run directory>"<<endl;
exit(1); exit(1);
} }
......
...@@ -77,6 +77,10 @@ tmerg::tmerg(string full_path_par, string dir_par, bool partial_run_par) ...@@ -77,6 +77,10 @@ tmerg::tmerg(string full_path_par, string dir_par, bool partial_run_par)
{ {
partial_run_lead=get_pr_lead(); partial_run_lead=get_pr_lead();
} }
else
{
partial_run_lead='_'; //just so it isn't not initialized
}
string logfile=path+"/"+bfn+"/logfile_tmerg.txt"; string logfile=path+"/"+bfn+"/logfile_tmerg.txt";
u.open_ofile_app(logstream,logfile,"logfile"); u.open_ofile_app(logstream,logfile,"logfile");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment