示例#1
0
        protected override List <SimulatorInitEvent> GetInitialEvents()
        {
            var pairs           = new List <SimulatorInitEvent>();
            var testTraceReader = new NSTraceReader(testTracePath, blockLength);
            var header          = testTraceReader.ReadHeader();         // bypass the header

            // load and schedule all NS-generated events
            while (!testTraceReader.Finished)
            {
                // group events of the block by their node IDs
                var nodeEventBlocks = testTraceReader.ReadNextGroupBlock(e => e.NodeID);

                // convert each event block to the corresponding signal and then
                // schedule the ProcessSignal method of the corresponding node passing
                // the signal as an EventArg
                foreach (var nodeEventBlock in nodeEventBlocks)
                {
                    var time    = nodeEventBlock.Last().Time;
                    var signals = GetSignals(nodeEventBlock.ToNSEventBlock());

                    foreach (var signal in signals)
                    {
                        pairs.Add(new SimulatorInitEvent(time, signal, nodeEventBlock.Key));
                    }
                }

                if (Initializing != null)
                {
                    Initializing(this, new ProgressEventArgs("Loading initial NS events...",
                                                             testTraceReader.Length, testTraceReader.Position));
                }
            }
            testTraceReader.Close();
            return(pairs);
        }
示例#2
0
        protected override List <MolecularPattern> GetSelfPatterns()
        {
            // load self molecular patterns
            var selfTraceReader = new NSTraceReader(selfTracePath, blockLength);
            var header          = selfTraceReader.ReadHeader();

            var MPs = new List <MolecularPattern>();

            while (!selfTraceReader.Finished)
            {
                // read a block of events
                var eventBlock = selfTraceReader.ReadNextEventBlock();

                // group events of the block by their node IDs
                var sinkEventBlock = eventBlock.Where(e => e.NodeID < header.NumSinks);

                // convert to molecular patterns
                var peptide = GetAntigenPeptide(sinkEventBlock.ToNSEventBlock());

                if (peptide != null)
                {
                    MPs.Add(peptide);
                }

                /*foreach (var nodeEventBlock in nodeEventBlocks)
                 * {
                 *      var peptide = GetAntigenPeptide(nodeEventBlock);
                 *
                 *      //var sdamp = GetSdamp(nodeEventBlock.ToNSEventBlock());
                 *      //var spamp = GetSpamp(nodeEventBlock.ToNSEventBlock());
                 *
                 *      //if (spamp != null)
                 *      //{
                 *      //	sw.WriteLine(spamp[0] + "," + spamp[1] + "," + spamp[2] + "," + nodeEventBlock.Key);
                 *      //}
                 *
                 *      if (peptide != null)
                 *      {
                 *              MPs.Add(peptide);
                 *      }
                 * }*/

                if (Initializing != null)
                {
                    // update progress indicator
                    Initializing(this, new ProgressEventArgs("Loading self events... ",
                                                             selfTraceReader.Length, selfTraceReader.Position));
                }
            }
            //sw.Close();
            selfTraceReader.Close();
            return(MPs);
        }
示例#3
0
        public void InitFromTrace(string selfTracePath, string testTracePath, double blockLength,
                                  int numBoneMarrows, int numThymuses, int numLymphNodes, int numAPCs, int numTCs, bool registerLogger)
        {
            this.selfTracePath = selfTracePath;
            this.testTracePath = testTracePath;
            this.blockLength   = blockLength;

            /*this.testTracePath = "spamp_ex1.csv";
             * this.selfTracePath = "../../../NSTraces/Traces-2009-12-23/ntr_ex1.tr";
             * GetSelfPatterns();
             *
             * this.testTracePath = "spamp_ex2.csv";
             * this.selfTracePath = "../../../NSTraces/Traces-2009-12-23/ntr_ex2.tr";
             * GetSelfPatterns();
             *
             * this.testTracePath = "spamp_ex3.csv";
             * this.selfTracePath = "../../../NSTraces/Traces-2009-12-23/ntr_ex3.tr";
             * GetSelfPatterns();
             *
             * this.testTracePath = "spamp_ex4.csv";
             * this.selfTracePath = "../../../NSTraces/Traces-2009-12-23/ntr_ex4.tr";
             * GetSelfPatterns();
             *
             * this.testTracePath = "spamp_ex5.csv";
             * this.selfTracePath = "../../../NSTraces/Traces-2009-12-23/ntr_ex5.tr";
             * GetSelfPatterns();
             *
             * this.testTracePath = "spamp_ex6.csv";
             * this.selfTracePath = "../../../NSTraces/Traces-2009-12-23/ntr_ex6.tr";
             * GetSelfPatterns();
             *
             * this.testTracePath = "spamp_ex7.csv";
             * this.selfTracePath = "../../../NSTraces/Traces-2009-12-23/ntr_ex7.tr";
             * GetSelfPatterns();
             *
             * this.testTracePath = "spamp_ex8.csv";
             * this.selfTracePath = "../../../NSTraces/Traces-2009-12-23/ntr_ex8.tr";
             * GetSelfPatterns();*/

            var tr     = new NSTraceReader(testTracePath, blockLength);
            var header = tr.ReadHeader();

            tr.Close();

            // TODO: Number of local tissues should be set to total number of nodes not number of sinks
            var args = new SimulatorInitArgs(numBoneMarrows, numThymuses, numLymphNodes,
                                             header.NumSinks, numAPCs, numTCs, PEPTIDE_LENGTH);

            Init(args, registerLogger);
        }
示例#4
0
        public void InitFromDump(string selfDump, string testTracePath, int blockLen, int numBoneMarrows, int numThymuses,
                                 int numLymphNodes, int numAPCs, int numTCs, bool registerLogger)
        {
            this.testTracePath = testTracePath;
            this.blockLength   = blockLen;

            var selfStream = File.Open(selfDump, FileMode.Open);

            var tr     = new NSTraceReader(testTracePath, blockLength);
            var header = tr.ReadHeader();

            tr.Close();

            // TODO: Number of local tissues should be set to total number of nodes not number of sinks
            var args = new SimulatorInitArgs(numBoneMarrows, numThymuses, numLymphNodes,
                                             header.NumSinks, numAPCs, numTCs, PEPTIDE_LENGTH);

            Init(selfStream, args, registerLogger);
        }