MCPcopy Create free account
hub / github.com/bebop/poly / TestAddCodonTable

Function TestAddCodonTable

synthesis/codon/codon_test.go:293–332  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

291}
292
293func TestAddCodonTable(t *testing.T) {
294 sequence, _ := genbank.Read("../../data/puc19.gbk")
295
296 // weight our codon optimization table using the regions we collected from the genbank file above
297
298 optimizationTable, err := NewTranslationTable(11)
299 if err != nil {
300 t.Fatalf("failed to initialise codon table: %s", err)
301 }
302
303 err = optimizationTable.UpdateWeightsWithSequence(sequence)
304 if err != nil {
305 t.Error(err)
306 }
307
308 sequence2, _ := genbank.Read("../../data/phix174.gb")
309 optimizationTable2, err := NewTranslationTable(11)
310 if err != nil {
311 t.Fatalf("failed to initialise codon table: %s", err)
312 }
313
314 err = optimizationTable2.UpdateWeightsWithSequence(sequence2)
315 if err != nil {
316 t.Error(err)
317 }
318
319 // replace chooser fn with test one
320 newChooserFn = func(choices ...weightedRand.Choice) (*weightedRand.Chooser, error) {
321 return nil, errors.New("new chooser rigged to fail")
322 }
323
324 defer func() {
325 newChooserFn = weightedRand.NewChooser
326 }()
327
328 _, err = AddCodonTable(optimizationTable, optimizationTable2)
329 if err == nil {
330 t.Errorf("Compromise table should fail when new chooser func rigged")
331 }
332}
333
334func TestCapitalizationRegression(t *testing.T) {
335 // Tests to make sure that amino acids are capitalized

Callers

nothing calls this directly

Calls 5

ReadFunction · 0.92
NewTranslationTableFunction · 0.85
AddCodonTableFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected