Beispiel #1
0
        public void LoadSearch(IGraphScene <IVisual, IVisualEdge> scene, IGraphSceneLayout <IVisual, IVisualEdge> layout, object name)
        {
            var graph = scene.Graph.Source <IVisual, IVisualEdge, IThing, ILink>();

            if (graph == null)
            {
                throw new ArgumentException("Search works only on ThingGraphs");
            }

            scene.CleanScene();

            var visuals = scene.Graph.ThingGraph()
                          .Search(name, false)
                          .Select(t => graph.Get(t));

            new GraphSceneFacade <IVisual, IVisualEdge>(() => scene, layout)
            .Add(visuals, false, false);

            var aligner = new Aligner <IVisual, IVisualEdge>(scene, layout);

            aligner.FullLayout(null, new Point(layout.Border.Width, layout.Border.Height), layout.Options(), new VisualComparer());
            aligner.Commit();

            scene.ClearSpatialIndex();
        }
Beispiel #2
0
 public Controller(FrmMain form)
 {
     formClass    = form;
     drawerClass  = new Drawer(form);
     AlignerClass = new Aligner();
     selected     = 0;
 }
Beispiel #3
0
    /// <inheritdoc/>
    protected override IEnumerable <Segment> Render(RenderContext context, int maxWidth)
    {
        if (context is null)
        {
            throw new ArgumentNullException(nameof(context));
        }

        if (_lines.Count == 0)
        {
            return(Array.Empty <Segment>());
        }

        var lines = context.SingleLine
            ? new List <SegmentLine>(_lines)
            : SplitLines(maxWidth);

        // Justify lines
        var justification = context.Justification ?? Alignment ?? Justify.Left;

        if (justification != Justify.Left)
        {
            foreach (var line in lines)
            {
                Aligner.Align(line, justification, maxWidth);
            }
        }

        if (context.SingleLine)
        {
            // Return the first line
            return(lines[0].Where(segment => !segment.IsLineBreak));
        }

        return(new SegmentLineEnumerator(lines));
    }
Beispiel #4
0
 public Goto(MyGridProgram argPg, Grid argG, Mover m, Aligner a)
 {
     pg      = argPg;
     g       = argG;
     mover   = m;
     aligner = a;
     rc      = new RemoteControl(g);
 }
Beispiel #5
0
    public void SetAligner_Pivot()
    {
        Aligner_Pivot aligner = new Aligner_Pivot();

        aligner       = new Aligner_Pivot();
        aligner.panel = this;
        this.aligner  = aligner;
    }
Beispiel #6
0
        public MAlignerViewer()
        {
            InitializeComponent();

            KeyValuePair <int[, ], Dictionary <char, int> > m = MAligner.Utils.LoadSubstitutionMatrixFromString(PepExplorer2.Properties.Resources.PAM30MS);

            mAligner = new Aligner(m);
        }
Beispiel #7
0
    public void SetAligner_FixedTile(Vector2 tileSize)
    {
        Aligner_FixedTile aligner = new Aligner_FixedTile();

        aligner       = new Aligner_FixedTile();
        aligner.panel = this;
        aligner.SetTileSize(tileSize);
        this.aligner = aligner;
    }
Beispiel #8
0
    public void SetAligner_AdaptiveTile(int linesCount, int tilesCountInLine)
    {
        Aligner_AdaptiveTile aligner = new Aligner_AdaptiveTile();

        aligner       = new Aligner_AdaptiveTile();
        aligner.panel = this;
        aligner.SetGrid(linesCount, tilesCountInLine, this);
        this.aligner = aligner;
    }
Beispiel #9
0
        public AlignmentForm()
        {
            InitializeComponent();

            examplesComboBox.SelectedIndex = 0;
            examplesComboBox_SelectedIndexChanged(null, null);
            aligner = new Aligner();
            globalAlignmentButton_Click(null, null);
        }
