private void Assembly() { profile.AddSequence(sequences[0], 0); var lastSegment = 0; var firstSegment = 0; AssemblyInit(sequences[0]); int change = 0; // 0 - there was align, 1 - there wasn't align on last, 2 - there wasn't align at all while (true) { int seq; if (change == 0) { seq = lastSegment; } else if (change == 1) { seq = firstSegment; } else { break; } var list = GetProbablyBest(seq); if (list.Count == 0) { if (change == 0) { seq = firstSegment; list = GetProbablyBest(seq); if (list.Count == 0) { break; } } else { break; } } var wasAlign = false; foreach (var probSeq in list) { var sm = new SmithWaterman(profile, sequences[probSeq]); sm.Calculate(); var alignment = sm.GetBest(); AssemblyCandidate(sequences[probSeq], alignment.First.Value.Item1 - alignment.First.Value.Item2); if (IsGoodAlignment(sequences[probSeq], alignment)) { var side = AddSequence(sequences[probSeq], alignment); if ((side & 1) != 0) { firstSegment = probSeq; } else if ((side & 2) != 0) { lastSegment = probSeq; change = 0; } RemoveSeq(probSeq); //AssemblyGoodAlignmentAdded(profile); AssemblyGoodAlignment(); wasAlign = true; break; } } if (!wasAlign) { change++; } } AssemblyEnd(); }
public static void SM() { var sequence = "AC TGTTTT"; var profile = new Profile(); profile.AddSequence("GGGGACTG", 0); var sm = new SmithWaterman(profile, sequence); sm.InsertionScore = -2; sm.DeletionScore = -2; sm.MismatchScore = -1; sm.MatchScore = 2; sm.Calculate(); sm.PrintResult(); var seq = sm.GetBest(); foreach (var i in seq) { Console.Write(string.Format("({0},{1}) ", i.Item1, i.Item2)); } }