Beispiel #1
0
 public UserControl2(UIParameters up)
 {
     InitializeComponent();
     Name         = "UserControl2";
     Up           = up;
     Up.FastaFile = "";
 }
Beispiel #2
0
 public UserControl10(UIParameters up)
 {
     InitializeComponent();
     Name        = "UserControl10";
     Up          = up;
     Up.CxmlFile = "";
 }
Beispiel #3
0
        private void fileProcessor_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            double           currProgress;
            BackgroundWorker worker     = sender as BackgroundWorker;
            UIParameters     parameters = (UIParameters)e.Argument;



            Dictionary <string, bool> staticLaunch  = new Dictionary <string, bool>();
            Dictionary <string, bool> dynamicLaunch = new Dictionary <string, bool>();

            foreach (CheckBox box in parameters.groupBoxStatic.Controls)
            {
                staticLaunch.Add(box.Text, box.Checked);
            }
            foreach (CheckBox box in parameters.groupBoxDynamic.Controls)
            {
                dynamicLaunch.Add(box.Text, box.Checked);
            }
            ParserParent parserClass = new ParserParent(worker);

            parserClass.dynamicLaunch = dynamicLaunch;
            parserClass.staticLaunch  = staticLaunch;
            parserClass.parameters    = parameters;
            if (UsePatterns.Checked)
            {
                parserClass.SplitFiles(PatternStorage);
            }
            else
            {
                parserClass.InOneGo();
            }
        }
Beispiel #4
0
        };                               // 12

        /*
         * private float[,] bgScRgb = {
         * { 1f, 1f, 0.75f, 0.5f },     // 1
         * { 0.7f, 0.8f, 0.5f, 0f },    // 2
         * { 1f, 1f, 1f, 0.6f },        // 3
         * { 1f, 1f, 1f, 0.2f },      // 4
         * { 1f, 0.7f, 1f, 0.55f },     // 5
         * { 0.7f, 0.2f, 1f, 0f },      // 6
         * { 1f, 0.65f, 0.93f, 1f },  // 7
         * { 0.7f, 0.1f, 0.7f, 1f },    // 8
         * { 1f, 0.8f, 0.75f, 1f },     // 9
         * { 0.7f, 0.4f, 0.3f, 1f },    // 10
         * { 1f, 1f, 0.6f, 0.75f },     // 11
         * { 0.7f, 0.9f, 0.1f, 0.2f }}; // 12
         */
        public UserControl8(UIParameters up)
        {
            InitializeComponent();
            this.KeyUp += new KeyEventHandler(FacetCategoryKeyUp);
            Up          = up;
            Name        = "UserControl8";
            // Create Colors from the RGB values.
            BgColors = new List <Color>();
            for (int i = 0; i < bgScRgb.GetLength(0); i++)
            {
                Color bgC = Color.FromScRgb(bgScRgb[i, 0], bgScRgb[i, 1], bgScRgb[i, 2], bgScRgb[i, 3]);
                BgColors.Add(bgC);
            }

            Up.BackgroundColorScheme       = BgColors; // Set the scheme to the above colors.
            ForeColorPicker.SelectedColor += SetForeColor;
            //BackColorPicker.SelectedColor += SetBackColor;
            foreach (FacetCategory f in Up.FacetCategories)
            {
                if ((f.Name == "Species") || (f.Name == "Genus"))
                {
                    BackgroundFacet.Items.Add(f);
                }
                AvailableFacets.Items.Add(f);
            }

            // Set the scale factor for translating the coordinates from the final image to the preview image
            Image.ScaleFactor              = ImagePreview.Width / Image.Width;
            ImagePreview.Background        = Brushes.White;                               // Set the BG color to a default color.
            CurrentBackgroundFacetCategory = (FacetCategory)BackgroundFacet.SelectedItem; // Set the current BG FacetCat to the selected item.
            // Load FacetCategories for BG color that are of type String and are FilterVisible.
            CurrentItemIndex          = 0;                                                // Set the current item to the first one in the collection.
            CurrentItemTextBox.Text   = "1";
            FontFamilyBox.ItemsSource = Fonts.SystemFontFamilies;                         // Load fonts into pulldown
        }
Beispiel #5
0
        public static void writePairwiseAlignment(UIParameters Up, int itemId)
        {
            TextWriter tw = new StreamWriter(Up.ProjectDir + "\\txt\\" + itemId + ".txt");

            tw.Write("No alignments for this query sequence.");
            tw.Close();
        }
Beispiel #6
0
        public static void writePairwiseAlignment(UIParameters Up, Hit blastHit, int blastHspId, int itemId)
        {
            string     pa = BlastUtil.ToString(blastHit, blastHspId);
            TextWriter tw = new StreamWriter(Up.ProjectDir + "\\txt\\" + itemId + ".txt");

            tw.Write(pa);
            tw.Close();
        }
Beispiel #7
0
 public UserControl1(UIParameters up)
 {
     InitializeComponent();
     Name                   = "UserControl1";
     Up                     = up;
     Up.ProjectDir          = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
     projectDirTextBox.Text = Up.ProjectDir;
 }
Beispiel #8
0
 public UserControl4(UIParameters up)
 {
     InitializeComponent();
     Name = "UserControl4";
     Up   = up;
     BlastDatabase.ItemsSource    = proteinDatabases;
     BlastAlgorithm.ItemsSource   = proteinAlgorithms;
     BlastDatabase.SelectedIndex  = 0;
     BlastAlgorithm.SelectedIndex = 0;
 }
Beispiel #9
0
 public static void RecordBlastThresholds(UIParameters Up, UserControl4 uc4, string blastProgram, string blastDb, string blastAlgo)
 {
     Up.BlastProgram                 = blastProgram;
     Up.BlastDatabase                = blastDb;
     Up.BlastAlgorithm               = blastAlgo;
     Up.BlastGeneticCode             = (uc4.BlastDatabase.SelectedIndex + 1).ToString();
     Up.BlastMinPercentQueryCoverage = uc4.QueryCoverageSlider.Value;
     Up.BlastMinPercentIdentity      = uc4.PercentIdSlider.Value;
     Up.BlastMaxEvalue               = Math.Pow(10, uc4.EvalueSlider.Value);
     Up.BlastMaxNumHits              = Convert.ToInt32(uc4.NumTopHitsSlider.Value);
 }
Beispiel #10
0
 public static void RecordPivotParameters(UIParameters Up, string collectionName, string collectionTitle)
 {
     //Up.CollectionName = collectionName;
     Up.CollectionName  = "blip";
     Up.CollectionTitle = collectionTitle;
     //Up.CollectionUrl = @"file:///" + Up.CollectionPath + "\\" + Up.CollectionName + ".cxml";
     Up.CollectionUid          = GetUid();
     Up.CollectionUrl          = Up.CollectionPath + "\\" + Up.CollectionName + ".cxml";
     Up.CollectionImagePath    = Up.CollectionPath + "\\" + Up.CollectionUid + "_images";
     Up.CollectionDeepzoomPath = Up.CollectionPath + "\\" + Up.CollectionUid + "_deepzoom";
 }
