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.


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

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.


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

def aspect
  @aspect
end

#assigned_byObject (readonly)

Returns the value of attribute assigned_by


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

def assigned_by
  @assigned_by
end

#dateObject (readonly)

Returns Date variable.


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

def date
  @date
end

#dbObject (readonly)

Returns DB variable.


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

def db
  @db
end

#db_object_idObject (readonly) Also known as: entry_id

Returns Db_Object_Id variable. Alias to entry_id.


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

def db_object_id
  @db_object_id
end

#db_object_nameObject (readonly)

Returns the value of attribute db_object_name


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

def db_object_name
  @db_object_name
end

#db_object_symbolObject (readonly)

Returns Db_Object_Symbol variable.


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

def db_object_symbol
  @db_object_symbol
end

#db_object_synonymObject (readonly)

-> []


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

def db_object_synonym
  @db_object_synonym
end

#db_object_typeObject (readonly)

Returns Db_Object_Type variable.


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

def db_object_type
  @db_object_type
end

#db_referenceObject (readonly)

Returns Db_Reference variable.


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

def db_reference
  @db_reference
end

#evidenceObject (readonly)

Retruns Evidence code variable.


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

def evidence
  @evidence
end

#qualifierObject (readonly)

Returns Db_Object_Name variable.


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

def qualifier
  @qualifier
end

#taxonObject (readonly)

Returns Taxon variable.


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

def taxon
  @taxon
end

#withObject (readonly)

Returns the entry is associated with this value.


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

def with
  @with
end

Class Method Details

.parser(str) ⇒ Object

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


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

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”


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

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.


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

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