示例#1
0
文件: splc.go 项目: mewmew/playground
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)
}
示例#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
}
示例#3
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
}
示例#4
0
文件: prot.go 项目: mewmew/playground
func main() {
	// Get input from stdin.
	br := bufioutil.NewReader(os.Stdin)
	rna, err := br.ReadLine()
	if err != nil {
		log.Fatalln(err)
	}

	// Translate the RNA sequence into a protein.
	prot, err := rosa.Prot(rna)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Println(prot)
}
示例#5
0
文件: orf.go 项目: mewmew/playground
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)
	}
}