From 1a741c85652e2b1e5543701499b6125d96deee3d Mon Sep 17 00:00:00 2001 From: Albert Kim Date: Mon, 7 May 2012 18:05:05 -0700 Subject: [PATCH] Do not modify contigs KmerContigMap --- contig.cpp | 6 ++++++ contig.h | 1 + kmer_contig_map.cpp | 7 ++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/contig.cpp b/contig.cpp index b6510cd..6c5ceb4 100644 --- a/contig.cpp +++ b/contig.cpp @@ -26,6 +26,12 @@ Contig::Contig(kmer_t init_kmer) s = kmer_str; } +Contig::Contig(Contig* contig) + : id(id_generator++), s(contig->s), left_ext(contig->left_ext), + right_ext(contig->right_ext) +{ +} + bool Contig::check_next_left_ext(base next_left_ext) { return char2base(s[s.size() - k]) == next_left_ext; diff --git a/contig.h b/contig.h index 717dc54..89d8ad2 100644 --- a/contig.h +++ b/contig.h @@ -15,6 +15,7 @@ class Contig { Contig(); Contig(kmer_t init_kmer); + Contig(Contig* contig); /* Checks the given base 'next_left_ext' against the s[size - k] to see if * they're the same. If the kmer overlaps properly, these bases should be diff --git a/kmer_contig_map.cpp b/kmer_contig_map.cpp index cb469a5..e89bd8c 100644 --- a/kmer_contig_map.cpp +++ b/kmer_contig_map.cpp @@ -41,14 +41,15 @@ void KmerContigMap::join_contigs(ContigStore& contig_store) for (map_type_t::iterator it = forward_map.map.begin(); it != forward_map.map.end(); it++) { - Contig* contig = it->second; - - if (contig->s.size() == 0) continue; + if (it->second->s.size() == 0) continue; + Contig* contig = new Contig(it->second); walk(contig); contig->revcmp(); walk(contig); contig_store.add(contig); + + it->second->s.clear(); } }