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

Function extractCodingRegion

synthesis/codon/codon.go:298–321  ·  view source on GitHub ↗

extractCodingRegion loops through genbank data to find all CDS (coding sequences)

(data genbank.Genbank)

Source from the content-addressed store, hash-verified

296
297// extractCodingRegion loops through genbank data to find all CDS (coding sequences)
298func extractCodingRegion(data genbank.Genbank) ([]string, error) {
299 codingRegions := []string{}
300
301 // iterate through the features of the genbank file and if the feature is a coding region, append the sequence to the string builder
302 for _, feature := range data.Features {
303 if feature.Type == "CDS" {
304 sequence, err := feature.GetSequence()
305 if err != nil {
306 return nil, err
307 }
308
309 // Note: sometimes, genbank files will have annotated CDSs that are pseudo genes (not having triplet codons).
310 // This will shift the entire codon table, messing up the end results. To fix this, make sure to do a modulo
311 // check.
312 if len(sequence)%3 != 0 {
313 continue
314 }
315
316 codingRegions = append(codingRegions, sequence)
317 }
318 }
319
320 return codingRegions, nil
321}
322
323// getCodonFrequency takes a DNA sequence and returns a hashmap of its codons and their frequencies.
324func getCodonFrequency(sequence string) map[string]int {

Callers 1

Calls 1

GetSequenceMethod · 0.45

Tested by

no test coverage detected