· 4 years ago · Mar 28, 2021, 01:34 AM
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using Microsoft.Data.Sqlite;
7
8namespace RNAi_Program {
9
10 public class mRNAItem {
11 public mRNAItem(int mNum, string mSeq, string m3UTR) {
12
13 mRNANum = mNum;
14 mRNASeq = mSeq;
15 mRNA3PUTR = m3UTR;
16
17
18 }
19
20
21 public int mRNANum { get; set; }
22 public string mRNASeq { get; set; }
23 public string mRNA3PUTR { get; set; }
24 }
25
26 class Program {
27
28 static void miRNALibraryCreator(ref List<string> miRNAList, ref int lineCounter, ref int readFileCounter, ref bool nxtLinemiRNA, ref string line) {
29
30 System.IO.StreamReader file =
31 new System.IO.StreamReader(@"C:\Users\toddp\Desktop\Mature.fa folder\hsa.fas");
32
33 while ((line = file.ReadLine()) != null) //Reads through the entire file
34 {
35 lineCounter += 1;
36
37 if (readFileCounter == 2) { //Checks if the line contains an miRNA sequence
38 if (nxtLinemiRNA == true) {
39 miRNAList.Add(line);
40
41 }
42
43 if (nxtLinemiRNA == false) {
44
45 }
46 readFileCounter = 1;
47 }
48
49 if (readFileCounter == 1) {
50 if (line.Contains(">Hsa")) { //Checks if the line starts with >hsa, therefore the next line will contain a human miRNA sequence
51 nxtLinemiRNA = true;
52 }
53
54 if (!line.Contains(">Hsa")) { //Opposite of the previous if statement
55 nxtLinemiRNA = false;
56 }
57
58 readFileCounter = 2;
59 }
60
61 }
62
63 }
64
65 static void mRNALibraryCreator(ref List<mRNAItem> mRNAList) {
66
67 bool newmRNA = false;
68 string UTR = "";
69 int firstIndexOfStartCodon = 0;
70 int firstIndexOfNewCodon = 0;
71 string figmRNA = "";
72 string longAltUTR = "";
73 List<string> altUTRList = new List<string>();
74 int mRNACounter = 0;
75 string line = "";
76 string prevLine = "";
77 bool nxtLinesCode = false;
78 string currentmRNA = "";
79
80 System.IO.StreamReader file =
81 new System.IO.StreamReader(@"C:\Users\toddp\Desktop\Mature.fa folder\gencode.v37.transcripts.fa");
82
83 using (var connection = new SqliteConnection("Data Source=C:\\Users\\toddp\\Desktop\\Mature.fa folder\\database.db")) {
84 connection.Open();
85 var command = connection.CreateCommand();
86 command.CommandText = @"CREATE TABLE IF NOT EXISTS mRNAs(
87 id INTEGER PRIMARY KEY,
88 mRNA_ID INTEGER,
89 mRNA_Seq TEXT,
90 UTR TEXT
91 );";
92 command.ExecuteNonQuery();
93
94 while ((line = file.ReadLine()) != null) //Reads through the entire file
95 {
96 if ((line.StartsWith("T") || line.StartsWith("A") || line.StartsWith("C") || line.StartsWith("G")) && nxtLinesCode == true) {
97 currentmRNA = currentmRNA + line;
98
99
100 }
101
102
103 if (line.Contains("protein_coding")) { //A new mRNA sequence that codes for a protein
104
105 if ((currentmRNA.Contains("ATG")) && currentmRNA.Length != 0) { //If it contains a start codon(if it is able to establish a reading frame)
106 figmRNA = currentmRNA; //Alternative Reading Frames create new sequences therefore alt-proteins occur
107
108 while (true) { //Adds a new mRNAItem to the List
109 if (!figmRNA.Contains("ATG")) { //Breaks if there is no start codons left(so no more alt-mRNA sequences)
110
111 IEnumerable<string> query = from sequence in altUTRList
112 orderby sequence.Length
113 select sequence;
114
115 longAltUTR = query.Cast<string>().ToList()[query.Count() / 2];
116
117
118 //CLASS STUFF
119 //mRNAItem mRNA = new mRNAItem(mRNACounter, currentmRNA, longAltUTR);
120 //mRNAList.Add(mRNA);
121 Console.WriteLine(mRNACounter);
122
123 var insertStatement = connection.CreateCommand();
124 insertStatement.CommandText = @"INSERT INTO mRNAs(mRNA_ID, mRNA_Seq, UTR) VALUES(@mRNA_ID, @mRNA_Seq, @UTR);";
125 insertStatement.Parameters.AddWithValue("mRNA_ID",mRNACounter);
126 insertStatement.Parameters.AddWithValue("mRNA_Seq", currentmRNA);
127 insertStatement.Parameters.AddWithValue("UTR", longAltUTR);
128 insertStatement.ExecuteNonQuery();
129
130 break;
131
132 }
133
134 firstIndexOfStartCodon = figmRNA.IndexOf("ATG");
135 firstIndexOfNewCodon = firstIndexOfStartCodon;
136
137 string mRNASeq = "";
138 string mRNA3PUTR = "";
139
140 while (true) {
141
142 firstIndexOfNewCodon += 3;
143
144 if (firstIndexOfNewCodon + 3 > figmRNA.Length || firstIndexOfNewCodon > figmRNA.Length) { //Breaks if it goes over the index of the mRNA sequence
145 figmRNA = figmRNA.Remove(firstIndexOfStartCodon, 3);
146 break;
147 }
148
149 string newCodon = figmRNA.Substring(firstIndexOfNewCodon, 3);
150
151 mRNASeq = mRNASeq + newCodon;
152 if (newCodon == "TAA" || newCodon == "TAG" || newCodon == "TGA") { //New codon is a stop codon
153 mRNA3PUTR = figmRNA.Substring(firstIndexOfNewCodon + 2, (figmRNA.Length - 1 - firstIndexOfNewCodon - 1)); //Grabs the region after the stop codon(The UTR)
154 altUTRList.Add(mRNA3PUTR);
155
156 figmRNA = figmRNA.Remove(firstIndexOfNewCodon, 3);
157 break;
158 }
159 }
160
161
162 }
163 }
164
165 nxtLinesCode = true;
166 mRNACounter += 1;
167 currentmRNA = "";
168
169 }
170
171 if (!line.Contains("protein_coding") && line.StartsWith(">")) {
172 nxtLinesCode = false;
173 }
174
175
176
177 }
178 }
179 }
180
181 static void Main(string[] args) {
182 //First stage: miRNA library creation
183
184 //Variables
185 List<string> miRNAList = new List<string>();
186 List<mRNAItem> mRNAList = new List<mRNAItem>();
187
188 int miRNALineCounter = 0;
189 int mRNALineCounter = 0;
190
191 int readFileCounter = 1;
192 bool nxtLineCodes = false;
193 string line = "";
194
195 //miRNALibraryCreator(ref miRNAList,ref miRNALineCounter, ref readFileCounter,ref nxtLineCodes,ref line);
196
197 mRNALibraryCreator(ref mRNAList);
198 for (int i = 0; i < mRNAList.Count;i++) {
199 Console.WriteLine("mRNA{0}: \nSequence:{1} \n3'UTR: {2}", mRNAList[i].mRNANum, mRNAList[i].mRNASeq, mRNAList[i].mRNA3PUTR);
200 }
201
202 Console.WriteLine("# of miRNAs: {0}, total # of lines {1}",miRNAList.Count, miRNALineCounter);
203 Console.WriteLine("\nPress any key to continue");
204 Console.ReadKey(true);
205
206 //Next stage begins: siRNA creation
207
208 //Variables
209 string mRNATarget = ""; //mRNA target of the siRNA (single stranded, INCLUDE THE 5' UTR)
210 string siRNA = ""; //siRNA that could potentially work(single stranded, 21-25 nt)
211 string miRNAseedReg = ""; //Seed region(1-8) of an miRNA (Should not be similar to the seed region of the siRNA)
212
213 Console.WriteLine("Enter mRNA sequence(Protein-Coding Sequence)");
214 mRNATarget = Console.ReadLine();
215
216
217
218
219
220
221 }
222 }
223}
224