How can i convert the text to DNA sequence ?

11 views (last 30 days)
How can i convert the text to DNA sequence ?
  3 Comments
James Tursa
James Tursa on 29 Sep 2020
Please post a small example showing input(s) and desired output(s).
hayder al gburi
hayder al gburi on 13 Oct 2020
Edited: hayder al gburi on 13 Oct 2020
Dear Joseph and James
the text what i need to convert it are complete character set (alphabets include uppercase and lowercase , numbers , special characters ) to DNA sequence in terms of each character = 4 baises ... as example the text (HIdE2$^) will be after convert it to DNA sequence is H=AAGC I= CCAA d=ACGA E= CCCA 2=CAGA $=AAAA ^=GGGG the result be (AAGCCCAAAVGACCCACAGAAAAAGGGG) and so on acoording to tabe that contant all characters set and each character = four baises that not similar another basise .

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 13 Oct 2020
Edited: Adam Danz on 13 Oct 2020
Use regexprep to replace the matches in key(:,1) with the definitions in key(:,2). Since some DNA codes are special characters in regular expressions (e.g. %, ^), you must add an escape character to them which is done programmatically below.
txt = 'HIdE2$^';
key = {
'H' 'AAGC'
'I' 'CCAA'
'd' 'ACGA'
'E' 'CCCA'
'2' 'CAGA'
'$' 'AAAA'
'^' 'GGGG'
};
% add escape char
needsEscape = ismember(key(:,1),{'$','^'}); % add more if needed
key(needsEscape,1) = strcat('\',key(needsEscape,1));
% Replace codes with DNC seq.
DNAseq = regexprep(txt,key(:,1),key(:,2));
Result:
DNAseq =
'AAGCCCAAACGACCCACAGAAAAAGGGG'
  4 Comments
hayder al gburi
hayder al gburi on 13 Oct 2020
Edited: hayder al gburi on 13 Oct 2020
The essential idea is ( give the program any text belong to 96 characters, then the program convert that text to DNA sequence). Of course the matches between DNA sequence that belong to different characters will be not acceptable because i use this program to cipher the text and any matches of DNA sequence for different characters will change the meaning of massage (original text) .
Adam Danz
Adam Danz on 14 Oct 2020
Edited: Adam Danz on 14 Oct 2020
I'm lost.
Are you saying you have a cypher that encodes DNA sequences and you'd like to build the "key" in my answer? Or are you asking how to create a cypher to encode DNA sequences in column 2 of "key" into random characters in col 1?

Sign in to comment.

More Answers (1)

hayder al gburi
hayder al gburi on 8 Nov 2020
Dear Mr.Adam
I am so sorry for my late becouse of my infaction (Covid19) and thank you for your help
I have defficult way to how can i explain my code to you ,SoI will summarize it by sequent steps .
1- I have plaintext Consists of 96 charachters(alphabets include uppercase and lowercase , numbers , special characters ) as ex ( HeLLLO AgenT @90!) .
2-I should convert each charachters to sequence DNA code each code have 4 baises called codon as ex H=AAAC , e=ACCG according to table 1 that attach below .we can consider that table is the key generation and existing in both side (sender and receiver) to encode and decode the text .
As a result we will have a sequence DNA codones as ex (AAACACCG........ to end of text) .
3-Now,i sould convert each codon (4 baises) to one code according to Table 2 of Amino acid that attach below ,as ex AAAA=PB and ACCG=S7 . The PB and S7 are called Amino acid .We can consider Table 2 exsisting in both side (sender and receiver) as a cipher table .
As a result we will have a sequence of the Amino acid as ex (PBS7.......... to end of DNA sequence ).
4-After i convert the plaintext to sequence of Amino acid(cipher text) by encoding the plaintext in the side of sender ,Then i sould decoding that chiper text to orginal plaintext on the receiver side. As ex PBS7=He...... until the end of Amino acid sequence .
Best Regards
  2 Comments
Adam Danz
Adam Danz on 10 Nov 2020
It sounds like step #2 can be solved by using the method described in my answer.
I think step 3 can also be solved by using the same method after you rearrange the table into columns and use a v-lookup approach.
hayder al gburi
hayder al gburi on 11 Nov 2020
please Mr.Adam if you can give me a small example for that , if you can .
thank you very much

Sign in to comment.

Categories

Find more on Genomics and Next Generation Sequencing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!