Skip to content

Commit

Permalink
fixed bug that produced wrong overhang in linear, non-directional, si…
Browse files Browse the repository at this point in the history
…ngle cut reactions.
  • Loading branch information
TimothyStiles committed Dec 1, 2023
1 parent 916c92d commit 93e89eb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
10 changes: 9 additions & 1 deletion clone/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,15 @@ func CutWithEnzyme(part Part, directional bool, enzyme Enzyme) []Fragment {
// 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]
overhangSequence := sequence[overhangs[0].Position : overhangs[0].Position+overhangs[0].Length]

var overhangSequence string

if len(forwardOverhangs) > 0 {
overhangSequence = sequence[overhangs[0].Position : overhangs[0].Position+overhangs[0].Length]
} else {
overhangSequence = sequence[overhangs[0].Position-overhangs[0].Length : overhangs[0].Position]
}

fragments = append(fragments, Fragment{fragmentSequence1, overhangSequence, ""})
fragments = append(fragments, Fragment{fragmentSequence2, "", overhangSequence})
return fragments
Expand Down
38 changes: 38 additions & 0 deletions clone/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,44 @@ func TestCutWithEnzyme(t *testing.T) {
}
}

func TestCutWithEnzymeRegression(t *testing.T) {
sequence := "AGCTGCTGTTTAAAGCTATTACTTTGAGACC" // this is a real sequence I came across that was causing problems

part := Part{sequence, false}

// get enzymes with enzyme manager
enzymeManager := NewEnzymeManager(GetBaseRestrictionEnzymes())
bsa1, err := enzymeManager.GetEnzymeByName("BsaI")
if err != nil {
t.Errorf("Error when getting Enzyme. Got error: %s", err)
}

// cut with BsaI
fragments := CutWithEnzyme(part, false, bsa1)

// check that the fragments are correct
if len(fragments) != 2 {
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].ReverseOverhang != "" {
t.Errorf("Expected reverse overhang to be GAGT, got: %s", fragments[0].ReverseOverhang)
}

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

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

Check failure on line 134 in clone/clone_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)
}

func TestCircularLigate(t *testing.T) {
// The following tests for complementing overhangs. Specific, this line:
// newSeed := Fragment{seedFragment.Sequence + seedFragment.ReverseOverhang + ReverseComplement(newFragment.Sequence), seedFragment.ForwardOverhang, ReverseComplement(newFragment.ForwardOverhang)}
Expand Down

0 comments on commit 93e89eb

Please sign in to comment.