using System; using System.Collections.Generic; using System.Text; using DNAModule.Sunweaver.Commands.Abstracts; using DNAModule.Sunweaver.DataPrototypes; namespace DNAModule.Sunweaver { public class CoduleTranslocationMutation : AdvancedCoduleMutation { public CoduleTranslocationMutation(int minLength, int maxLength, double probability) : base(minLength, maxLength, probability) { } public CoduleTranslocationMutation() : base() { } public override void mutate(Codule c, int index1, int index2, int length) { //index 1 if (length < 1) { length = 1; } if (index1 + length > c.BasePairs.Count) { index1 = c.BasePairs.Count - length; } if (index1 < 0) { index1 = 0; } if (index1 + length > c.BasePairs.Count) { length = c.BasePairs.Count - index1; } //index 2 if (index2 + length > c.BasePairs.Count) { index2 = c.BasePairs.Count - length; } if (index2 < 0) { index2 = 0; } //mutate List temp = new List(); temp.AddRange(c.BasePairs.GetRange(index1, length)); c.BasePairs.InsertRange(index2, temp); c.BasePairs.RemoveRange(index1, length); } } }