Class: Bio::GO::GeneAssociation

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/go.rb

Overview

Bio::GO::GeneAssociation

$CVSROOT/go/gene-associations/gene_association.*

Data parser for the gene_association go annotation. See also the file format www.geneontology.org/doc/GO.annotation.html#file

Example

mgi_data = File.open('gene_association.mgi').read
mgi = Bio::GO::GeneAssociation.parser(mgi_data)

Bio::GO::GeneAssociation.parser(mgi_data) do |entry|
  p [entry.entry_id, entry.evidence, entry.goid]
end

Constant Summary collapse

DELIMITER =

Delimiter

"\n"
RS =

Delimiter

DELIMITER

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry) ⇒ GeneAssociation

Parsing an entry (in a line) in the gene_association flatfile.



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/bio/db/go.rb', line 261

def initialize(entry) 
  tmp = entry.chomp.split(/\t/)
  @db                = tmp[0] 
  @db_object_id      = tmp[1]
  @db_object_symbol  = tmp[2]
  @qualifier         = tmp[3]  # 
  @goid              = tmp[4]
  @db_reference      = tmp[5].split(/\|/)  #
  @evidence          = tmp[6]
  @with              = tmp[7].split(/\|/)  # 
  @aspect            = tmp[8]
  @db_object_name    = tmp[9]  #
  @db_object_synonym = tmp[10].split(/\|/) #
  @db_object_type    = tmp[11]
  @taxon             = tmp[12] # taxon:4932
  @date              = tmp[13] # 20010118
  @assigned_by       = tmp[14] 
end

Instance Attribute Details

#aspectObject (readonly)

Returns Aspect valiable.



237
238
239
# File 'lib/bio/db/go.rb', line 237

def aspect
  @aspect
end

#assigned_byObject (readonly)

Returns the value of attribute assigned_by.



255
256
257
# File 'lib/bio/db/go.rb', line 255

def assigned_by
  @assigned_by
end

#dateObject (readonly)

Returns Date variable.



252
253
254
# File 'lib/bio/db/go.rb', line 252

def date
  @date
end

#dbObject (readonly)

Returns DB variable.



216
217
218
# File 'lib/bio/db/go.rb', line 216

def db
  @db
end

#db_object_idObject (readonly) Also known as: entry_id

Returns Db_Object_Id variable. Alias to entry_id.



219
220
221
# File 'lib/bio/db/go.rb', line 219

def db_object_id
  @db_object_id
end

#db_object_nameObject (readonly)

Returns the value of attribute db_object_name.



240
241
242
# File 'lib/bio/db/go.rb', line 240

def db_object_name
  @db_object_name
end

#db_object_symbolObject (readonly)

Returns Db_Object_Symbol variable.



222
223
224
# File 'lib/bio/db/go.rb', line 222

def db_object_symbol
  @db_object_symbol
end

#db_object_synonymObject (readonly)

-> []



243
244
245
# File 'lib/bio/db/go.rb', line 243

def db_object_synonym
  @db_object_synonym
end

#db_object_typeObject (readonly)

Returns Db_Object_Type variable.



246
247
248
# File 'lib/bio/db/go.rb', line 246

def db_object_type
  @db_object_type
end

#db_referenceObject (readonly)

Returns Db_Reference variable.



228
229
230
# File 'lib/bio/db/go.rb', line 228

def db_reference
  @db_reference
end

#evidenceObject (readonly)

Retruns Evidence code variable.



231
232
233
# File 'lib/bio/db/go.rb', line 231

def evidence
  @evidence
end

#qualifierObject (readonly)

Returns Db_Object_Name variable.



225
226
227
# File 'lib/bio/db/go.rb', line 225

def qualifier
  @qualifier
end

#taxonObject (readonly)

Returns Taxon variable.



249
250
251
# File 'lib/bio/db/go.rb', line 249

def taxon
  @taxon
end

#withObject (readonly)

Returns the entry is associated with this value.



234
235
236
# File 'lib/bio/db/go.rb', line 234

def with
  @with
end

Class Method Details

.parser(str) ⇒ Object

Retruns an Array of parsed gene_association flatfile. Block is acceptable.



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/bio/db/go.rb', line 199

def self.parser(str)
  if block_given?
    str.each_line(DELIMITER) {|line|
      next if /^!/ =~ line
      yield GeneAssociation.new(line)
    }
  else
    galist = []
    str.each_line(DELIMITER) {|line|
      next if /^!/ =~ line
      galist << GeneAssociation.new(line)
    }
    return galist
  end
end

Instance Method Details

#goid(org = nil) ⇒ Object

Returns GO_ID in /d7/ format. Giving not nil arg, returns /GO:d7/ style.

  • Bio::GO::GeneAssociation#goid -> “001234”

  • Bio::GO::GeneAssociation#goid(true) -> “GO:001234”



286
287
288
289
290
291
292
# File 'lib/bio/db/go.rb', line 286

def goid(org = nil)
  if org
    @goid
  else
    @goid.sub('GO:','')
  end
end

#to_strObject

Bio::GO::GeneAssociation#to_str -> a line of gene_association file.



295
296
297
298
299
300
# File 'lib/bio/db/go.rb', line 295

def to_str
  return [@db, @db_object_id, @db_object_symbol, @qualifier, @goid, 
          @db_reference.join("|"), @evidence, @with.join("|"), @aspect,
          @db_object_name, @db_object_synonym.join("|"), @db_object_type,
          @taxon, @date, @assigned_by].join("\t")
end