Boris Nagaev avatar Boris Nagaev committed 1ab5c13

Fragment: add method detach_row()

Comments (0)

Files changed (3)

src/model/Fragment.cpp

     return result;
 }
 
+AlignmentRow* Fragment::detach_row() {
+    AlignmentRow* result = row_;
+    if (row_) {
+        row_->set_fragment(0);
+        row_ = 0;
+    }
+    return result;
+}
+
 void Fragment::set_row(AlignmentRow* row) {
     if (row_ && row_->fragment()) {
         row_->set_fragment(0);

src/model/Fragment.hpp

         return row_;
     }
 
+    /** Detach a row from the fragment and return it.
+    Detached row is not owned by a fragment.
+    */
+    AlignmentRow* detach_row();
+
     /** Set alignemnt row of this fragment.
     Ownership is transferred.
     Previous alignemnt row is deleted if set.

src/test/alignment_row.cpp

     MapAlignmentRow row("tggtccgaga", &f1);
 }
 
+BOOST_AUTO_TEST_CASE (MapAlignmentRow_detach) {
+    using namespace bloomrepeats;
+    SequencePtr s1 = boost::make_shared<InMemorySequence>("tggtccgagatgcgggcc");
+    MapAlignmentRow row("tggtccgaga");
+    Fragment f1(s1, 0, 9, 1);
+    f1.set_row(&row);
+    f1.detach_row();
+}
+
 BOOST_AUTO_TEST_CASE (MapAlignmentRow_2) {
     using namespace bloomrepeats;
     SequencePtr s1 = boost::make_shared<InMemorySequence>("tggtccgagatgcgggcc");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.