updates the scores of the alignment matrix for a given amino acid as well as the location heap/scenario.
284{
285 int score_found, score_shift, best_score, current_score, alt_score, tree_id;
286 uint32_t condition;
287 std::size_t best_column, alt_column,
shift, beginning, missing_aas, length, perfect_shift_origin;
288 KeyCell *current_cell_ptr, *tested_cell_ptr;
289 AlignType alignment_type, temp_align_type;
290
292
293
294 if(fast_align)
295 {
296 condition = 3;
297 if(row_number > 1)
298 {
300 qDebug() << "condition" << condition << sequence[row_number - 2]
302 }
303 }
304
305 for(std::vector<AaPosition>::const_iterator aa_position = aa_positions.begin();
306 aa_position != aa_positions.end();
307 aa_position++)
308 {
309 if(((condition & aa_position->condition) != 0) ||
310 !fast_align)
311 {
313 if(spectrum->peakType(aa_position->r_peak) ==
315 {
318 }
319 else
320 {
323 }
324
325
326 best_column = aa_position->r_peak;
327 best_score = current_cell_ptr->score + (row_number - current_cell_ptr->n_row) *
329 beginning = current_cell_ptr->beginning;
330 tree_id = current_cell_ptr->tree_id;
332
333
334 if(aa_position->l_support)
335 {
337 if(aa_position->l_peak == 0)
338 {
339 alt_score = tested_cell_ptr->score + score_found;
340 }
341 else
342 {
343 if(tested_cell_ptr->n_row == row_number - 1)
344 {
345 alt_score = tested_cell_ptr->score +
346 (row_number - tested_cell_ptr->n_row - 1) *
348 score_found;
349 }
350 else
351 {
352 alt_score = tested_cell_ptr->score +
353 (row_number - tested_cell_ptr->n_row - 1) *
355 score_shift;
356 }
357 }
358 if(alt_score >= best_score)
359 {
361 best_score = alt_score;
362 best_column = aa_position->l_peak;
363 if(best_column == 0)
364 {
366 {
367 beginning = 0;
368 }
369 else
370 {
371 beginning =
373 }
374 if(fast_align)
375 {
377 }
378 }
379 else
380 {
381 beginning = tested_cell_ptr->beginning;
382 tree_id = tested_cell_ptr->tree_id;
383 }
384 }
385 }
386
387
389 while(shift < aa_position->next_l_peak)
390 {
392
394 spectrum,
395 tested_cell_ptr->n_row,
396 row_number,
397 aa_position->next_l_peak - shift,
398 aa_position->r_peak))
399 {
400 alt_score = tested_cell_ptr->score +
401 (row_number - tested_cell_ptr->n_row - 1) *
403 score_found;
405 }
406 else
407 {
408 alt_score = tested_cell_ptr->score +
409 (row_number - tested_cell_ptr->n_row - 1) *
411 score_shift;
413 }
414 if(alt_score > best_score)
415 {
416 alignment_type = temp_align_type;
417 best_score = alt_score;
418 best_column = aa_position->next_l_peak -
shift;
419 beginning = tested_cell_ptr->beginning;
420 tree_id = tested_cell_ptr->tree_id;
421 }
423 }
424
425
427
428 perfect_shift_origin =
430 if(perfect_shift_origin != row_number)
431 {
432 alt_score = tested_cell_ptr->score + score_found;
434 }
435 else
436 {
437 alt_score = tested_cell_ptr->score + score_shift;
439 }
440 if(alt_score > best_score)
441 {
442 alignment_type = temp_align_type;
443 best_score = alt_score;
444 best_column = 0;
445 missing_aas =
446 std::floor(spectrum->getMZShift(0, aa_position->l_peak) /
m_aaCode.
getMass(
'G'));
448 {
449 beginning = 0;
450 }
451 else
452 {
453 beginning = std::max((std::size_t)(row_number - missing_aas -
ALIGNMENT_SURPLUS),
454 (std::size_t)0);
455 }
456 if(fast_align)
457 {
459 }
460 }
461 if(best_column != aa_position->r_peak)
462 {
464 {aa_position->r_peak, {row_number, best_score, beginning, tree_id}});
465 }
467 {
468 length =
469 row_number - beginning + 1 +
470 std::ceil(spectrum->getMissingMass(aa_position->r_peak) / Aa('G').getMass()) +
473 }
474 else if(!fast_align)
475 {
477 {
479 aa_position->r_peak,
480 perfect_shift_origin,
481 0,
482 best_score,
484 }
485 else
486 {
488 aa_position->r_peak,
490 best_column,
491 best_score,
492 alignment_type);
493 }
494 }
495 }
496 }
497
498
500
501
503 {
506 }
507}
uint8_t getAaCode(char aa_letter) const
get the integer code of an amino acid with the one letter code
double getMass(uint8_t aa_code) const
get the mass of the amino acid given its integer code the amino acid can bear some modification (if a...
int getMinScore(int tree_id) const
Returns the minimum score for a location with the provided tree_id to be saved in the heap.
void addLocation(std::size_t beginning, std::size_t length, int tree, int score, const QString &protein)
Adds a location to the locations heap. If a saved location has the same tree_id, it will replace it....
std::size_t getNextTree()
Creates a new alignment tree and returns its id.
void saveOrigin(std::size_t current_row, std::size_t current_column, std::size_t previous_row, std::size_t previous_column, int score, AlignType alignment_type)
Stores the origin (cell location and alignment type) of the provided cell in the backtracking matrix.
bool perfectShiftPossible(const QString &sequence, const SpOMSSpectrumCsp &spectrum, const std::size_t origin_row, const std::size_t current_row, const std::size_t l_peak, const std::size_t r_peak) const
indicates if a perfect shift is possible between the provided positions
std::vector< std::pair< std::size_t, KeyCell > > m_updated_cells
std::size_t perfectShiftPossibleFrom0(const QString &sequence, const SpOMSSpectrumCsp &spectrum, const std::size_t current_row, const std::size_t r_peak) const
const uint ALIGNMENT_SURPLUS(5)