-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSequencer.cpp
115 lines (108 loc) · 2.84 KB
/
Sequencer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// Sequencer.cpp
// Project 3
//
// Created by Pranav Manik on 3/21/17.
// Copyright © 2017 Pranav Manik. All rights reserved.
//
#include <stdio.h>
#include "Sequencer.h"
//name: Sequencer (default constructor)
//pre: A linked list (DNA) is available
//post: A linked list (DNA) where m_head and m_tail points to NULL
Sequencer::Sequencer(string fileName)
{
m_dna.SizeOf();
m_fileName = fileName;
readFile();
m_dna.SizeOf();
mainMenu();
}
//name: Sequencer (destructor)
//pre: There is an existing linked list (DNA)
//post: A linked list (DNA) is deallocated (including nucleotides) to have no memory leaks!
Sequencer::~Sequencer()
{
//delete *m_dna;
m_dna.~DNA();
}
//name: readFile
//pre: Valid file name of characters (Either A, T, G, or C)
//post: Populates the LinkedList (DNA)
void Sequencer::readFile()
{
ifstream myFile;
char *fileName[m_fileName.length()];
//Converts string to char
for (unsigned int i = 0; i < m_fileName.length()-1; i++)
{
fileName[i] = &m_fileName[i];
}
cout << *fileName << endl;
myFile.open(*fileName);
int numOfLines = 0;
//Finds the number of lines in file
while (!myFile.eof())
{
string line;
myFile >> line;
numOfLines++;
}
numOfLines--;
myFile.close();
//Loads in Linked List
myFile.open(*fileName);
for (int i = 0; i < numOfLines; i++)
{
char nucleotide;
myFile >> nucleotide;
m_dna.InsertEnd(nucleotide);
}
myFile.close();
}
//name: mainMenu
//pre: Populated LinkedList (DNA)
//post: None
void Sequencer::mainMenu()
{
int userChoice;
while (userChoice != 5)
{
cout << "What would you like to do?:" << endl;
cout << "1. Display Sequencer (Leading Pairs)" << endl;
cout << "2. Display Sequencer (Base Pairs)" << endl;
cout << "3. Inventory Basic Amino Acids" << endl;
cout << "4. Sequence Entire DNA Strand" << endl;
cout << "5. Exit" << endl;
cin >> userChoice;
switch (userChoice)
{
//Displays Single Nucleotides
case (1):
m_dna.Display(1);
break;
//Displays Base Pairs
case (2):
m_dna.Display(2);
break;
//Displays Number of any Amino Acid you want
case (3):
m_dna.NumAmino("Tryptophan", "TGG");
m_dna.NumAmino("Phenylalanine", "TTT");
break;
//Displays all TriNucleotides as Amino Acids
case (4):
m_dna.Sequence();
break;
//Exits program
case (5):
cout << "DNA removed from memory" << endl;
m_dna.~DNA();
//~Sequencer();
break;
default:
cout << "I'm sorry this is not a choice" << endl;
break;
}
}
}