← RoseCode

ROSECODE 367

DNA sequences alignment

Philippe_57721 · Programming ·

Given two sequences of nucleic acid, we try to align them the best way possible. We can insert any number of gaps in both sequences.

We use the following rules:
- if at a given position the acids are the same, we count +2
- if at a given position the acids are different, we count -1
- if there is a gap in one string, we count -2

For example, consider the two following sequences:
  • GAATTCAGTTA
  • GGATCGA
The best possible alignment (the one with the greater score) is:
GAATTCAGTTA
GGA-TC-G--A
which gives a score of 3
  • G G +2
  • A G -1
  • A A +2
  • T - -2
  • T T +2
  • C C +2
  • A - -2
  • G G +2
  • T - -2
  • T - -2
  • A A +2
You are given the 2 following sequences:
'GTAATAGACTCGGAAACGCAACCGTCAGCAAAACGCGTTCGGTCGATCGTAATATGTAAGATCCAATTAGGGCGACCTCTTGTGCGGTCAGTAGGAGTCT' 'ATAACTCTGAATCCCCCGACGTGTCGTGATGGGCGACGGACGGCACCCTTAACGTGATCCTGAACTCCCGTGGGGACCGTTGTCGGTAATGCAGGGTGTG'

What is the score for the best alignment and the number of acids identical in both aligned sequences?

Answer format: comma separated

Example: 3,6 // For the sequences GAATTCAGTTA and GGATCGA

[My timing: < 1 sec]