Beispiel #10
0
        public IEnumerable <IModListingGetter> Get()
        {
            var mods = RawListingsReader.Read(ListingsPathProvider.Path);

            return(Aligner.AlignToTimestamps(
                       mods,
                       DirectoryProvider.Path,
                       throwOnMissingMods: Prefs.ThrowOnMissingMods));
        }
        public MainForm()
        {
            InitializeComponent();

            // initialize
            this.detector   = new Detector("data\\models\\Detector2.0.ats");
            this.aligner    = new Aligner("data\\models\\PointDetector2.0.pts5.ats");
            this.recognizer = new Recognizer("data\\models\\Recognizer2.0.ats");
        }
Beispiel #12
0
 public static SyntaxNode AlignIndents(this SyntaxNode root, Action<int, string> onLineVisualized = null)
 {
     if (Runtime.Settings.AlignIndents)
         try
         {
             root = new Aligner(onLineVisualized).AlignIndents(root);
         }
         catch { }
     return root;
 }
        public MaintainPrealignerTabPanel()
        {
            InitializeComponent();
            comboBoxMode.DataSource = System.Enum.GetValues(typeof(AlignerCommand.MainTainMovingMode));

            if (AppData.IsRuntime)
            {
                preAligner = ATSCore.Instance.Aligner;
            }
        }
Beispiel #14
0
        public void Test4()
        {
            // Batch.exe --highlight-spaces xx.in xx.in xx.in 01.in xx.in xx.in ex08.out 80
            string[] files   = new string[] { "01.in", "01.in", "01.in" };
            IReader  reader  = new MultifileReader(files);
            Aligner  aligner = new Aligner(reader, "ex12_actual.out", 17, false);

            aligner.Process();
            Assert.AreEqual(ReadFile("ex12.out"), ReadFile("ex12_actual.out"));
        }
