Commit a51aac66 authored by Raquel Bromberg's avatar Raquel Bromberg

Minor changes to make mtax.cpp more standalone and not rely on files generated by other classes

parent f27a7156
......@@ -4,19 +4,27 @@
#include <vector>
#include <map>
#include "util.h"
using namespace std;
void separate_fields(string line,vector<string>& fields, char separator);
void create_genome_names(string path, string bfn);
int main(int argc, char* argv[])
{
if(argc<3)
{
cout<<"Wrong use of mtax: ./mtax <path to directory containing genome names> <path to directory containing names.dmp and nodes.dmp>"<<endl;
cout<<"Wrong use of mtax: ./mtax <path to main directory> <path to Taxonomy directory containing names.dmp and nodes.dmp>"<<endl;
exit(1);
}
string names_file=argv[1];
string path,bfn;
util u;
u.extract_paths(names_file,path,bfn);
create_genome_names(path,bfn);
string names_file1=names_file+"/genome_names.txt";
string tax_dir=argv[2];
......@@ -295,3 +303,36 @@ void separate_fields(string line,vector<string>& fields, char separator)
// cout<<"i="<<fields.at(i)<<endl;
}
}
void create_genome_names(string path,string bfn)
{
ofstream gmstream;
string gmfile=path+"/"+bfn+"/genome_names.txt";
gmstream.open(gmfile.c_str());
if(gmstream.fail())
{
cout<<"Failed to open gmstream to gmfile="<<gmfile<<endl;
exit(1);
}
util u;
int main_set_size;
int ref_set_size;
u.get_mss(path+"/"+bfn+"/"+bfn+"_info.txt",main_set_size);
u.get_rss(path+"/"+bfn+"/"+bfn+"_info.txt",ref_set_size);
for(int i=0; i<main_set_size+ref_set_size; i++)
{
string tn=u.get_oname(path+"/"+bfn+"/",i);
// string tn=organisms.at(i).get_directory();
for(int f=0; f<tn.length(); f++)
{
if(tn[f]=='_')
{
tn[f]=' ';
}
}
gmstream<<tn<<endl;
}
gmstream.close();
}
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