From 3f2baabae128a88580c3ea98b27083f8126ab5ee Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Wed, 9 Nov 2011 03:50:48 +0000 Subject: [PATCH] Edited wiki page RubyExamples through web user interface. --- wiki/RubyExamples.wiki | 50 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/wiki/RubyExamples.wiki b/wiki/RubyExamples.wiki index b52eef0..f653629 100644 --- a/wiki/RubyExamples.wiki +++ b/wiki/RubyExamples.wiki @@ -1,13 +1,49 @@ -#summary One-sentence summary of this page. +#summary Ruby examples + + = Introduction = -Add your content here. +Various Ruby examples + +Author: [http://www.cmzmasek.net/ Christian M Zmasek], Sanford-Burnham Medical Research Institute + + +Copyright (C) 2011 Christian M Zmasek. All rights reserved. + + += Multiple Sequence Alignment = +{{{ +require 'net/ftp' -= Details = +EMAIL = 'czmasek@burnham.org' +PUB_RELEASE_DIR = '/pub/release-64/fasta' +PEP_DIR = '/pep' -Add your content here. Format your content with: - * Text in *bold* or _italic_ - * Headings, paragraphs, and lists - * Automatic links to other wiki pages \ No newline at end of file +ftp = Net::FTP.new('ftp.ensembl.org', 'anonymous', EMAIL) +ftp.passive = true # To avoid "No route to host" error. +ftp.chdir( PUB_RELEASE_DIR ) +files = ftp.list('*_*') # To only look at files with an underscore. +count = 0 +files.each do | file | + species = file.split().last + begin + ftp.chdir(species + PEP_DIR) + pepfiles = ftp.list() + pepfiles.each do | pepfile | + pepfile = pepfile.split().last + if pepfile =~ /all.fa./ + ftp.getbinaryfile(pepfile) + puts 'downloaded "' + pepfile + '"' + count += 1 + end + end + rescue Exception + puts 'ignoring "' + species + '"' + end + ftp.chdir(PUB_RELEASE_DIR) # To go back to the starting directory. +end +ftp.close +puts 'done (downloaded ' + count.to_s + ' files)' +}}} -- 1.7.10.2