Beispiel #15
0
        public string GetString(int MatchNumber, int RefMatchNumber /* if no refs =-1 */)
        {
            string      comment = ""; //comment сейчас вообще никак не работает
            QMatch      Match, Refs;
            PeptidePair Pair;

            if (Aligner != null)
            {
                Pair  = Aligner.GetPeptPair(this, MatchNumber, RefMatchNumber);
                Match = Pair.LeftMatch;
                Refs  = Pair.RightMatch;
            }
            else
            {
                Match = Matches[MatchNumber];
                Refs  = null;
                Pair  = null;
            }


            string Out =
                ((ReportString[0] != '1')?"":String.Format("{0:20} \t", (Sequence ?? "NOSEQUENCE"))) +
                ((ReportString[1] != '1')?"":String.Format("{0:f4}\t", MascotRT)) +
                ((ReportString[2] != '1')?"":String.Format("{0:f4}\t", (Match != null)?Match.ApexRT:0.0)) +
                ((ReportString[3] != '1')?"":String.Format("{0}\t", MascotScan)) +
                ((ReportString[4] != '1')?"":String.Format("{0:F6}\t", (Match != null)?Match.RTDisp:0.0)) +
                ((ReportString[5] != '1')?"":String.Format("{0}\t", (Pair != null)?Pair.Shift:0.0)) +
                ((ReportString[6] != '1')?"":String.Format("{0}\t", (Pair != null)?Pair.MaxConv:0.0)) +
                ((ReportString[7] != '1')?"":String.Format("{0}\t", (Match != null && Refs != null)?Match.RTDisp / Refs.RTDisp:0.0)) +
                ((ReportString[8] != '1')?"":String.Format("{0:f4}\t", (Pair != null)?Pair.ESIFactor:0.0)) +
                ((ReportString[9] != '1')?"":String.Format("{0:f2}\t", (Match != null)?Match.Score:0.0)) +
                ((ReportString[10] != '1')?"":String.Format("{0}\t", (Refs != null)?Refs.Score:0.0)) +
                ((ReportString[11] != '1')?"":String.Format("{0}\t", (Match != null)?Math.Log10(Match.Score):0.0)) +
                ((ReportString[12] != '1')?"":String.Format("{0}\t", (Refs != null)?Math.Log10(Refs.Score):0.0)) +
                ((ReportString[13] != '1')?"":String.Format("{0:f2}\t", (Match != null)?Match.ApexScore:0.0)) +
                ((ReportString[14] != '1')?"":String.Format("{0:f5}\t", MascotMZ)) +
                ((ReportString[15] != '1')?"":String.Format("{0:f5}\t", (Match != null)?Match.ApexMZ:0.0)) +
                ((ReportString[16] != '1')?"":String.Format("{0}\t", Charge)) +
                ((ReportString[17] != '1')?"":String.Format("{0}\t", PI)) +
                ((ReportString[18] != '1')?"":String.Format("{0}\t", Sequence == null?"NOSEQUENCE":Fragmentation.Peptide.CalcElemComp(Sequence))) +
                ((ReportString[19] != '1')?"":String.Format("{0}\t", Match == null || Match.MSMatches == null?0:Match.MSMatches.Count - 2)) +
                ((ReportString[20] != '1')?"":String.Format("{0}\t", (IPI ?? "NOPROTEIN"))) +
                ((ReportString[21] != '1')?"":String.Format("{0}\t", (PartOfProtein != null ? PartOfProtein.Desc : "NOPROTEIN"))) +
                ((ReportString[22] != '1')?"":(Utils.IPIListtoString(IPIs)) + "\t") +
                ((ReportString[23] != '1')?"":String.Format("{0:f2}\t", MascotScore)) +
                ((ReportString[24] != '1')?"":String.Format("{0:f5}\t", ModMass)) +
                ((ReportString[25] != '1')?"":String.Format("{0:f5}\t", (Match != null)?Match.IsotopeRatio:0.0)) +
                ((ReportString[26] != '1')?"":String.Format("{0:f5}\t", TheorIsotopeRatio)) +
                ((ReportString[27] != '1')?"":String.Format("{0}\t", ModDesk)) +
                ((ReportString[28] != '1')?"":String.Format("{0}\t", Case)) +
                ((ReportString[29] != '1')?"":String.Format("{0}", comment));

//              Out = String.Format("{0}\t{1}\t"+Out,RTNumber,MascotScan);
            return(Out);
        }
        public void DistanceEst(object IndexObj)
        {
            int Index      = (IndexObj as IntArg).Arg;
            int UpperIndex = Math.Min(Index + 1000, Aligners.Count);

            for (int i = Index; i < UpperIndex; i++)
            {
                //для каждого спектра - проходим вних и вверх считая спектры не на месте
                //на полную длинну файла???
                int    Count = 0;
                double MinRT = Aligners[i].Best.RT - RTMin * 2.0;
                double MaxRT = Aligners[i].Best.RT + RTMin * 2.0;
                for (int k = i - 1; k >= 0; k--)
                {
                    if (Aligners[k].Best.RT < MinRT)
                    {
                        break;
                    }
                    for (int l = 0; l < FileCount; l++)
                    {
                        if (Aligners[i].Indexes[l] != -1 &&
                            Aligners[k].Indexes[l] != -1 &&
                            Aligners[i].Indexes[l] < Aligners[k].Indexes[l])
                        {
                            Count--;
                        }
                    }
                }
                for (int k = i + 1; k < Aligners.Count; k++)
                {
                    if (Aligners[k].Best.RT > MaxRT)
                    {
                        break;
                    }
                    for (int l = 0; l < FileCount; l++)
                    {
                        if (Aligners[i].Indexes[l] != -1 &&
                            Aligners[k].Indexes[l] != -1 &&
                            Aligners[i].Indexes[l] > Aligners[k].Indexes[l])
                        {
                            Count++;
                        }
                    }
                }
                lock (Als){
                    Aligner Al = Aligners[i];
                    Al.Equalizer = Count;
                    Aligners[i]  = Al;
                }
            }

            lock (ForCountLock){
                ExecCount++;
            }
        }
