function [qinfo,p,a,b] = qtlsim2(x,snp1,snp2,vfrac1,vfrac2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%                       QTL_SIM2                         %
%                                                        %
%   A function to simulate the quantitive trait values   %
%                    for 2 markers                       %
%                                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

x_dim=size(x);
nsub = x_dim(1);



qinfo=zeros(nsub,1);
n2=sum(x(:,snp1));

p=n2/(2*nsub);



v=p*(1-p)*2;
a = sqrt(vfrac1/v);

n3=sum(x(:,snp2));
p2=n3/(2*nsub);
v2=p2*(1-p2)*2;
b=sqrt(vfrac2/v2);


for i=1:nsub
    qinfo(i)=0+ (x(i,snp1)-1)*a +(x(i,snp2)-1)*b + normrnd(0,(1-vfrac1-vfrac2)^0.5);
end
    




end

