Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.test.gb";

            GBSequence gbSequence = new GBSequence(fileName);
            GBSeq      gbSeq      = gbSequence.GbSeq();
            TrinucCalc trinucCalc = new TrinucCalc();

            int    scanStart = 20000;
            int    scanEnd   = 40000;
            string scanSeq   = gbSeq.Seq.Substring(scanStart, scanEnd - scanStart);
            int    fragment  = 65;
            //int step = 66;
            int step = 5;

            try
            {
                for (int i = 0; i < scanSeq.Length; i += step)
                {
                    string fragSeq = scanSeq.Substring(i, fragment);
                    //Console.WriteLine( fragSeq);
                    double trinucDiff = trinucCalc.Calculation("FRAG", fragSeq);
                    Console.WriteLine($"FRAG\t{fragSeq}\t{trinucDiff.ToString("0.0000")}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Oligonucleotides frq calculation.");

            string seq = string.Empty;

            //string fileName = @"/home/alvydas/Sequencies/H**o.sapience/Cromosome1.fasta";
            //string fileName = @"/home/alvydas/Sequencies/Virus/Hepatitis.delta.fasta";
            //string fileName = "//home//alvydas//Sequencies//Bacteria//Lactococcus.lactis.fasta";
            //seq = "aaacagatcacccgctgagcgggttatctgtt";


            seq = "aaaaacaagaatacaaccacgactagaagcaggagtataatcatgattcaacaccagcatccacccccgcctcgacgccggcgtctactcctgcttgaagacgaggatgcagccgcggctggaggcgggggtgtagtcgtggtttaatactagtattcatcctcgtcttgatgctggtgtttattcttgttt";

            /*
             * string fileName = @"/home/alvydas/Sequencies/Bacteria/Escherichia.coli.fasta";
             *
             * var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
             * using (var streamReader = new StreamReader(fileStream))
             * {
             *  seq = streamReader.ReadToEnd().ToLower().Replace("\n", string.Empty);
             * }
             * Console.WriteLine(fileName);
             * /*
             * string [ ] mono = { "a" , "c" , "g" , "t" };
             * foreach(var item1 in mono )
             * {
             *  foreach ( var item2 in mono )
             *  {
             *      foreach ( var item3 in mono )
             *      {
             *          foreach ( var item4 in mono )
             *          {
             *              seq += item1 + item2 + item3 + item4;
             *          }
             *      }
             *  }
             * }
             */
            DinucCalc dinucCalc = new DinucCalc(seq);
            var       diCalc    = dinucCalc.Calculation();

            TrinucCalc trinucCalc = new TrinucCalc();
            var        triCalc    = trinucCalc.Calculation("FromBoard", seq);

            TetranucCalc tetranucCalc = new TetranucCalc(seq);
            var          tetraCalc    = tetranucCalc.Calculation( );
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.gb";
            string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.test.gb";

            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short1.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short2.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short3.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.shuffle.test.gb";
            Console.WriteLine($"Calc seq cds trinucs for { Path.GetFileName(fileName) }");

            GBSequence gbSequence = new GBSequence(fileName);
            GBSeq      gbSeq      = gbSequence.GbSeq();

            Console.WriteLine(gbSeq);

            GBSeqFeatures gBSeqFeatures    = new GBSeqFeatures(fileName);
            List <GBFeat> cdsFeatures      = gBSeqFeatures.FeaturesSeparation();
            List <GBFeat> completeFeatures = gBSeqFeatures.CompleteSeparation(cdsFeatures);

            TrinucCalc trinucCalc = new TrinucCalc();
            Sequence   mixSeq     = new Sequence()
            {
                SeqName = "CDS and random seq mix"
            };
            RandSeq randSeq = new RandSeq();

            double trinucDiff = 0;

            foreach (var item in completeFeatures)
            {
                string subSeq       = string.Empty;
                string randomSubSeq = string.Empty;

                if (item.SeqType == "CDS" && item.SeqEnd - item.SeqStart > 30)
                {
                    Console.Write($"{item.SeqType}\t{item.SeqStart}\t{item.SeqEnd}\t");
                    subSeq = gbSeq.Seq.Substring(item.SeqStart, item.SeqEnd - item.SeqStart + 1);
                    //var trinucCalc = new TrinucCalc(item.SeqType, subSeq);
                    trinucDiff = trinucCalc.Calculation("CDS", subSeq);
                    Console.WriteLine($"{subSeq}\t{trinucDiff.ToString("0.0000")}");
                    mixSeq.Seq += subSeq;

                    int    randSeqNumber = 20;
                    double averageRCDS1  = 0;

                    for (int i = 0; i < randSeqNumber; i++)
                    {
                        randomSubSeq = randSeq.RandomSeq(subSeq, 1);
                        Console.Write($"RCDS1\t{item.SeqStart}\t{item.SeqEnd}\t");
                        trinucDiff = trinucCalc.Calculation("RCDS1", randomSubSeq);
                        Console.WriteLine($"{randomSubSeq}\t{trinucDiff.ToString("0.0000")}");
                        averageRCDS1 += trinucDiff;
                    }
                    Console.WriteLine($"Average RCDS1 {(averageRCDS1/randSeqNumber).ToString("0.0000")}\n");
                    mixSeq.Seq += randomSubSeq;

                    double averageRCDS2 = 0;
                    for (int i = 0; i < randSeqNumber; i++)
                    {
                        randomSubSeq = randSeq.RandomSeq(subSeq, 2);
                        Console.Write($"RCDS2\t{item.SeqStart}\t{item.SeqEnd}\t");
                        trinucDiff = trinucCalc.Calculation("RCDS2", randomSubSeq);
                        Console.WriteLine($"{randomSubSeq}\t{trinucDiff.ToString("0.0000")}");
                        averageRCDS2 += trinucDiff;
                    }
                    Console.WriteLine($"Average RCDS2 {(averageRCDS2/ randSeqNumber).ToString("0.0000")}\n");
                    mixSeq.Seq += randomSubSeq;

                    double averageRCDS3 = 0;
                    for (int i = 0; i < randSeqNumber; i++)
                    {
                        randomSubSeq = randSeq.RandomSeq(subSeq, 3);
                        Console.Write($"RCDS3\t{item.SeqStart}\t{item.SeqEnd}\t");
                        trinucDiff = trinucCalc.Calculation("RCDS3", randomSubSeq);
                        Console.WriteLine($"{randomSubSeq}\t{trinucDiff.ToString("0.0000")}");
                        averageRCDS3 += trinucDiff;
                    }
                    Console.WriteLine($"Average RCDS3 {(averageRCDS3 / randSeqNumber).ToString("0.0000")}\n");
                    mixSeq.Seq += randomSubSeq;

                    Console.WriteLine("\n");
                    //Console.WriteLine(subSeq);
                    //Console.WriteLine(randomSubSeq);
                    //Console.WriteLine(  );
                }
            }

            //CDS search in artificial sequence mooving fragment by particular step.
            //for (int i = 0; i < mixSeq.Seq.Length; i++)
            //{
            //    if (i > 0 && i % 60 == 0) Console.Write("\n");
            //    Console.Write(mixSeq.Seq[i]);
            //}
            Console.WriteLine("\n");

            string seq      = mixSeq.Seq;
            int    fragment = 65;
            //int step = 66;
            int step = 5;

            try
            {
                for (int i = 0; i < seq.Length; i += step)
                {
                    string fragSeq = seq.Substring(i, fragment);
                    //Console.WriteLine( fragSeq);
                    trinucDiff = trinucCalc.Calculation("FRAG", fragSeq);
                    Console.WriteLine($"FRAG\t{fragSeq}\t{trinucDiff.ToString("0.0000")}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 4
0
        public static void Main(string [] args)
        {
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.gb";
            string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.test.gb";

            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short1.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short2.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.shuffle.test.gb";
            Console.WriteLine($"Calc seq cds trinucs for { Path.GetFileName (fileName) }");

            GBSequence gbSequence = new GBSequence(fileName);
            var        gbSeq      = gbSequence.GbSeq();



            GBFeatures gbFeatures = new GBFeatures(fileName);
            var        gbCds      = gbFeatures.Cds();

            GBSeparation gBSeparation = new GBSeparation(gbSeq, gbCds);

            gBSeparation.GBSeq();

            TrinucDiff trinucDiff = new TrinucDiff();

            Console.WriteLine($"Seq length {gbSeq.Seq.Length}\n{ gbSeq.Seq.Substring (0, 30)}....{ gbSeq.Seq.Substring (gbSeq.Seq.Length - 30)}\n");

            int randFragLength = 1;

            foreach (var item in gbCds)
            {
                if (item.CdsEnd - item.CdsStart >= 60)
                {
                    TrinucCalc trinucCalc = new TrinucCalc();
                    double     triDiff    = trinucCalc.Calculation("CDS", item.CdsSeq);
                    Console.Write($"CDS\t{item.CdsStart}\t{item.CdsEnd}\t{item.CdsSeq.Substring (0, 9)}...{item.CdsSeq.Substring (item.CdsSeq.Length - 9)}\t");
                    Console.Write($"{trinucDiff.DiffSum1st2nd.ToString("0.0000")}\t{trinucDiff.DiffSum1st3rd.ToString ("0.0000")}\t{trinucDiff.DiffSum2nd3rd.ToString ("0.0000")}\t");
                    Console.WriteLine($"{triDiff.ToString("0.0000")}");

                    for (int i = 0; i < 10; i++)
                    {
                        RandomSeq randomSeq = new RandomSeq(item.CdsSeq);
                        string    randSeq   = randomSeq.RandomSeqByFragment(randFragLength);

                        TrinucCalc randtrinucCalc = new TrinucCalc();
                        triDiff = randtrinucCalc.Calculation("RCDS", randSeq);
                        Console.Write($"RCDS\t{item.CompCdsStart}\t{item.CompCdsEnd}\t{randSeq.Substring (0, 9)}...{randSeq.Substring (randSeq.Length - 9)}\t");
                        Console.Write($"{trinucDiff.DiffSum1st2nd.ToString ("0.0000")}\t{trinucDiff.DiffSum1st3rd.ToString ("0.0000")}\t{trinucDiff.DiffSum2nd3rd.ToString ("0.0000")}\t");
                        Console.WriteLine($"{triDiff.ToString ("0.0000")}");
                    }
                }

                if (item.CompCdsEnd - item.CompCdsStart >= 60)
                {
                    TrinucCalc trinucCalc = new TrinucCalc();
                    double     triDiff    = trinucCalc.Calculation("CCDS", item.CompCdsSeq);
                    Console.Write($"CCDS\t{item.CompCdsStart}\t{item.CompCdsEnd}\t{item.CompCdsSeq.Substring (0, 9)}...{item.CompCdsSeq.Substring (item.CompCdsSeq.Length - 9)}\t");
                    Console.Write($"{trinucDiff.DiffSum1st2nd.ToString ("0.0000")}\t{trinucDiff.DiffSum1st3rd.ToString ("0.0000")}\t{trinucDiff.DiffSum2nd3rd.ToString ("0.0000")}\t");
                    Console.WriteLine($"{triDiff.ToString ("0.0000")}");

                    for (int i = 0; i < 10; i++)
                    {
                        RandomSeq randomSeq = new RandomSeq(item.CompCdsSeq);
                        string    randSeq   = randomSeq.RandomSeqByFragment(randFragLength);

                        TrinucCalc randtrinucCalc = new TrinucCalc();
                        triDiff = randtrinucCalc.Calculation("RCCDS", randSeq);
                        Console.Write($"RCCDS\t{item.CdsStart}\t{item.CdsEnd}\t{randSeq.Substring (0, 9)}...{randSeq.Substring (randSeq.Length - 9)}\t");
                        Console.Write($"{trinucDiff.DiffSum1st2nd.ToString ("0.0000")}\t{trinucDiff.DiffSum1st3rd.ToString ("0.0000")}\t{trinucDiff.DiffSum2nd3rd.ToString ("0.0000")}\t");
                        Console.WriteLine($"{triDiff.ToString ("0.0000")}");
                    }
                }

                //PrintOut printOut = new PrintOut (gbSeq, gbCds, 30, trinucDiff);
                //printOut.SeqPrint ();
                //printOut.CdsPrint ();
                //printOut.CompCdsPrint ();
            }
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.test.gb";
            string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short.gb";

            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short1.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.short2.gb";
            //string fileName = "/home/alvydas/Oligonucleotides/Sequencies/Bacteria/Escherichia.coli.shuffle.test.gb";
            Console.WriteLine($"Calc seq cds trinucs for { Path.GetFileName(fileName) }");

            GBSequence gbSequence = new GBSequence(fileName);
            var        gbSeq      = gbSequence.GbSeq();

            GBSeqFeatures gBSeqFeatures    = new GBSeqFeatures(fileName);
            List <GBFeat> cdsFeatures      = gBSeqFeatures.FeaturesSeparation();
            List <GBFeat> completeFeatures = gBSeqFeatures.CompleteSeparation(cdsFeatures);

            List <TrinucDiff> triDiff = new List <TrinucDiff>();

            foreach (var item in completeFeatures)
            {
                string subSeq = string.Empty;
                Console.Write($"{item.SeqType}\t{item.SeqStart}\t{item.SeqEnd}\t");

                if (item.SeqEnd - item.SeqStart > 40)
                {
                    subSeq = gbSeq.Seq.Substring(item.SeqStart, item.SeqEnd - item.SeqStart + 1);

                    if (item.SeqType == "CDS" || item.SeqType == "JCDS" || item.SeqType == "NCDS")
                    {
                        Console.Write($"{subSeq.Substring(0, 10)}...{subSeq.Substring(subSeq.Length - 10)}\t");
                        TrinucCalc trinucCalc = new TrinucCalc();
                        TrinucDiff trinucDiff = trinucCalc.Calculation(item.SeqType, subSeq);
                        Console.WriteLine($"{ trinucDiff.DiffSum1st2nd.ToString("0.0000") }\t" +
                                          $"{ trinucDiff.DiffSum1st3rd.ToString("0.0000") }\t" +
                                          $"{ trinucDiff.DiffSum2nd3rd.ToString("0.0000") }\t" +
                                          $"{ trinucDiff.DiffSum.ToString("0.0000") }");

                        if (item.SeqType == "CDS" || item.SeqType == "NCDS")
                        {
                            triDiff.Add(new TrinucDiff {
                                SeqType       = item.SeqType,
                                DiffSum1st2nd = trinucDiff.DiffSum1st2nd,
                                DiffSum1st3rd = trinucDiff.DiffSum1st3rd,
                                DiffSum2nd3rd = trinucDiff.DiffSum2nd3rd,
                                DiffSum       = trinucDiff.DiffSum
                            });
                        }
                    }
                    else if (item.SeqType == "CCDS" || item.SeqType == "CJCDS")
                    {
                        GBSequenceComp gbSequenceComp = new GBSequenceComp(subSeq);
                        subSeq = gbSequenceComp.SeqComp();
                        Console.Write($"{subSeq.Substring(0, 10)}...{subSeq.Substring(subSeq.Length - 10)}\t");
                        TrinucCalc trinucCalc = new TrinucCalc();
                        TrinucDiff trinucDiff = trinucCalc.Calculation(item.SeqType, subSeq);
                        Console.WriteLine($"{ trinucDiff.DiffSum1st2nd.ToString("0.0000") }\t" +
                                          $"{ trinucDiff.DiffSum1st3rd.ToString("0.0000") }\t" +
                                          $"{ trinucDiff.DiffSum2nd3rd.ToString("0.0000") }\t" +
                                          $"{ trinucDiff.DiffSum.ToString("0.0000") }");

                        triDiff.Add(new TrinucDiff {
                            SeqType       = item.SeqType,
                            DiffSum1st2nd = trinucDiff.DiffSum1st2nd,
                            DiffSum1st3rd = trinucDiff.DiffSum1st3rd,
                            DiffSum2nd3rd = trinucDiff.DiffSum2nd3rd,
                            DiffSum       = trinucDiff.DiffSum
                        });
                    }
                }
                else
                {
                    Console.WriteLine("nnnnnnnnnn...nnnnnnnnnn\t0.0000");
                }
            }

            Console.WriteLine();

            string       filePath = string.Empty;
            StreamWriter FH;

            filePath = "/home/alvydas/Oligonucleotides/TrinucCalc/cdsframe.dat";
            FH       = new StreamWriter(filePath);
            foreach (var item in triDiff)
            {
                if (item.SeqType == "CDS" || item.SeqType == "CCDS")
                {
                    Console.WriteLine($"{item.SeqType}\t{item.DiffSum1st2nd.ToString("0.0000")}\t{item.DiffSum1st3rd.ToString("0.0000")}\t{item.DiffSum2nd3rd.ToString("0.0000")}\t{item.DiffSum.ToString("0.0000")}");
                    FH.WriteLine($"{item.SeqType}\t{item.DiffSum1st2nd.ToString("0.0000")}\t{item.DiffSum1st3rd.ToString("0.0000")}\t{item.DiffSum2nd3rd.ToString("0.0000")}\t{item.DiffSum.ToString("0.0000")}");
                }
            }
            FH.Close();

            Console.WriteLine();

            filePath = "/home/alvydas/Oligonucleotides/TrinucCalc/ncdsframe.dat";
            FH       = new StreamWriter(filePath);
            foreach (var item in triDiff)
            {
                if (item.SeqType == "NCDS")
                {
                    Console.WriteLine($"{item.SeqType}\t{item.DiffSum1st2nd.ToString("0.0000")}\t{item.DiffSum1st3rd.ToString("0.0000")}\t{item.DiffSum2nd3rd.ToString("0.0000")}\t{item.DiffSum.ToString("0.0000")}");
                    FH.WriteLine($"{item.SeqType}\t{item.DiffSum1st2nd.ToString("0.0000")}\t{item.DiffSum1st3rd.ToString("0.0000")}\t{item.DiffSum2nd3rd.ToString("0.0000")}\t{item.DiffSum.ToString("0.0000")}");
                }
            }
            FH.Close();

            string rpath = "/usr/bin/Rscript";
            //string arg1 = "/home/alvydas/Oligonucleotides/TrinucCalc/R/cdsframe.dat";
            //string arg2 = "/home/alvydas/Oligonucleotides/TrinucCalc/R/ncdsframe.dat";
            string scriptpath = "/home/alvydas/Oligonucleotides/TrinucCalc/framefrq.R cdsframe.dat ncdsframe.dat";
            string output     = RScript.RunRScript(rpath, scriptpath);
        }