Beispiel #17
0
        public void TestMethod1()
        {
            Bitmap bmp1 = (Bitmap)Bitmap.FromFile("2.jpg");
            Bitmap bmp2 = (Bitmap)Bitmap.FromFile("6.jpg");

            Face.Aligner    aligner    = new Aligner("models\\pd_2_00_pts5.dat");
            Face.Detector   detector   = new Detector("models\\fd_2_00.dat");
            Face.Recognizer recognizer = new Recognizer("models\\fr_2_10.dat");
            Face.Assessor   assessor   = new Assessor();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            List <Rectangle> faces1 = detector.Detect(bmp1);
            List <Rectangle> faces2 = detector.Detect(bmp2);

            sw.Stop();

            long detect = sw.ElapsedMilliseconds;

            sw.Restart();
            List <PointF> pt1 = aligner.Align(bmp1, faces1[0]);
            List <PointF> pt2 = aligner.Align(bmp2, faces2[0]);

            sw.Stop();

            long align = sw.ElapsedMilliseconds;

            sw.Restart();
            double s = recognizer.Verify(bmp1, pt1, bmp2, pt2);

            sw.Stop();

            long recognize = sw.ElapsedMilliseconds;

            for (int i = 0; i < faces1.Count; i++)
            {
                Console.WriteLine(faces1[i].X + "\t" + faces1[i].Y + "\t" + faces1[i].Width + "\t" + faces1[i].Height);
            }

            sw.Restart();
            double score = assessor.Evaluate(bmp2, faces2[0], pt2);

            sw.Stop();

            long assert = sw.ElapsedMilliseconds;

            Console.WriteLine(s);
            Console.WriteLine(score);
            Console.WriteLine("detect:" + detect);
            Console.WriteLine("align:" + align);
            Console.WriteLine("recognize:" + recognize);
            Console.WriteLine("assert:" + assert);
        }
Beispiel #18
0
 private void globalAlignmentButton_Click(object sender, EventArgs e)
 {
     try
     {
         Aligner aligner = new Aligner();
         aligner.Input      = inputRichTextBox.Text;
         aligner.Parameters = parametersRichTextBox.Text;
         at = aligner.getGlobalAlignmentTable();
         generateAndDisplayAlignments();
     }
     catch (Exception ex) { MessageBox.Show("Invalid parameter or input data:\r\n" + ex.Message); }
 }
Beispiel #19
0
        public void TestExpand()
        {
            var options = new AlignerOptions {
                AlignX     = Alignment.Start,
                AlignY     = Alignment.Center,
                Dimension  = Dimension.X,
                PointOrder = PointOrder.XY,
            };

            var worker = SceneWorkerWithTestData2(3, options);

            options.Distance = worker.Layout.Distance;

            var origins   = new IVisual [] { worker.Scene.Focused };
            var aligner   = new Aligner <IVisual, IVisualEdge> (worker.Scene, worker.Layout);
            var deep      = false;
            var graphView = worker.Scene.Graph as SubGraph <IVisual, IVisualEdge>;

            var affected = new SubGraphWorker <IVisual, IVisualEdge>
                               (graphView).Expand(origins, deep);

            var walk = graphView.Walk();

            origins.ForEach(origin => {
                var route = (deep ? walk.DeepWalk(origin, 1) : walk.ExpandWalk(origin, 1))
                            .Where(l => !(l.Node is IVisualEdge)).ToArray();
                var bounds         = new Rectangle(aligner.Locator.GetLocation(origin), aligner.Locator.GetSize(origin));
                options.Collisions = Collisions.None;
                var cols           = aligner.MeasureWalk(route, ref bounds, options);
                var removeCol      = cols.Dequeue();

                if (options.Dimension == Dimension.X)
                {
                    var adjust      = options.AlignY.Delta(bounds.Height, removeCol.Item2.Height);
                    bounds.Location = new Point(bounds.X + removeCol.Item2.Width + options.Distance.Width, bounds.Y - adjust);
                }
                else
                {
                    var adjust      = options.AlignX.Delta(bounds.Width, removeCol.Item2.Width);
                    bounds.Location = new Point(bounds.X + adjust, bounds.Y + removeCol.Item2.Height + options.Distance.Height);
                }
                options.Collisions = Collisions.NextFree | Collisions.PerColumn | Collisions.Toggle;
                aligner.LocateColumns(cols, bounds, options);
            });

            aligner.Commit();
            worker.Modeller.Perform();
            worker.Modeller.Finish();

            ReportPainter.PushPaint(ctx => worker.Painter.Paint(ctx));

            WritePainter();
        }
Beispiel #20
0
        public void Test1()
        {
            // Batch.exe --highlight-spaces 01.in ex01.out 17

            string[] files   = new string[] { "01.in" };
            IReader  reader  = new MultifileReader(files);
            Aligner  aligner = new Aligner(reader, "ex01_actual.out", 17, true);

            aligner.Process();

            Assert.AreEqual(ReadFile("ex01.out"), ReadFile("ex01_actual.out"));
        }
Beispiel #21
0
 private void lcsButton_Click(object sender, EventArgs e)
 {
     try
     {
         Aligner aligner = new Aligner();
         aligner.Input = this.inputRichTextBox.Text;
         at            = aligner.getLcsTable();
         selectedPath  = 0;
         generateAndDisplayAlignments();
     }
     catch (Exception ex) { MessageBox.Show("Invalid parameter or input data:\r\n" + ex.Message); }
 }
        /*
         * (non-Javadoc)
         *
         * @see edu.cmu.sphinx.decoder.ResultListener#newResult(edu.cmu.sphinx.result.Result)
         */

        public override void NewResult(Result result)
        {
            String @ref = result.ReferenceText;

            if (result.IsFinal() && @ref != null)
            {
                String hyp = result.GetBestResultNoFiller();
                Aligner.Align(@ref, hyp);
                ShowFullPath(result);
                ShowDetails(result.ToString());
            }
        }
 public static SyntaxNode AlignIndents(this SyntaxNode root, string singleIndent, Action <int, string> onLineVisualized = null)
 {
     if (Runtime.Settings.AlignIndents)
     {
         try
         {
             // todo add parameter and read value her from caller
             root = new Aligner(singleIndent, onLineVisualized).AlignIndents(root);
         }
         catch { }
     }
     return(root);
 }
        public string CalculateLocalCharacteristicsSimilarityMatrix(
            int taskId,
            Aligner aligner,
            DistanceCalculator distanceCalculator,
            Aggregator aggregator)
        {
            var data = TaskManager.Instance.GetTaskData(taskId);

            var characteristicsObject = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(data);
            var characteristics       = characteristicsObject["characteristics"];

            LocalCharacteristicsData[] chars = characteristics.ToObject <LocalCharacteristicsData[]>();

            var series = new double[chars.Length][];

            for (int i = 0; i < chars.Length; i++)
            {
                series[i] = chars[i].FragmentsData.Select(fd => fd.Characteristics[0]).ToArray();
            }

            var alignersFactory    = new AlignersFactory();
            var calculatorsFactory = new DistanceCalculatorsFactory();
            var aggregatorsFactory = new AggregatorsFactory();

            var comparer = new OneDimensionalTimeSeriesComparer(
                alignersFactory.GetAligner(aligner),
                calculatorsFactory.GetDistanceCalculator(distanceCalculator),
                aggregatorsFactory.GetAggregator(aggregator));

            var result = new double[series.Length, series.Length];

            for (int i = 0; i < series.Length - 1; i++)
            {
                for (int j = i + 1; j < series.Length; j++)
                {
                    result[i, j] = comparer.GetDistance(series[i], series[j]);
                    result[j, i] = comparer.GetDistance(series[i], series[j]);
                }
            }

            var response = new Dictionary <string, object>
            {
                { "aligner", aligner },
                { "distanceCalculator", distanceCalculator },
                { "aggregator", aggregator },
                { "result", result }
            };

            return(JsonConvert.SerializeObject(response));
        }
Beispiel #25
0
    /// <inheritdoc/>
    public IEnumerable <Segment> Render(RenderContext context, int maxWidth)
    {
        var alignment = Alignment ?? Justify.Left;

        var rootStyle      = RootStyle ?? Style.Plain;
        var separatorStyle = SeparatorStyle ?? Style.Plain;
        var stemStyle      = StemStyle ?? Style.Plain;
        var leafStyle      = LeafStyle ?? Style.Plain;

        var fitted = Fit(context, maxWidth);
        var parts  = new List <Segment>();

        foreach (var(_, first, last, item) in fitted.Enumerate())
        {
            // Leaf?
            if (last)
            {
                parts.Add(new Segment(item, leafStyle));
            }
            else
            {
                if (first && _rooted)
                {
                    // Root
                    parts.Add(new Segment(item, rootStyle));

                    if (_windows)
                    {
                        // Windows root has a slash
                        parts.Add(new Segment("/", separatorStyle));
                    }
                }
                else
                {
                    // Normal path segment
                    parts.Add(new Segment(item, stemStyle));
                    parts.Add(new Segment("/", separatorStyle));
                }
            }
        }

        // Align the result
        Aligner.Align(parts, Alignment, maxWidth);

        // Insert a line break
        parts.Add(Segment.LineBreak);

        return(parts);
    }
