lib/bio/shell/plugin/entry.rb in bio-0.7.1 vs lib/bio/shell/plugin/entry.rb in bio-1.0.0
- old
+ new
@@ -1,32 +1,14 @@
#
# = bio/shell/plugin/entry.rb - extract entry and sequence
#
-# Copyright:: Copyright (C) 2005
-# Toshiaki Katayama <k@bioruby.org>
-# License:: LGPL
+# Copyright:: Copyright (C) 2005
+# Toshiaki Katayama <k@bioruby.org>
+# License:: Ruby's
#
-# $Id: entry.rb,v 1.4 2005/12/07 05:12:07 k Exp $
+# $Id: entry.rb,v 1.8 2006/02/27 09:37:14 k Exp $
#
-#--
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#++
-#
module Bio::Shell
private
@@ -56,30 +38,57 @@
elsif ent.respond_to?(:aaseq)
seq = ent.aaseq
end
if tmp and tmp.is_a?(String) and not tmp.empty?
- seq = Bio::Sequence.auto(tmp)
+ seq = Bio::Sequence.auto(tmp).seq
end
return seq
end
# Obtain a database entry from
# * IO -- IO object (first entry only)
# * "filename" -- local file (first entry only)
- # * "db:entry" -- local bioflat, OBDA, KEGG API
+ # * "db:entry" -- local BioFlat, OBDA, EMBOSS, KEGG API
def ent(arg)
entry = ""
db, entry_id = arg.to_s.strip.split(/:/)
+
+ # local file
if arg.respond_to?(:gets) or File.exists?(arg)
+ puts "Retrieving entry from file (#{arg})"
entry = flatfile(arg)
+
+ # BioFlat in ./.bioruby/bioflat/ or ~/.bioinformatics/.bioruby/bioflat/
elsif Bio::Shell.find_flat_dir(db)
+ puts "Retrieving entry from local BioFlat database (#{arg})"
entry = flatsearch(db, entry_id)
+
+ # OBDA in ~/.bioinformatics/seqdatabase.ini
elsif obdadbs.include?(db)
+ puts "Retrieving entry from OBDA (#{arg})"
entry = obdaentry(db, entry_id)
+
else
- entry = bget(arg)
+ # EMBOSS USA in ~/.embossrc
+ str = entret(arg)
+ if $?.exitstatus == 0 and str.length != 0
+ puts "Retrieving entry from EMBOSS (#{arg})"
+ entry = str
+
+ # KEGG API at http://www.genome.jp/kegg/soap/
+ else
+ puts "Retrieving entry from KEGG API (#{arg})"
+ entry = bget(arg)
+ end
end
+
return entry
+ end
+
+ # Obtain a parsed object from sources that ent() supports.
+ def obj(arg)
+ str = ent(arg)
+ flatparse(str)
end
end