5 Various simple Ruby examples.
7 Author: [http://www.cmzmasek.net/ Christian M Zmasek], Sanford-Burnham Medical Research Institute
10 Copyright (C) 2011 Christian M Zmasek. All rights reserved.
13 = Using net/ftp to download all Proteomes from the Ensembl Database =
15 This, or something like it, can be used to download from Ensembl all "pep.all.fa.gz" files.
21 PUB_RELEASE_DIR = '/pub/release-64/fasta'
24 ftp = Net::FTP.new('ftp.ensembl.org', 'anonymous', EMAIL)
25 ftp.passive = true # To avoid "No route to host" error.
26 ftp.chdir( PUB_RELEASE_DIR )
27 files = ftp.list('*_*') # To only look at files with an underscore.
29 files.each do | file |
30 species = file.split().last
32 ftp.chdir(species + PEP_DIR)
34 pepfiles.each do | pepfile |
35 pepfile = pepfile.split().last
36 if pepfile =~ /all.fa.gz/ # Only want the "all.fa.gz" files (and not the
38 ftp.getbinaryfile(pepfile)
39 puts 'downloaded "' + pepfile + '"'
44 puts 'ignoring "' + species + '"'
46 ftp.chdir(PUB_RELEASE_DIR) # To go back to the starting directory.
49 puts 'done (downloaded ' + count.to_s + ' files)'