Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug where linear, non-directional, single cuts were copying and not just moving overhangs from the fragment sequence. #409

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading