Class: Bio::DBGET

Inherits:
Object show all
Defined in:
lib/bio/io/dbget.rb

Constant Summary collapse

SERV =

SERV = “dbgetserv.genome.jp”

"dbget.genome.jp"
PORT =

default DBGET port number

"3266"

Class Method Summary collapse

Class Method Details

.aaseq(arg) ⇒ Object

aaseq(“db entry”) method retrieves the amino acid sequence of the entry if any.



142
143
144
# File 'lib/bio/io/dbget.rb', line 142

def DBGET.aaseq(arg)
  dbget("bget", "-f -n a #{arg}")
end

alink(“db entry”) method returns relations



100
101
102
# File 'lib/bio/io/dbget.rb', line 100

def DBGET.alink(arg)
  dbget("alink", arg)
end

.bfind(arg) ⇒ Object

bfind(“db keyword”) method searches entries by keyword



105
106
107
# File 'lib/bio/io/dbget.rb', line 105

def DBGET.bfind(arg)
  dbget("bfind", arg)
end

.bget(arg) ⇒ Object

bget(“db entry”) method retrieves entries specified by the entry names



110
111
112
# File 'lib/bio/io/dbget.rb', line 110

def DBGET.bget(arg)
  dbget("bget", arg)
end

.binfo(arg) ⇒ Object

binfo(“db”) method retrieves the database information



147
148
149
# File 'lib/bio/io/dbget.rb', line 147

def DBGET.binfo(arg)
  dbget("binfo", arg)
end

blink(“db entry”) method retrieves the link information



152
153
154
# File 'lib/bio/io/dbget.rb', line 152

def DBGET.blink(arg)
  dbget("blink", arg)
end

.bman(arg) ⇒ Object

bman (“db entry”) method shows the manual page



157
158
159
# File 'lib/bio/io/dbget.rb', line 157

def DBGET.bman(arg)
  dbget("bman", arg)
end

.bref(arg) ⇒ Object

bref(“db entry”) method retrieves the references and authors



162
163
164
# File 'lib/bio/io/dbget.rb', line 162

def DBGET.bref(arg)
  dbget("bref", arg)
end

.btab(arg) ⇒ Object

btab (“db entry”) method retrives (and generates) the database alias table



167
168
169
# File 'lib/bio/io/dbget.rb', line 167

def DBGET.btab(arg)
  dbget("btab", arg)
end

.btit(arg) ⇒ Object

btit(“db entry ..”) method retrieves the entry definition



172
173
174
# File 'lib/bio/io/dbget.rb', line 172

def DBGET.btit(arg)
  dbget("btit", arg)
end

.dbget(com, arg, serv = nil, port = nil) ⇒ Object

Main class method to access DBGET server. Optionally, this method can be called with the alternative DBGET server address and the TCP/IP port number.

‘com’ should be one of the following DBGET commands:

  • alink, bfind, bget, binfo, blink, bman, bref, btab, btit

These methods are shortcut for the dbget commands. Actually, Bio::DBGET.((|com|))(arg) internally calls Bio::DBGET.dbget(com, arg). Most of these methods accept the argument “-h” for help.

‘arg’ should be one of the following formats :

  • options

    db

    • specify the database name only for binfo, bman etc.

  • options

    db:entry

    • specify the database name and the entry name to retrieve.

  • options

    db entry1 entry2 …

    • specify the database name and the list of entries to retrieve.

Note that options in the above example can be omitted. If ‘arg’ is empty, the help message with a list of options for ‘com’ will be shown by default. Supported database names will be found at the GenomeNet DBGET web page www.genome.jp/dbget/.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/bio/io/dbget.rb', line 55

def DBGET.dbget(com, arg, serv = nil, port = nil)

  unless serv or port		# if both of serv and port are nil
    if ENV["DBGET"] =~ /:/		# and ENV["DBGET"] exists
      serv, port = ENV["DBGET"].split(':')
    end
  end
  serv = serv ? serv : SERV
  port = port ? port : PORT

  if arg.empty?
    arg = "-h"			# DBGET help message
  end

  query = "#{com} #{arg}\n"		# DBGET query string

  sock = TCPSocket.open("#{serv}", "#{port}")

  sock.write(query)			# submit query
  sock.flush			# buffer flush

  sock.gets				# skip "+Helo DBgetServ ..."
  sock.gets				# skip "#If you see this message, ..."
  sock.gets				# skip "*Request-IDent"

  result = sock.read		# DBGET result

  sock.close

  return result
end

.naseq(arg) ⇒ Object

naseq(“db entry”) method retrieves the nucleic acid sequence of the entry if any.



136
137
138
# File 'lib/bio/io/dbget.rb', line 136

def DBGET.naseq(arg)
  dbget("bget", "-f -n n #{arg}")
end

.seq(arg) ⇒ Object

seq(“db entry”) method retrieves the first sequence of the entry

Shortcut to retrieve the sequence of the entry in FASTA format. This method is equivalent to Bio::DBGET.bget(“-f -n 1 #arg”) and ‘arg’ should be the “db:entry” or “db entry1 entry2 …” format.



119
120
121
# File 'lib/bio/io/dbget.rb', line 119

def DBGET.seq(arg)
  dbget("bget", "-f -n 1 #{arg}")
end

.seq2(arg) ⇒ Object

seq2(“db entry”) method retrieves the second sequence of the entry if any

Shortcut to retrieve the second sequence of the entry in FASTA format. This method is equivalent to Bio::DBGET.bget(“-f -n 2 #arg”). Only useful when treating the KEGG GENES database entries which have both AASEQ and NTSEQ fields. This method is obsolete and it is recommended to use ‘naseq’ and ‘aaseq’ instead.



130
131
132
# File 'lib/bio/io/dbget.rb', line 130

def DBGET.seq2(arg)
  dbget("bget", "-f -n 2 #{arg}")
end

.versionObject

Show the version information of the DBGET server.



88
89
90
# File 'lib/bio/io/dbget.rb', line 88

def DBGET.version
  dbget("bget", "-V")
end