(t *testing.T)
| 291 | } |
| 292 | |
| 293 | func 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 | |
| 334 | func TestCapitalizationRegression(t *testing.T) { |
| 335 | // Tests to make sure that amino acids are capitalized |
nothing calls this directly
no test coverage detected