Beispiel #26
0
        public Attendance()
        {
            InitializeComponent();

            this.BindWindowsUIButtonEvents();

            this.DisposeNeeded = true;
            this.RefreshNeeded = true;


            // initialize
            this.detector   = new Detector("data\\models\\Detector2.0.ats");
            this.aligner    = new Aligner("data\\models\\PointDetector2.0.pts5.ats");
            this.recognizer = new Recognizer("data\\models\\Recognizer2.0.ats");
        }
Beispiel #27
0
        /*
         * (non-Javadoc)
         *
         * @see edu.cmu.sphinx.util.props.Configurable#newProperties(edu.cmu.sphinx.util.props.PropertySheet)
         */
        public override void NewProperties(PropertySheet ps)
        {
            base.NewProperties(ps);
            InitRecognizer((Recognizer)ps.GetComponent(PropRecognizer));

            _showSummary        = ps.GetBoolean(PropShowSummary);
            _showDetails        = ps.GetBoolean(PropShowDetails);
            _showResults        = ps.GetBoolean(PropShowResults);
            _showAlignedResults = ps.GetBoolean(PropShowAlignedResults);

            _showRaw = ps.GetBoolean(PropShowRawResults);

            Aligner.SetShowResults(_showResults);
            Aligner.SetShowAlignedResults(_showAlignedResults);
        }
Beispiel #28
0
        protected void Align(Aligner aligner)
        {
            Vector2 pos = aligner.OriginalPos;

            if (Mode == PositionMode.Percent)
            {
                pos = PercentToPixels(pos);
            }
            Rectangle bounds = aligner.Child.LocalBounds;

            switch (aligner.XAlignment)
            {
            case Alignment.Center:
                pos.X = 0.5f * LocalBounds.Width - bounds.Width * 0.5f;
                break;

            case Alignment.Left:
                pos.X = 0;
                break;

            case Alignment.Right:
                pos.X = LocalBounds.Width - bounds.Width;
                break;

            default:
                break;
            }

            switch (aligner.YAlignment)
            {
            case Alignment.Center:
                pos.Y = 0.5f * LocalBounds.Height - bounds.Height * 0.5f;
                break;

            case Alignment.Bottom:
                pos.Y = LocalBounds.Height - bounds.Height;
                break;

            case Alignment.Top:
                pos.Y = 0;
                break;

            default:
                break;
            }

            aligner.Child.LocalBounds = new Rectangle((int)pos.X, (int)pos.Y, bounds.Width, bounds.Height);
        }
        protected virtual void AfterEdit()
        {
            var scene = Scene;

            if (focusAfterEdit)
            {
                scene.Selected.Clear();
                scene.SetFocused(Current);
            }
            if (Current != null)
            {
                var aligner = new Aligner <IVisual, IVisualEdge>(scene, this.Layout);
                aligner.Justify(new IVisual[] { Current });
                aligner.Commit();
            }
        }
Beispiel #30
0
        public void Call(IGraphSceneDisplay <IVisual, IVisualEdge> display, Action <Aligner <IVisual, IVisualEdge>, IEnumerable <IVisual> > call, IEnumerable <IVisual> items)
        {
            if (display == null)
            {
                return;
            }

            var aligner = new Aligner <IVisual, IVisualEdge> (display.Data, display.Layout);

            call(aligner, items);

            aligner.Locator.Commit(aligner.GraphScene.Requests);

            StoreUndo(display, aligner, items);

            display.Perform();
        }