Skip to content

Commit

Permalink
fixed bug where linear, non-directional, single cuts were copying and…
Browse files Browse the repository at this point in the history
… not just moving overhangs from the fragment sequence. (#409)
  • Loading branch information
TimothyStiles authored Dec 1, 2023
1 parent d0f6ab3 commit f76bf05
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
14 changes: 10 additions & 4 deletions clone/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,25 @@ func CutWithEnzyme(part Part, directional bool, enzyme Enzyme) []Fragment {
// 2 fragments
if len(overhangs) == 1 && !directional && !part.Circular { // Check the case of a single cut
// In the case of a single cut in a linear sequence, we get two fragments with only 1 stick end
fragmentSequence1 := sequence[overhangs[0].Position+overhangs[0].Length:]
fragmentSequence2 := sequence[:overhangs[0].Position]

var fragmentSequence1 string
var fragmentSequence2 string
var overhangSequence string

if len(forwardOverhangs) > 0 {
fragmentSequence1 = sequence[overhangs[0].Position+overhangs[0].Length:]
fragmentSequence2 = sequence[:overhangs[0].Position]
overhangSequence = sequence[overhangs[0].Position : overhangs[0].Position+overhangs[0].Length]
fragments = append(fragments, Fragment{fragmentSequence1, overhangSequence, ""})
fragments = append(fragments, Fragment{fragmentSequence2, "", overhangSequence})
} else {
fragmentSequence1 = sequence[overhangs[0].Position:]
fragmentSequence2 = sequence[:overhangs[0].Position-overhangs[0].Length]
overhangSequence = sequence[overhangs[0].Position-overhangs[0].Length : overhangs[0].Position]
fragments = append(fragments, Fragment{fragmentSequence2, "", overhangSequence})
fragments = append(fragments, Fragment{fragmentSequence1, overhangSequence, ""})
}

fragments = append(fragments, Fragment{fragmentSequence1, overhangSequence, ""})
fragments = append(fragments, Fragment{fragmentSequence2, "", overhangSequence})
return fragments
}

Expand Down
22 changes: 14 additions & 8 deletions clone/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,26 @@ func TestCutWithEnzymeRegression(t *testing.T) {
t.Errorf("Expected 2 fragments, got: %d", len(fragments))
}

if fragments[0].ForwardOverhang != "ACTT" {
t.Errorf("Expected forward overhang to be ACTT, got: %s", fragments[0].ForwardOverhang)
if fragments[0].ForwardOverhang != "" {
t.Errorf("Expected forward overhang to be empty, got: %s", fragments[1].ForwardOverhang)
}

if fragments[0].ReverseOverhang != "" {
t.Errorf("Expected reverse overhang to be GAGT, got: %s", fragments[0].ReverseOverhang)
if fragments[0].ReverseOverhang != "ACTT" {
t.Errorf("Expected reverse overhang to be GAGT, got: %s", fragments[1].ReverseOverhang)
}

if fragments[1].ForwardOverhang != "" {
t.Errorf("Expected forward overhang to be empty, got: %s", fragments[1].ForwardOverhang)
if fragments[1].ForwardOverhang != "ACTT" {
t.Errorf("Expected forward overhang to be ACTT, got: %s", fragments[0].ForwardOverhang)
}

if fragments[1].ReverseOverhang != "ACTT" {
t.Errorf("Expected reverse overhang to be GAGT, got: %s", fragments[1].ReverseOverhang)
if fragments[1].ReverseOverhang != "" {
t.Errorf("Expected reverse overhang to be GAGT, got: %s", fragments[0].ReverseOverhang)
}

// assemble the fragments back together
assembly := fragments[0].Sequence + fragments[0].ReverseOverhang + fragments[1].Sequence
if assembly != sequence {
t.Errorf("Expected assembly to be %s, got: %s", sequence, assembly)
}
}

Expand Down

0 comments on commit f76bf05

Please sign in to comment.