I'm trying to create a random sequence of 100 DNA bases, with an equal number of A,C,G and T, but I can't make it happen.

조회 수: 3 (최근 30일)

I'm trying to create a random sequence of 100 DNA bases, with an equal number of A,C,G and T, but I can't make it happen. My code is:

total_bp=10000;
%open file
fid=fopen('Seq_Out.txt','w');
for i=1:total_bp
%random DNA sequence
SeqLength=100;
Seq=randseq(SeqLength,'Weights',[0.25 0.25 0.25 0.25]);
%write to file
fprintf(fid,'%s\n',Seq);
end
fclose('all');

채택된 답변

Walter Roberson
Walter Roberson 2018년 4월 19일

Before the loop:

SeqLength=100;
bases = repmat('ACGT', 1, SeqLength/4);

The replace your

SeqLength=100;
Seq=randseq(SeqLength,'Weights',[0.25 0.25 0.25 0.25]);

with

Seq = bases(randperm(SeqLength));
  댓글 수: 3
Radhwan Jawad
Radhwan Jawad 2022년 11월 23일
How can I read a DNA sequence from NCBI and store it in array or in a specific variable
Image Analyst
Image Analyst 2022년 11월 23일
@Radhwan Jawad start a new question for this.
@Nitzan Kahn If this solves the question for you then please click the "Accept this answer" link to award @Walter Roberson "reputation points" for the answer. Thanks in advance. 🙂

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genomics and Next Generation Sequencing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by