public bool Create(EvaluateDto evaluateDto) { var expert = _context.Users.Find(evaluateDto.ExpertId); var user = _context.Users.Find(evaluateDto.UserId); var skill = _context.Skills.Find(evaluateDto.SkillId); if (expert == null || user == null || skill == null) { throw new AppException("User, Expert or Skill not found. Username: "******", skill: " + skill + ", expert:"); } var userSkill = user.UserSkills.Where(r => r.SkillId == skill.Id); if (userSkill == null) { throw new AppException("Can't find evaluated skill. Username: "******", skill: " + skill.Name); } var newEvaluate = new Evaluation { Expert = expert, Skill = skill, User = user, Value = evaluateDto.Value }; _context.Evaluations.Add(newEvaluate); _context.SaveChanges(); return(true); }
public static void RunTheCode(string seq1File, string seq2File, int matchWeight, int misMatchWeight, int indlWeight) { ScoringParameterDto scoringParameter = new ScoringParameterDto(matchWeight, misMatchWeight, indlWeight); var seq1 = LoadProteinDatabase.GetProteins(seq1File); var seq2 = LoadProteinDatabase.GetProteins(seq2File); SequencesDto sequences = new SequencesDto(seq1[0].Seq, seq2[0].Seq); EvaluateDto evaluation = GridEvaluateFunction.Evaluate(scoringParameter, sequences); ResultsDto results = Traceback.Trace(evaluation, sequences); WriteAlignment.Write(results, scoringParameter); }
public static ResultsDto Trace(EvaluateDto eval, SequencesDto seqs) { string seq1 = seqs.Sequence1; string seq2 = seqs.Sequence2; string remstrA = seq1; string remstrB = seq2; int i = seq1.Length; int j = seq2.Length; string A = ""; string B = ""; while (remstrA.Length > 0 && remstrB.Length > 0) { if (eval.directs[i, j][0] == eval.matrix[i, j]) { B = seq2[j - 1].ToString() + B; A = '_'.ToString() + A; j--; } else if (eval.directs[i, j][1] == eval.matrix[i, j]) { A = seq1[i - 1].ToString() + A; B = '_'.ToString() + B; i--; } else if (eval.directs[i, j][2] == eval.matrix[i, j]) { A = seq1[i - 1].ToString() + A; B = seq2[j - 1].ToString() + B; i--; j--; remstrA = remstrA.Substring(0, i); remstrB = remstrB.Substring(0, j); } } int simScore = eval.matrix[seq1.Length, seq2.Length]; Alignment align = new Alignment(A, B); List <Alignment> aligns = new List <Alignment>(); aligns.Add(align); ResultsDto results = new ResultsDto(aligns, simScore); return(results); }
public static EvaluateDto Evaluate(ScoringParameterDto scoringParameters, SequencesDto sequences) { int[,] matrx = new int[sequences.Sequence1.Length + 1, sequences.Sequence2.Length + 1]; List <int>[,] direx = new List <int> [sequences.Sequence1.Length + 1, sequences.Sequence2.Length + 1]; for (int j = 0; j < sequences.Sequence2.Length + 1; j++) { for (int i = 0; i < sequences.Sequence1.Length + 1; i++) { direx[i, j] = new List <int>(); if (i == 0 || j == 0) { direx[i, j].Add(0); direx[i, j].Add(0); direx[i, j].Add(0); } } } for (int j = 1; j < sequences.Sequence2.Length + 1; j++) { for (int i = 1; i < sequences.Sequence1.Length + 1; i++) { if (sequences.Sequence1[i - 1] == sequences.Sequence2[j - 1]) { direx[i, j].Add(matrx[i, j - 1] + scoringParameters.gap); direx[i, j].Add(matrx[i - 1, j] + scoringParameters.gap); direx[i, j].Add(matrx[i - 1, j - 1] + scoringParameters.match); direx[i, j].Add(0); } else { direx[i, j].Add(matrx[i, j - 1] + scoringParameters.gap); direx[i, j].Add(matrx[i - 1, j] + scoringParameters.gap); direx[i, j].Add(matrx[i - 1, j - 1] + scoringParameters.mismatch); direx[i, j].Add(0); } matrx[i, j] = direx[i, j].Max(); } } EvaluateDto evaluation = new EvaluateDto(matrx, direx); return(evaluation); }
public static ResultsDto Trace(EvaluateDto eval, SequencesDto seqs) { string seq1 = seqs.Sequence1; string seq2 = seqs.Sequence2; int largest = eval.matrix.Cast <int>().Max(); List <Alignment> aligns = new List <Alignment>(); int c = 0; List <int> rowmax = new List <int>(); List <int> colmax = new List <int>(); for (int row = 0; row < eval.matrix.GetLength(0); row++) { for (int col = 0; col < eval.matrix.GetLength(1); col++) { if (eval.matrix[row, col] == largest) { rowmax.Add(row); colmax.Add(col); c++; } } } List <string> A = new List <string>(); List <string> B = new List <string>(); for (int count = 0; count < c; count++) { string remstrA = seq1.Substring(0, rowmax[count] - 1); string remstrB = seq2.Substring(0, colmax[count] - 1); int i = rowmax[count]; int j = colmax[count]; A.Add(""); B.Add(""); while (remstrA.Length > 0 && remstrB.Length > 0) { if (eval.directs[i, j][0] == eval.matrix[i, j]) { B[count] = seq2[j - 1].ToString() + B[count]; A[count] = '_'.ToString() + A[count]; j--; } else if (eval.directs[i, j][1] == eval.matrix[i, j]) { A[count] = seq1[i - 1].ToString() + A[count]; B[count] = '_'.ToString() + B[count]; i--; } else if (eval.directs[i, j][2] == eval.matrix[i, j]) { A[count] = seq1[i - 1].ToString() + A[count]; B[count] = seq2[j - 1].ToString() + B[count]; i--; j--; remstrA = remstrA.Substring(0, i); remstrB = remstrB.Substring(0, j); } else { break; } } Alignment align = new Alignment(A[count], B[count]); aligns.Add(align); } int simScore = largest; ResultsDto results = new ResultsDto(aligns, simScore); return(results); }
public IActionResult Create([FromBody] EvaluateDto evaluation) { var res = _evaluateService.Create(evaluation); return(Ok(res)); }