internal static (SequenceChange AaChange, int ProteinStart, int ProteinEnd) TryTrimAminoAcidsAndUpdateProteinPositions(SequenceChange aaChange, int proteinStart, int proteinEnd) { (int newStart, string newReference, string newAlternate) = BiDirectionalTrimmer.Trim(proteinStart, aaChange.Reference, aaChange.Alternate); return(string.IsNullOrEmpty(newReference) ? (aaChange, proteinStart, proteinEnd) : (new SequenceChange(newReference, newAlternate), newStart, newStart + newReference.Length - 1)); }
public void Trim(int start, string refAllele, string altAllele, int expectedStart, string expectedRef, string expectedAlt) { (int observedStart, string observedRef, string observedAlt) = BiDirectionalTrimmer.Trim(start, refAllele, altAllele); Assert.Equal(expectedStart, observedStart); Assert.Equal(expectedRef, observedRef); Assert.Equal(expectedAlt, observedAlt); }
public static void Trim(this ISupplementaryDataItem saItem) { if (saItem.RefAllele == null || saItem.AltAllele == null || saItem.Position < 0) { return; } (int start, string refAllele, string altAllele) = BiDirectionalTrimmer.Trim(saItem.Position, saItem.RefAllele, saItem.AltAllele); saItem.Position = start; saItem.RefAllele = refAllele; saItem.AltAllele = altAllele; }
public static void Trim(this ISupplementaryDataItem saItem) { if (saItem.RefAllele == null || saItem.AltAllele == null || saItem.Position < 0) { return; } var newAlleles = BiDirectionalTrimmer.Trim(saItem.Position, saItem.RefAllele, saItem.AltAllele); saItem.Position = newAlleles.Start; saItem.RefAllele = newAlleles.RefAllele; saItem.AltAllele = newAlleles.AltAllele; }
public static IVariant Create(IChromosome chromosome, int start, string refAllele, string altAllele, bool isDecomposedVar, bool isRecomposed) { if (isDecomposedVar && isRecomposed) { throw new InvalidConstraintException("A variant cann't be both decomposed and recomposed"); } (start, refAllele, altAllele) = BiDirectionalTrimmer.Trim(start, refAllele, altAllele); var end = start + refAllele.Length - 1; var variantType = GetVariantType(refAllele, altAllele); var vid = GetVid(chromosome.EnsemblName, start, end, altAllele, variantType); return(new Variant(chromosome, start, end, refAllele, altAllele, variantType, vid, false, isDecomposedVar, isRecomposed, null, null, SmallVariantBehavior)); }
public static void ShiftAndRotateAlleles(ref int start, ref string refAminoAcids, ref string altAminoAcids, string peptideSeq) { var trimmedAlleles = BiDirectionalTrimmer.Trim(start, refAminoAcids, altAminoAcids); start = trimmedAlleles.Start; refAminoAcids = trimmedAlleles.RefAllele; altAminoAcids = trimmedAlleles.AltAllele; var rotatedAlleles = Rotate3Prime(refAminoAcids, altAminoAcids, start, peptideSeq); start = rotatedAlleles.Start; refAminoAcids = rotatedAlleles.RefAminoAcids; altAminoAcids = rotatedAlleles.AltAminoAcids; }
/// <summary> /// Extracts a splice AI item from the specified VCF line. /// </summary> /// <param name="vcfLine"></param> /// <returns></returns> private SpliceAiItem ExtractItem(string vcfLine) { var splitLine = vcfLine.Split('\t'); if (splitLine.Length < VcfCommon.InfoIndex + 1) { return(null); } var chromosomeName = splitLine[VcfCommon.ChromIndex]; if (!_sequenceProvider.RefNameToChromosome.ContainsKey(chromosomeName)) { return(null); } var chromosome = _sequenceProvider.RefNameToChromosome[chromosomeName]; var position = int.Parse(splitLine[VcfCommon.PosIndex]); var refAllele = splitLine[VcfCommon.RefIndex]; var altAllele = splitLine[VcfCommon.AltIndex]; if (altAllele.Contains(',')) { throw new DataException($"multiple alt allele present for {chromosome}-{position}"); } var start = position; //skipping insertions/deletions that were shifted if (VariantUtils.IsLeftShiftPossible(refAllele, altAllele)) { return(null); } (start, refAllele, altAllele) = BiDirectionalTrimmer.Trim(start, refAllele, altAllele); var end = start + refAllele.Length - 1; var isSpliceAdjacent = _spliceIntervals[chromosome.Index].OverlapsAny(start, end); ParseInfoField(splitLine[VcfCommon.InfoIndex]); if (!HasSignificantScore() && !isSpliceAdjacent) { return(null); } Count++; return(new SpliceAiItem(chromosome, start, refAllele, altAllele, _geneSymbol, _acceptorGainScore, _acceptorLossScore, _donorGainScore, _donorLossScore, _acceptorGainPosition, _acceptorLossPosition, _donorGainPosition, _donorLossPosition, isSpliceAdjacent)); }
/// <summary> /// Given a ref and alt allele string, return their trimmed version. /// This method should be decommissioned once VariantAlternateAlleles are used in SA. /// </summary> /// <param name="start"></param> /// <param name="refAllele"> The reference allele string </param> /// <param name="altAllele">The alternate allele string</param> /// <returns>Trimmed position, reference allele and reduced alternate allele as expected by SA</returns> public static Tuple <int, string, string> GetReducedAlleles(int start, string refAllele, string altAllele) { // we have a deletion if (string.IsNullOrEmpty(altAllele)) { return(Tuple.Create(start, refAllele, refAllele.Length.ToString(CultureInfo.InvariantCulture))); } // when we have a supplementary annotation for the ref allele (as in clinVar sometimes), we should not apply any trimming or modification to the alleles. if (refAllele == altAllele) { return(Tuple.Create(start, refAllele, altAllele)); } // When we have a item that is derived from an entry, the alt alleles may have already been processed. We can detect the inserts and deletions and just return without any further processing. For MNVs, we have no way of detecting // we should also avoid any modifications for symbolic allele if (altAllele[0] == 'i' || altAllele[0] == '<' || char.IsDigit(altAllele[0]) || altAllele.All(x => x == 'N')) { return(Tuple.Create(start, refAllele, altAllele)); } var trimmedTuple = BiDirectionalTrimmer.Trim(start, refAllele, altAllele); start = trimmedTuple.Item1; refAllele = trimmedTuple.Item2; altAllele = trimmedTuple.Item3; // we have detected a deletion after trimming if (string.IsNullOrEmpty(altAllele)) { return(Tuple.Create(start, refAllele, refAllele.Length.ToString(CultureInfo.InvariantCulture))); } // we have an insertion and we indicate that with an i at the beginning if (string.IsNullOrEmpty(refAllele)) { return(Tuple.Create(start, refAllele, 'i' + altAllele)); } if (refAllele.Length == altAllele.Length) //SNV or CNV { return(Tuple.Create(start, refAllele, altAllele)); } // its a delins altAllele = refAllele.Length.ToString(CultureInfo.InvariantCulture) + altAllele; return(Tuple.Create(start, refAllele, altAllele)); }
public static IVariant Create(IChromosome chromosome, int start, string refAllele, string altAllele, bool isDecomposedVar, bool isRecomposed, string[] linkedVids) { if (isDecomposedVar && isRecomposed) { throw new InvalidConstraintException("A variant can't be both decomposed and recomposed"); } (start, refAllele, altAllele) = BiDirectionalTrimmer.Trim(start, refAllele, altAllele); int end = start + refAllele.Length - 1; var variantType = GetVariantType(refAllele, altAllele); string vid = GetVid(chromosome.EnsemblName, start, end, altAllele, variantType); var annotationBehavior = variantType == VariantType.non_informative_allele ? AnnotationBehavior.MinimalAnnotationBehavior : AnnotationBehavior.SmallVariantBehavior; return(new Variant(chromosome, start, end, refAllele, altAllele, variantType, vid, false, isDecomposedVar, isRecomposed, linkedVids, null, annotationBehavior)); }
public static (int Start, string RefAllele, string AltAllele) GetReducedAlleles(int start, string refAllele, string altAllele) { // we have a deletion if (refAllele == "-") { refAllele = ""; } if (altAllele == "-") { altAllele = ""; } if (!NeedsReduction(refAllele, altAllele)) { return(start, refAllele, altAllele); } var trimmedTuple = BiDirectionalTrimmer.Trim(start, refAllele, altAllele); start = trimmedTuple.Start; refAllele = trimmedTuple.RefAllele; altAllele = trimmedTuple.AltAllele; // we have detected a deletion after trimming if (string.IsNullOrEmpty(altAllele)) { return(start, refAllele, refAllele.Length.ToString(CultureInfo.InvariantCulture)); } // we have an insertion and we indicate that with an i at the beginning if (string.IsNullOrEmpty(refAllele)) { return(start, refAllele, 'i' + altAllele); } if (refAllele.Length == altAllele.Length) //SNV or CNV { return(start, refAllele, altAllele); } // its a delins altAllele = refAllele.Length.ToString(CultureInfo.InvariantCulture) + altAllele; return(start, refAllele, altAllele); }
public static void ShiftAndRotateAlleles(ref int start, ref string refAminoAcids, ref string altAminoAcids, string peptides) { (start, refAminoAcids, altAminoAcids) = BiDirectionalTrimmer.Trim(start, refAminoAcids, altAminoAcids); (start, refAminoAcids, altAminoAcids) = Rotate3Prime(refAminoAcids, altAminoAcids, start, peptides); }