Esempio n. 1
0
        public void Initialize(IDataset dataset, XmlElement filterNode)
        {
            intronSize = new double[dataset.Rows][];
            antiSense  = new bool[dataset.Rows];
            int strandIdx = dataset.IndexOfColumn("Strand");

            for (int row = 0; row < dataset.Rows; row++)
            {
                string[] beginList = dataset.GetDataAt(row, 3).Split(',');
                string[] endList   = dataset.GetDataAt(row, 4).Split(',');
                if (beginList.Length != endList.Length)
                {
                    continue;
                }
                double[] R = new double[beginList.Length - 1];
                intronSize[row] = R;
                for (int col = 0; col < R.Length; col++)
                {
                    R[col] = int.Parse(beginList[col + 1]) - int.Parse(endList[col]) - 1;
                }

                antiSense[row] = (dataset.GetDataAt(row, strandIdx) == "-1");
                if (antiSense[row])
                {
                    Array.Reverse(intronSize[row]);
                }

                // normalize
                double sum = R.Sum();
                for (int col = 0; col < R.Length; col++)
                {
                    R[col] /= sum;
                }
            }
        }
Esempio n. 2
0
        public void Initialize(IDataset dataset, XmlElement filterNode)
        {
            seqList   = new int[dataset.Rows][];
            cdsLength = new int[dataset.Rows];
            geneSpan  = new int[dataset.Rows];
            antiSense = new bool[dataset.Rows];
            int strandIdx = dataset.IndexOfColumn("Strand");

            for (int row = 0; row < dataset.Rows; row++)
            {
                string[] beginList = dataset.GetDataAt(row, 3).Split(',');
                string[] endList   = dataset.GetDataAt(row, 4).Split(',');
                if (beginList.Length != endList.Length)
                {
                    continue;
                }
                seqList[row] = new int[2 * beginList.Length];
                int   cdsLen   = 0;
                int   minBegin = int.MaxValue;
                int   maxEnd   = int.MinValue;
                int[] R        = seqList[row];
                for (int col = 0; col < beginList.Length; col++)
                {
                    int idxBegin = int.Parse(beginList[col]) - 1;
                    int idxEnd   = int.Parse(endList[col]) - 1;
                    R[2 * col]     = idxBegin;
                    R[2 * col + 1] = idxEnd;
                    cdsLen        += idxEnd - idxBegin + 1;
                    minBegin       = Math.Min(minBegin, idxBegin);
                    maxEnd         = Math.Max(maxEnd, idxEnd);
                }
                cdsLength[row] = cdsLen;
                geneSpan[row]  = maxEnd - minBegin + 1;

                antiSense[row] = (dataset.GetDataAt(row, strandIdx) == "-1");

                for (int col = 0; col < R.Length; col++)
                {
                    R[col] -= minBegin;
                }

                if (antiSense[row])
                {
                    int maxIdx = R[R.Length - 1];
                    for (int col = 0; col < R.Length; col++)
                    {
                        R[col] = maxIdx - R[col];
                    }
                    Array.Reverse(R);
                }
            }
        }
Esempio n. 3
0
        public void Initialize(IDataset dataset, XmlElement filterNode)
        {
            IList <IColumnSpec> columnList = dataset.ColumnSpecList;

            columns = 0;
            foreach (IColumnSpec cs in columnList)
            {
                if (cs.DataType == 'n')
                {
                    columns++;
                }
            }
            table = new double[dataset.Rows][];

            for (int row = 0; row < dataset.Rows; row++)
            {
                table[row] = new double[columns];
                int col = 0;
                for (int ch = 0; ch < dataset.Columns; ch++)
                {
                    if (columnList[ch].DataType == 'n')
                    {
                        table[row][col] = double.Parse(dataset.GetDataAt(row, ch));
                        col++;
                    }
                }
            }
        }
