Example #1
0
func main() {
	// Parse FASTA from stdin.
	fas, err := rosa.ParseFASTA(os.Stdin)
	if err != nil {
		log.Fatalln(err)
	}

	// The first sequence in the FASTA file is the DNA sequence and all other
	// sequences are introns.
	dnaLabel, err := fas.Label(0)
	if err != nil {
		log.Fatalln(err)
	}
	dna := fas.Seqs[dnaLabel]
	introns := make([]string, len(fas.Seqs)-1)
	for label, s := range fas.Seqs {
		if label == dnaLabel {
			continue
		}
		introns = append(introns, s)
	}

	// Splice the DNA, transcribe it into RNA and translate it into a protein.
	rna := rosa.Trans(Splice(dna, introns))
	prot, err := rosa.Prot(rna)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Println(prot)
}
Example #2
0
func ExampleORFs() {
	dna := "AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG"
	revc := rosa.RevComp(dna)

	// Locates each open reading frame (ORF) of the DNA-sequence and its reverse
	// complement. Use a map for the store unique proteins.
	orfs := ORFs(dna)
	orfs = append(orfs, ORFs(revc)...)
	uniq := make(map[string]bool)
	for _, orf := range orfs {
		rna := rosa.Trans(orf)
		prot, err := rosa.Prot(rna)
		if err != nil {
			log.Fatalln(err)
		}
		uniq[prot] = true
	}

	// Print sorted proteins.
	var prots []string
	for prot := range uniq {
		prots = append(prots, prot)
	}
	sort.Strings(prots)
	for _, prot := range prots {
		fmt.Println(prot)
	}
	// Output:
	// M
	// MGMTPRLGLESLLE
	// MLLGSFRLIPKETLIQVAGSSPCNLS
	// MTPRLGLESLLE
}
Example #3
0
func main() {
	// Get input from stdin.
	buf, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		log.Fatalln(err)
	}
	dna := string(buf)

	// Transcribe the DNA sequence into an RNA sequence.
	fmt.Println(rosa.Trans(dna))
}
Example #4
0
func ExampleSplc() {
	// Splice the DNA, transcribe it into RNA and translate it into a protein.
	dna := "ATGGTCTACATAGCTGACAAACAGCACGTAGCAATCGGTCGAATCTCGAGAGGCATATGGTCACATGATCGGTCGAGCGTGTTTCAAAGTTTGCGCCTAG"
	introns := []string{"ATCGGTCGAA", "ATCGGTCGAGCGTGT"}
	rna := rosa.Trans(Splice(dna, introns))
	prot, err := rosa.Prot(rna)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Println(prot)
	// Output: MVYIADKQHVASREAYGHMFKVCA
}
Example #5
0
func main() {
	// Parse FASTA from stdin.
	fas, err := rosa.ParseFASTA(os.Stdin)
	if err != nil {
		log.Fatalln(err)
	}
	label, err := fas.Label(0)
	if err != nil {
		log.Fatalln(err)
	}
	dna := fas.Seqs[label]
	revc := rosa.RevComp(dna)

	// Locates each open reading frame (ORF) of the DNA-sequence and its reverse
	// complement. Use a map for the store unique proteins.
	orfs := ORFs(dna)
	orfs = append(orfs, ORFs(revc)...)
	uniq := make(map[string]bool)
	for _, orf := range orfs {
		rna := rosa.Trans(orf)
		prot, err := rosa.Prot(rna)
		if err != nil {
			log.Fatalln(err)
		}
		uniq[prot] = true
	}

	// Print sorted proteins.
	var prots []string
	for prot := range uniq {
		prots = append(prots, prot)
	}
	sort.Strings(prots)
	for _, prot := range prots {
		fmt.Println(prot)
	}
}