Esempio n. 1
0
void get_segmentation(em::DensityMap *dmap, double apix,
                      double density_threshold, int num_means,
                      const std::string pdb_filename,
                      const std::string cmm_filename,
                      const std::string seg_filename,
                      const std::string txt_filename) {
  IMP_LOG_VERBOSE("start setting trn_em" << std::endl);
  IMP_NEW(DensityDataPoints, ddp, (dmap, density_threshold));
  IMP_LOG_VERBOSE("initialize calculation of initial centers" << std::endl);
  statistics::internal::VQClustering vq(ddp, num_means);
  vq.run();
  DataPointsAssignment assignment(ddp, &vq);
  AnchorsData ad(assignment.get_centers(), *(assignment.get_edges()));
  multifit::write_pdb(pdb_filename, assignment);
  // also write cmm string into a file:
  if (cmm_filename != "") {
    write_cmm(cmm_filename, "anchor_graph", ad);
  }
  if (seg_filename != "") {
    write_segments_as_mrc(dmap, assignment, apix, apix, density_threshold,
                          seg_filename);
  }
  if (txt_filename != "") {
    write_txt(txt_filename, ad);
  }
}
Esempio n. 2
0
void Manifold::write_txt(const char* filename, bool MMA) const {
	ofstream file;

	file.open(filename, ios::out);

	if (file.fail())
		ibex_error("[manifold]: cannot create output file.\n");

	// character to separate elements in a list
	char s=MMA? ',' : ' ';
	// character that ends a list
	//char e=MMA? ' ' : '}';

	if (MMA) file << "{{";
	file << n << s << m << s << nb_ineq;
	if (MMA) file << "},"; else file << '\n';
	file << status;
	if (MMA) file << ",{"; else file << '\n';
	file << inner.size() << s << boundary.size() << s << unknown.size() << s << pending.size();
	if (MMA) file << "},{"; else file << '\n';
	file << time << s << nb_cells;
	if (MMA) file << "}"; else file << '\n';

	if (MMA) file << ",{";
	bool first_sol=true;
	for (vector<SolverOutputBox>::const_iterator it=inner.begin(); it!=inner.end(); it++) {
		if (!first_sol && MMA) file << ','; else first_sol=false;
		write_txt(file,*it,MMA);
	}
	for (vector<SolverOutputBox>::const_iterator it=boundary.begin(); it!=boundary.end(); it++) {
		if (!first_sol && MMA) file << ','; else first_sol=false;
		write_txt(file,*it,MMA);
	}
	for (vector<SolverOutputBox>::const_iterator it=unknown.begin(); it!=unknown.end(); it++) {
		if (!first_sol && MMA) file << ','; else first_sol=false;
		write_txt(file,*it,MMA);
	}
	for (vector<SolverOutputBox>::const_iterator it=pending.begin(); it!=pending.end(); it++) {
		if (!first_sol && MMA) file << ','; else first_sol=false;
		write_txt(file,*it,MMA);
	}
	if (MMA) file << '}';

	if (MMA) file << "}\n";

	file.close();
}