Skip to content

Instantly share code, notes, and snippets.

@fataltes
Last active July 1, 2019 21:50
Show Gist options
  • Save fataltes/35fbcc30fe9cace8fddeb5df9907f130 to your computer and use it in GitHub Desktop.
Save fataltes/35fbcc30fe9cace8fddeb5df9907f130 to your computer and use it in GitHub Desktop.
int getPufferfishContigStats(IndexT& pi) {
//size_t k = pi.k();
CanonicalKmer::k(pi.k());
size_t found = 0;
size_t notFound = 0;
size_t correctPosCntr = 0;
size_t incorrectPosCntr = 0;
size_t numTrueTxp = 0;
size_t numLostTxp = 0;
std::ofstream out("contigInfo.txt");
std::cerr << "store the contig info\n";
uint64_t cid{0}, totalLength{0};
while (totalLength < pi.getSeq().size()) {
auto kmer = pi.getStartKmer(cid);
auto clen = pi.getContigLen(cid);
totalLength += clen;
out << cid << "\t" << clen << "\t"; // contigId, contigLen
float sumTxphits{0};
std::unordered_map<uint64_t, uint64_t> txpCntMap;
auto chits = pi.getRefPos(kmer) ;
for (auto& rpos : chits.refRange) {
if (txpCntMap.find(rpos.transcript_id()) == txpCntMap.end())
txpCntMap[rpos.transcript_id()] = 0;
txpCntMap[rpos.transcript_id()]++;
}
for (auto kv: txpCntMap) {
sumTxphits += kv.second;
}
out << txpCntMap.size() << "\t" << (txpCntMap.size() > 0 ? sumTxphits/txpCntMap.size():0) << "\n"; // # of txps, avg of hits per txp
cid++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment