0001 function exitFlag=downloadKEGG(keggPath)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 exitFlag=-1;
0015
0016
0017 necessaryFiles={'compound';'compound.inchi';'genes.pep';'ko';'reaction';'reaction.lst';'taxonomy';'reaction_mapformula.lst'};
0018 filePathways={'/pub/kegg/ligand/compound/';'/pub/kegg/ligand/compound/';'/pub/kegg/genes/fasta/';'/pub/kegg/genes/';'/pub/kegg/ligand/reaction/';'/pub/kegg/ligand/reaction/';'/pub/kegg/genes/';'pub/kegg/ligand/reaction/'};
0019 fileExists=false(numel(necessaryFiles),1);
0020 for i=1:numel(necessaryFiles)
0021 if exist(fullfile(keggPath,necessaryFiles{i}),'file')
0022 fileExists(i)=true;
0023 end
0024 end
0025
0026
0027 if any(~fileExists)
0028 retrieveFiles=input('One or more files are missing from the local database. Do you want to connect to KEGG and retrieve them? (Y/N)','s');
0029 if strmatch(lower(retrieveFiles),'y')
0030 fprintf('\nWARNING: This might take a very long time. The database is about 2 GB.\n');
0031 getFiles=find(~fileExists);
0032 fprintf('Attempting to connect to the KEGG database and retrieve the files. The FTP client in Matlab has some known issues. If you do not see that it is sucessfully downloading the files you could get them manually from KEGG. Files to get and place in keggPath:\n');
0033 for i=1:numel(getFiles)
0034 fprintf(['ftp.genome.jp' filePathways{getFiles(i)} necessaryFiles{getFiles(i)} '\n']);
0035 end
0036
0037 f = ftp('ftp.genome.jp');
0038 pasv(f);
0039 for i=numel(getFiles)
0040 cd(f,filePathways{getFiles(i)});
0041 fprintf(['Retrieving ' filePathways{getFiles(i)} necessaryFiles{getFiles(i)} '\n']);
0042 mget(f,necessaryFiles{getFiles(i)},keggPath);
0043 end
0044 close(ftp);
0045 exitFlag=1;
0046 end
0047 end
0048 end