Esempio n. 4
0
        public void Initialize(IDataset dataset, XmlElement filterNode)
        {
            vecList = new double[dataset.Rows][];
            var    rg   = new Random();
            String ACGT = "ACGT";

            double[] amplitudes1 = new double[L];
            for (int k = 0; k < L; k++)
            {
                amplitudes1[k] = rg.NextDouble();
            }
            double[] amplitudes2 = new double[L];
            for (int k = 0; k < L; k++)
            {
                amplitudes2[k] = rg.NextDouble();
            }

            for (int row = 0; row < dataset.Rows; row++)
            {
                vecList[row] = new double[8];
                var s = dataset.GetDataAt(row, 0);
                for (int k = 0; k < s.Length; k++)
                {
                    int kk = k % L;
                    int ii = ACGT.IndexOf(s[k]);
                    vecList[row][ii]     += amplitudes1[kk];
                    vecList[row][4 + ii] += amplitudes2[kk];
                }
            }
        }
Esempio n. 5
0
 public void Initialize(IDataset dataset, XmlElement filterNode)
 {
     motifPos = new int[dataset.Rows][];
     for (int row = 0; row < dataset.Rows; row++)
     {
         string[] posList = dataset.GetDataAt(row, 0).Split(',');
         int[]    R       = new int[posList.Length];
         for (int i = 0; i < R.Length; i++)
         {
             R[i] = int.Parse(posList[i]);
         }
         motifPos[row] = R;
     }
 }
        public void Initialize(IDataset dataset, XmlElement filterNode)
        {
            motifs = new string[dataset.Rows];
            for (int row = 0; row < dataset.Rows; row++)
            {
                motifs[row] = dataset.GetDataAt(row, 0);
            }
            maxLength = motifs.Max(s => s.Length);
            mem       = null; // This is only for the single threaded execution.

            string settings = GeneticAnalysis.App.ScriptApp.GetProperty("GeneticAnalysis.NeedlemanWunsch", null);

            if (settings != null)
            {
                string[] fs = settings.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                gapCost      = short.Parse(fs[0]);
                matchCost    = short.Parse(fs[1]);
                mismatchCost = short.Parse(fs[2]);
            }
        }
Esempio n. 7
0
        public void Initialize(IDataset dataset, XmlElement filterNode)
        {
            int    sparseSetColumn = 0;
            var    csList          = dataset.ColumnSpecList;
            string flags           = null;

            if (filterNode != null)
            {
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
                nsmgr.AddNamespace("vm", "urn:VisuMap.Technologies:VisuMap");
                flags = filterNode.SelectSingleNode("vm:EnabledFlag", nsmgr).InnerText;
            }

            for (int col = 0; col < csList.Count; col++)
            {
                if (csList[col].Name == "SparseSet")
                {
                    sparseSetColumn = col;
                    sparseTable     = new int[dataset.Rows][];
                    break;
                }
            }

            if (sparseTable != null)
            {
                for (int row = 0; row < dataset.Rows; row++)
                {
                    string[] fs = dataset.GetDataAt(row, sparseSetColumn).Split(',');
                    sparseTable[row] = new int[fs.Length];
                    int col2 = 0;
                    for (int col = 0; col < fs.Length; col++)
                    {
                        if ((fs[col] != null) && (fs[col] != ""))
                        {
                            sparseTable[row][col2++] = int.Parse(fs[col]);
                        }
                    }
                    if (col2 < fs.Length)
                    {
                        Array.Resize(ref sparseTable[row], col2);
                    }
                }
            }
            else
            {
                int columns = 0;
                for (int col = 0; col < csList.Count; col++)
                {
                    if (csList[col].IsNumber && ((flags == null) || flags[col] == 'y'))
                    {
                        columns++;
                    }
                }

                setTable = new bool[dataset.Rows][];
                for (int row = 0; row < dataset.Rows; row++)
                {
                    setTable[row] = new bool[columns];
                    int idx = 0;
                    for (int col = 0; col < csList.Count; col++)
                    {
                        if (csList[col].IsNumber && ((flags == null) || flags[col] == 'y'))
                        {
                            setTable[row][idx] = (double.Parse(dataset.GetDataAt(row, col)) != 0);
                            idx++;
                        }
                    }
                }
            }
        }