function [ location_vector,founder_matrix,founder_id,founder_selector,founder_data] = hmm_input( founders,no_locations,block_size )
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here
 
dir='/Net/mus/data/www/19genomes/variants.tables/';
filename='chr1.alleles.txt';
whole=[dir filename];
fileID = fopen(whole);
%columns chromomsome, psebp, bp, no. alleles, major AF, 19 strains
i=1;
k=1
no_founders=19;
maxlen=100;
while ~feof(fileID)

tline = fgetl(fileID);
w=length(tline)
%pause
if w<maxlen
raw_founder_data = textscan(tline, '%f %f %f %f %f %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s ');
if k==1
else
    for j=1:no_founders
    if j==1 
        tempd=raw_founder_data{5+j};
    else
        tempd=horzcat(tempd, raw_founder_data{5+j});
    end
    end
    a=cellfun('length',tempd);
    d=max(a');
    if d==1
        
        raw_chromosome(i)=raw_founder_data{1};
        founder_pse_bp(i)=raw_founder_data{2};
        founder_data(i,:)=tempd;
        i=i+1;
    end
end
end
%founder_data=horzcat(founder_data, raw_founder_data{5+i});
k=k+1;
end

clearvars raw_founder_data
for i=1:length(raw_chromosome)
    ch=num2str(raw_chromosome(i));
    chr='chr';
    chr1=[chr ch];
    chromosome{i}=chr1;
end
dir='/Net/mus/data/www/POOLING/ARABIDOPSIS/FOUNDER/MAGIC/MAGIC.';
filename='18';
whole=[dir filename];
fileID = fopen(whole);
raw_indiv_data=textscan(fileID, '%s %f %s %s');
fclose(fileID);
indiv_chr=raw_indiv_data{1};
indiv_bp=raw_indiv_data{2};
indiv_SNP=raw_indiv_data{3};
clearvars raw_indiv
%founder matrix creation
%delete no SNP rows

% create usible vectors and matrices
location_selection=randperm(length(raw_chromosome));
location_selector= location_selection(1:no_locations);
location_selector=sort(location_selector);
founder_selection=randperm(19);
founder_selector= founder_selection(1:(founders));

block_total=no_locations/block_size;
founder_id=zeros(block_total,1);
for i=1:block_total
    randiser=randperm(founders);
    founder_id(i)=founder_selector(randiser(1));
end
j=1;
location_vector=zeros(no_locations,1);
founder_matrix=zeros(no_locations,19);
for i=1:no_locations 
    location_vector(i)=founder_pse_bp(location_selector(i));
    for n=1:no_founders
        founder_matrix(i,n)=strcmp(founder_data(location_vector(i),n),founder_id(j));
    end
    if i==block_size*j
        j=j+1;
    end
end
end
    




