% onePointCrossOver.m
% Script to generate two random DNA sequences of a given length 
% embedded with a certain maximum number of gaps.
% A random location is chosen to perform crossover.
% Given parameters:
%   lengthDNA: the length of each DNA sequence
%   numberGaps: the number of gaps in the sequence
% User-defined functions needed:
%   randomDNA_ to generate a random DNA sequence with gaps
%       randomDNA_ in turn calls function RandIntegers_
%   RandIntegers_ to choose the crossover point
%   onePointCrossOver_ to perform the crossover operation
% K. Ming Leung, Nov. 14, 2008.

format compact;
lengthDNA = input('Enter the length of the 2 DNA sequences: ');
numberGaps = input('Enter the maximum number of gaps in the sequences: ');

% generate the 2 original DNA sequences having up to a number of gaps:
DNA1 = randomDNA_(lengthDNA,numberGaps);
DNA2 = randomDNA_(lengthDNA,numberGaps);

% pick a point within the sequences to perform a one-point crossover
% operation:
crossOverPoint = RandIntegers_(1,1,1,lengthDNA-1),

% perform the one-point crossover operation to get 2 new DNA sequences:
[Dna1,Dna2] = onePointCrossOver_(DNA1,DNA2,crossOverPoint);

% display the original DNA sequences:
disp([ 'DNA1 = ' DNA1 ]);
disp([ 'DNA2 = ' DNA2 ]);
disp('After a one-point crossover process, the sequences are:');
% display the new DNA sequences after crossover:
disp([ 'DNA1 = ' Dna1 ]);
disp([ 'DNA2 = ' Dna2 ]);

% %%  RESULT 1:
% 
% Enter the length of the 2 DNA sequences: 7
% Enter the maximum number of gaps in the sequences: 2
% crossOverPoint =
%      2
% DNA1 = GT-TGA-
% DNA2 = -CC-TCT
% After a one-point crossover process, the sequences are:
% DNA1 = -C-TGA-
% DNA2 = GTC-TCT

%  %%  RESULT 2:
% Enter the length of the 2 DNA sequences: 8
% Enter the maximum number of gaps in the sequences: 3
% crossOverPoint =
%      7
% DNA1 = GC-CGA--
% DNA2 = ACAGG-CG
% After a one-point crossover process, the sequences are:
% DNA1 = GC-CGA-G
% DNA2 = ACAGG-C-




