Created
April 2, 2014 04:20
-
-
Save mduvall/9927873 to your computer and use it in GitHub Desktop.
Get possible protein strings from reading frames in DNA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fasta" | |
"fmt" | |
"strings" | |
) | |
func main() { | |
fastaFile := fasta.NewFastaFileWithPath("orf.txt") | |
candidateStrings := make(map[string]bool) | |
for _, dnaSeq := range fastaFile.DnaSeqs { | |
orfs := dnaSeq.GetOpenReadingFrames() | |
for _, orf := range orfs { | |
aminoAcidSequence := orf.GetAminoAcidSequence() | |
for i, amino := range aminoAcidSequence { | |
if amino == "M" { | |
sequence := strings.Join((getAminoSequenceFromIndex(aminoAcidSequence[i:])), "") | |
candidateStrings[sequence] = true | |
} | |
} | |
} | |
} | |
for candidate, _ := range candidateStrings { | |
if len(candidate) > 0 { | |
fmt.Println(candidate) | |
} | |
} | |
} | |
func getAminoSequenceFromIndex(sequence []string) []string { | |
for i, val := range sequence { | |
if val == "Stop" { | |
return sequence[0:i] | |
} | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment