示例#1
0
        /// <summary>
        /// Generate all the sequence for the number.
        /// </summary>
        /// <param name="number"></param>
        /// <returns>model object</returns>
        public SequenceModel GenerateSequences(string number)
        {
            try
            {
                SequenceModel sequenceModel = new SequenceModel();//fill the sequence model object
                sequenceModel.Number = Convert.ToInt32(number);

                if (_sequence.GetAllNumbers(sequenceModel.Number).Count > 0)
                {
                    sequenceModel.AllNumberSequence = _sequence.GetAllNumbers(sequenceModel.Number).ToList();
                }

                if (_sequence.GetEvenNumbers(sequenceModel.Number).Count > 0)
                {
                    sequenceModel.EvenNumberSequence = _sequence.GetEvenNumbers(sequenceModel.Number).ToList();
                }

                if (_sequence.GetOddNumbers(sequenceModel.Number).Count > 0)
                {
                    sequenceModel.OddNumberSequence = _sequence.GetOddNumbers(sequenceModel.Number).ToList();
                }

                if (_sequence.GetFibonacciNumbers(sequenceModel.Number).Count > 0)
                {
                    sequenceModel.FibonacciNumberSequence = _sequence.GetFibonacciNumbers(sequenceModel.Number).ToList();
                }

                return(sequenceModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public HttpResponseMessage RunForSequence(SequenceModel sequenceFromClient)
        {
            KeySequence keySeq = new History.UserSessionHistory().GetHistoryDetailsByKeySequence(sequenceFromClient.SequenceId);

            //if the text entered from the db and the text from the client is 
            //empty or null then return analysis unavailable
            if (string.IsNullOrWhiteSpace(keySeq.TextEntered)
                && string.IsNullOrWhiteSpace(sequenceFromClient.TextEntered))
            {
                var invalid =  new List<HighlightedText>() { new HighlightedText() {
                    HighlightType = HighlightType.Unevaluated,
                    Text = "No analysis available for this sequence.  No user provided text detected."
                }};
                return Request.CreateResponse(HttpStatusCode.OK, invalid);
            }

            Accuracy accuracy = new Accuracy(new AnalyticData() {
                TextShown = keySeq.TextShown,
                TextEntered = 
                    (string.IsNullOrWhiteSpace(keySeq.TextEntered))
                    ? sequenceFromClient.TextEntered : keySeq.TextEntered
            });
            accuracy.Compute();

            IList<HighlightDetail> details = new HighlightDeterminator().Compute(accuracy);
            HighlightedTextBuilder highlightBuilder = new HighlightedTextBuilder();
            Queue<HighlightedText> highlightedSections = highlightBuilder.Compute(keySeq.TextShown, details);

            return Request.CreateResponse(HttpStatusCode.OK, highlightedSections.ToList());
        }
示例#3
0
        public override List <SequenceTable_11> Resolve(DbContextOracle context, Action <SequenceTable_11> action)
        {
            List <SequenceTable_11> List = new List <SequenceTable_11>();

            this.OracleContext = context;
            var db = context.Database;

            if (action == null)
            {
                action =
                    t =>
                {
                    var           name = t.Owner + "." + t.Sequence_name;
                    SequenceModel s;

                    if (db.Sequences.TryGet(name, out s))
                    {
                        s.MinValue    = t.Min_value;
                        s.MaxValue    = t.Max_value;
                        s.IncrementBy = t.Increment_by;
                        s.CycleFlag   = t.Cycle_flag;
                        s.OrderFlag   = t.Order_flag;
                        s.CacheSize   = t.Cache_size;
                    }
                    else
                    {
                        s = new SequenceModel()
                        {
                            Key         = name,
                            Owner       = t.Owner,
                            Name        = t.Sequence_name,
                            MinValue    = t.Min_value,
                            MaxValue    = t.Max_value,
                            IncrementBy = t.Increment_by,
                            CycleFlag   = t.Cycle_flag,
                            OrderFlag   = t.Order_flag,
                            CacheSize   = t.Cache_size,
                            Keep        = SequenceModel.Default.Keep,
                            Session     = SequenceModel.Default.Session,
                        };

                        db.Sequences.Add(s);
                    }
                }
            }
            ;


            SequenceDescriptor_11 view = new SequenceDescriptor_11(context.Manager.ConnectionString);

            sql = string.Format(sql, TableQueryWhereCondition("s", "sequence_owner"));

            using (var reader = context.Manager.ExecuteReader(CommandType.Text, sql))
            {
                List = view.ReadAll(reader, action).ToList();
            }

            return(List);
        }
    }
 public SingleByteCharSetProber(SequenceModel model, bool reversed, CharsetProber nameProber)
 {
     this.model = model;
     this.reversed = reversed;
     this.nameProber = nameProber;
     this.Reset();
 }
        public void LinkLeftElement()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);

            var result = model.LinkPreviousElement(elementB, elementA);
            var linkA  = model.GetElementLink(elementA);
            var linkB  = model.GetElementLink(elementB);

            Assert.IsTrue(result);
            Assert.IsNotNull(linkA);
            Assert.IsNotNull(linkB);
            Assert.AreEqual(elementB.Id, linkA.NextElementId);
            Assert.AreEqual(elementA.Id, linkB.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkA.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkB.NextElementId);
        }
        public void LinkLeftElementWrongPositionsReturnsFalse()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var elementC = GetElementC();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);
            model.Tracks[0].Shots.Add(elementC);

            var result = model.LinkPreviousElement(elementC, elementA);
            var linkA  = model.GetElementLink(elementA);
            var linkB  = model.GetElementLink(elementB);

            Assert.IsFalse(result);
            Assert.AreEqual(Guid.Empty, linkA.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkA.NextElementId);
            Assert.AreEqual(Guid.Empty, linkB.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkB.NextElementId);
        }
        public IEnumerable <Match> GetUniqueMatches(SequenceModel sequenceData)
        {
            var sequence = _sequenceProvider.Provide(sequenceData?.FileName, sequenceData?.Content)?.First();

            _suffixTree = new MultiWaySuffixTree(sequence);
            return(_suffixTree.SearchMatchesUniqueInReference(sequence));
        }
        public long GetEdgesCount(SequenceModel sequenceData)
        {
            var sequence = _sequenceProvider.Provide(sequenceData?.FileName, sequenceData?.Content)?.First();

            _suffixTree = new MultiWaySuffixTree(sequence);
            return(_suffixTree.EdgesCount);
        }
 public override void AppendChange(SequenceModel source, SequenceModel target, string propertyName)
 {
     if (_buckets.Add(source))
     {
         base.AppendChange(source, target, propertyName);
     }
 }
示例#10
0
 public void VisitSequence(SequenceModel item)
 {
     if (InFile(item))
     {
         _sequenceToDelete.Add(item);
     }
 }
        public void ShouldGetIfAnElementIsLinkedToOther()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var elementC = GetElementC();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);
            model.Tracks[0].Shots.Add(elementC);

            // B -> C
            model.LinkNextElement(elementB, elementC);

            var result = model.IsElementLinkedTo(elementB, elementC);

            Assert.IsTrue(result);

            result = model.IsElementLinkedTo(elementA, elementC);

            Assert.IsFalse(result);
        }
 public SingleByteCharSetProber(SequenceModel model, bool reversed, CharsetProber nameProber)
 {
     this.model      = model;
     this.reversed   = reversed;
     this.nameProber = nameProber;
     this.Reset();
 }
示例#13
0
        public ActionResult Generate(SequenceModel o)
        {
            if (o != null)
            {
                var sequences = Service.Execute(o.Number);

                StringBuilder sb = null;

                foreach (var i in sequences.Keys)
                {
                    sb = new StringBuilder();

                    foreach (var x in sequences[i])
                    {
                        sb.AppendFormat("{0}, ", x);
                    }

                    if (sb.Length > 1)
                    {
                        sb = sb.Remove(sb.Length - 2, 1);
                    }

                    o.Sequences.Add(i, sb.ToString());
                }
            }

            return(View(o));
        }
示例#14
0
 void IOracleModelVisitor.VisitSequence(SequenceModel item)
 {
     if (this._filter(item))
     {
         _items.Add(item);
     }
 }
示例#15
0
        public override object VisitAlter_sequence([NotNull] PlSqlParser.Alter_sequenceContext context)
        {
            Stop();

            var    name = context.sequence_name().GetCleanedTexts();
            string key  = $"{name[0]}.{name[1]}";

            SequenceModel sequence = new SequenceModel()
            {
                Key   = key,
                Owner = name[0],
                Name  = name[1],
            };

            AppendFile(sequence, context.Start);

            using (Enqueue(sequence))
                foreach (var item in context.sequence_spec())
                {
                    this.VisitSequence_spec(item);
                }

            Append(new OAlter()
            {
                Item = sequence
            });

            return(sequence);
        }
示例#16
0
        /// <summary>
        ///     CREATE SEQUENCE sequence_name (sequence_start_clause | sequence_spec)* ';'
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override object VisitCreate_sequence([NotNull] PlSqlParser.Create_sequenceContext context)
        {
            if (context.exception != null)
            {
                AppendException(context.exception);
                return(null);
            }

            var           name     = context.sequence_name().GetCleanedTexts();
            string        key      = $"{name[0]}.{name[1]}";
            SequenceModel sequence = new SequenceModel()
            {
                Key   = key,
                Owner = name[0],
                Name  = name[1],
            };

            AppendFile(sequence, context.Start);

            using (Enqueue(sequence))
                foreach (var item in context.sequence_spec())
                {
                    this.VisitSequence_spec(item);
                }

            Append(sequence);
            return(sequence);
        }
示例#17
0
    //getResNum for the UV.
    public int getResidueNum(Vector2 uv)
    {
        int result;

        Debug.Log("Splitting.cs: getResidueNum(uv): " + uv);
        if (DNA_Panel == null)
        {
            DNA_Panel = DNAPanelController.Instance.DNA_Panel;
        }
        if (DNA_Panel.GetComponent <Renderer>().enabled)
        {
            if (seqModel == null)
            {
                seqModel = new SequenceModel();
            }

            int    DNASeqNum = DNAPanelController.Instance.getSeqPos(uv);
            string nuc       = DNAPanelController.Instance.getNucAcidForUV(uv);
            Debug.Log("Pos: " + DNASeqNum + ", DNA: " + nuc + ", seqModel: " + seqModel);
            string nucStr = nuc.Split(':')[0];

            //string niceName, int pos, Nuc n, Seq type
            int pos = seqModel.getPeptidePos("Rattus norvegicus", DNASeqNum, Nucleotide.StrToNuc(nucStr), Seq.DNA);
            // residueSeq[x].name;
            return(pos);
        }
        else
        {
            //do it
            Debug.Log("RNA panel");
        }

        return(0);
    }
        public void ShouldGetLastElementInChainOfLinks()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var elementC = GetElementC();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);
            model.Tracks[0].Shots.Add(elementC);

            // B -> C
            model.LinkNextElement(elementB, elementC);

            // A -> B
            model.LinkPreviousElement(elementB, elementA);

            var element = model.FindLastElementLinking(elementA, model.Tracks[0]);

            Assert.AreEqual(elementC, element);

            element = model.FindLastElementLinking(elementB, model.Tracks[0]);

            Assert.AreEqual(elementC, element);
        }
        private void Append(SequenceModel source, DifferenceModel d)
        {
            string p = BuildPath(Path.Combine(this.folderForTarget, source.Owner), "Sequences", source.Key);

            if (!File.Exists(p))
            {
                d.Addfile(p);
                StringBuilder sb = new StringBuilder();

                var file = source.Files.OfType <FileElement>().FirstOrDefault();

                if (file != null && file.Exist(this.rootFolderSource))
                {
                    sb = new StringBuilder(ContentHelper.LoadContentFromFile(this.rootFolderSource, file.Path));
                }

                else
                {
                }

                if (sb.Length > 0)
                {
                    WriteFile(p, sb.ToString());
                    d.Addfile(p);
                }
            }
        }
        private void GetSequences()
        {
            var command = _connection.CreateCommand();

            command.CommandText = @"SELECT name,
                        is_cycling,
                        CAST(minimum_value AS bigint) as [minimum_value],
                        CAST(maximum_value AS bigint) as [maximum_value],
                        CAST(start_value AS bigint) as [start_value],
                        CAST(increment AS int) as [increment],
                        TYPE_NAME(user_type_id) as [type_name],
                        OBJECT_SCHEMA_NAME(object_id) AS [schema_name]
                        FROM sys.sequences";

            using (var reader = command.ExecuteReader())
            {
                var dboIdx   = reader.GetOrdinal("schema_name");
                var typeIdx  = reader.GetOrdinal("type_name");
                var nameIdx  = reader.GetOrdinal("name");
                var cycleIdx = reader.GetOrdinal("is_cycling");
                var minIdx   = reader.GetOrdinal("minimum_value");
                var maxIdx   = reader.GetOrdinal("maximum_value");
                var startIdx = reader.GetOrdinal("start_value");
                var incrIdx  = reader.GetOrdinal("increment");

                while (reader.Read())
                {
                    var sequence = new SequenceModel
                    {
                        SchemaName  = reader.GetStringOrNull(dboIdx),
                        Name        = reader.GetStringOrNull(nameIdx),
                        DataType    = reader.GetStringOrNull(typeIdx),
                        IsCyclic    = reader.GetBoolean(cycleIdx),
                        IncrementBy = reader.GetInt32(incrIdx),
                        Start       = reader.GetInt64(startIdx),
                        Min         = reader.GetInt64(minIdx),
                        Max         = reader.GetInt64(maxIdx)
                    };

                    if (string.IsNullOrEmpty(sequence.Name))
                    {
                        Logger.LogWarning(SqlServerDesignStrings.SequenceNameEmpty(sequence.SchemaName));
                        continue;
                    }

                    if (_defaultSequenceMinMax.ContainsKey(sequence.DataType))
                    {
                        var defaultMin = _defaultSequenceMinMax[sequence.DataType][0];
                        sequence.Min   = sequence.Min == defaultMin ? null : sequence.Min;
                        sequence.Start = sequence.Start == defaultMin ? null : sequence.Start;

                        var defaultMax = _defaultSequenceMinMax[sequence.DataType][1];
                        sequence.Max = sequence.Max == defaultMax ? null : sequence.Max;
                    }

                    _databaseModel.Sequences.Add(sequence);
                }
            }
        }
示例#21
0
        private void GetSequences()
        {
            var command = _connection.CreateCommand();

            command.CommandText = @"SELECT name,
                        is_cycling,
                        CAST(minimum_value AS bigint) as [minimum_value],
                        CAST(maximum_value AS bigint) as [maximum_value],
                        CAST(start_value AS bigint) as [start_value],
                        CAST(increment AS int) as [increment],
                        TYPE_NAME(user_type_id) as [type_name],
                        OBJECT_SCHEMA_NAME(object_id) AS [schema_name]
                        FROM sys.sequences";

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    var sequence = new SequenceModel
                    {
                        Database    = _databaseModel,
                        SchemaName  = reader.GetValueOrDefault <string>("schema_name"),
                        Name        = reader.GetValueOrDefault <string>("name"),
                        DataType    = reader.GetValueOrDefault <string>("type_name"),
                        IsCyclic    = reader.GetValueOrDefault <bool?>("is_cycling"),
                        IncrementBy = reader.GetValueOrDefault <int?>("increment"),
                        Start       = reader.GetValueOrDefault <long?>("start_value"),
                        Min         = reader.GetValueOrDefault <long?>("minimum_value"),
                        Max         = reader.GetValueOrDefault <long?>("maximum_value")
                    };

                    Logger.LogDebug(
                        RelationalDesignEventId.FoundSequence,
                        () => SqlServerDesignStrings.FoundSequence(
                            sequence.SchemaName, sequence.Name, sequence.DataType, sequence.IsCyclic,
                            sequence.IncrementBy, sequence.Start, sequence.Min, sequence.Max));

                    if (string.IsNullOrEmpty(sequence.Name))
                    {
                        Logger.LogWarning(
                            RelationalDesignEventId.SequenceMustBeNamedWarning,
                            () => RelationalDesignStrings.SequencesRequireName);
                        continue;
                    }

                    if (_defaultSequenceMinMax.ContainsKey(sequence.DataType))
                    {
                        var defaultMin = _defaultSequenceMinMax[sequence.DataType][0];
                        sequence.Min   = sequence.Min == defaultMin ? null : sequence.Min;
                        sequence.Start = sequence.Start == defaultMin ? null : sequence.Start;

                        var defaultMax = _defaultSequenceMinMax[sequence.DataType][1];
                        sequence.Max = sequence.Max == defaultMax ? null : sequence.Max;
                    }

                    _databaseModel.Sequences.Add(sequence);
                }
            }
        }
示例#22
0
        public SingleByteCharSetProber(SequenceModel model, bool reversed, AbstractCSProber nameProber)
        {
            mModel      = model;
            mReversed   = reversed;
            mNameProber = nameProber;

            Reset();
        }
示例#23
0
        public void PropertiesTest()
        {
            // preparation
            var model = new SequenceModel();

            // model property access
            Helper.ModelTestHelper.PropetiesTest(model);
        }
示例#24
0
        public void CreateMethod()
        {
            // action
            var model = new SequenceModel();

            // assert
            Assert.IsNotNull(model);
        }
 ////////////////////////////////////////////////////////////////
 // methods
 ////////////////////////////////////////////////////////////////
 public SingleByteCharsetProber(SequenceModel model) : base()
 {
     this.model       = model;
     this.reversed    = false;
     this.nameProber  = null;
     this.seqCounters = new int[NUMBER_OF_SEQ_CAT];
     reset();
 }
 public override void AppendMissing(SequenceModel source)
 {
     if (_buckets.Add(source))
     {
         var d = base.AppendDifference(source, false);
         Append(source, d);
     }
 }
 public SingleByteCharsetProber(SequenceModel model, bool reversed, CharsetProber nameProber) : base()
 {
     this.model       = model;
     this.reversed    = reversed;
     this.nameProber  = nameProber;
     this.seqCounters = new int[NUMBER_OF_SEQ_CAT];
     reset();
 }
示例#28
0
        public IDictionary <string, IList <int> > GetMatches(SequenceModel sequenceData, string[] searches, bool ignoreCase = false, int startIndex = 0)
        {
            var sequence = _sequenceProvider.Provide(sequenceData?.FileName, sequenceData?.Content)?.First();

            _boyerMoore.IgnoreCase = ignoreCase;
            _boyerMoore.StartIndex = startIndex;
            return(_boyerMoore.FindMatch(sequence, searches));
        }
示例#29
0
        /* EXPERIMENTAL GET CDS */
        public void getCDS()
        {
            if (seqModel == null)
            {
                seqModel = new SequenceModel();
            }
            List <string> cds = seqModel.getCDS(key);

            BuildCDSTexture(cds);
        }
        public ActionResult Index(SequenceModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.Sequences = _sequenceService.GetSequences(model.EnteredInput.Value, ",");

            return(View(model));
        }
示例#31
0
    public void getResidueForUV(Vector2 uv)
    {
        Debug.Log("Splitting.cs: getResidueForUV(uv): " + uv);

        if (DNAPanelController.Instance.DNA_Panel == null)
        {
            //do it
            Debug.Log("RNA panel");
            if (seqModel == null)
            {
                seqModel = new SequenceModel();
            }

            int    RNASeqNum = RNAPanelController.Instance.getSeqPos(uv);
            string nuc       = RNAPanelController.Instance.getNucAcidForUV(uv);
            Debug.Log("Pos: " + RNASeqNum + ", RNA: " + nuc + ", seqModel: " + seqModel);
            string nucStr = nuc.Split(':')[0];

            //string niceName, int pos, Nuc n, Seq type
            int num = seqModel.getPeptidePos("Rattus norvegicus", RNASeqNum, Nucleotide.StrToNuc(nucStr), Seq.RNA);
            Debug.Log("peptidePos: " + num);

            if (ProteinFocus != null)
            {
                GameObject.Destroy(ProteinFocus);
            }
            updateSplit(num);

            Residue r       = residueSeq[num];
            string  resName = r.name;
            RNAPanelController.Instance.setSeqPos(resName);
        }
        else
        {
            if (DNAPanelController.Instance.DNA_Panel.GetComponent <Renderer>().enabled)
            {
                if (seqModel == null)
                {
                    seqModel = new SequenceModel();
                }

                int    DNASeqNum = DNAPanelController.Instance.getSeqPos(uv);
                string nuc       = DNAPanelController.Instance.getNucAcidForUV(uv);
                Debug.Log("Pos: " + DNASeqNum + ", DNA: " + nuc + ", seqModel: " + seqModel);
                string nucStr = nuc.Split(':')[0];

                //string niceName, int pos, Nuc n, Seq type
                int num = seqModel.getPeptidePos("Rattus norvegicus", DNASeqNum, Nucleotide.StrToNuc(nucStr), Seq.DNA);

                Debug.Log("peptidePos: " + num);
            }
        }
    }
 public SingleByteCharSetProber(SequenceModel model)
     : this(model, false, null)
 {
 }
        public SingleByteCharSetProber(SequenceModel model, bool reversed, AbstractCSProber nameProber)
        {
            mModel = model;
            mReversed = reversed;
            mNameProber = nameProber;

            Reset();
        }