static void output_vertices (vertex_db & vertices) { std::string tmp_file_name = "tmpidmap"; boost::shared_ptr<SpatialIndex::IStorageManager> tmp_file (SpatialIndex::StorageManager::createNewDiskStorageManager ( tmp_file_name,page_size)); idmap_t idmap (tmp_file, page_size); vertex_db::iterator v_start = vertices.begin (); vertex_db::iterator v_ptr = v_start; ofstream myfile; myfile.open ("example.txt"); long v_id = 1; long edges = 0; // map<vertex_id,long> idmap; while (v_ptr != vertices.end ()) { edges += ((vertex_info)v_ptr->second).neighbours.size (); // idmap.insert(pair<vertex_id,long>((vertex_id)v_ptr->first,v_id)); idmap.insert (v_ptr->first, v_id); v_id++; v_ptr++; } v_id--; ldiv_t divresult = ldiv(edges,2); myfile << v_id << " " << divresult.quot << " 0\n"; v_start = vertices.begin (); v_ptr = v_start; v_id = 1; while (v_ptr != vertices.end ()) { std::vector<vertex_id> n = ((vertex_info)v_ptr->second).neighbours; vertex_id id = (vertex_id)v_ptr->first; // map<vertex_id,long>::iterator it; // it = idmap.find(id); std::cout << get_remapped_vertex (idmap, id) << " : "; //std::cout << it->second << " : "; BOOST_FOREACH (vertex_id n_id, n) { // it = idmap.find(n_id); myfile << get_remapped_vertex (idmap, n_id) << " "; } myfile << endl; v_id++; v_ptr++; }
void mmuinit(void) { uintptr pa; PTE *l1, *l2; pa = ttbget(); l1 = KADDR(pa); /* redundant with l.s; only covers first MB of 17MB */ l1[L1X(VIRTIO)] = PHYSIO|Dom0|L1AP(Krw)|Section; idmap(l1, PHYSETHER); /* igep 9221 ethernet regs */ idmap(l1, PHYSL4PROT); idmap(l1, PHYSL3); idmap(l1, PHYSSMS); idmap(l1, PHYSDRC); idmap(l1, PHYSGPMC); /* map high vectors to start of dram, but only 4K, not 1MB */ pa -= MACHSIZE+2*1024; l2 = KADDR(pa); memset(l2, 0, 1024); /* vectors step on u-boot, but so do page tables */ l2[L2X(HVECTORS)] = PHYSDRAM|L2AP(Krw)|Small; l1[L1X(HVECTORS)] = pa|Dom0|Coarse; /* vectors -> ttb-machsize-2k */ coherence(); cacheuwbinv(); l2cacheuwbinv(); mmuinvalidate(); m->mmul1 = l1; // mmudump(l1); /* DEBUG */ }
static int do_idmap(char **arg, char reply[REPLY_MAX]) { return idmap(arg[0], arg[1], atoi(arg[2])); }
int MFGraph::decompose(const int componentID, std::ostream & patt_stream, std::string chr) { IdMap<ListDigraph, ListDigraph::Node> idmap(mfGraph); // compute total flow float total_flow = this->total_flow(); #ifndef NDEBUG std::cout << "total flow:: " << total_flow << std::endl; #endif int flownum = 0; // iterate while residual flow while (total_flow > 0.00001) { // compute residual flow for each arc ListDigraph::ArcMap<float> residual_flow(mfGraph); for (ListDigraph::ArcIt arc(mfGraph); arc != INVALID; ++arc) { residual_flow[arc] = (total_flow - flow_map[arc]); if(flow_map[arc] != 0){ // #ifndef NDEBUG // std::cout << "source: " << mfGraph.id(mfGraph.source(arc))<< ", target: " << mfGraph.id(mfGraph.target(arc)) << ", flow: " << flow_map[arc] <<std::endl; // #endif } } #ifndef NDEBUG std::cout << "run the min-max dijkstra algorithm " << std::endl; #endif // run the min-max dijkstra algorithm ListDigraph::NodeMap<float> dist(mfGraph); Dijkstra<ListDigraph, ListDigraph::ArcMap<float> > ::SetOperationTraits<DijkstraMinMaxOperationTraits<float> > ::Create dijkstra(mfGraph, residual_flow); dijkstra.distMap(dist); dijkstra.run(source, sink); #ifndef NDEBUG std::cout << "get the resulting path and it's flow " << std::endl; #endif // get the resulting path and it's flow Path<ListDigraph> shortestPath = dijkstra.path(sink); float path_flow = total_flow - dijkstra.dist(sink); // break out if this is not a valid path if (path_flow == 0) { #ifndef NDEBUG std::cout << "Found invalid path" << std::endl; #endif break; } // construct a meth fragment from path here // and remove path flow from each arc in path #ifndef NDEBUG std::cout << "dijkstra.dist: " << dijkstra.dist(sink) << ", path_flow:" << path_flow << ", total flow: " << total_flow << " length: " << shortestPath.length() << std::endl; #endif // it's a valid pattern, so increase number of paths found flownum++; std::stringstream region_list; MethylRead* pattern = NULL; int start, end; //MethylRead pattern = MethylRead(*read_map[source]); //int start = read_map[source]->start(); //int end = read_map[sink]->end(); for(Path<ListDigraph>::ArcIt arc(shortestPath); arc != INVALID; ++arc) { ListDigraph::Node s = mfGraph.source(arc); ListDigraph::Node t = mfGraph.target(arc); if (s == source) { pattern = new MethylRead(*read_map[t]); start = read_map[t]->start(); end = read_map[t]->end(); // end = read_map[sink]->end(); #ifndef NDEBUG std::cout << "Original pattern = " << pattern->getMethString() << std::endl; #endif break; } } #ifndef NDEBUG if (!pattern) { std::cout << "We should not hit this" << std::endl; for (Path<ListDigraph>::ArcIt arc(shortestPath); arc != INVALID; ++arc) { ListDigraph::Node s = mfGraph.source(arc); ListDigraph::Node t = mfGraph.target(arc); std::cout << mfGraph.id(s) << " -> " << mfGraph.id(t) << std::endl; } } #endif for(Path<ListDigraph>::ArcIt arc(shortestPath); arc != INVALID; ++arc) { // #ifndef NDEBUG // std::cout << " After finding a path, " << "source: " << mfGraph.id(mfGraph.source(arc))<< ", target: " << mfGraph.id(mfGraph.target(arc)) << ", flow: " << flow_map[arc] << " ,arc - pathFlow: " << flow_map[arc] - path_flow << std::endl; // #endif ListDigraph::Node s = mfGraph.source(arc); ListDigraph::Node t = mfGraph.target(arc); MethylRead *read = read_map[t]; // don't print the source node or nodes connected to sink if (s != source && t != get_sink()) { region_list << idmap[s]; if (!childless[t]) { region_list << ","; } } flow_map[arc] -= path_flow; // delete arc if no residual flow if (flow_map[arc] < 1e-6) { mfGraph.erase(arc); } if (s == source) { continue; } if (!read || t == get_sink()) { continue; } if (s != source && t != get_sink()) { pattern->merge(read); end = read->end(); //std::cout << "new pattern = " << pattern->getMethString() << std::endl; } // if (childless[t]) { // end = read->end(); // } } #ifndef NDEBUG std::cout << "new pattern = " << pattern->getMethString() << std::endl; #endif //Note we add source one nucleotide before every read patt_stream << chr << "\t" << start << "\t" << end; patt_stream << "\t" << componentID << "\t" << flownum << "\t" << path_flow; patt_stream << "\t" << pattern->getMethString() << "\t" << region_list.str() << std::endl; delete pattern; // recompute residual flow total_flow -= path_flow; } // all done return flownum; }
static int do_idmap(char **arg, char reply[REPLY_MAX]) { ALOGD("do_idmap : %s %s %s", arg[0], arg[1], arg[2]); return idmap(arg[0], arg[1], atoi(arg[2])); }