rosa

package
v0.0.0-...-ec3c368 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2023 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package rosa implements utility functions to facilitate problem solving on the bioinformatics platform Rosalind.

Index

Examples

Constants

View Source
const (
	// Stop indicates the stop of amino acid translation.
	Stop byte = 0
)

Variables

This section is empty.

Functions

func Prot

func Prot(rna string) (prot string, err error)

Prot translates the provided RNA sequence to a protein which consists of a sequence of amino acids.

Example
rna := "AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA"
prot, err := Prot(rna)
if err != nil {
	log.Fatalln(err)
}
fmt.Println(prot)
Output:

MAMAPRTEINSTRING

func RevComp

func RevComp(dna string) (revc string)

RevComp returns the reverse complement of the provided DNA sequence. The bases are complemented as follows:

A: T
C: G
G: C
T: A
Example
dna := "AAAACCCGGT"
fmt.Println(RevComp(dna))
Output:

ACCGGGTTTT

func Trans

func Trans(dna string) (rna string)

Trans transcribes the provided DNA sequence into an RNA sequence where the nucleotide uracil is used in place of thymine.

Example
dna := "GATGGAACTTGACTACGTAAATT"
fmt.Println(Trans(dna))
Output:

GAUGGAACUUGACUACGUAAAUU

Types

type FASTA

type FASTA struct {
	// Seqs is a map from FASTA label names to DNA sequences.
	Seqs map[string]string
	// contains filtered or unexported fields
}

FASTA handles labeled DNA sequences.

func ParseFASTA

func ParseFASTA(r io.Reader) (fas *FASTA, err error)

ParseFASTA reads data from r and parses it according to the FASTA file format.

Example
// Parse FASTA.
fas, err := ParseFASTA(strings.NewReader(s))
if err != nil {
	log.Fatalln(err)
}

// Sort keys.
var labels []string
for label := range fas.Seqs {
	labels = append(labels, label)
}
sort.Strings(labels)

for _, label := range labels {
	dna := fas.Seqs[label]
	fmt.Println(label)
	fmt.Println(dna)
}
Output:

Rosalind_0808
CCACCCTCGTGGTATGGCTAGGCATTCAGGAACCGGAGAACGCTTCAGACCAGCCCGGACTGGGAACCTGCGGGCAGTAGGTGGAAT
Rosalind_5959
CCATCGGTAGCGCATCCTTAGTCCAATTAAGTCCCTATCCAGGCGCTCCGCCGAAGGTCTATATCCATTTGTCAGCAGACACGC
Rosalind_6404
CCTGCGGAAGATCGGCACTAGAATAGCCAGAACCGTTTCTCTGAGGCTTCCGGCCTTCCCTCCCACTAATAATTCTGAGG

func (*FASTA) Index

func (fas *FASTA) Index(label string) (n int, err error)

Index returns the index of the provided label.

Example
// Parse FASTA.
fas, err := ParseFASTA(strings.NewReader(s))
if err != nil {
	log.Fatalln(err)
}

// Locate the index of the label named "Rosalind_0808".
i, err := fas.Index("Rosalind_0808")
if err != nil {
	log.Fatalln(err)
}
fmt.Println(i)
Output:

2

func (*FASTA) Label

func (fas *FASTA) Label(n int) (label string, err error)

Label returns the nth label of the FASTA file.

Example
// Parse FASTA.
fas, err := ParseFASTA(strings.NewReader(s))
if err != nil {
	log.Fatalln(err)
}

// Locate the second label.
label, err := fas.Label(1)
if err != nil {
	log.Fatalln(err)
}
fmt.Println(label)
Output:

Rosalind_5959

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL