Wednesday, 15 April 2015

matlab - Placing a character randomly in a bio-seq -



matlab - Placing a character randomly in a bio-seq -

suppose have bio_sequence :

vyddgyhngn

and we're gonna place random number of '.' in random positions along sequence, sth this:

..vy.dd...gy..hn.gn..

is there function or optimum solution task in matlab?

according comments, next assumes that:

the total number of dots random integer uniformly distributed between 0 , 0.2 times sequence length rounded nearest integer. dot locations random , uniformly distributed.

code:

%// info seq = 'vyddgyhngn'; %// let's go m = numel(seq); %// sequence length n = randi([0 round(.2*m)]); %// number of dots p = m+n; result = repmat('.', 1, p); %// initiallize result dots result(sort(randsample(p,m))) = seq; %// place sequence in uniformly random positions

matlab alignment bioinformatics

No comments:

Post a Comment