Home > RAVEN > downloadKEGG.m

downloadKEGG

PURPOSE ^

downloadKEGG

SYNOPSIS ^

function exitFlag=downloadKEGG(keggPath)

DESCRIPTION ^

 downloadKEGG
   Retrieves files used by getKEGGModelForOrganism from the KEGG FTP

   keggPath    the directory to store the files in

   exitFlag    1 if everything worked, -1 if something went wrong
               
   Usage: exitFlag=downloadKEGG(keggPath)

   Rasmus Agren, 2012-12-16

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function exitFlag=downloadKEGG(keggPath)
0002 % downloadKEGG
0003 %   Retrieves files used by getKEGGModelForOrganism from the KEGG FTP
0004 %
0005 %   keggPath    the directory to store the files in
0006 %
0007 %   exitFlag    1 if everything worked, -1 if something went wrong
0008 %
0009 %   Usage: exitFlag=downloadKEGG(keggPath)
0010 %
0011 %   Rasmus Agren, 2012-12-16
0012 %
0013 
0014 exitFlag=-1;
0015 %Check if all necessary files exist in the KEGG path. Otherwise download
0016 %them from KEGG
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 %Download missing files
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

Generated on Tue 23-Apr-2013 15:18:37 by m2html © 2005