Question: ProteinDatabase Module Design and code a class named ProteinDatabase that manages a dynamically allocated array of elements of type std::string. Your class keeps track of
ProteinDatabase Module
Design and code a class named ProteinDatabase that manages a dynamically allocated array of elements of type std::string. Your class keeps track of the number of strings currently stored and defines the following member functions:
- a no-argument default constructor
- a 1-argument constructor that receives as parameter a string containing the name of a file from which this member function populates the current object. This function
-
reads the file to count the number of protein sequence present in the file.
In the file, each protein sequence is prefixed by a line starting with a greater than character (">") followed by a description of the origin of the sequence of no more than 131 characters.
The protein sequence will begin on the next line for some number of lines. Each line (except the last one) will contain exactly 80 characters.
-
allocates memory for that number of protein sequences in the array
-
re-reads the file and loads the protein sequences (i.e., string of characters not sequence names) into the array.
-
- size_t size(): a query that returns the number of protein sequences stored in the current object.
- std::string operator[](size_t): a query that returns a copy of the protein sequence at the index received as the function parameter. If the index is invalid, this function should return an empty string.
- upgrade the ProteinDatabase class to include a move constructor and a move assignment operator
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
