Binary to DNA sequence encoding - matlab
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I am implementing DNA encryption algorithm.
For that, I have a vector containing binary values such as:
01100011 01110010 01111001 01110000 01110100 01101111.
Now, these values should be mapped to DNA sequence. How do I do that in MATLAB?
2 件のコメント
Star Strider
2015 年 9 月 20 日
DNA has four bases (two complementary sets, A-T and C-G) and you have a binary sequence ...
Meghashree G
2015 年 9 月 20 日
yeah..i know To use ATGC concept,but i don't know how to code..Like how do i extract only 2 digits from the binary vector and assign it to either A,T,G,C..
採用された回答
Image Analyst
2015 年 9 月 20 日
Perhaps this:
% Assign sample data.
binaryArray = [0,1,1,0,0,0,1,1, 0,1,1,1,0,0,1,0, 0,1,1,1,1,0,0,1, 0,1,1,1,0,0,0,0, 0,1,1,1,0,1,0,0, 0,1,1,0,1,1,1,1];
% Define base letters to choose from.
bases = 'ATGC';
for k = 1 : 2 : length(binaryArray)
% Convert these two digits into a number 1 - 4.
index = 2 * binaryArray(k) + binaryArray(k+1) + 1;
% Use that index to assign a letter to our result.
result((k+1)/2) = bases(index);
end
% Display in command window:
result
It shows:
result =
TGACTCAGTCGTTCAATCTATGCC
12 件のコメント
Meghashree G
2015 年 9 月 20 日
Thank you so much :) it worked :)
Saurabh Kumar
2018 年 2 月 12 日
I want to create a function in Matlab of above solution you have given. So that I don't need to describe different binary Everytime in .m blank file format. Please help Function []=binary()
Image Analyst
2018 年 2 月 12 日
function result = LabelBinaryArray(binaryArray)
% Define base letters to choose from.
bases = 'ATGC';
for k = 1 : 2 : length(binaryArray)
% Convert these two digits into a number 1 - 4.
index = 2 * binaryArray(k) + binaryArray(k+1) + 1;
% Use that index to assign a letter to our result.
result((k+1)/2) = bases(index);
end
Saurabh Kumar
2018 年 2 月 12 日
Attempted to access binaryArray(2); index out of bounds because numel(binaryArray)=1.
Error in LabelBinaryArray (line 6) index = 2 * binaryArray(k) + binaryArray(k+1) + 1;
NOT WORKING
Image Analyst
2018 年 2 月 12 日
It works if you pass in something like you said, like '01100011'. You can't pass in a single value like '1' like you did because that can't be mapped to a letter. How do I know you passed in only a single element? Because the error message says "because numel(binaryArray)=1" Are you sure you're passing in a binary array like you said? I'm assuming a binary array, which is class logical, though a double will work. You aren't passing in a string are you? Show me how you defined the array you passed in to the function.
Saurabh Kumar
2018 年 2 月 12 日
LabelBinaryArray('011000110111001001111001011100000111010001101111')
Attempted to access bases(146); index out of bounds because numel(bases)=4.
Error in LabelBinaryArray (line 8) result((k+1)/2) = bases(index);
Image Analyst
2018 年 2 月 12 日
OK, you have a string, not a binary/logical array. To convert to a binary array you need to do this:
str = '011000110111001001111001011100000111010001101111'
binaryArray = logical(str - '0')
You can do that either inside the function, if you want to pass a string, or in your main program before you call the function, if you want to pass a binary array.
Saurabh Kumar
2018 年 2 月 13 日
it worked. THANKS
Saravanakumar Chandrasekaran
2020 年 12 月 5 日
How to decrypt it back to binary sequence
Image Analyst
2020 年 12 月 5 日
Decrypt what back to a binary sequence. You have the binary sequence both as a character array, str, and a logical/boolean array, binaryArray. What else do you want? What's missing? Just keep both things and you're all set.
Shiva Reddy
2021 年 2 月 5 日
Pls Can I get the decryption code
Image Analyst
2021 年 2 月 5 日
Shiva, I'm not sure who you're asking, but personally I don't have any to give you.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Cell Arrays についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
