Code covered by the BSD License  

Highlights from
CODIS

image thumbnail

CODIS

by

 

14 May 2009 (Updated )

Combined DNA Index System: a GUI tool for forensic paternity lawsuit

SI=CODISSIBS(handles,k0,k1,k2)
function SI=CODISSIBS(handles,k0,k1,k2) %#ok<INUSL>
global C F HC HF MP matF Amb pmatF CODISpop x y Z I loci NL
%Set the match-flag vectors:
%the the matF is all switched off.
matF=zeros(18,1); pmatF=matF; Amb=matF;
%set the Sibship Index and Matching Probability arrays
SI=matF; MP=matF;
%sort C and F vectors
C=sort(C,2); F=sort(F,2);
%highlight the homozygous loci
HC=C(:,1)==C(:,2); HF=F(:,1)==F(:,2);
for I=1:18
    eval(sprintf('loci{I}=get(handles.text%i,''String'');',I))
    TF=sum(strcmp(loci{I},CODISpop(:,7)).*(1:1:NL)');
    % Check for errors: the child's and the alleged father's loci are required
    if (all(C(I,:)) && all(F(I,:))) 
        %set the frequencies and the labels of the STRs
        x=CODISpop{TF,1}; y=CODISpop{TF,2}; Z=CODISpop{TF,5};
        
        %Remember that it is necessary to update the alleles frequecies because it is possible that
        %the subjcets bring an allele that was not previously observed in the
        %selected population: in this case all the SI will be 0.
        %So firstly we can add the alleles of the first subjects
        z=round(x.*y); y=y+2; z(C(I,:)-1)=z(C(I,:)-1)+1+HC(I); x=z./y;
        
        if (~HC(I) && ~HF(I)) && isequal(C(I,:),F(I,:)) %C=PQ & F=PQ
            matF(I)=1; Amb(I)=1; %switch on the Match and the Ambigous flags
            %In this case no more alleles must be added.
            %compute the Sibship index
            pipj=prod(x(C(I,:)-1));
            SI(I)=k0+2*k1*sum(x(C(I,:)-1))/pipj/4+k2/2/pipj;
        else  % we are not in the condition C=PQ & F=PQ
            if any(ismember(C(I,:),F(I,:))) %there is a match
                matF(I)=1; %switch on the Match flag
                %check if swaps are required
                if HC(I) %If the child's locus is homozygous...
                    %swap the alleged father's locus only if C=PP & F=XP
                    if ~HF(I) && C(I,2)==F(I,2)
                        CODISswap(0,0,1) %C=PP & F=PX
                    end
                else %the child's locus is heterozygous...
                    if HF(I) %If the alleged father's locus is homozygous...
                        %swap the child's locus only if C=PQ & F=PP
                        if C(I,1)==F(I,1)
                            CODISswap(0,1,0) %C=QP & F=PP
                        end
                    else %the alleged father's locus is heterozygous...
                        if C(I,1)==F(I,1) %if C=PQ & F=PX
                            CODISswap(0,1,0) %C=QP & F=PX
                        elseif C(I,1)==F(I,2) %if C=PQ & F=XP
                            CODISswap(0,1,1) %C=QP & F=PX
                        elseif C(I,2)==F(I,2) %if C=QP & F=XP
                            CODISswap(0,0,1) %C=QP & F=PX
                        end
                    end
                end
                %Update the frequencies
                %In this case, we know can add another allele.
                z=round(x.*y); y=y+1; z(F(I,2)-1)=z(F(I,2)-1)+1; x=z./y;
                SI(I)=k0+2*k1/((2-HC(I))*(2-HF(I))*x(C(I,2)-1))+k2/x(C(I,2)-1)^2*(HC(I)&HF(I)); 
                %note that the k2 addend is added only if both subjects are
                %homozygotes
            else%there is not a match
                SI(I)=k0;
            end
        end
    end
end

        
        
        
        
        
        

Contact us