Beispiel #1
0
        static void Main(string[] args)
        {
            string strPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            string[] files = Directory.GetFiles(strPath + @"\Rosalind", "*.txt"); //Assumes only one txt file in this directory - the data set
            string[] lines = { "" };
            foreach (string file in files)
            {
                lines = File.ReadAllLines(file);
            }
            List <Fasta> fastaList = Fasta.DecodeFasta(lines);

            string[] dnaStrings = new string[fastaList.Count];
            for (int i = 0; i < fastaList.Count; i++)
            {
                dnaStrings[i] = fastaList[i].DNA;
            }
            string[] introns = dnaStrings.Skip(1).ToArray();
            for (int i = 0; i < introns.Length; i++)
            {
                introns[i] = introns[i].Replace('T', 'U');
            }
            Console.WriteLine(TranscribeRNAToProtein(dnaStrings[0].Replace('T', 'U'), introns));

            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            string strPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            string[] files = Directory.GetFiles(strPath + @"\Rosalind", "*.txt"); //Assumes only one txt file in this directory - the data set
            string[] lines = { "" };
            foreach (string file in files)
            {
                lines = File.ReadAllLines(file);
            }
            List <Fasta> fastaList = Fasta.DecodeFasta(lines);

            string[] strings = new string[fastaList.Count];
            for (int i = 0; i < fastaList.Count; i++)
            {
                strings[i] = fastaList[i].DNA;
            }

            ProfileMatrix matrix = new ProfileMatrix(strings);

            Console.WriteLine(matrix.ConsensusString);
            ProfileMatrix.OutputProfileMatrix(matrix);

            Console.ReadLine();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            string strPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            string[] files = Directory.GetFiles(strPath + @"\Rosalind", "*.txt"); //Assumes only one txt file in this directory - the data set
            string[] lines = { "" };

            lines = File.ReadAllLines(files[0]);

            List <Fasta> fastas = Fasta.DecodeFasta(lines);

            Stopwatch itime = new Stopwatch();

            string[] dnaOnly = new string[fastas.Count];
            for (int i = 0; i < fastas.Count; i++)
            {
                dnaOnly[i] = fastas[i].DNA;
            }
            itime.Start();
            Console.WriteLine(LongestCommonSubstring(dnaOnly.ToList()));
            itime.Stop();
            Console.WriteLine("Took: {0}ms", itime.ElapsedMilliseconds);

            Console.ReadLine();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            string strPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            string[] files = Directory.GetFiles(strPath + @"\Rosalind", "*.txt"); //Assumes only one txt file in this directory - the data set
            string[] lines = { "" };
            foreach (string file in files)
            {
                lines = File.ReadAllLines(file);
            }

            Regex regex = new Regex(@"N[^P][ST][^P]", RegexOptions.Multiline);

            string url = @"http://www.uniprot.org/uniprot/";
            List <(string id, int[] positions)> tuples = new List <(string id, int[] positions)>();

            foreach (string protein in lines)
            {
                List <int> positions = new List <int>();
                (string id, int[] positions)tuple;
                tuple.id = protein;
                string html  = MakeGetRequest(url + protein + ".fasta");
                Fasta  fasta = Fasta.DecodeFasta(html.Split('\n'))[0];
                for (int i = 0; i < fasta.DNA.Length - 4; i++)
                {
                    if (regex.IsMatch(fasta.DNA.Substring(i, 4)))
                    {
                        positions.Add(i + 1);
                    }
                }
                if (positions.Count != 0)
                {
                    tuple.positions = positions.ToArray();
                    tuples.Add(tuple);
                }
            }


            for (int i = 0; i < tuples.Count; i++)
            {
                if (tuples[i].positions.Length != 0)
                {
                    Console.WriteLine(tuples[i].id);
                    tuples[i].positions.ToList().ForEach(s => Console.Write(s + " "));
                    Console.WriteLine();
                }
            }

            Console.ReadLine();
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            string strPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            string[] files = Directory.GetFiles(strPath + @"\Rosalind", "*.txt"); //Assumes only one txt file in this directory - the data set
            string[] lines = { "" };
            foreach (string file in files)
            {
                lines = File.ReadAllLines(file);
            }

            Fasta fasta = Fasta.DecodeFasta(lines)[0];

            List <string> proteins = ReadFrames(fasta.DNA);

            proteins.ForEach((s) => Console.WriteLine(s));
            Console.ReadLine();
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            string strPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            string[] files = Directory.GetFiles(strPath + @"\Rosalind", "*.txt"); //Assumes only one txt file in this directory - the data set
            string[] lines = { "" };
            foreach (string file in files)
            {
                lines = File.ReadAllLines(file);
            }

            Fasta fasta = Fasta.DecodeFasta(lines)[0];


            int?[][] palindromes = FindDNAReversePalindrome(fasta.DNA, 4, 12);



            Console.WriteLine();

            Console.ReadLine();
        }