Exemple #1
0
func main() {
	if len(os.Args) < 2 {
		fmt.Println("no filename given")
		return
	}
	if s, err := ioutil.ReadFile(os.Args[1]); err == nil {
		fmt.Println(rosalind.Translate(string(s)))
	}
}
Exemple #2
0
func main() {
	var lines [][]byte
	var line []byte
	var prefix bool

	f, err := os.Open(os.Args[1]) // open file
	if err != nil {
		panic(err)
	}

	reader := bufio.NewReader(f)

reading:
	for {
		line, prefix, err = reader.ReadLine()
		switch {
		case err == io.EOF:
			break reading
		case prefix:
			fmt.Println(line[:100])
			panic("Line too long")
		case len(line) == 0:
			continue // skip empty line
		default:
			lines = append(lines, line)
		}
	}

	gene := lines[0]
	introns := lines[1:]

	// sort.Sort(ByLength(introns))

	for _, intron := range introns {
		gene = rosalind.Splice(gene, intron)
	}

	asRNA := string(bytes.Replace(gene, []byte{'T'}, []byte{'U'}, -1))
	fmt.Printf("%s\n", rosalind.Translate(asRNA))
}