public void CalculateType() { // Sanity check if (SecondAlleleString.IndexOf(',') >= 0 || SecondAlleleString.IndexOf('/') >= 0) { throw new ArgumentException("Variants with multiple ALTs are not allowed (ALT: '" + SecondAlleleString + "')"); } // Remove leading char (we still have some test cases using old TXT format) if (ReferenceAlleleString == "*") { ReferenceAlleleString = ""; } // Possibly some old formatting with +, -, and = if (SecondAlleleString.StartsWith("+")) { // Insertion SecondAlleleString = ReferenceAlleleString + SecondAlleleString.Substring(1); } else if (SecondAlleleString.StartsWith("-")) { // Deletion ReferenceAlleleString = SecondAlleleString.Substring(1); SecondAlleleString = ""; } else if (SecondAlleleString.StartsWith("=")) { // Mixed variant SecondAlleleString = SecondAlleleString.Substring(1); } //--- // Calculate variant type //--- if (ReferenceAlleleString == SecondAlleleString) { VarType = VariantType.INTERVAL; } else if (ReferenceAlleleString.Length == 1 && SecondAlleleString.Length == 1) { VarType = VariantType.SNV; } else if (ReferenceAlleleString.Length == SecondAlleleString.Length) { VarType = VariantType.MNV; } else if (ReferenceAlleleString.Length < SecondAlleleString.Length && SecondAlleleString.StartsWith(ReferenceAlleleString)) { VarType = VariantType.INS; } else if (ReferenceAlleleString.Length > SecondAlleleString.Length && ReferenceAlleleString.StartsWith(SecondAlleleString)) { VarType = VariantType.DEL; } else { VarType = VariantType.MIXED; } //--- // Start and end position // - Start is always the leftmost base // - End is always the rightmost affected base in the ReferenceAlleleStringerence genome //--- if (VarType == VariantType.INS || VarType == VariantType.SNV) { // These changes only affect one position in the reference genome OneBasedEnd = OneBasedStart; } else // if (isDel() || isMnp()) { { // Update 'end' position if (ReferenceAlleleString.Length > 1) { OneBasedEnd = OneBasedStart + ReferenceAlleleString.Length - 1; } } }