#ifndef TMERG_H #define TMERG_H /* tmerg: Takes the list of kmers that were sorted in batches and merges them into a final sorted list. */ #include #include #include #include #include #include #include #include #include #include #include "file_info.h" #include "amino_acids.h" #include "util.h" using namespace std; const bool TMERG_DEBUG=true; class tmerg { private: string bfn; string path; int tag_length; int ref_set_size; string dir; //specifies whether the tags are from TAGS or TAGSscr //and whether the merged tags go to TAGS_MERGED or TAGS_MERGEDscr ofstream logstream; amino_acids aas; util u; vector fiv; vector files; void read_in_files(); void open_tag_files(); void read_in_tags(vector& tags, char current_amino_acid, int& num_refs); void read_in_tags_um(vector& tags, char current_amino_acid, int& num_refs); void write_out_tags(vector& tags,int ordinal, int num_refs); void write_out_tags_um(vector& tags,int ordinal, int num_refs); bool compare_tags(string s1, string s2); public: //constructors tmerg(string full_path_par, string dir_par); void merge(); }; tmerg::tmerg(string full_path_par, string dir_par) { if(TMERG_DEBUG) { cout<<"tmerg::tmerg(string,string)"<d_name); std::string fn=sin.str(); if( ((string)de->d_name).length() > 5 && ((string)de->d_name).substr(0,4)=="TAGS") { files.push_back( (string)(de->d_name)); } } if(TMERG_DEBUG) { cout<<"tmerg::read_in_files() : Size of files = "<open(path+"/"+bfn+"/TAGS"+dir+"/"+files.at(i)); if(TMERG_DEBUG) { cout<<"i="<, char, int&) : current_amino_acid = "<, char, int&) : "; cout<<"Merged "<, char, int&) : current_amino_acid = "<, char, int&) : "; cout<<"Merged "<, char, int&) : "; cout<<"Merged "<&, int, int) : tags.size() = "<&, int, int) : invalid tags.size() = "<0) { char buf[30]; sprintf(buf,"%d",ordinal); string buf2=buf; string out_file_name = "TAGS"+buf2+".txt"; FILE* oFile; FILE* oFile_ref; oFile = fopen( (path + "/"+bfn+"/MERGED_TAGS"+dir+"/"+out_file_name).c_str(), "w"); if(num_refs>0) { oFile_ref = fopen( (path + "/"+bfn+"/REF_MERGED_TAGS"+dir+"/"+out_file_name).c_str(), "w"); } std::sort(tags.begin(), tags.end()); if(TMERG_DEBUG) { cout<<"tmerg::write_out_tags(vector&, int, int) : Successfully completed quicksort..."<0) { fprintf(oFile_ref,"%d\n",(int)num_refs); } for(int i=0; (unsigned)i>e>>gnum; if(num_refs>0) { if(gnum0) { fclose(oFile_ref); } tags.clear(); } else { cout<<"tmerg::write_out_tags(vector&, int, int) : tags.size() = "<& tags,int ordinal, int num_refs) { if(TMERG_DEBUG) { cout<<"tmerg::write_out_tags_um(vector&, int, int) : tags.size() = "<&, int, int) : invalid tags.size() = "<0) { char buf[30]; sprintf(buf,"%d",ordinal); string buf2=buf; string out_file_name = "TAGS"+buf2+".txt"; FILE* oFile; FILE* oFile_ref; oFile = fopen( (path + "/"+bfn+"/MERGED_TAGS"+dir+"/"+out_file_name).c_str(), "w"); if(num_refs>0) { oFile_ref = fopen( (path + "/"+bfn+"/REF_MERGED_TAGS"+dir+"/"+out_file_name).c_str(), "w"); } fprintf(oFile,"%d\n",(int)tags.size()); if(num_refs>0) { fprintf(oFile_ref,"%d\n",(int)num_refs); } for(int i=0; (unsigned)i>e>>gnum; if(num_refs>0) { if(gnum0) { fclose(oFile_ref); } tags.clear(); } else { cout<<"tmerg::write_out_tags_um(vector&, int, int): tags.size = "<