Beispiel #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)
}
Beispiel #2
0
func main() {
	// Get input 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 the second
	// sequence is the subsequence sep.
	dnaLabel, err := fas.Label(0)
	if err != nil {
		log.Fatalln(err)
	}
	sepLabel, err := fas.Label(1)
	if err != nil {
		log.Fatalln(err)
	}
	dna := fas.Seqs[dnaLabel]
	sep := fas.Seqs[sepLabel]

	// Print the location of each character in sep as a subsequence of dna.
	locs := SubSeq(dna, sep)
	for i, loc := range locs {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(loc + 1)
	}
	fmt.Println()
}
Beispiel #3
0
func main() {
	// Parse FASTA from stdin.
	fas, err := rosa.ParseFASTA(os.Stdin)
	if err != nil {
		log.Fatalln(err)
	}

	// Locate the DNA sequence with the highest GC-content.
	label, gc := MaxGC(fas)
	fmt.Println(label)
	fmt.Printf("%.6f\n", gc)
}
Beispiel #4
0
func ExampleMaxGC() {
	// Parse FASTA.
	fas, err := rosa.ParseFASTA(strings.NewReader(s))
	if err != nil {
		log.Fatalln(err)
	}

	label, gc := MaxGC(fas)
	fmt.Println(label)
	fmt.Printf("%.6f\n", gc)
	// Output:
	// Rosalind_0808
	// 60.919540
}
Beispiel #5
0
func main() {
	// Parse FASTA from stdin.
	fas, err := rosa.ParseFASTA(os.Stdin)
	if err != nil {
		log.Fatalln(err)
	}

	// Create a profile of the provided DNA-sequences and use it to calculate the
	// consensus sequence.
	var seqs []string
	for _, seq := range fas.Seqs {
		seqs = append(seqs, seq)
	}
	profile, err := NewProfile(seqs, true)
	if err != nil {
		log.Fatalln(err)
	}
	cons := profile.Cons()
	fmt.Println(cons)
}
Beispiel #6
0
func main() {
	// Parse FASTA from stdin.
	fas, err := rosa.ParseFASTA(os.Stdin)
	if err != nil {
		log.Fatalln(err)
	}

	// Locate the single DNA sequence present in the FASTA file.
	label, err := fas.Label(0)
	if err != nil {
		log.Fatalln(err)
	}
	dna := fas.Seqs[label]

	// Calculate the length and locating of each reverse palindrome within the
	// DNA sequence which has a length of between 4 and 12 nucleotides.
	locs, ns := RevPal(dna)
	for i := range locs {
		loc := locs[i]
		n := ns[i]
		fmt.Println(loc+1, n)
	}
}
Beispiel #7
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)
	}
}