Beispiel #11
0
        public static void CreateFacetCategories(UIParameters Up)
        {
            // Query information
            Up.FacetCategories.Add(new FacetCategory("InputOrder", "Number", "0", true));
            Up.FacetCategories.Add(new FacetCategory("QueryLen", "Number", "0", true));
            FacetCategory fc = new FacetCategory("QueryName", "String", false);

            fc.IsMetaDataVisible  = false;
            fc.IsWordWheelVisible = true;
            Up.FacetCategories.Add(fc);
            FacetCategory fc_seq = new FacetCategory("QuerySequence", "String", false);

            fc.IsMetaDataVisible  = false;
            fc.IsWordWheelVisible = false;
            Up.FacetCategories.Add(fc_seq);

            // BLAST alignment information
            Up.FacetCategories.Add(new FacetCategory("Rank", "Number", "0", true));
            Up.FacetCategories.Add(new FacetCategory("Annotated", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Score", "Number", "0.0", true));
            Up.FacetCategories.Add(new FacetCategory("EValue", "String", false));
            Up.FacetCategories.Add(new FacetCategory("Identity", "Number", "0.00", true));
            Up.FacetCategories.Add(new FacetCategory("Span", "Number", "0.00", true));
            Up.FacetCategories.Add(new FacetCategory("AlignLen", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("NextScore", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Strand", "String", false));
            Up.FacetCategories.Add(new FacetCategory("SubjStart", "Number", "0", false));
            Up.FacetCategories.Add(new FacetCategory("SubjLen", "Number", "0", false));
            // Gene information
            Up.FacetCategories.Add(new FacetCategory("Gene", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("GI", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("Accession", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("Definition", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Product", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Function", "LongString", false));
            // Organism information
            Up.FacetCategories.Add(new FacetCategory("Lineage", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Organism", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Species", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Genus", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Kingdom", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Phylum", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Class", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Order", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Family", "String", true));
            // References
            Up.FacetCategories.Add(new FacetCategory("RefCount", "Number", "0", true));
            fc = new FacetCategory("References", "Link", false);
            fc.IsMetaDataVisible  = true;
            fc.IsWordWheelVisible = false;
            Up.FacetCategories.Add(fc);
            Up.FacetCategories.Add(new FacetCategory("SubmissionDate", "DateTime", true));
        }
Beispiel #12
0
        private void ChangeValues(UIParameters vp, Plugin p)
        {
            if (pm != null)
            {
                pm = (UIParameters)vp.Clone();

                statLabel.Font      = vp.TextFont;
                statLabel.ForeColor = vp.TextColor;

                BackColor = vp.Color;
                Opacity   = vp.Opacity;
            }
            if (p != null)
            {
                this.p         = p;
                statLabel.Text = p.Update();
            }
        }
Beispiel #13
0
        private void SetUIParameters_VisibleChanged(object sender, EventArgs e)
        {
            if (Visible == false)
            {
                if (DialogResult == DialogResult.OK)
                {
                    v1 = (UIParameters)v2.Clone();
                }
                else
                {
                    v2 = (UIParameters)v1.Clone();
                }
            }

            else
            {
                ChangeValues(v2);
            }
        }
Beispiel #14
0
        public static void ExecuteLogcat(object parameter)
        {
            UIParameters parameters = (UIParameters)parameter;

            Context = parameters.Context;
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += async(sender, args) =>
            {
                await Context.Dispatcher.InvokeAsync(() => { _adb = new AdbTools(Context); });

                await
                Task.Run(
                    async() =>
                    await _adb.Logcat(parameters.Context2, parameters.Bool, parameters.Target));
            };
            worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
            worker.RunWorkerAsync();
        }
        public static void ExecuteToken(object parameter)
        {
            UIParameters parameters = (UIParameters)parameter;

            Context = parameters.Context;
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += async(sender, args) =>
            {
                await Context.Dispatcher.InvokeAsync(() => { Fastboot = new FastbootTools(Context); });

                await
                Task.Run(
                    async() =>
                    await Fastboot.GetIdentiferToken(parameters.Context2, parameters.Bool));
            };
            worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
            worker.RunWorkerAsync();
        }
Beispiel #16
0
        private void ChangeValues(UIParameters v)
        {
            v2 = (UIParameters)v.Clone();

            color1ChooseButton.BackColor = v.DesktopLabelColor1;
            color1ChooseButton.ForeColor = (colorDialog.Color.GetBrightness() < 0.5) ? Color.White : Color.Black;

            color2ChooseButton.BackColor = v.DesktopLabelColor2;
            color2ChooseButton.ForeColor = (colorDialog.Color.GetBrightness() < 0.5) ? Color.White : Color.Black;

            colorChooseButton.BackColor = v.Color;
            colorChooseButton.ForeColor = (colorDialog.Color.GetBrightness() < 0.5) ? Color.White : Color.Black;

            mainTextColorChooseButton.BackColor = v.TextColor;
            mainTextColorChooseButton.ForeColor = (colorDialog.Color.GetBrightness() < 0.5) ? Color.White : Color.Black;

            mainTextFontChooseButton.Font = new Font(v.TextFont.FontFamily, 8.25F, v.TextFont.Style, GraphicsUnit.Point, (byte)204);
            desktopChooseFontButton.Font  = new Font(v.DesktopLabelFont.FontFamily, 8.25F, v.DesktopLabelFont.Style, GraphicsUnit.Point, (byte)204);


            opacityNumeric.Value = (decimal)v2.Opacity;
            deskXnumeric.Value   = (decimal)v2.DesktopLabelCoordinates.X;
            deskYnumeric.Value   = (decimal)v2.DesktopLabelCoordinates.Y;
            switch (v2.DesktopLabelEffect)
            {
            case LinearGradientMode.BackwardDiagonal:
                desktopLabelEffectListBox.SelectedIndex = 0;
                break;

            case LinearGradientMode.ForwardDiagonal:
                desktopLabelEffectListBox.SelectedIndex = 1;
                break;

            case LinearGradientMode.Horizontal:
                desktopLabelEffectListBox.SelectedIndex = 2;
                break;

            case LinearGradientMode.Vertical:
                desktopLabelEffectListBox.SelectedIndex = 3;
                break;
            }
        }
Beispiel #17
0
 public AdbViewModel()
 {
     ThreeTextCommandParameters    = new ThreeTextCommandParameters();
     FiveTextCommandParameters     = new FiveTextCommandParameters();
     InstallTwoCommandParameters   = new TwoCommandParameters();
     UninstallTwoCommandParameters = new TwoCommandParameters();
     UiParameters = new UIParameters();
     ExecuteSingleCommandParameters = new TwoCommandParameters();
     CopyCommandParameters          = new ThreeTextCommandParameters();
     MoveCommandParameters          = new ThreeTextCommandParameters();
     DeleteCommandParameters        = new TwoCommandParameters();
     SideloadParameters             = new TwoCommandParameters();
     ExecuteCommandsParameters      = new ExecuteCommandParameters();
     BackupParameters           = new BackupParameters();
     RestoreParameters          = new TwoCommandParameters();
     RemoteConnectParameters    = new ThreeTextCommandParameters();
     RemoteDisconnectParameters = new SingleCommandParameters();
     RemoteSaveParameters       = new ThreeTextCommandParameters();
     _remoteInfoRepository      = ((ViewModelLocator)Application.Current.Resources["Locator"]).RemoteInfoRepository;
 }
        public static void ExecuteListDevices(object parameter)
        {
            UIParameters parameters = (UIParameters)parameter;

            if (parameters != null)
            {
                Context = parameters.Context;
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += async(sender, args) =>
                {
                    await Context.Dispatcher.InvokeAsync(async() =>
                    {
                        Fastboot = new FastbootTools(Context);
                        await Fastboot.ListDevices(parameters.Context2, parameters.Bool);
                    });
                };
                worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
                worker.RunWorkerAsync();
            }
        }
Beispiel #19
0
        private void toExcel_Click(object sender, EventArgs e)
        {
            if (fileProcessor.IsBusy != true)
            {
                cancelWorker.Visible    = true;
                fileProgressBar.Visible = true;
                UIParameters parameters = new UIParameters();
                parameters.groupBoxStatic  = groupBoxStatic;
                parameters.groupBoxDynamic = groupBoxDynamic;
                parameters.groupBoxCommon  = groupBoxCommon;
                parameters.fileList        = fileList.Items.Cast <ListViewItem>().ToList();
                parameters.ExportDir       = saveTo.Text;
                if (templateDirectory.Text == "")
                {
                    selectFile.Title = "No Template selected please select one!";
                    selectFile.ShowDialog();
                    templateDirectory.Text = selectFile.FileName;
                }

                parameters.TemplateDir = templateDirectory.Text;
                fileProcessor.RunWorkerAsync(parameters);
            }
        }
Beispiel #20
0
    /// <summary>
    /// Loads Next UI Menu
    /// </summary>
    /// <param name="menu"></param>
    public static void LoadMenu(UIMenu menu, UIParameters parameters = null)
    {
        if (menu == null)
        {
            Debug.LogWarning("No UI Menu to load!");
            return;
        }

        if (ActiveMenu != null)
        {
            ActiveMenu.DisableMenu();
            ActiveMenu.gameObject.SetActive(false);
        }

        ActiveMenu = menu;
        ActiveMenu.gameObject.SetActive(true);

        if (parameters != null)
        {
            ActiveMenu.parameters = parameters;
        }

        ActiveMenu.InitializeMenu();
    }
Beispiel #21
0
 //TODO: Наклепать цветные кнопки
 public SetUIParameters(UIParameters v)
 {
     InitializeComponent();
     v2 = (UIParameters)v.Clone();
     v1 = (UIParameters)v.Clone();
 }
Beispiel #22
0
        public static int CreateItems(UIParameters Up, ISequence rec, int itemId, int seqPos, Collection collection)
        {
            string queryName = rec.DisplayID.ToString().Split(' ')[0];

            // BLAST reports are saved in individual files by query and
            // numbered in the same order as they appear in the input FASTA file.
            string blastFile = Up.ProjectDir + "\\xml\\" + seqPos + ".xml";

            if (!File.Exists(blastFile))
            {
                throw new Exception("File does not exist.");
            }
            BlastXmlParser      blastParser  = new BlastXmlParser();
            IList <BlastResult> blastResults = blastParser.Parse(blastFile);
            GenBankParser       gbParser     = new GenBankParser();

            int[] annotatedIndex = GetBestAnnotatedIndex(Up, seqPos);

            // iterate through the BLAST results.
            foreach (BlastResult blastResult in blastResults)
            {
                foreach (BlastSearchRecord record in blastResult.Records)
                {
                    int hitsProcessed = 0;
                    // If there are not hits in the BLAST result ...
                    int rank = 0;
                    if (record.Hits.Count() > 0)
                    {
                        // For each hit
                        for (int i = 0; i < record.Hits.Count(); i++)
                        {
                            Hit blastHit = record.Hits[i];
                            // For each HSP
                            for (int j = 0; j < blastHit.Hsps.Count(); j++)
                            {
                                Hsp    blastHsp      = blastHit.Hsps[j];
                                double percentId     = (blastHsp.IdentitiesCount / (double)blastHsp.AlignmentLength) * 100;
                                double queryCoverage = ((double)(blastHsp.QueryEnd - blastHsp.QueryStart + 1) / record.IterationQueryLength) * 100;
                                string txt           = String.Format("{0} {1} {2} {3} {4} {5} {6} {7}", percentId, Up.BlastMinPercentIdentity,
                                                                     Up.BlastMaxEvalue, blastHsp.EValue, queryCoverage, Up.BlastMinPercentQueryCoverage,
                                                                     hitsProcessed, Up.BlastMaxNumHits);
                                // if HSP passes user-defined thresholds
                                if ((percentId >= Up.BlastMinPercentIdentity) &&
                                    (Up.BlastMaxEvalue >= blastHsp.EValue) &&
                                    (queryCoverage >= Up.BlastMinPercentQueryCoverage) &&
                                    (hitsProcessed < Up.BlastMaxNumHits))
                                {
                                    rank += 1;
                                    string nextScore = "no";
                                    if ((i + 1) < record.Hits.Count())
                                    {
                                        if (blastHsp.Score > record.Hits[i + 1].Hsps[0].Score)
                                        {
                                            nextScore = "less than";
                                        }
                                        else
                                        {
                                            nextScore = "equal";
                                        }
                                    }
                                    else
                                    {
                                        nextScore = "non existent";
                                    }

                                    // parse GI numner from hit
                                    long        gi     = Convert.ToInt64(blastHit.Id.Split('|')[1]);
                                    GenBankItem gitem  = new GenBankItem(gi, blastHsp.HitStart, blastHsp.HitEnd);
                                    string      gbFile = Up.ProjectDir + "\\gb\\" + gitem.Id.ToString();
                                    gbFile += "_" + gitem.HitStart.ToString();
                                    gbFile += "_" + gitem.HitEnd.ToString();
                                    gbFile += ".gb";
                                    // init item
                                    string   img          = "#" + itemId.ToString();
                                    Item     item         = new Item(itemId, img);
                                    string[] headerTokens = parseFastaHeader(rec.DisplayID.ToString());
                                    item.Name        = headerTokens[0];
                                    item.Description = headerTokens[1];

                                    // write pairwise alignment
                                    writePairwiseAlignment(Up, blastHit, j, itemId);

                                    // try to parse the GB record associated with the hit and set facet values to data from BLAST/GB record
                                    try
                                    {
                                        Console.WriteLine("GB OK: " + record.Hits[0].Id + " " + i.ToString() + " " + j.ToString());
                                        ISequence gbRecord = gbParser.ParseOne(gbFile);
                                        item.Href = GetNCBIUrl(Up.BlastProgram) + GetGenBankIdentifier(gbRecord);
                                        GenBankMetadata     gbMeta   = (GenBankMetadata)gbRecord.Metadata["GenBank"];
                                        CodingSequence      bestCds  = null;
                                        IList <FeatureItem> features = gbMeta.Features.All;
                                        FeatureItem         bestItem = getBestFeatureItem(features);


                                        if (gbMeta.Features.CodingSequences.Count > 0)
                                        {
                                            bestCds = gbMeta.Features.CodingSequences[0];
                                        }

                                        for (int k = 1; k < gbMeta.Features.CodingSequences.Count; k++)
                                        {
                                            CodingSequence cds = gbMeta.Features.CodingSequences[k];
                                            //int bestSize = Math.Abs(bestCds.Location.End - bestCds.Location.Start);
                                            int bestSize = Math.Abs(bestItem.Location.End - bestItem.Location.Start);
                                            int cdsSize  = Math.Abs(cds.Location.End - cds.Location.Start);
                                            if (cdsSize > bestSize)
                                            {
                                                bestCds = cds;
                                            }
                                        }
                                        foreach (FacetCategory f in Up.FacetCategories)
                                        {
                                            Facet facet = new Facet();
                                            switch (f.Name)
                                            {
                                            case "InputOrder":
                                                facet = new Facet(f.Name, f.Type, seqPos);
                                                break;

                                            case "QuerySequence":
                                                facet = new Facet(f.Name, f.Type, rec.ToString());
                                                break;

                                            case "NextScore":
                                                facet = new Facet(f.Name, f.Type, nextScore);
                                                break;

                                            case "Annotated":
                                                string value = "na";
                                                if ((annotatedIndex[0] == i) && (annotatedIndex[1] == j))
                                                {
                                                    value = "top_annotated";
                                                }
                                                else
                                                {
                                                    if ((i == 0) && (j == 0) && (annotatedIndex[0] == -1) && (annotatedIndex[1] == -1))
                                                    {
                                                        value = "top_unannotated";
                                                    }
                                                    else
                                                    {
                                                        if (bestItem != null)
                                                        {
                                                            value = "annotated";
                                                        }
                                                        else
                                                        {
                                                            value = "unannotated";
                                                        }
                                                    }
                                                }
                                                facet = new Facet(f.Name, f.Type, value);
                                                break;

                                            default:
                                                //facet = CreateFacet(f.Name, f.Type, record, i, j, gbRecord, item, GetNCBIUrl(Up.BlastProgram), bestCds, rank);
                                                facet = CreateFacet(f.Name, f.Type, record, i, j, gbRecord, item, GetNCBIUrl(Up.BlastProgram), bestItem, rank);
                                                break;
                                            }

                                            /*
                                             * if (f.Name == "InputOrder")
                                             * {
                                             *  facet = new Facet(f.Name, f.Type, seqPos);
                                             * }
                                             *
                                             * else
                                             * {
                                             *  facet = CreateFacet(f.Name, f.Type, record, i, j, gbRecord, item);
                                             * }
                                             */
                                            item.Facets.Add(facet);
                                        }
                                    }
                                    //catch (System.NullReferenceException e) // if parsing failed init the item w/ default values (similar to 'no hit' above)
                                    catch
                                    {
                                        Console.WriteLine("GB ERROR: " + record.Hits[0].Id + " " + i.ToString() + " " + j.ToString());
                                        item.Href = "#";
                                        foreach (FacetCategory f in Up.FacetCategories)
                                        {
                                            Facet facet = new Facet();
                                            switch (f.Name)
                                            {
                                            case ("InputOrder"):
                                                facet = new Facet(f.Name, f.Type, seqPos);
                                                break;

                                            case "QuerySequence":
                                                facet = new Facet(f.Name, f.Type, rec.ToString());
                                                break;

                                            case ("NextScore"):
                                                facet = new Facet(f.Name, f.Type, "no");
                                                break;

                                            case "Annotated":
                                                string value = "na";
                                                if ((annotatedIndex[0] == i) && (annotatedIndex[1] == j))
                                                {
                                                    value = "top_annotated";
                                                }
                                                else
                                                {
                                                    if ((i == 0) && (j == 0) && (annotatedIndex[0] == -1) && (annotatedIndex[1] == -1))
                                                    {
                                                        value = "top_unannotated";
                                                    }
                                                    else
                                                    {
                                                        value = "unannotated";
                                                    }
                                                }
                                                facet = new Facet(f.Name, f.Type, value);
                                                break;

                                            default:
                                                facet = CreateGBErrorFacet(f.Name, f.Type, record, i, j, item, GetNCBIUrl(Up.BlastProgram), rank);
                                                break;
                                            }
                                            item.Facets.Add(facet);
                                        }
                                        //throw (e);
                                    }
                                    // Add item to collection, increment to next item,
                                    collection.Items.Add(item);
                                    hitsProcessed += 1;
                                    itemId        += 1;
                                }
                            }
                        }
                    }
                    if ((record.Hits.Count()) == 0 || (hitsProcessed == 0))
                    {
                        // Init Pivot item
                        string img  = "#" + itemId.ToString();
                        Item   item = new Item(itemId, img);
                        item.Href = "#";
                        string[] headerTokens = parseFastaHeader(rec.DisplayID.ToString());
                        item.Name        = headerTokens[0];
                        item.Description = headerTokens[1];

                        // Write pairwise alignment to file.
                        writePairwiseAlignment(Up, itemId);

                        // Set facet values for each facet category to default values
                        foreach (FacetCategory f in Up.FacetCategories)
                        {
                            Facet facet = new Facet();
                            switch (f.Name)
                            {
                            case ("InputOrder"):
                                facet = new Facet(f.Name, f.Type, seqPos);
                                break;

                            case ("QuerySequence"):
                                facet = new Facet(f.Name, f.Type, rec.ToString());
                                break;

                            default:
                                facet = CreateFacet(f.Name, f.Type, record, item, 0);
                                break;
                            }
                            item.Facets.Add(facet);
                        }

                        // Add item to collection, increment to next item, skip remaining code
                        collection.Items.Add(item);
                        itemId        += 1;
                        hitsProcessed += 1;
                    }
                }
            }
            return(itemId);
        }
Beispiel #23
0
        public static int[] GetBestAnnotatedIndex(UIParameters Up, int seqPos)
        {
            // BLAST reports are saved in individual files by query and
            // numbered in the same order as they appear in the input FASTA file.
            int[] annotatedIndex = new int[2];
            annotatedIndex[0] = -1;
            annotatedIndex[1] = -1;

            string blastFile = Up.ProjectDir + "\\xml\\" + seqPos + ".xml";

            if (!File.Exists(blastFile))
            {
                throw new Exception("File does not exist.");
            }
            BlastXmlParser      blastParser  = new BlastXmlParser();
            IList <BlastResult> blastResults = blastParser.Parse(blastFile);
            GenBankParser       gbParser     = new GenBankParser();

            // iterate through the BLAST results.
            foreach (BlastResult blastResult in blastResults)
            {
                foreach (BlastSearchRecord record in blastResult.Records)
                {
                    int hitsProcessed = 0;
                    // If there are not hits in the BLAST result ...
                    int rank = 0;
                    if (record.Hits.Count() > 0)
                    {
                        // For each hit
                        for (int i = 0; i < record.Hits.Count(); i++)
                        {
                            Hit blastHit = record.Hits[i];
                            for (int j = 0; j < blastHit.Hsps.Count(); j++)
                            {
                                Hsp    blastHsp      = blastHit.Hsps[j];
                                double percentId     = (blastHsp.IdentitiesCount / (double)blastHsp.AlignmentLength) * 100;
                                double queryCoverage = ((double)(blastHsp.QueryEnd - blastHsp.QueryStart + 1) / record.IterationQueryLength) * 100;

                                if ((percentId >= Up.BlastMinPercentIdentity) &&
                                    (Up.BlastMaxEvalue >= blastHsp.EValue) &&
                                    (queryCoverage >= Up.BlastMinPercentQueryCoverage) &&
                                    (hitsProcessed < Up.BlastMaxNumHits))
                                {
                                    rank += 1;
                                    long        gi     = Convert.ToInt64(blastHit.Id.Split('|')[1]);
                                    GenBankItem gitem  = new GenBankItem(gi, blastHsp.HitStart, blastHsp.HitEnd);
                                    string      gbFile = Up.ProjectDir + "\\gb\\" + gitem.Id.ToString();
                                    gbFile += "_" + gitem.HitStart.ToString();
                                    gbFile += "_" + gitem.HitEnd.ToString();
                                    gbFile += ".gb";

                                    try
                                    {
                                        Console.WriteLine("GB OK: " + record.Hits[0].Id + " " + i.ToString() + " " + j.ToString());
                                        ISequence           gbRecord = gbParser.ParseOne(gbFile);
                                        GenBankMetadata     gbMeta   = (GenBankMetadata)gbRecord.Metadata["GenBank"];
                                        IList <FeatureItem> features = gbMeta.Features.All;
                                        FeatureItem         bestItem = getBestFeatureItem(features);
                                        if (bestItem != null)
                                        {
                                            annotatedIndex[0] = i;
                                            annotatedIndex[1] = j;
                                            return(annotatedIndex);
                                        }
                                    }

                                    catch
                                    {
                                        Console.WriteLine("ISANNOTATED: " + record.Hits[0].Id + " " + i.ToString() + " " + j.ToString());
                                    }
                                    hitsProcessed += 1;
                                }
                            }
                        }
                    }
                }
            }

            return(annotatedIndex);
        }
Beispiel #24
0
            //Creation Methods
            public UIText2 createText2(UIParameters aArgs)
            {
                //Create the game object
                GameObject uiGameObject = new GameObject("Sprite(Text2)");
                Transform uiTransform = uiGameObject.GetComponent<Transform>();
                uiTransform.rotation = Quaternion.identity;
                uiTransform.position = Vector3.zero;
                uiTransform.localRotation = Quaternion.identity;
                uiTransform.localPosition = Vector3.zero;
                uiTransform.localScale = new Vector3(0.0f, 0.0f, 1.0f);
                uiTransform.parent = transform;

                //Create the required Components
                GUIText uiGUIText = uiGameObject.AddComponent<GUIText>();
                //Create the UIText2 Component
                UIText2 uiText = uiGameObject.AddComponent<UIText2>();
                //Set the Defaults
                uiGUIText.anchor = TextAnchor.LowerLeft;
                uiGUIText.alignment = TextAlignment.Left;
                uiText.setManager(this);
                uiText.setDefault(true);
                //Set the UIParamaters

                uiText.toggleName = aArgs.toggleName;
                uiText.isInteractive = aArgs.interactive;
                uiText.text = aArgs.text;
                uiText.font = aArgs.font;
                uiText.fontSize = aArgs.fontSize;
                uiText.fontStyle = aArgs.fontStyle;
                uiText.fontColor = aArgs.color;
                uiText.scale = new Vector2(aArgs.scale,aArgs.scale);
                uiText.setBounds(aArgs.bounds.x, aArgs.bounds.y, aArgs.bounds.width, aArgs.bounds.height);
                //Register the Control
                registerToggle(uiText);
                return uiText;
            }
Beispiel #25
0
            public UILabel createLabel2(UIParameters aArgs)
            {
                bool defaultInteractive = aArgs.interactive;
                Texture defaultTexture = aArgs.texture;
                //Create the GameObject
                GameObject uiGO = new GameObject("Sprite (Label 2)");
                Transform uiTransform = uiGO.transform;
                uiTransform.rotation = Quaternion.identity;
                uiTransform.position = Vector3.zero;
                uiTransform.localRotation = Quaternion.identity;
                uiTransform.localPosition = Vector3.zero;
                uiTransform.localScale = new Vector3(0.0f, 0.0f, 1.0f);
                uiTransform.parent = transform;
                //Create Text2 && Texture2
                aArgs.interactive = true;
                UIText2 text2 = createText2(aArgs);
                aArgs.interactive = false;
                aArgs.texture = null;
                UITexture2 texture2 = createTexture2(aArgs);

                //Create UILabel
                UILabel label = uiGO.AddComponent<UILabel>();
                label.uiText = text2;
                label.uiTexture = texture2;
                text2.setHandler(label);
                texture2.setHandler(label);
                text2.transform.parent = label.transform;
                texture2.transform.parent = label.transform;

                aArgs.interactive = defaultInteractive;
                aArgs.texture = defaultTexture;

                return null;
            }
Beispiel #26
0
            public UITexture2 createTexture2(UIParameters aArgs)
            {
                //Create the Game Object
                GameObject uiGameObject = new GameObject("Sprite(Texture2)");
                Transform uiTransform = uiGameObject.GetComponent<Transform>();
                uiTransform.rotation = Quaternion.identity;
                uiTransform.position = Vector3.zero;
                uiTransform.localRotation = Quaternion.identity;
                uiTransform.localPosition = Vector3.zero;
                uiTransform.localScale = new Vector3(0.0f, 0.0f, 1.0f);
                uiTransform.parent = transform;

                //Create the required Components
                GUITexture uiGUITexture = uiGameObject.AddComponent<GUITexture>();
                //Create the UITexture2 Component
                UITexture2 uiTexture = uiGameObject.AddComponent<UITexture2>();
                //Set the Defaults
                uiTexture.setManager(this);
                uiTexture.setDefault(true);

                //Set the UIParameters
                uiTexture.toggleName = aArgs.toggleName;
                uiTexture.isInteractive = aArgs.interactive;
                uiTexture.texture = aArgs.texture;
                uiTexture.color = aArgs.color;
                uiTexture.scale = new Vector2(aArgs.scale, aArgs.scale);
                uiTexture.setBounds(aArgs.bounds.x, aArgs.bounds.y, aArgs.bounds.width, aArgs.bounds.height);

                //Register the Control
                registerToggle(uiTexture);
                return uiTexture;
            }
Beispiel #27
0
 private void setUIParametersMenuItem_Click(object sender, EventArgs e)
 {
     s.ShowDialog();
     pm = s.GetViewParameters();
     ChangeValues(pm, null);
 }
Beispiel #28
0
            public UIText3 createText3(UIParameters aArgs)
            {
                //Create the Game Object
                GameObject uiGameObject = new GameObject("Sprite(Text3)");
                Transform uiTransform = uiGameObject.GetComponent<Transform>();
                uiTransform.rotation = Quaternion.identity;
                uiTransform.position = Vector3.zero;
                uiTransform.localRotation = Quaternion.identity;
                uiTransform.localPosition = Vector3.zero;
                uiTransform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
                uiTransform.parent = transform;

                //Create the required components
                MeshRenderer uiMeshRenderer = uiGameObject.AddComponent<MeshRenderer>();
                TextMesh uiTextMesh = uiGameObject.AddComponent<TextMesh>();

                uiMeshRenderer.material = m_TextMaterial;
                uiTextMesh.characterSize = 0.1f;
                uiTextMesh.anchor = TextAnchor.MiddleCenter;
                uiTextMesh.alignment = TextAlignment.Center;

                //Create the UIText3 Component
                UIText3 uiText = uiGameObject.AddComponent<UIText3>();
                // set The default
                uiText.setManager(this);
                uiText.setDefault(true);
                //set the UIParameters
                uiText.toggleName = aArgs.toggleName;
                uiText.isInteractive = aArgs.interactive;
                uiText.text = aArgs.text;
                uiText.font = aArgs.font;
                uiText.fontSize = aArgs.fontSize;
                uiText.fontStyle = aArgs.fontStyle;
                uiText.color = aArgs.color;
                uiText.position = aArgs.position;
                uiText.rotation = aArgs.rotation;

                uiTextMesh.font = aArgs.font;
                //Register the Control
                registerToggle(uiText);

                uiText.updateTransform(false);
                return uiText;
            }
Beispiel #29
0
            public UITexture3 createTexture3(UIParameters aArgs)
            {
                //Create the Game Object
                GameObject uiGameObject = new GameObject("Sprite(Texture3)");
                Transform uiTransform = uiGameObject.GetComponent<Transform>();
                uiTransform.rotation = Quaternion.identity;
                uiTransform.position = Vector3.zero;
                uiTransform.localRotation = Quaternion.identity;
                uiTransform.localPosition = Vector3.zero;
                uiTransform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                uiTransform.parent = transform;

                //Create the required components
                MeshRenderer uiMeshRenderer = uiGameObject.AddComponent<MeshRenderer>();
                MeshFilter uiMeshFilter = uiGameObject.AddComponent<MeshFilter>();

                uiMeshRenderer.material = m_TextureMaterial;
                uiMeshFilter.mesh = m_PlaneMesh;

                //Create the UIText3 Component
                UITexture3 uiTexture = uiGameObject.AddComponent<UITexture3>();
                // set The default
                uiTexture.setManager(this);
                uiTexture.setDefault(true);
                //set the UIParameters
                uiTexture.toggleName = aArgs.toggleName;
                uiTexture.isInteractive = aArgs.interactive;
                uiTexture.texture = aArgs.texture;
                uiTexture.color = aArgs.color;
                uiTexture.position = aArgs.position;
                uiTexture.rotation = aArgs.rotation;

                //Register the Control
                registerToggle(uiTexture);

                uiTexture.updateTransform(false);
                return uiTexture;
            }
Beispiel #30
0
 public UserControl0(UIParameters up)
 {
     InitializeComponent();
     Name = "UserControl0";
     Up   = up;
 }
Beispiel #31
0
 public UserControl7(UIParameters up)
 {
     InitializeComponent();
     Up   = up;
     Name = "UserControl7";
 }
Beispiel #32
0
 public UILabel createLabel3(UIParameters aArgs)
 {
     return null;
 }