public static void testLevenshteinDistanceCalculatorForNonAlpha() //tests to see that calculator can handle non-alpha values { int actualDistance = 3; // the peptides below have an edit distance of three string stringOne = "LKAEEQAADQVA*QQAVQAIKDKQFVLEADQVI!FKR"; string stringTwo = "LKAEEQAADQVAYQQAVQAIKDKQFVLEADAVIKFKR"; int distanceCalculated = ComputeLevenshteinDistance.LevenshteinDistance(stringOne, stringTwo); Assert.That(distanceCalculated, Is.EqualTo(actualDistance)); }
public static void testLevenshteinDistanceCalculator() // tests to see that calculator is giving correct values { int actualDistance = 1; // the peptides below are one edit distance apart string stringOne = "LKAEEQAADQVAYQQAVQAIKDKQFVLEADQVIFKR"; string stringTwo = "LKAEEQAADQVAYQQAVQAIKDKQFVLEADAVIFKR"; int distanceCalculated = ComputeLevenshteinDistance.LevenshteinDistance(stringOne, stringTwo); Assert.That(distanceCalculated, Is.EqualTo(actualDistance)); }
public static void testLevenshteinDistanceCalculatorForAsterick() // tests to see that calculator can handle asterisk { int actualDistance = 2; // the peptides below have an edit distance of two string stringOne = "LKAEEQAADQVAYQQAVQAIKDKQFVLEADQVI*FKR"; string stringTwo = "LKAEEQAADQVAYQQAVQAIKDKQFVLEADAVIKFKR"; int distanceCalculated = ComputeLevenshteinDistance.LevenshteinDistance(stringOne, stringTwo); Assert.That(distanceCalculated, Is.EqualTo(actualDistance)); }
public void MakeAllCombinations() { Stopwatch time = new Stopwatch(); time.Start(); ulong count = 0; for (int i = 0; i < inputs.Count - 1; i++)// prsmFile used to be a List<PrSmAndFile> { for (int j = i + 1; j < inputs.Count; j++) { count++; if (count % 100000000 == 0) // only output every 100 million lines { Console.WriteLine("Processed: " + count + ", Elapsed Time: " + time.ElapsedMilliseconds); } var left = inputs[i]; // this is one object var right = inputs[j]; // this is the second object for comparison if (filterForPeptideLength(left.peptide, right.peptide) != true) { continue; } if (filterForSameCharge(left.charge, right.charge) != true) { continue; } if (filterForBeginningOrEndMatch(left.peptide, right.peptide) != true) { continue; } if (filterForOrganismMatch(left.organismName, right.organismName) != true) { continue; } //later use actual org name, not codex var tableAppendix = ComputeLevenshteinDistance.LevenshteinDistance(left.peptide, right.peptide); string valuesForPairsTable = "('" + left.id + "','" + right.id + "','" + tableAppendix + "')"; if (tableAppendix < 3) { aggregateValuesForPairsTable.Add(valuesForPairsTable); } if (aggregateValuesForPairsTable.Count >= 800 && aggregateValuesForPairsTable.Count > 0) { SQLiteConnector.FillDatabase(string.Join(",", aggregateValuesForPairsTable.ToArray())); aggregateValuesForPairsTable = new List <string>(); } } } }