Exemplo n.º 1
0
        public void DrawPaint(object sender, PaintEventArgs e)
        {
            if (!drawing)
            {
                return;
            }
            Graphics g = e.Graphics;

            g.CompositingQuality = CompositingQuality.HighQuality;
            g.SmoothingMode      = SmoothingMode.AntiAlias;
            g.InterpolationMode  = InterpolationMode.Low;
            g.TextRenderingHint  = TextRenderingHint.AntiAlias;

            g.ScaleTransform(scalar, scalar);

            try {
                Map?.Draw(g);

                DrawWhite?.Invoke(g);
                Blast.DrawAll(g);
                DrawTail?.Invoke(g);
                DrawBullet?.Invoke(g);
                DrawHead?.Invoke(g);

                DrawKeys?.Invoke(g);
                DrawAnimation?.Invoke(g);

                if (ActiveKeys.Contains(Leader))
                {
                    Map.DrawCrown(g);
                }

                MVP.Draw(g);
            } catch (Exception) { }
        }
Exemplo n.º 2
0
        protected override async Task KillStealAsync(CancellationToken token)
        {
            if (Game.IsPaused || !this.Owner.IsAlive || !AbilityExtensions.CanBeCasted(this.Blast))
            {
                await Task.Delay(125, token);

                return;
            }

            var damageBlast = Blast.GetAbilitySpecialData("blast_damage");

            damageBlast *= Ensage.SDK.Extensions.UnitExtensions.GetSpellAmplification(this.Owner);

            bool comboMana = Blast.GetManaCost(Blast.Level - 1) + Decrepify.GetManaCost(Decrepify.Level - 1) <
                             Owner.Mana;

            var decrepifyKillable =
                EntityManager <Hero> .Entities.FirstOrDefault(
                    x =>
                    x.IsAlive && x.Team != this.Owner.Team && !x.IsIllusion &&
                    x.Health < damageBlast *(1 - x.MagicDamageResist) &&
                    Blast != null && Blast.IsValid && x.Distance2D(this.Owner) <= 900 &&
                    Ensage.Common.Extensions.AbilityExtensions.CanBeCasted(Decrepify, x) && Ensage.Common.Extensions.AbilityExtensions.CanBeCasted(Blast, x) &&
                    !UnitExtensions.IsMagicImmune(x) && comboMana);

            var blastKillable =
                EntityManager <Hero> .Entities.FirstOrDefault(
                    x =>
                    x.IsAlive && x.Team != this.Owner.Team && !x.IsIllusion &&
                    x.Health < damageBlast *(1 - x.MagicDamageResist) &&
                    Ensage.Common.Extensions.AbilityExtensions.CanBeCasted(Blast, x) && !UnitExtensions.IsMagicImmune(x) && Blast.CanHit(x) &&
                    Ensage.SDK.Extensions.EntityExtensions.Distance2D(Owner, x.NetworkPosition) <= 800);

            if (!UnitExtensions.IsChanneling(this.Owner))
            {
                if (decrepifyKillable != null)
                {
                    if (Decrepify.UseAbility(decrepifyKillable))
                    {
                        await this.AwaitKillstealDelay((int)AbilityExtensions.GetCastDelay(this.Decrepify, this.Owner, decrepifyKillable, true), token); // decrepify
                    }

                    if (Blast.CanHit(decrepifyKillable))
                    {
                        if (Blast.UseAbility(decrepifyKillable))
                        {
                            await this.AwaitKillstealDelay((int)AbilityExtensions.GetCastDelay(this.Blast, this.Owner, decrepifyKillable, true), token);
                        }
                    }
                }

                if (blastKillable != null)
                {
                    if (Blast.UseAbility(blastKillable.NetworkPosition))
                    {
                        await this.AwaitKillstealDelay((int)AbilityExtensions.GetCastDelay(this.Blast, this.Owner, blastKillable, true), token);
                    }
                }
            }
        }
Exemplo n.º 3
0
            public static bool Prefix(Blast __instance, ref List <Hitbox> ___cachedHitBox)
            {
                if (!__instance.OwnerCharacter || __instance.OwnerCharacter.IsAI || !PvP.Instance.FriendlyFireEnabled)
                {
                    return(true);
                }

                Collider[] array = Physics.OverlapSphere(__instance.transform.position, __instance.Radius, Global.WeaponHittingMask);

                List <Character> list = new List <Character>();

                ___cachedHitBox.Clear();

                for (int i = 0; i < array.Length; i++)
                {
                    Hitbox component = array[i].GetComponent <Hitbox>();
                    if (component != null &&
                        component.OwnerChar != null &&
                        component.OwnerChar.UID != __instance.OwnerCharacter.UID &&
                        !component.BlockBox &&
                        !list.Contains(component.OwnerChar))
                    //&& __instance.m_targetableFactions.Contains(component.OwnerChar.Faction)
                    //&& (!__instance.IgnoreShooter || component.OwnerChar != __instance.OwnerCharacter))
                    {
                        ___cachedHitBox.Add(component);
                        list.Add(component.OwnerChar);
                    }
                }

                //__instance.AffectHit(___cachedHitBox);
                At.Call(typeof(Blast), __instance, "AffectHit", null, ___cachedHitBox);

                return(false);
            }
Exemplo n.º 4
0
        public IHttpActionResult CreateNewBlast([FromBody] BlastCreateBindingModel model)
        {
            if (model == null)
            {
                return(this.BadRequest());
            }

            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            var user = this.Data.Users.Find(this.User.Identity.GetUserId());

            var newBlast = new Blast
            {
                AuthorId  = user.Id,
                Content   = model.Content,
                PostedOn  = DateTime.Now,
                BlastType = model.BlastType
            };

            this.Data.Blasts.Add(newBlast);
            this.Data.SaveChanges();

            var blastToReturn = Mapper.Map <BlastViewModel>(newBlast);

            blastToReturn.IsMine = true;

            return(Ok(blastToReturn));
        }
Exemplo n.º 5
0
        // [InlineData("apache-license.html.blast")]
        public void decompress_test_files(string compressedSourceFile)
        {
            // setup
            var    baseFolder         = GetTestFileFolder();
            string expectedOutputFile = Path.GetFileNameWithoutExtension(compressedSourceFile);

            string compressedSourceFilePath = Path.Combine(baseFolder, compressedSourceFile);
            string expectedOutputFilePath   = Path.Combine(baseFolder, expectedOutputFile);
            string actualOutputFilePath     = Path.Combine(baseFolder, ".output", expectedOutputFile);

            Directory.CreateDirectory(Path.GetDirectoryName(actualOutputFilePath));

            using (var input = new FileStream(compressedSourceFilePath, FileMode.Open, FileAccess.Read))
                using (var output = new FileStream(actualOutputFilePath, FileMode.Create, FileAccess.Write))
                {
                    // test
                    var b = new Blast(input, output);
                    b.Decompress();

                    output.Flush();
                }

            // assert
            AssertFile(expectedOutputFilePath, actualOutputFilePath);
        }
Exemplo n.º 6
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Blast")
        {
            Blast blast = collision.gameObject.GetComponent <Blast>();
            float score = blast.power;
            switch (blast.blastMode)
            {
            case BlastManager.BlastMode.Green:
                planetManager.AddStat(0, score, 0, 0);
                break;

            case BlastManager.BlastMode.Water:
                planetManager.AddStat(score, 0, 0, 0);
                break;

            case BlastManager.BlastMode.Earth:
                planetManager.AddStat(0, 0, score, 0);
                break;

            case BlastManager.BlastMode.Hot:
                planetManager.AddStat(0, 0, 0, score);
                break;
            }
            Destroy(blast.gameObject);
        }
    }
Exemplo n.º 7
0
        /// <summary>
        /// Sets the controls properties to the values in the given command.
        /// </summary>
        /// <param name="command">The command, if null is passed, the UI is cleared.</param>
        private void ShowCommandDetails(Command command)
        {
            if (command == null)
            {
                tbName.Text          = "";
                iIcon.Source         = null;
                tbNoImage.Visibility = Visibility.Hidden;
                return;
            }

            tbName.Text = command.Name;
            MadCatzProfile profile = presenter.ActiveProfile;
            Blast          blast   = profile.Blasts.GetBlastForCommand(command);

            if (blast != null)
            {
                iIcon.Source         = ImageHelper.CreateImage(blast.GetData());
                tbNoImage.Visibility = Visibility.Hidden;
                iIcon.Visibility     = Visibility.Visible;
            }
            else
            {
                tbNoImage.Visibility = Visibility.Visible;
                iIcon.Visibility     = Visibility.Hidden;
            }
        }
Exemplo n.º 8
0
        public void HitEnemy()
        {
            ViewModel vm = new ViewModel();

            vm.Ship.X = 300;
            vm.Ship.Y = 300;

            Enemy0 enemy = new Enemy0(300, 0);

            vm.AddEnemy(enemy);

            vm.KeyDown(Windows.System.VirtualKey.Space);
            vm.Tick(1);
            Bullet bullet = (Bullet)vm.Bullets[0];

            int nFrame = (int)((bullet.Y - (enemy.Y + enemy.Height))
                               / (enemy.SpeedY - bullet.SpeedY));

            vm.Tick(nFrame + 1);

            Assert.IsFalse(enemy.IsValid);
            Assert.IsFalse(bullet.IsValid);
            Assert.AreEqual(1, vm.Blasts.Count);

            Blast blast = (Blast)vm.Blasts[0];

            Assert.AreEqual(bullet.X + bullet.Width / 2, blast.X + blast.Width / 2);
            Assert.AreEqual(bullet.Y + bullet.Height / 2, blast.Y + blast.Height / 2);

            vm.Tick(10);
            Assert.AreEqual(0, vm.Blasts.Count);
        }
Exemplo n.º 9
0
 public void SetData(TowerData data)
 {
     this.data           = data;
     interval            = data.Interval;
     damage              = data.Damage;
     simultaneousTargets = data.SimultaneousTargets;
     blastPrefab         = data.BlastPrefab;
 }
Exemplo n.º 10
0
    IEnumerator StartWait()
    {
        yield return(StartCoroutine(Wait(1.50F)));

        Spark.SetActive(false);
        Cyclone.SetActive(false);
        Blast.SetActive(false);
    }
Exemplo n.º 11
0
        public void ChangeCommandIcon(MadCatzProfile profile, Command command, Blast blast)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            command.SetIcon(blast);
            profileInfos[profile].Edited = true;
        }
Exemplo n.º 12
0
        public void RemoveIcon(MadCatzProfile profile, Blast blast)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            profile.Blasts.Remove(blast);
            profileInfos[profile].Edited = true;
        }
