本文整理汇总了C++中SequenceTree::write方法的典型用法代码示例。如果您正苦于以下问题:C++ SequenceTree::write方法的具体用法?C++ SequenceTree::write怎么用?C++ SequenceTree::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SequenceTree
的用法示例。
在下文中一共展示了SequenceTree::write方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_partitions
void write_partitions(std::ostream& o,const vector<Partition>& partitions)
{
vector<Partition> full;
vector<Partition> sub;
for(int i=0;i<partitions.size();i++)
if (partitions[i].full())
full.push_back(partitions[i]);
else
sub.push_back(partitions[i]);
if (full.size()) {
SequenceTree consensus = get_mf_tree(partitions[0].names,full);
o<<consensus.write(false)<<endl;
}
for(int i=0;i<sub.size();i++)
o<<sub[i]<<endl;
}
示例2: main
int main(int argc,char* argv[]) {
Arguments args;
args.read(argc,argv);
unsigned long seed =0;
if (args.set("seed")) {
seed = convertTo<unsigned long>(args["seed"]);
myrand_init(seed);
}
else
seed = myrand_init();
assert(args.set("names"));
vector<string> names = split(args["names"],':');
double branch_mean = 0.1;
if (args.set("mean"))
branch_mean = convertTo<double>(args["mean"]);
SequenceTree T = RandomTree(names,branch_mean);
std::cout<<T.write()<<std::endl;
}
示例3: main
int main(int argc,char* argv[])
{
try {
//----------- Parse command line ----------//
variables_map args = parse_cmd_line(argc,argv);
int skip = args["skip"].as<int>();
int max = -1;
if (args.count("max"))
max = args["max"].as<int>();
int subsample = args["sub-sample"].as<int>();
vector<string> prune;
if (args.count("prune")) {
string p = args["prune"].as<string>();
prune = split(p,',');
}
//----------- Read the topology -----------//
SequenceTree Q = load_T(args);
standardize(Q);
const int B = Q.n_branches();
const int N = Q.n_nodes();
vector<double> bf(B);
for(int b=0;b<bf.size();b++)
bf[b] = Q.branch(b).length();
//-------- Read in the tree samples --------//
if ( args.count("simple") ) {
accum_branch_lengths_ignore_topology A(Q);
scan_trees(std::cin,skip,subsample,max,prune,A);
for(int b=0;b<B;b++)
Q.branch(b).set_length(A.m1[b]);
cout<<Q.write_with_bootstrap_fraction(bf,true)<<endl;
exit(0);
}
accum_branch_lengths_same_topology A(Q);
try {
scan_trees(std::cin,skip,subsample,max,prune,A);
}
catch (std::exception& e)
{
if (args.count("safe"))
cout<<Q.write(false)<<endl;
std::cerr<<"tree-mean-lengths: Error! "<<e.what()<<endl;
exit(0);
}
if (log_verbose) std::cerr<<A.n_matches<<" out of "<<A.n_samples<<" trees matched the topology";
if (log_verbose) std::cerr<<" ("<<double(A.n_matches)/A.n_samples*100<<"%)"<<std::endl;
//------- Merge lengths and topology -------//
if (args.count("var")) {
for(int b=0;b<B;b++)
Q.branch(b).set_length(A.m2[b]);
cout<<Q;
exit(0);
}
else {
for(int b=0;b<B;b++)
Q.branch(b).set_length(A.m1[b]);
if (not args.count("no-node-lengths") and
not args.count("show-node-lengths")) {
for(int n=0;n<N;n++) {
int degree = Q[n].neighbors().size();
for(out_edges_iterator b = Q[n].branches_out();b;b++)
(*b).set_length((*b).length() + A.n1[n]/degree);
}
}
//------- Print Tree and branch lengths -------//
cout<<Q.write_with_bootstrap_fraction(bf,true)<<endl;
//------------ Print node lengths -------------//
if (args.count("show-node-lengths"))
for(int n=0;n<Q.n_nodes();n++) {
if (A.n1[n] > 0) {
cout<<"node "<<A.n1[n]<<endl;
int b = (*Q[n].branches_in()).name();
cout<<partition_from_branch(Q,b)<<endl;
}
}
}
}
catch (std::exception& e) {
std::cerr<<"tree-mean-lengths: Error! "<<e.what()<<endl;
exit(1);
}
return 0;
}
示例4: topology
string topology(const string& t) {
SequenceTree T = standardized(t);
return T.write(false);
}
示例5: main
int main(int argc,char* argv[])
{
try {
std::cout.precision(3);
std::cout.setf(ios::fixed);
//---------- Parse command line -------//
variables_map args = parse_cmd_line(argc,argv);
//--------------------- Initialize ---------------------//
if (args.count("seed")) {
unsigned long seed = args["seed"].as<unsigned long>();
myrand_init(seed);
}
else
myrand_init();
int skip = args["skip"].as<int>();
int subsample=args["sub-sample"].as<int>();
int max = -1;
if (args.count("max"))
max = args["max"].as<int>();
double min_support = args["min-support"].as<double>();
// leaf taxa to ignore
vector<string> ignore;
if (args.count("ignore") and args["ignore"].as<string>().size() > 0)
ignore = split(args["ignore"].as<string>(),',');
// consensus levels
string c_levels = args.count("consensus") ? args["consensus"].as<string>() : "";
vector<double> consensus_levels = get_consensus_levels(c_levels);
double report_ratio = args["odds-ratio"].as<double>();
bool show_sub = args.count("sub-partitions");
//-------------- Read in tree distributions --------------//
string filename = args["file"].as<string>();
ifstream file(filename.c_str());
if (not file)
throw myexception()<<"Couldn't open file "<<filename;
tree_sample tree_dist(file,skip,subsample,max,ignore);
const unsigned N = tree_dist.size();
dynamic_bitset<> ignore_mask = group_from_names(tree_dist.names(),vector<string>());
//------ Compute Ml partitions or sub-partitions --------//
vector< pair<Partition,unsigned> > all_partitions;
if (show_sub)
{
int depth = args["depth"].as<int>();
double min_rooting = args["rooting"].as<double>();
all_partitions = get_Ml_sub_partitions_and_counts(tree_dist,min_support, ~ignore_mask,min_rooting,depth);
// std::cerr<<"n_sub_partitions = "<<all_partitions.size()<<"\n";
}
else
all_partitions = get_Ml_partitions_and_counts(tree_dist,min_support, ~ignore_mask);
vector<int> which_topology;
vector<int> topology_counts;
std::map<tree_record,int> topologies_index;
for(int i=0;i<tree_dist.size();i++)
{
std::map<tree_record,int>::iterator record = topologies_index.find(tree_dist[i]);
if (record == topologies_index.end())
{
which_topology.push_back(i);
topology_counts.push_back(0);
topologies_index[tree_dist[i]] = which_topology.size()-1;
record = topologies_index.find(tree_dist[i]);
}
topology_counts[record->second]++;
}
vector<int> order = iota<int>(topology_counts.size());
std::sort(order.begin(),order.end(),sequence_order<int>(topology_counts));
std::reverse(order.begin(), order.end());
//------ Topologies to analyze -----//
vector<string> topologies;
cout<<"# n_trees = "<<tree_dist.size()<<" n_topologies = "<<topology_counts.size()<<endl;
cout<<"\nTopology support: \n\n";
for(int i=0;i < args["map-trees"].as<int>() ;i++)
{
if (i >= order.size()) continue;
string t = tree_dist.T(which_topology[order[i]]).write(false);
//.........这里部分代码省略.........