我正在尝试编写一个程序来尽可能地打乱 dna 序列以破坏序列中的顺序。我写了matlab代码,但是太慢了。此外,我正在研究汉明距离测量或列文斯坦测量,以及如何结合这些测量以确保正确的洗牌。我在洗牌时遵循的规则
- 规则 1:第 i 个残差不应靠近 i-1,i-2,i-3,i+1,i+2,i+3
- 规则2:在接下来的安排中,我的新位置和旧位置必须相差20位。即,如果 A 在 shuffled 字符串中的字符串中排名第 1,则它必须大于等于第 21 位。
function seq=shuffling(str)
len=length(str);
t1=0.4;
seqlen=1:len;
if(len>150)
t1=0.90;
elseif(len>=100)
t1=0.7;
end
while 1
shufseq=randperm(len);
temp1=diff([seqlen;shufseq]);%differences between order indices of original and shuffled arrangement
if(isempty(find(temp1==0)) && isempty(find(diff(shufseq)==1|diff(shufseq)==2 |diff(shufseq)==3 |diff(shufseq)==4 |diff(shufseq)==-1|diff(shufseq)==-2 |diff(shufseq)==-3 |diff(shufseq)==-4)))% rule 1
if((length(find(temp1>20|temp1<-20))/len)>t1)%rule 2 if ratio of (counts of arrangements/length of the string) should be more than one after certain length threshhold(=t1)
break
else
continue
end
else
continue
end
end
seq=str(shufseq);