Exemplo n.º 13
0
 // Use this for initialization
 void Awake()
 {
     _state      = GetComponent <DuckState>();
     _health     = GetComponent <Health>();
     _data       = _state.Data;
     _carrier    = GetComponentInChildren <Carrier>();
     _blast      = GetComponentInChildren <Blast>();
     _body       = GetComponent <MovableBody>();
     _flyControl = GetComponent <FlyControl>();
 }
Exemplo n.º 14
0
 /// <summary>
 /// Sets the icon associated with this command.
 /// </summary>
 /// <param name="blast">The blast containing the icon data or null to specify that no icon is associated.</param>
 public void SetIcon(Blast blast)
 {
     if (blast == null)
     {
         iconUuid = Guid.Empty;
     }
     else
     {
         iconUuid = blast.Uuid;
     }
 }
Exemplo n.º 15
0
        public void AddIcon(MadCatzProfile profile, byte[] pngData)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            var blast = new Blast(pngData);

            profile.Blasts.Add(blast);
            profileInfos[profile].Edited = true;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Shows a selection dialog for the given blasts.
        /// </summary>
        /// <param name="options">The blasts the user can select from.</param>
        /// <param name="selected">The initially selected blast.</param>
        /// <returns>An instance of ChooseIconWindowResult representing the dialogs result.</returns>
        public static ChooseIconWindowResult ShowDialog(IList <Blast> options, Blast selected)
        {
            var window = new ChooseIconWindow(options, selected);

            window.ShowDialog();
            Blast        sel     = null;
            ListViewItem selItem = (ListViewItem)window.lvBlasts.SelectedItem;

            if (selItem.Tag != null)
            {
                sel = (Blast)selItem.Tag;
            }
            return(new ChooseIconWindowResult(!window.success, sel));
        }
Exemplo n.º 17
0
        public Stream GetStream(string filename)
        {
            Entry e;

            if (!index.TryGetValue(filename, out e))
            {
                return(null);
            }

            s.Seek(dataStart + e.Offset, SeekOrigin.Begin);
            var data = s.ReadBytes((int)e.Length);

            return(new MemoryStream(Blast.Decompress(data)));
        }
Exemplo n.º 18
0
        public Stream GetContent(uint hash)
        {
            PackageEntry e;

            if (!index.TryGetValue(hash, out e))
            {
                return(null);
            }

            s.Seek(dataStart + e.Offset, SeekOrigin.Begin);
            var data = s.ReadBytes((int)e.Length);

            return(new MemoryStream(Blast.Decompress(data)));
        }
Exemplo n.º 19
0
            public Stream GetStream(string filename)
            {
                if (!index.TryGetValue(filename, out var e))
                {
                    return(null);
                }

                s.Seek(dataStart + e.Offset, SeekOrigin.Begin);

                var ret = new MemoryStream();

                Blast.Decompress(s, ret);
                ret.Seek(0, SeekOrigin.Begin);

                return(ret);
            }
Exemplo n.º 20
0
    // === Attack ===
    void attack()
    {
        if (inp_attack)
        {
            int     dirOffset = 1 * (facingRight ? 1 : -1);
            Vector2 pos       = new Vector2(this.transform.position.x + dirOffset, this.transform.position.y);

            Blast blast = Instantiate(oAttack, pos, Quaternion.identity).GetComponent <Blast>();

            if (!facingRight)    // Flip shot to match player
            {
                Vector3 newScale = blast.GetComponent <Transform>().localScale;
                newScale.x *= -1;
                blast.GetComponent <Transform>().localScale = newScale;
            }
        }
    }
Exemplo n.º 21
0
    void Start()
    {
        controller = GetComponent <PlayerController> ();

        if (GameManager.maxLevelReached > 0)
        {
            abilities |= Ability.DESOLIDIFY;
        }
        if (GameManager.maxLevelReached > 1)
        {
            abilities |= Ability.POSSESS;
        }
        if (GameManager.maxLevelReached > 2)
        {
            abilities |= Ability.INVISIBILITY;
        }
        if (GameManager.maxLevelReached > 3)
        {
            abilities |= Ability.BLAST;
        }
        if (GameManager.maxLevelReached > 4)
        {
            abilities |= Ability.FOCUSED_BLAST;
        }

        if ((abilities & Ability.DESOLIDIFY) != 0)
        {
            gameObject.layer = 9;
        }
        else
        {
            gameObject.layer = 12;
        }

        hold         = GetComponent <Hold> ();
        possess      = GetComponent <Possess> ();
        invisible    = GetComponent <Invisible> ();
        blast        = GetComponent <Blast> ();
        focusedBlast = GetComponent <FocusedBlast> ();

        hold.pc         = controller;
        possess.pc      = controller;
        invisible.pc    = controller;
        blast.pc        = controller;
        focusedBlast.pc = controller;
    }
Exemplo n.º 22
0
        public void basic_decompression_from_example()
        {
            // setup
            byte[] compressedInput = { 0x00, 0x04, 0x82, 0x24, 0x25, 0x8f, 0x80, 0x7f };
            byte[] expectedResult  = Encoding.ASCII.GetBytes("AIAIAIAIAIAIA");

            var actualOutput = new MemoryStream();

            // test
            var sut = new Blast(new MemoryStream(compressedInput, writable: false), actualOutput);

            sut.Decompress();

            byte[] actualResult = actualOutput.ToArray();

            // assert
            actualResult.ShouldBe(expectedResult);
        }
Exemplo n.º 23
0
    void Start()
    {
        animator = this.GetComponent <Animator>();

        path = GetComponentInParent <CharacterPath>().path;

        blastGO = Instantiate(BlastPrefab, transform);
        _blast  = blastGO.AddComponent(typeof(Blast)) as Blast;
        blastGO.SetActive(false);
        nextPoint = Mathf.RoundToInt(Random.Range(0f, path.Length - 1));
        _isoTransform.Position = path[nextPoint];


        if (infected)
        {
            this.Infect(true);
        }
    }
Exemplo n.º 24
0
        public void Stage3()
        {
            // introduce blast
            text = "Blasts will pop when eaten\nUse them to pick up any balls\ninside its range";
            Head player = HEADS[key_player];

            player.act = Activities.DEFAULT;
            player.pos = new IPoint(W * .6d, W * .19d);
            player.v   = speed * IVector.Left;

            bot.INACTIVE = bot1.INACTIVE = true;
            bot.pos      = bot1.pos = new IPoint(0, -HeadR * 2);

            Blast blast = new Blast();

            blast.pos = new IPoint(W * .8f, W * .19d);
            Blast.All.Add(blast);

            new Thread(() => {
                Thread.CurrentThread.Name = "Blast_Animation";
                int starttick             = Tick;
                new Animation(blast.pos, 30, BlastR, BlastRange / 5f, 5 * Scale, 10 * Scale, Color.White, Color.Yellow, AnimationTypes.SIN);
                SpinWait.SpinUntil(() => Tick >= starttick + 30 || !ApplicationRunning);
                new Animation(blast.pos, 10, BlastRange / 5f, BlastR, 10 * Scale, Scale, Color.Yellow, Color.Yellow, AnimationTypes.COS);
                SpinWait.SpinUntil(() => Tick >= starttick + 50 || !ApplicationRunning);
                new Animation(blast.pos, 30, BlastR, BlastRange, 5 * Scale, 5 * Scale, Color.White, Color.White, AnimationTypes.SQRT);
            }).Start();

            List <IPoint> ps = new List <IPoint>()
            {
                new IPoint(W * .79d, W * .14d),
                new IPoint(W * .7d, W * .24d),
                new IPoint(W * .94d, W * .22d),
                new IPoint(W * .7d, W * .1d),
                new IPoint(W * .87d, W * .32d),
                new IPoint(W * .82d, W * .4d)
            };

            lock (Orb.OrbLock) foreach (IPoint p in ps)
                {
                    new Orb().pos = p;
                }
        }
Exemplo n.º 25
0
    public void Shoot(int diretion, GameController gc)
    {
        var direction = new Vector3(diretion, 0, 0);
        var left      = new Blast
        {
            velocity = direction,
            position = puppet.position + direction * 1.5f + new Vector3(0, 0.5f, 0)
        };

        gc.SpawnEntity(left, "Blast");

        var right = new Blast
        {
            velocity = direction,
            position = puppet.position + direction * 1.5f + new Vector3(0, -0.5f, 0)
        };

        gc.SpawnEntity(right, "Blast");
    }
Exemplo n.º 26
0
 // Update is called once per frame
 void Update()
 {
     if (Screen.lockCursor && Input.GetMouseButtonDown(0))
     {
         GameObject go    = GameObjectPool.Instance.Spawn(Spell1, shootPosition.position, shootPosition.rotation);
         Blast      blast = go.GetComponent <Blast>();
         blast.reset();
         if (towardsMouse)
         {
             blast.SetDirection((targetPosition.position - shootPosition.position).normalized);
         }
         else
         {
             blast.SetDirection(shootPosition.forward);
         }
         blast.poolName = Spell1;
         blast.SetDamage(10);
     }
 }
Exemplo n.º 27
0
        public void ExtractIconRequested(Blast blast)
        {
            if (blast == null)
            {
                throw new ArgumentNullException("blast");
            }

            FileInfo saveFile = view.SelectImageSaveFile();

            if (saveFile == null)
            {
                return;
            }

            switch (saveFile.Extension.ToUpperInvariant())
            {
            case ".BMP":
                SaveToFile(saveFile, blast, new BmpBitmapEncoder());
                break;

            case ".GIF":
                SaveToFile(saveFile, blast, new GifBitmapEncoder());
                break;

            case ".JPEG":
            case ".JPG":
                SaveToFile(saveFile, blast, new JpegBitmapEncoder());
                break;

            case ".PNG":
                SaveToFile(saveFile, blast.GetData());
                break;

            case ".TIF":
            case ".TIFF":
                SaveToFile(saveFile, blast, new TiffBitmapEncoder());
                break;

            default:
                mainPresenter.ForwardError((string)Application.Current.FindResource(ERROR_MESSAGE_INVALID_IMAGE_FORMAT));
                break;
            }
        }
Exemplo n.º 28
0
        private ChooseIconWindow(IList <Blast> options, Blast selected)
        {
            InitializeComponent();

            foreach (Blast blast in options)
            {
                var imageControl = ImageHelper.CreateImageControl(blast.GetData());
                var grid         = new Grid();
                grid.Children.Add(imageControl);
                var item = new ListViewItem();
                item.Content = grid;
                item.Tag     = blast;
                lvBlasts.Items.Add(item);

                if (blast == selected)
                {
                    lvBlasts.SelectedItem = item;
                }
            }
        }
Exemplo n.º 29
0
        public void Stage4()
        {
            // introduce the orbits
            // use Maps.STANDARD from now on
            text  = "When you're inside an orbit,\npress to go in orbit\npress again to go straight again";
            point = new PointF(.367f * W, .4f * W);

            SyncUpdate = false;
            if (Orbits == Empty)
            {
                Orbits = Standard;
            }
            SyncUpdate = true;

            Head player = HEADS[key_player];

            player.act = Activities.DEFAULT;
            player.pos = new IPoint(W * .45d, W * .45d);
            player.v   = IVector.Up;

            bot.INACTIVE = bot1.INACTIVE = true;
            bot.pos      = bot1.pos = new IPoint(0, -HeadR * 2);

            Blast blast = new Blast();

            blast.pos = new IPoint(W * .15d, W * .18d);
            Blast.All.Add(blast);

            List <IPoint> ps = new List <IPoint>()
            {
                new IPoint(W * .07d, W * .07d),
                new IPoint(W * .93d, W * .43d),
                new IPoint(W * .07d, W * .43d),
                new IPoint(W * .93d, W * .07d)
            };

            lock (Orb.OrbLock) foreach (IPoint p in ps)
                {
                    new Orb().pos = p;
                }
        }
Exemplo n.º 30
0
        public virtual async Task KillStealAsync()
        {
            var damageBlast = Blast.GetAbilityData("blast_damage");

            damageBlast *= GetSpellAmp();

            bool comboMana = Blast.GetManaCost(Blast.Level - 1) + Decrepify.GetManaCost(Decrepify.Level - 1) <
                             Owner.Mana;

            var decrepifyKillable =
                EntityManager <Hero> .Entities.FirstOrDefault(
                    x =>
                    x.IsAlive && x.Team != this.Owner.Team && !x.IsIllusion &&
                    x.Health < damageBlast *(1 - x.MagicDamageResist) &&
                    Decrepify.CanBeCasted(x) && Blast.CanBeCasted() &&
                    !UnitExtensions.IsMagicImmune(x) && comboMana);

            var blastKillable =
                EntityManager <Hero> .Entities.FirstOrDefault(
                    x =>
                    x.IsAlive && x.Team != this.Owner.Team && !x.IsIllusion &&
                    x.Health < damageBlast *(1 - x.MagicDamageResist) &&
                    Blast.CanBeCasted() && !UnitExtensions.IsMagicImmune(x) &&
                    Ensage.SDK.Extensions.EntityExtensions.Distance2D(Owner, x.NetworkPosition) <= 400);

            if (decrepifyKillable != null)
            {
                Decrepify.UseAbility(decrepifyKillable);
                await Await.Delay(GetAbilityDelay(decrepifyKillable, Decrepify));

                Blast.UseAbility(decrepifyKillable);
                await Await.Delay(GetAbilityDelay(decrepifyKillable, Decrepify));
            }

            if (blastKillable != null)
            {
                Blast.UseAbility(blastKillable.NetworkPosition);
                await Await.Delay(GetAbilityDelay(blastKillable, Blast));
            }
        }
