Skip to content

Commit

Permalink
Add fragmentation to synthesis directory (#198)
Browse files Browse the repository at this point in the history
* Moved synthesis to fixer and wrote fragment
  • Loading branch information
Koeng101 authored Sep 27, 2021
1 parent 1201768 commit 27152b0
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 47 deletions.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions synthesis/example_test.go → synthesis/fix/example_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package synthesis_test
package fix_test

import (
"fmt"
"github.com/TimothyStiles/poly/synthesis"
"github.com/TimothyStiles/poly/transform/codon"
"github.com/TimothyStiles/poly/synthesis/codon"
"github.com/TimothyStiles/poly/synthesis/fix"
)

// This example shows basic usage of the synthesis package. In this example,
Expand All @@ -14,11 +14,11 @@ func Example_basic() {

// Here, we initialize a codon table. This table is used to pick the
// appropriate new synonymous codons.
codonTable := codon.ReadCodonJSON("../data/pichiaTable.json")
codonTable := codon.ReadCodonJSON("../../data/pichiaTable.json")

// Finally, we fix the sequence with the optimization table, getting
// rid of the BsaI cut site, GGTCTC
fixedSeq, _, _ := synthesis.FixCdsSimple(bla, codonTable, []string{"GGTCTC"})
fixedSeq, _, _ := fix.CdsSimple(bla, codonTable, []string{"GGTCTC"})

fmt.Println(fixedSeq)
// Output: ATGAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGATCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA
Expand Down
26 changes: 13 additions & 13 deletions synthesis/synthesis.go → synthesis/fix/synthesis.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Package synthesis fixes synthetic DNA molecules in preparation for synthesis.
Package fix fixes synthetic DNA molecules in preparation for synthesis.
Many synthesis companies have restrictions on the DNA they can synthesize. This
synthesis fixer takes advantage of synonymous codons in protein coding
Expand All @@ -11,14 +11,14 @@ This synthesis fixer is meant to cover the majority of use cases for DNA
fixing. It is not intended to cover all possible use cases, since the majority
of DNA design does not actually have these edge cases.
For most users, using `FixCdsSimple` will be sufficient to prepare a sequence
For most users, using `CdsSimple` will be sufficient to prepare a sequence
for synthesis (you may want to add in restriction enzyme sites to remove).
FixCds does not guarantee that all requested features will be removed. If you
have use case that FixCds cannot properly fix, please put an issue in the poly
Cds does not guarantee that all requested features will be removed. If you
have use case that Cds cannot properly fix, please put an issue in the poly
github.
*/
package synthesis
package fix

import (
"errors"
Expand All @@ -29,8 +29,8 @@ import (
"sync"

"github.com/TimothyStiles/poly/checks"
"github.com/TimothyStiles/poly/synthesis/codon"
"github.com/TimothyStiles/poly/transform"
"github.com/TimothyStiles/poly/transform/codon"
)

// DnaSuggestion is a suggestion of a fixer, generated by a
Expand All @@ -45,7 +45,7 @@ type DnaSuggestion struct {
}

// Change is a change to a given DNA sequence. A list of changes is given as
// the output of FixCds.
// the output of Cds.
type Change struct {
Position int `db:"position"`
Step int `db:"step"`
Expand Down Expand Up @@ -207,10 +207,10 @@ At the end, the user should get a fixed CDS as an output, as well as a list of
changes that were done to the sequence.
*/

// FixCds fixes a CDS given the CDS sequence, a codon table, a list of
// Cds fixes a CDS given the CDS sequence, a codon table, a list of
// functions to solve for, and a number of iterations to attempt fixing.
// Unless you are an advanced user, you should use FixCdsSimple.
func FixCds(sequence string, codontable codon.Table, problematicSequenceFuncs []func(string, chan DnaSuggestion, *sync.WaitGroup)) (string, []Change, error) {
// Unless you are an advanced user, you should use CdsSimple.
func Cds(sequence string, codontable codon.Table, problematicSequenceFuncs []func(string, chan DnaSuggestion, *sync.WaitGroup)) (string, []Change, error) {

codonLength := 3
if len(sequence)%codonLength != 0 {
Expand Down Expand Up @@ -377,10 +377,10 @@ func FixCds(sequence string, codontable codon.Table, problematicSequenceFuncs []
}
}

// FixCdsSimple is FixCds with some defaults for normal usage, including
// CdsSimple is FixCds with some defaults for normal usage, including
// removing of homopolymers, removing any repeat larger than 18 base pairs, and
// fixing if a CDS's gc content is above 80% or below 20%
func FixCdsSimple(sequence string, codontable codon.Table, sequencesToRemove []string) (string, []Change, error) {
func CdsSimple(sequence string, codontable codon.Table, sequencesToRemove []string) (string, []Change, error) {
var functions []func(string, chan DnaSuggestion, *sync.WaitGroup)
// Remove homopolymers
functions = append(functions, RemoveSequence([]string{"AAAAAAAA", "GGGGGGGG"}, "Homopolymers"))
Expand All @@ -394,5 +394,5 @@ func FixCdsSimple(sequence string, codontable codon.Table, sequencesToRemove []s
// Ensure normal GC range
functions = append(functions, GcContentFixer(0.80, 0.20))

return FixCds(sequence, codontable, functions)
return Cds(sequence, codontable, functions)
}
Loading

0 comments on commit 27152b0

Please sign in to comment.