Pulling pieces from a string

closed account (38qG1hU5)
So I take a biology class, and in my class we are working on sequencing DNA and mRNA. I was wondering how I could make a program that reads each character in my input as a string, example: AATGC, and translates that to mRNA and the DNA complement. I have the translation, but am quite new to c++ and don't know how to make the program read each letter in the string differently. Also I want to make my own cypher, I know there is millions of programs for this, but I want the experience and accomplishment for myself. Thanks :)
Last edited on
If the sequences are in a file read that file character by character. Then output the character to another file except, if the character is a T (thymine), output a U (uracil). You could use the same concept to write to another file the DNA complement, or store each in a data structure (string, presumably) and write to one file after you have finished reading/converting.

Library for file i/o:
http://www.cplusplus.com/reference/fstream/
- the get() function is useful for reading one char at a time

Library for string:
http://www.cplusplus.com/reference/string/
- '+' operator can be used to append to a string
Last edited on
Topic archived. No new replies allowed.