Exemplo n.º 31
0
        public void StartWorkflow()
        {
            //--------------------------------------------------------------------------------------------------------------

            RaiseProgress("Initializing...", 0);
            /* internal program stuff
             * creating all necessary strings */

            Blast blastObject = new Blast();
            allIDs allIDsObject = new allIDs();

            string path_wholeOutput = _storageLocationPath + "NOmESS_Output\\";
            string path_temporaryWorkingDirectory = path_wholeOutput + "temp\\";
            string path_step1 = path_wholeOutput + "Step 1\\";
            string path_step2 = path_wholeOutput + "Step 2\\";
            string path_step3 = path_wholeOutput + "Step 3\\";
            string path_step4 = path_wholeOutput + "Step 4\\";
            string path_finalOutput = path_wholeOutput + "Final_Output\\";
            string path_sortedDictionaryFiles_step2 = path_step2 + "SortedDictionaryFiles_Step2\\";
            string path_sortedDictionaryFiles_step3 = path_step3 + "SortedDictionaryFiles_Step3\\";
            string path_allSequenceFilesHomologName = path_finalOutput + "allSequences_filename=scaffoldID\\";

            //create all needed folders
            Directory.CreateDirectory(path_wholeOutput);
            Directory.CreateDirectory(path_temporaryWorkingDirectory);
            Directory.CreateDirectory(path_step1);
            Directory.CreateDirectory(path_step2);
            Directory.CreateDirectory(path_step3);
            Directory.CreateDirectory(path_step4);
            Directory.CreateDirectory(path_sortedDictionaryFiles_step2);
            Directory.CreateDirectory(path_sortedDictionaryFiles_step3);

            /*copy the executable files into the working directory
             * --> blastp.exe and makeblastdb.exe
             * --> cd-hit.exe */
            File.Copy(_blastPath + "blastp.exe", path_temporaryWorkingDirectory + "blastp.exe", true);
            File.Copy(_blastPath + "makeblastdb.exe", path_temporaryWorkingDirectory + "makeblastdb.exe", true);
            File.Copy(_cdHitPath + "cd_hit.exe", path_temporaryWorkingDirectory + "cd-hit.exe", true);

            /*print settings in a file
             */
            StreamWriter writer = new StreamWriter(path_wholeOutput + "used_settings.txt");

            writer.WriteLine("Required parameters");
            writer.WriteLine();
            writer.WriteLine("Storage location\t" + _storageLocationPath);
            writer.WriteLine("Blastp\t" + _blastPath);
            writer.WriteLine("Cd-hit\t" + _cdHitPath);
            writer.WriteLine("Input set\t" + _inputSetPath);
            writer.WriteLine("Scaffold set\t" + _scaffoldSetPath);
            writer.WriteLine(); writer.WriteLine(); writer.WriteLine(); writer.WriteLine(); writer.WriteLine();

            writer.WriteLine("Optional parameters");
            writer.WriteLine();
            writer.WriteLine("ID prefixes");
            writer.WriteLine("Prefix step 1\t" + _prefixNewId1);
            writer.WriteLine("Prefix step 2\t" + _prefixNewId2);
            writer.WriteLine("Prefix step 3\t" + _prefixNewId3);
            writer.WriteLine("Prefix step 4\t" + _prefixNewId4);
            writer.WriteLine();

            writer.WriteLine("Preprocessing");
            writer.WriteLine("Preprocessing ( step 1 )\t" + _preprocessing);
            writer.WriteLine("Non amino acid characters\t" + _noAaMotiv);
            writer.WriteLine("Minimal sequence length\t" + _minimalSeqLength);
            writer.WriteLine();

            writer.WriteLine("Identity thresholds (cd-hit)");
            writer.WriteLine("Scaffold set\t" + _cS);
            writer.WriteLine("Step 1\t" + _c1);
            writer.WriteLine("Step 2\t" + _c2);
            writer.WriteLine("Step 3\t" + _c3);
            writer.WriteLine();

            writer.WriteLine("Homology thresholds (blastp)");
            writer.WriteLine("Step 2: percentage identity\t" + _percentageIdentity2);
            writer.WriteLine("Step 2: e-value\t" + _eValue2);
            writer.WriteLine("Step 2: bit score\t" + _bitScore2);
            writer.WriteLine("Step 2: query length\t" + _queryLength2);
            writer.WriteLine("Step 2: alignment length\t" + _alignmentLength2);
            writer.WriteLine("Step 3: percentage identity\t" + _percentageIdentity3);
            writer.WriteLine("Step 3: e-value\t" + _eValue3);
            writer.WriteLine("Step 3: bit score\t" + _bitScore3);
            writer.WriteLine("Step 3: query length\t" + _queryLength3);
            writer.WriteLine("Step 3: alignment length\t" + _alignmentLength3);
            writer.WriteLine("Step 4: percentage identity\t" + _percentageIdentity4);
            writer.WriteLine("Step 4: e-value\t" + _eValue4);
            writer.WriteLine("Step 4: bit score\t" + _bitScore4);
            writer.WriteLine("Step 4: query length\t" + _queryLength4);
            writer.WriteLine("Step 4: alignment length\t" + _alignmentLength4);

            writer.Close();

            /*use cd-hit for reducing sequences of homologous database --> 0.95 percentage identity
             *                                                         --> copy homologous database into working directory
             *                                                         --> copy output file in storage location */
            String ids_scaffold = path_wholeOutput + "IDs_scaffoldOrganism.txt";
            Dictionary<String, String> oldDatabase = Database.GetDictionary(_scaffoldSetPath);
            Database.CreateInternalScaffoldId(oldDatabase, ">scaffold_", path_temporaryWorkingDirectory + "scaffoldSet.fasta", ids_scaffold);

            CdHitCall(path_temporaryWorkingDirectory, "scaffoldSet.fasta", "scaffoldSet-Cl.fasta", _cS);
            File.Copy(path_temporaryWorkingDirectory + "scaffoldSet-Cl.fasta", path_wholeOutput + "scaffoldSet-Cl.fasta", true);
            string scaffoldSet = _storageLocationPath + "scaffoldSet-Cl.fasta";
            File.Delete(path_temporaryWorkingDirectory + "scaffoldSet.fasta");

            /*preprocessing / step 0 --> cut the sequences containing non aa characters before and after those
             *                       --> check if sequence longer than given minimal length */
            string database_step1 = path_step1 + "STEP1.fasta";
            string ids_step1 = path_step1 + "IDs_Step1.txt";

            if (_preprocessing)
            {
            RaiseProgress("Step 1: Preprocessing...", 5);
                Database.Preprocessing(_inputSetPath, database_step1, ids_step1, _noAaMotiv, _minimalSeqLength, _prefixNewId1);
            }
            else
            {
                Dictionary<String, String> oldInputDatabase = Database.GetDictionary(_inputSetPath);
                Database.CreateInternalScaffoldId(oldInputDatabase, _prefixNewId1, database_step1, ids_step1);
            }

            /*use cd-hit for reducing sequences of database_step1 --> 1.0 percentage identity
             *                                                    --> copy database_step1 into working directory
             *                                                    --> copy output file in Output_Step0 */
            File.Copy(database_step1, path_temporaryWorkingDirectory + "STEP1.fasta", true);
            CdHitCall(path_temporaryWorkingDirectory, "STEP1.fasta", "STEP1-Cl.fasta",_c1);

            File.Copy(path_temporaryWorkingDirectory + "STEP1-Cl.fasta", path_step1 + "STEP1-Cl.fasta", true);

            RaiseProgress("Step 2: Fragment grouping...", 15);
            /*first blast --> copy homologous database into working directory
             *            --> use makeblastdb.exe and blastp.exe
                          --> copy blast output into Output_Step1 */
            Process proc_MakeDB = new Process();
            proc_MakeDB.StartInfo.WorkingDirectory = @path_temporaryWorkingDirectory;
            proc_MakeDB.StartInfo.FileName = _blastPath + "makeblastdb.exe";
            proc_MakeDB.StartInfo.Arguments = "-in scaffoldSet-Cl.fasta -out scaffoldDatabase";
            proc_MakeDB.StartInfo.UseShellExecute = true;
            proc_MakeDB.StartInfo.RedirectStandardError = false;
            proc_MakeDB.Start();
            proc_MakeDB.WaitForExit();
            proc_MakeDB.Close();

            BlastCall(path_temporaryWorkingDirectory, "STEP1-Cl.fasta", "blastForStep2.txt");

            File.Copy(path_temporaryWorkingDirectory + "blastForStep2.txt", path_step2 + "blastForStep2.txt", true);
            File.Delete(path_temporaryWorkingDirectory + "STEP1.fasta");
            File.Delete(path_temporaryWorkingDirectory + "blastForStep2.txt");

            /*step 1 --> sequence assembly */
            string blastOutput_step2 = path_step2 + "blastForStep2.txt";
            string database_step2 = path_step2 + "STEP2.fasta";
            string ids_step2 = path_step2 + "IDs_Step2.txt";
            string sortedList_step2 = path_step2 + "sortedLists_Step2.txt";
            string restSequences_step2 = path_step2 + "restSequencePieces_Step2.fasta";
            string blastDictionary_step2 = path_step2 + "BlastDictionary_Step2.txt";
            string notTakenSequences_step2 = path_step2 + "SNT2.fasta";
            string seqsWithoutScaffoldPath = path_step2 + "SWS.fasta";
            Boolean printSWS = true;

            RaiseProgress("Step 2: Assembly...", 15);
            blastObject.CreateNonRedundantDatabase_step2(blastOutput_step2, scaffoldSet, path_step1 + "STEP1-Cl.fasta", database_step2, ids_step2, sortedList_step2, restSequences_step2, blastDictionary_step2, path_sortedDictionaryFiles_step2, notTakenSequences_step2, _percentageIdentity2, _eValue2, _bitScore2, _queryLength2, _alignmentLength2, _prefixNewId2, seqsWithoutScaffoldPath, printSWS);

            /*use cd-hit for reducing sequences of database_step2 --> 0.95 percentage identity
             *                                                    --> copy database_step2 into working directory
             *                                                    --> copy output file in Output_Step1 */
            File.Copy(database_step2, path_temporaryWorkingDirectory + "STEP2.fasta", true);
            CdHitCall(path_temporaryWorkingDirectory, "STEP2.fasta", "STEP2-Cl.fasta", _c2);

            File.Copy(path_temporaryWorkingDirectory + "STEP2-Cl.fasta", path_step2 + "STEP2-Cl.fasta", true);
            File.Delete(path_temporaryWorkingDirectory + "STEP2.fasta");

            RaiseProgress("Step 3: Fragment grouping...", 55);
            /*second blast --> use blastp.exe
                           --> copy blast output into Output_Step2 */
            BlastCall(path_temporaryWorkingDirectory, "STEP2-Cl.fasta", "blastForStep3.txt");

            File.Copy(path_temporaryWorkingDirectory + "blastForStep3.txt", path_step3 + "blastForStep3.txt", true);
            File.Delete(path_temporaryWorkingDirectory + "STEP2-Cl.fasta");
            File.Delete(path_temporaryWorkingDirectory + "blastForStep3.txt");

            /* step 2 --> concatenation of non-overlapping sequence pieces */
            string blastOutput_step3 = path_step3 + "blastForStep3.txt";
            string database_step3 = path_step3 + "STEP3.fasta";
            string ids_step3 = path_step3 + "IDs_Step3.txt";
            string sortedList_step3 = path_step3 + "sortedLists_Step3.txt";
            string blastDictionary_step3 = path_step3 + "BlastDictionary_Step3.txt";
            string notTakenSequences_step3 = path_step3 + "SNT3.fasta";

            RaiseProgress("Step 3: Concatenation...", 55);
            blastObject.CreateNonRedundantDatabase_step3(blastOutput_step3, path_step2 + "STEP2-Cl.fasta", database_step3, ids_step3, sortedList_step3, path_sortedDictionaryFiles_step3, blastDictionary_step3, notTakenSequences_step3, _percentageIdentity3, _eValue3, _bitScore3, _queryLength3, _alignmentLength3, _prefixNewId3);

            /*use cd-hit for reducing sequences of database_step3 --> 0.95 percentage identity
             *                                                    --> copy database_step3 into working directory
             *                                                    --> copy output file in Output_Step2 */
            File.Copy(database_step3, path_temporaryWorkingDirectory + "STEP3.fasta", true);
            CdHitCall(path_temporaryWorkingDirectory, "STEP3.fasta", "STEP3-Cl.fasta", _c3);

            File.Copy(path_temporaryWorkingDirectory + "STEP3-Cl.fasta", path_step3 + "STEP3-Cl.fasta", true);
            File.Delete(path_temporaryWorkingDirectory + "STEP3.fasta");

            RaiseProgress("Step 4: Fragment grouping...", 80);
            /*third blast --> use blastp.exe
                          --> copy blast output into Output_Step3 */
            BlastCall(path_temporaryWorkingDirectory, "STEP3-Cl.fasta", "blastForStep4.txt");

            File.Copy(path_temporaryWorkingDirectory + "blastForStep4.txt", path_step4 + "blastForStep4.txt", true);

            /*step 3 --> take longest representant for each homologous protein */
            string blastOutput_step4 = path_step4 + "blastForStep4.txt";
            string ids_step4 = path_step4 + "IDs_Step4.txt";
            string sortedList_step4 = path_step4 + "sortedLists_Step4.txt";
            string longestSequences_step4 = path_step4 + "STEP4.fasta";
            string shorterSequences_step4 = path_step4 + "shorterSequences_Step4.fasta";
            string blastDictionary_step4 = path_step4 + "BlastDictionary_Step4.txt";
            string notTakenSequences_step4 = path_step4 + "SNT4.fasta";

            RaiseProgress("Step 4: Representative selection...", 80);
            blastObject.CreateNonRedundantDatabase_step4(blastOutput_step4, path_step3 + "STEP3-Cl.fasta", ids_step4, sortedList_step4, longestSequences_step4, shorterSequences_step4, blastDictionary_step4, notTakenSequences_step4, _percentageIdentity4, _eValue4, _bitScore4, _queryLength4, _alignmentLength4, _prefixNewId4);

            //creating file with all IDs and for each homolog sequence all including sequences
            Dictionary<string, List<string>> ids_0 = allIDsObject.GetDict(ids_step1, 0, 1);
            Dictionary<string, List<string>> ids_1 = allIDsObject.GetDict(ids_step2, 0, 2);
            Dictionary<string, List<string>> ids_2 = allIDsObject.GetDict(ids_step3, 0, 2);
            Dictionary<string, List<string>> ids_3 = allIDsObject.GetDict(ids_step4, 0, 1);
            Dictionary<string, List<string>> ids_homo = allIDsObject.GetDict(ids_scaffold, 0, 1);

            Dictionary<string, string> databaseOriginal = Database.GetDictionary(_inputSetPath);
            Dictionary<string, string> databaseAfter0 = Database.GetDictionary(path_step1 + "STEP1-Cl.fasta");
            Dictionary<string, string> databaseAfter1 = Database.GetDictionary(path_step2 + "STEP2-Cl.fasta");
            Dictionary<string, string> databaseAfter2 = Database.GetDictionary(path_step3 + "STEP3-Cl.fasta");
            Dictionary<string, string> databaseAfter3 = Database.GetDictionary(path_step4 + "STEP4.fasta");
            Dictionary<string, string> scaffoldDatabase = Database.GetDictionary(path_wholeOutput + "scaffoldSet-Cl.fasta");

            string idOutputPath = path_wholeOutput + "IDs.txt";
            allIDsObject.createFinalIDOutput(ids_0, ids_1, ids_2, ids_3, ids_homo, databaseOriginal, databaseAfter0, databaseAfter1, databaseAfter2, databaseAfter3, scaffoldDatabase, idOutputPath, path_allSequenceFilesHomologName, 1);

            //copying all interesting files into the output folder
            File.Copy(path_step1 + "STEP1-Cl.fasta", path_wholeOutput + "STEP1-Cl.fasta",true);
            File.Copy(path_step2 + "STEP2.fasta", path_wholeOutput + "STEP2.fasta", true);
            File.Copy(path_step2 + "STEP2-Cl.fasta", path_wholeOutput + "STEP2-Cl.fasta", true);
            File.Copy(path_step3 + "STEP3.fasta", path_wholeOutput + "STEP3.fasta", true);
            File.Copy(path_step3 + "STEP3-Cl.fasta", path_wholeOutput + "STEP3-Cl.fasta", true);
            File.Copy(path_step4 + "STEP4.fasta", path_wholeOutput + "STEP4.fasta", true);
            File.Copy(path_step2 + "SNT2.fasta", path_wholeOutput + "SNT2.fasta", true);
            File.Copy(path_step3 + "SNT3.fasta", path_wholeOutput + "SNT3.fasta", true);
            File.Copy(path_step4 + "SNT4.fasta", path_wholeOutput + "SNT4.fasta", true);
            File.Copy(path_step2 + "SWS.fasta", path_wholeOutput + "SWS.fasta", true);

            //deleting the non necessary files
            Directory.Delete(path_step1, true);
            Directory.Delete(path_step2, true);
            Directory.Delete(path_step3, true);
            Directory.Delete(path_step4, true);
            Directory.Delete(path_wholeOutput + "temp", true);
            File.Delete(path_wholeOutput + "scaffoldSet-Cl.fasta");
            File.Delete(path_wholeOutput + "IDs.txt");
            File.Delete(path_wholeOutput + "IDs_scaffoldOrganism.txt");

            //pop up "Done!" window
            RaiseProgress("Done!", 100);
            Done done = new Done();
            done.ShowDialog();
        }
Exemplo n.º 32
0
 protected override void LoadContent()
 {
     sprite = new SpriteBatch(GraphicsDevice);
     cpu = new CPU(Gm.GraphicsDevice, sprite, mapa);
     atch = new ATch();
     blast = new Blast(Gm.GraphicsDevice, sprite);
     cmap = new createmap(Gm.GraphicsDevice, sprite);
     Tgazo = Content.Load<Texture2D>("Content/sampgame");
     gazo2 = Content.Load<Texture2D>("Content/sampgame2");
     base.LoadContent();
 }