void Gui_ResultFileWriter::writeRows(const bool detail,const ResultMap& res_map,const std::vector<int>& idxs){ Glib::RefPtr< Gio::FileOutputStream > fout = m_out_file->append_to(); if(detail){ for (auto i : idxs){ const Result& res_ref = res_map.getResultAt(i); const std::string& path = (res_map.getFileFromIdx(i)->get_path()); const std::string& comment = res_map.getCommentAt(i); if(!res_map.getIsNAAt(i)){ for (unsigned int j=0; j<res_ref.size();++j){ std::stringstream ss; const OneObjectRow& oor = res_ref.getRow(j); ss <<"\""<<path<<"\", "<< oor.print()<<", \""<<comment<<"\""<<std::endl; fout->write(ss.str()); } } } } else{ for (auto i : idxs){ const Result& res_ref = res_map.getResultAt(i); Glib::RefPtr<Gio::File> tmp_file = res_map.getFileFromIdx(i); const std::vector<int> roi_keys = res_ref.getROIs(); const std::string& comment = res_map.getCommentAt(i); std::map < unsigned int,std::pair<unsigned int,unsigned int> > table; table[0].first = res_ref.getNValid(); table[0].second = res_ref.size() - res_ref.getNValid(); for(unsigned int i=0; i != (unsigned int)res_ref.size(); ++i){ OneObjectRow object = res_ref.getRow(i); int roi = object.getROI(); if (roi > 0){ if(object.getGUIValid() && object.isValid()) //otherwise colour filters etc. don't work ++(table[roi].first); else ++(table[roi].second); } } for (auto &it : table){ int roi = it.first; if ((table.size() == 1) || (roi >= 1)){ std::stringstream ss; ss <<i<<"," <<"\""<<tmp_file->get_basename()<<"\""<<"," <<roi<<","; if(!res_map.getIsNAAt(i)){ ss<<it.second.first<<"," <<it.second.second<<","; } else{ ss<<"NA,NA,"; } ss<<res_ref.getROIClusterData(roi).clusterPop(1)<<"," <<res_ref.getROIClusterData(roi).clusterPop(2)<<"," <<res_ref.getROIClusterData(roi).clusterPop(3)<<"," <<"\""<<comment<<"\""<<"," <<"\""<<tmp_file->get_path()<<"\"," <<"\""<<res_ref.getROIClusterData(roi).str()<<"\""<<std::endl; fout->write(ss.str()); } } } } fout->flush (); fout->close(); }
void Result::add_at(const OneObjectRow& row,const unsigned int i){ v[i] = row; if(row.isValid()) m_n_valid++; }